Stop scrolling upon mouse exit of program window
This commit is contained in:
parent
7f9255b12a
commit
f4bccd741a
11 changed files with 90 additions and 4 deletions
|
@ -8,3 +8,4 @@ core
|
|||
srcdoc
|
||||
.depend
|
||||
.gdbinit
|
||||
obj
|
||||
|
|
|
@ -57,7 +57,9 @@ IFLAGS= -I$(TOPDIR)/src/include $(XIFLAGS)
|
|||
DFLAGS= $(THREAD) $(CCL) $(VERSION) \
|
||||
$(VIDEO) $(ZDEFS) $(DSOUND) \
|
||||
$(DEBUG)
|
||||
CFLAGS=-O2 -pipe -fomit-frame-pointer -fconserve-space -fexpensive-optimizations -ffast-math $(IFLAGS) $(DFLAGS) -DUNIT_ON_MAP -DNEW_AI -DUSE_LIBMODPLUG -DUSE_HP_FOR_XP
|
||||
#CFLAGS=-O2 -pipe -fomit-frame-pointer -fconserve-space -fexpensive-optimizations -ffast-math $(IFLAGS) $(DFLAGS) -DUNIT_ON_MAP -DNEW_AI -DUSE_LIBMODPLUG -DUSE_HP_FOR_XP
|
||||
#CFLAGS=-O2 -pipe -fomit-frame-pointer -fexpensive-optimizations -ffast-math $(IFLAGS) $(DFLAGS) -DUNIT_ON_MAP -DNEW_AI -DUSE_LIBMODPLUG -DUSE_HP_FOR_XP
|
||||
CFLAGS=-g -pipe $(IFLAGS) $(DFLAGS) -DUNIT_ON_MAP -DNEW_AI -DUSE_LIBMODPLUG -DUSE_HP_FOR_XP
|
||||
CTAGSFLAGS=-i defptvS -a -f
|
||||
|
||||
# Locks versions with a symbolic name
|
||||
|
|
|
@ -260,7 +260,7 @@ extern int AddButton(int pos,int level,const char* IconIdent,
|
|||
extern void SaveButtons(FILE* file);
|
||||
|
||||
//
|
||||
// in interface.c
|
||||
// in mouse.c
|
||||
//
|
||||
/// Called if any mouse button is pressed down
|
||||
extern void HandleButtonDown(unsigned button);
|
||||
|
@ -268,17 +268,45 @@ extern void HandleButtonDown(unsigned button);
|
|||
extern void HandleButtonUp(unsigned button);
|
||||
/// Called if the mouse is moved
|
||||
extern void HandleMouseMove(int x,int y);
|
||||
/// Called if the mouse exits the game window (only for some videomodes)
|
||||
extern void HandleMouseExit(void);
|
||||
|
||||
/// Called if a key is pressed
|
||||
extern void HandleKeyDown(unsigned keycode,unsigned keychar);
|
||||
/// Called when a key is released
|
||||
extern void HandleKeyUp(unsigned keycode,unsigned keychar);
|
||||
|
||||
//
|
||||
// in interface.c (for link between video and mouse.c)
|
||||
//
|
||||
/// Called if any mouse button is pressed down
|
||||
extern void InputMouseButtonPress(const EventCallback*,unsigned,unsigned);
|
||||
/// Called if any mouse button is released up
|
||||
extern void InputMouseButtonRelease(const EventCallback*,unsigned,unsigned);
|
||||
/// Called if the mouse is moved
|
||||
extern void InputMouseMove(const EventCallback*,unsigned,int,int);
|
||||
/// Called if the mouse exits the game window (when supported by videomode)
|
||||
extern void InputMouseExit(const EventCallback*,unsigned);
|
||||
/// Called to look for mouse timeout's
|
||||
extern void InputMouseTimeout(const EventCallback*,unsigned);
|
||||
|
||||
//
|
||||
// Chaos pur.
|
||||
//
|
||||
/// Called if right mouse button is pressed
|
||||
extern void DoRightButton(int tx,int ty);
|
||||
/// Cancel the building input mode
|
||||
extern void CancelBuildingMode(void);
|
||||
|
||||
/// Draw messages as overlay over of the map
|
||||
extern void DrawMessage(void);
|
||||
/// Draw the player resource in resource line
|
||||
extern void DrawResources(void);
|
||||
/// Set message to display
|
||||
extern void SetMessage( const char* fmt, ... );
|
||||
/// Set message to display with event point
|
||||
extern void SetMessageEvent( int x, int y, const char* fmt, ... );
|
||||
/// Center view-point on last event message
|
||||
/// Called to look for mouse timeout's
|
||||
extern void InputMouseTimeout(const EventCallback*,unsigned);
|
||||
|
||||
|
|
|
@ -316,6 +316,8 @@ typedef struct _event_callback_ {
|
|||
void (*ButtonReleased)(unsigned buttons);
|
||||
/// Callback for mouse move
|
||||
void (*MouseMoved)(int x,int y);
|
||||
/// Callback for mouse exit of game window
|
||||
void (*MouseExit)(void);
|
||||
|
||||
/// Callback for key press
|
||||
void (*KeyPressed)(unsigned keycode,unsigned keychar);
|
||||
|
|
|
@ -344,6 +344,7 @@ local void WaitForInput(int timeout)
|
|||
callbacks.ButtonPressed=WaitCallbackKey;
|
||||
callbacks.ButtonReleased=WaitCallbackKey;
|
||||
callbacks.MouseMoved=WaitCallbackMouse;
|
||||
callbacks.MouseExit=WaitCallbackMouse;
|
||||
callbacks.KeyPressed=WaitCallbackKey2;
|
||||
callbacks.KeyReleased=WaitCallbackKey2;
|
||||
|
||||
|
|
|
@ -910,6 +910,7 @@ local int LastMouseTicks; /// Ticks of last mouse event
|
|||
** FIXME: dragging is not supported.
|
||||
**
|
||||
** @param callbacks Callback structure for events.
|
||||
** @param ticks Denotes time-stamp of video-system
|
||||
** @param button Mouse button pressed.
|
||||
*/
|
||||
global void InputMouseButtonPress(const EventCallback* callbacks,
|
||||
|
@ -943,6 +944,7 @@ global void InputMouseButtonPress(const EventCallback* callbacks,
|
|||
** Called if any mouse button is released up
|
||||
**
|
||||
** @param callbacks Callback structure for events.
|
||||
** @param ticks Denotes time-stamp of video-system
|
||||
** @param button Mouse button released.
|
||||
*/
|
||||
global void InputMouseButtonRelease(const EventCallback* callbacks,
|
||||
|
@ -980,6 +982,7 @@ global void InputMouseButtonRelease(const EventCallback* callbacks,
|
|||
** Called if the mouse is moved
|
||||
**
|
||||
** @param callbacks Callback structure for events.
|
||||
** @param ticks Denotes time-stamp of video-system
|
||||
**
|
||||
*/
|
||||
global void InputMouseMove(const EventCallback* callbacks,
|
||||
|
@ -990,10 +993,24 @@ global void InputMouseMove(const EventCallback* callbacks,
|
|||
callbacks->MouseMoved(x,y);
|
||||
}
|
||||
|
||||
/**
|
||||
** Called if the mouse exits the game window (when supported by videomode)
|
||||
**
|
||||
** @param callbacks Callback structure for events.
|
||||
** @param ticks Denotes time-stamp of video-system
|
||||
**
|
||||
*/
|
||||
global void InputMouseExit(const EventCallback* callbacks, unsigned ticks)
|
||||
{
|
||||
//FIXME: should we do anything here with ticks? don't know, but conform others
|
||||
callbacks->MouseExit();
|
||||
}
|
||||
|
||||
/**
|
||||
** Called each frame to handle mouse time outs.
|
||||
**
|
||||
** @param callbacks Callback structure for events.
|
||||
** @param ticks Denotes time-stamp of video-system
|
||||
*/
|
||||
global void InputMouseTimeout(const EventCallback* callbacks,unsigned ticks)
|
||||
{
|
||||
|
|
|
@ -556,6 +556,33 @@ local void HandleMouseOn(int x,int y)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Handle cursor exits the game window (only for some videomodes)
|
||||
** FIXME: make it so that the game is partially 'paused'.
|
||||
** Game should run (for network play), but not react on or show
|
||||
** interactive events.
|
||||
*/
|
||||
global void HandleMouseExit(void)
|
||||
{
|
||||
//
|
||||
// Denote cursor not on anything in window (used?)
|
||||
//
|
||||
CursorOn=-1;
|
||||
|
||||
//
|
||||
// Prevent scrolling while out of focus (on other applications) */
|
||||
//
|
||||
KeyScrollState = MouseScrollState = ScrollNone;
|
||||
|
||||
//
|
||||
// Show hour-glass (to denote to the user, the game is waiting)
|
||||
// FIXME: couldn't define a hour-glass that easily, so used pointer
|
||||
//
|
||||
CursorX = VideoWidth/2;
|
||||
CursorY = VideoHeight/2;
|
||||
GameCursor = TheUI.Point.Cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
** Handle movement of the cursor.
|
||||
**
|
||||
|
|
|
@ -809,7 +809,7 @@ local void X11DoEvent(const EventCallback* callbacks)
|
|||
|
||||
case FocusOut:
|
||||
DebugLevel3("\tfocus out\n");
|
||||
CursorOn=-1;
|
||||
InputMouseExit(callbacks, X11GetTicks());
|
||||
break;
|
||||
|
||||
case ClientMessage:
|
||||
|
@ -1072,6 +1072,8 @@ global void WaitEventsAndKeepSync(void)
|
|||
callbacks.ButtonPressed=HandleButtonDown;
|
||||
callbacks.ButtonReleased=HandleButtonUp;
|
||||
callbacks.MouseMoved=HandleMouseMove;
|
||||
callbacks.MouseExit=HandleMouseExit;
|
||||
|
||||
callbacks.KeyPressed=HandleKeyDown;
|
||||
callbacks.KeyReleased=HandleKeyUp;
|
||||
|
||||
|
|
|
@ -528,7 +528,7 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event * event)
|
|||
case SDL_ACTIVEEVENT:
|
||||
DebugLevel3("\tFocus changed\n");
|
||||
if (!event->active.state) {
|
||||
CursorOn = -1;
|
||||
InputMouseExit(callbacks,SDL_GetTicks());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -708,6 +708,8 @@ global void WaitEventsAndKeepSync(void)
|
|||
callbacks.ButtonPressed=(void*)HandleButtonDown;
|
||||
callbacks.ButtonReleased=(void*)HandleButtonUp;
|
||||
callbacks.MouseMoved=(void*)HandleMouseMove;
|
||||
callbacks.MouseExit=(void*)HandleMouseExit;
|
||||
|
||||
callbacks.KeyPressed=HandleKeyDown;
|
||||
callbacks.KeyReleased=HandleKeyUp;
|
||||
|
||||
|
|
|
@ -1095,6 +1095,8 @@ global void WaitEventsAndKeepSync(void)
|
|||
callbacks.ButtonPressed=(void*)HandleButtonDown;
|
||||
callbacks.ButtonReleased=(void*)HandleButtonUp;
|
||||
callbacks.MouseMoved=(void*)HandleMouseMove;
|
||||
callbacks.MouseExit=(void*)HandleMouseExit; // @note never called!
|
||||
|
||||
callbacks.KeyPressed=HandleKeyDown;
|
||||
callbacks.KeyReleased=HandleKeyUp;
|
||||
|
||||
|
|
|
@ -270,6 +270,8 @@ global void WaitEventsAndKeepSync(void)
|
|||
callbacks.ButtonPressed=(void*)HandleButtonDown;
|
||||
callbacks.ButtonReleased=(void*)HandleButtonUp;
|
||||
callbacks.MouseMoved=(void*)HandleMouseMove;
|
||||
callbacks.MouseExit=(void*)HandleMouseExit; // @note never called!
|
||||
|
||||
callbacks.KeyPressed=HandleKeyDown;
|
||||
callbacks.KeyReleased=HandleKeyUp;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue