Disable mouse scrolling when mouse leaves the window.

Keyboard scrolling still works. Really fixes #1141, and makes the game always
behave as mentioned in r9428.

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@9447 4a71c877-e1ca-e34f-864e-861f7616d084
master
Christian Ohm 2010-01-24 03:39:44 +00:00 committed by Git SVN Gateway
parent 35a510aa61
commit 897eeadedd
3 changed files with 36 additions and 27 deletions

View File

@ -210,6 +210,7 @@ static BOOL ignoreRMBC = true;
static DROID *psSelectedVtol;
static DROID *psDominantSelected;
static BOOL bRadarDragging = false;
static bool mouseScroll = true;
BOOL rotActive = false;
BOOL gameStats = false;
@ -243,6 +244,10 @@ static BOOL bLasSatStruct;
static MOUSE_TARGET itemUnderMouse(BASE_OBJECT **ppObjUnderCursor);
static BOOL bShakingPermitted = true;
void setMouseScroll(bool scroll)
{
mouseScroll = scroll;
}
void setRadarJump(BOOL val)
{
@ -1047,33 +1052,7 @@ void scroll(void)
return;
}
if(!keyDown(KEY_LCTRL) && !keyDown(KEY_RCTRL))
{
/* Scroll left */
if (keyDown(KEY_LEFTARROW) || mouseXPos < BOUNDARY_X)
{
mouseAtLeft = true;
}
/* Scroll right */
if ( keyDown(KEY_RIGHTARROW) || mouseXPos > (pie_GetVideoBufferWidth() - BOUNDARY_X) )
{
mouseAtRight = true;
}
/* Scroll up */
if (keyDown(KEY_UPARROW) || (mouseYPos < BOUNDARY_Y))
{
mouseAtBottom = true;
}
/* Scroll down */
if ( keyDown(KEY_DOWNARROW) || mouseYPos > (pie_GetVideoBufferHeight() - BOUNDARY_Y) )
{
mouseAtTop = true;
}
}
else
if (mouseScroll)
{
/* Scroll left */
if (mouseXPos < BOUNDARY_X)
@ -1099,6 +1078,32 @@ void scroll(void)
mouseAtTop = true;
}
}
if (!keyDown(KEY_LCTRL) && !keyDown(KEY_RCTRL))
{
/* Scroll left */
if (keyDown(KEY_LEFTARROW))
{
mouseAtLeft = true;
}
/* Scroll right */
if (keyDown(KEY_RIGHTARROW))
{
mouseAtRight = true;
}
/* Scroll up */
if (keyDown(KEY_UPARROW))
{
mouseAtBottom = true;
}
/* Scroll down */
if ( keyDown(KEY_DOWNARROW))
{
mouseAtTop = true;
}
}
/* Time to update scroll - change to should be time */
timeDiff = SDL_GetTicks() - scrollRefTime;

View File

@ -48,6 +48,7 @@ extern void processMouseClickInput(void);
extern void scroll(void);
extern void resetScroll(void);
extern void setMouseScroll(bool);
extern BOOL DrawnInLastFrame(SDWORD Frame);

View File

@ -864,7 +864,10 @@ static void handleActiveEvent(SDL_ActiveEvent * activeEvent)
// Ignore focus loss through SDL_APPMOUSEFOCUS, since it mostly happens accidentialy
// active.state is a bitflag! Mixed events (eg. APPACTIVE|APPMOUSEFOCUS) will thus not be ignored.
if ( activeEvent->state == SDL_APPMOUSEFOCUS )
{
setMouseScroll(activeEvent->gain);
return;
}
if ( activeEvent->gain == 1 )
{