mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-22 19:25:33 +00:00
Fixed interactions between mouse capture and grab on X11
Fixes https://github.com/libsdl-org/SDL/issues/6072
This commit is contained in:
parent
7da74eb5be
commit
8acb4e45b3
|
@ -358,16 +358,20 @@ static int
|
|||
X11_CaptureMouse(SDL_Window *window)
|
||||
{
|
||||
Display *display = GetDisplay();
|
||||
SDL_Window *mouse_focus = SDL_GetMouseFocus();
|
||||
|
||||
if (window) {
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;
|
||||
Window confined = (data->mouse_grabbed ? data->xwindow : None);
|
||||
const int rc = X11_XGrabPointer(display, data->xwindow, False,
|
||||
mask, GrabModeAsync, GrabModeAsync,
|
||||
None, None, CurrentTime);
|
||||
confined, None, CurrentTime);
|
||||
if (rc != GrabSuccess) {
|
||||
return SDL_SetError("X server refused mouse capture");
|
||||
}
|
||||
} else if (mouse_focus) {
|
||||
SDL_UpdateWindowGrab(mouse_focus);
|
||||
} else {
|
||||
X11_XUngrabPointer(display, CurrentTime);
|
||||
}
|
||||
|
|
|
@ -1600,6 +1600,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
data->mouse_grabbed = SDL_FALSE;
|
||||
|
||||
display = data->videodata->display;
|
||||
|
||||
|
@ -1622,6 +1623,7 @@ X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
|||
result = X11_XGrabPointer(display, data->xwindow, True, mask, GrabModeAsync,
|
||||
GrabModeAsync, data->xwindow, None, CurrentTime);
|
||||
if (result == GrabSuccess) {
|
||||
data->mouse_grabbed = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
SDL_Delay(50);
|
||||
|
|
|
@ -59,6 +59,7 @@ typedef struct
|
|||
int border_right;
|
||||
int border_top;
|
||||
int border_bottom;
|
||||
SDL_bool mouse_grabbed;
|
||||
Uint32 last_focus_event_time;
|
||||
PendingFocusEnum pending_focus;
|
||||
Uint32 pending_focus_time;
|
||||
|
|
Loading…
Reference in a new issue