Skip to content

Commit

Permalink
X11: Fixed SDL_GetGlobalMouseState() to work better with multimonitor…
Browse files Browse the repository at this point in the history
… configs.

Fixes Bugzilla #2770.

Thanks to Epic Games for contributing this fix.
  • Loading branch information
RCL committed Oct 30, 2014
1 parent 37720dd commit 3a916c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/video/x11/SDL_x11mouse.c
Expand Up @@ -382,8 +382,14 @@ X11_GetGlobalMouseState(int *x, int *y)
retval |= (mask & Button1Mask) ? SDL_BUTTON_LMASK : 0;
retval |= (mask & Button2Mask) ? SDL_BUTTON_MMASK : 0;
retval |= (mask & Button3Mask) ? SDL_BUTTON_RMASK : 0;
*x = data->x + rootx;
*y = data->y + rooty;
/* SDL_DisplayData->x,y point to screen origin, and adding them to mouse coordinates relative to root window doesn't do the right thing
* (observed on dual monitor setup with primary display being the rightmost one - mouse was offset to the right).
*
* Adding root position to root-relative coordinates seems to be a better way to get absolute position. */
XWindowAttributes root_attrs;
X11_XGetWindowAttributes(display, root, &root_attrs);
*x = root_attrs.x + rootx;
*y = root_attrs.y + rooty;
return retval;
}
}
Expand Down

0 comments on commit 3a916c6

Please sign in to comment.