| Summary: | DIB_GenerateMouseMotionEvent generates erroneous mouse motion events | ||
|---|---|---|---|
| Product: | SDL | Reporter: | maf6 |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 1.2.14 | ||
| Hardware: | All | ||
| OS: | Windows 7 | ||
This occurs when the openmsx emulator is running full screen and the user reverts to the desktop by hitting Win+D. In this case, the screen size reverts to the original size (in my case, 1920x1200) instead of 1024x768. However, in this scenario, the SDL window is now off-screen, and Windows returns some rather odd values for the physical position of the middle of the window (e.g. center.x = -31520, center.y = -31640). Long story short, we created an SDL patch for openmsx builds that causes DIB_GenerateMouseMotionEvent to only post a new event if (after calling SetCursorPos) the cursor's position actually changed from the original position (in the scenario I describe, it actually doesn't: it was 0,0 before and it remains 0,0 after calling SetCursorPos). In other words: diff -ru SDL-1.2.14.org/src/video/windib/SDL_dibevents.c SDL-1.2.14/src/video/windib/SDL_dibevents.c --- SDL-1.2.14.org/src/video/windib/SDL_dibevents.c Mon Feb 15 11:49:09 2010 +++ SDL-1.2.14/src/video/windib/SDL_dibevents.c Mon Feb 15 11:51:15 2010 @@ -328,12 +328,13 @@ extern int mouse_relative; extern int posted; - POINT mouse; + POINT mouse, originalMouse; #ifdef _WIN32_WCE if ( !GetCursorPos(&mouse) && !GetLastStylusPos(&mouse) ) return; #else if ( !GetCursorPos(&mouse) ) return; #endif + originalMouse = mouse; if ( mouse_relative ) { POINT center; @@ -345,7 +346,11 @@ mouse.y -= center.y; if ( mouse.x || mouse.y ) { SetCursorPos(center.x, center.y); - posted = SDL_PrivateMouseMotion(0, 1, (Sint16)mouse.x, (Sint16)mouse.y); + GetCursorPos(&mouse); + // Make sure the mouse position actually changed + if (mouse.x != originalMouse.x || mouse.y != originalMouse.y) { + posted = SDL_PrivateMouseMotion(0, 1, (Sint16)mouse.x, (Sint16)mouse.y); + } } } else { ScreenToClient(SDL_Window, &mouse);