# HG changeset patch # User Sam Lantinga # Date 1029823280 0 # Node ID a888b3ae31fff02a5292345df18a8fa7fe329008 # Parent 2a778055dbba2d5a6c2331c9ec2ffedd2f271f29 Reset mouse state when changing video modes diff -r 2a778055dbba -r a888b3ae31ff src/events/SDL_events_c.h --- a/src/events/SDL_events_c.h Tue Aug 20 05:59:31 2002 +0000 +++ b/src/events/SDL_events_c.h Tue Aug 20 06:01:20 2002 +0000 @@ -63,7 +63,7 @@ extern int SDL_PrivateSysWMEvent(SDL_SysWMmsg *message); /* Used by the activity event handler to remove mouse focus */ -extern void SDL_MouseFocus(int focus); +extern void SDL_ResetMouse(void); /* Used by the activity event handler to remove keyboard focus */ extern void SDL_ResetKeyboard(void); diff -r 2a778055dbba -r a888b3ae31ff src/events/SDL_mouse.c --- a/src/events/SDL_mouse.c Tue Aug 20 05:59:31 2002 +0000 +++ b/src/events/SDL_mouse.c Tue Aug 20 06:01:20 2002 +0000 @@ -59,6 +59,17 @@ return(0); } +/* We lost the mouse, so post button up messages for all pressed buttons */ +void SDL_ResetMouse(void) +{ + int i; + for ( i = 0; i < sizeof(SDL_ButtonState)*8; ++i ) { + if ( SDL_ButtonState & SDL_BUTTON(i) ) { + SDL_PrivateMouseButton(SDL_RELEASED, i, 0, 0); + } + } +} + Uint8 SDL_GetMouseState (int *x, int *y) { if ( x ) diff -r 2a778055dbba -r a888b3ae31ff src/video/SDL_video.c --- a/src/video/SDL_video.c Tue Aug 20 05:59:31 2002 +0000 +++ b/src/video/SDL_video.c Tue Aug 20 06:01:20 2002 +0000 @@ -607,6 +607,7 @@ /* Reset the keyboard here so event callbacks can run */ SDL_ResetKeyboard(); + SDL_ResetMouse(); /* Clean up any previous video mode */ if ( SDL_PublicSurface != NULL ) { diff -r 2a778055dbba -r a888b3ae31ff src/video/windx5/SDL_dx5events.c --- a/src/video/windx5/SDL_dx5events.c Tue Aug 20 05:59:31 2002 +0000 +++ b/src/video/windx5/SDL_dx5events.c Tue Aug 20 06:01:20 2002 +0000 @@ -221,33 +221,6 @@ return(0); } -/* Change cooperative level based on whether or not we are fullscreen */ -void DX5_DInputReset(_THIS, int fullscreen) -{ - DWORD level; - int i; - HRESULT result; - - for ( i=0; i 0) - button = 4; + button = SDL_BUTTON_WHEELUP; else - button = 5; - posted = SDL_PrivateMouseButton( + button = SDL_BUTTON_WHEELDOWN; + posted = SDL_PrivateMouseButton( SDL_PRESSED, button, 0, 0); posted |= SDL_PrivateMouseButton( SDL_RELEASED, button, 0, 0); @@ -543,7 +516,7 @@ 1 if there was input, 0 if there was no input, or -1 if the application has posted a quit message. */ -static int DX5_CheckInput(_THIS, int timeout) +static int DX5_CheckInput(_THIS, int timeout, BOOL processInput) { MSG msg; int i; @@ -602,7 +575,7 @@ evtbuf, &numevents, 0); } /* Handle the events */ - if ( result == DI_OK ) { + if ( result == DI_OK && processInput ) { /* Note: This can post multiple events to event queue */ (*SDL_DIfun[event])((int)numevents, evtbuf); @@ -623,10 +596,40 @@ return(0); } +/* Change cooperative level based on whether or not we are fullscreen */ +void DX5_DInputReset(_THIS, int fullscreen) +{ + DWORD level; + int i; + HRESULT result; + + for ( i=0; i 0 ) { + while ( DX5_CheckInput(this, 0, TRUE) > 0 ) { /* Loop and check again */; } }