--- a/hedgewars/SDLh.pas Thu Jan 04 18:54:24 2007 +0000
+++ b/hedgewars/SDLh.pas Sun Jan 07 16:53:16 2007 +0000
@@ -55,10 +55,13 @@
SDL_RLEACCEL = $00004000;
SDL_NOEVENT = 0;
+ SDL_ACTIVEEVENT = 1;
SDL_KEYDOWN = 2;
SDL_KEYUP = 3;
SDL_QUITEV = 12;
+ SDL_APPINPUTFOCUS = 2;
+
SDL_INIT_VIDEO = $00000020;
SDL_INIT_AUDIO = $00000010;
@@ -158,6 +161,12 @@
unicode: Word;
end;
+ TSDL_ActiveEvent = record
+ type_: byte;
+ gain: byte;
+ state: byte;
+ end;
+
TSDL_KeyboardEvent = record
type_: Byte;
which: Byte;
@@ -172,6 +181,7 @@
TSDL_Event = record
case Byte of
SDL_NOEVENT: (type_: byte);
+ SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent);
SDL_KEYDOWN, SDL_KEYUP: (key: TSDL_KeyboardEvent);
SDL_QUITEV: (quit: TSDL_QuitEvent);
end;
--- a/hedgewars/hwengine.dpr Thu Jan 04 18:54:24 2007 +0000
+++ b/hedgewars/hwengine.dpr Sun Jan 07 16:53:16 2007 +0000
@@ -135,6 +135,8 @@
end;
gsConsole: KeyPressConsole(event.key.keysym.sym);
end;
+ SDL_ACTIVEEVENT: if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
+ cHasFocus:= event.active.gain = 1;
SDL_QUITEV: isTerminated:= true
end;
CurrTime:= SDL_GetTicks;
--- a/hedgewars/uMisc.pas Thu Jan 04 18:54:24 2007 +0000
+++ b/hedgewars/uMisc.pas Sun Jan 07 16:53:16 2007 +0000
@@ -71,6 +71,7 @@
cInitVolume : integer = 128;
cVolumeDelta : integer = 0;
cTimerInterval : Longword = 5;
+ cHasFocus : boolean = true;
var
cSendEmptyPacketTime : LongWord = 2000;
--- a/hedgewars/uWorld.pas Thu Jan 04 18:54:24 2007 +0000
+++ b/hedgewars/uWorld.pas Sun Jan 07 16:53:16 2007 +0000
@@ -402,7 +402,7 @@
if CursorPoint.Y < cScreenHeight - 75 - SlotsNum * 33 then CursorPoint.Y:= cScreenHeight - 75 - SlotsNum * 33;
if CursorPoint.Y > cScreenHeight - 76 then CursorPoint.Y:= cScreenHeight - 76;
prevPoint:= CursorPoint;
- SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
+ if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
exit
end;
@@ -440,13 +440,15 @@
CursorPoint.Y:= cScreenHeight - EdgesDist
end;
end else
- begin
+ if cHasFocus then
+ begin
WorldDx:= WorldDx - CursorPoint.X + prevPoint.X;
WorldDy:= WorldDy - CursorPoint.Y + prevPoint.Y;
CursorPoint.X:= (cScreenWidth shr 1);
CursorPoint.Y:= (cScreenHeight shr 1);
- end;
-SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
+ end;
+
+if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
prevPoint:= CursorPoint;
if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater;
if WorldDy > 2048 then WorldDy:= 2048;