Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DIB_GenerateMouseMotionEvent generates erroneous mouse motion events #551

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 1.2.14
Reported for operating system, platform: Windows 7, All

Comments on the original bug report:

On 2010-02-20 12:46:13 +0000, wrote:

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);

On 2011-03-07 14:12:09 +0000, Sam Lantinga wrote:

I believe this is fixed by the patch mentioned in bug 1158.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant