x11: don't grab the pointer while buttons are pressed
Grabbing the mouse interrupts touch events in progress, so if someone enables relative mode while a button is pressed, wait for the button to be released before grabbing the mouse.
This commit is contained in:
@@ -1180,6 +1180,10 @@ void X11_HandleButtonRelease(SDL_VideoDevice *_this, SDL_WindowData *windowdata,
|
|||||||
button -= (8 - SDL_BUTTON_X1);
|
button -= (8 - SDL_BUTTON_X1);
|
||||||
}
|
}
|
||||||
SDL_SendMouseButton(timestamp, window, mouseID, button, false);
|
SDL_SendMouseButton(timestamp, window, mouseID, button, false);
|
||||||
|
|
||||||
|
if (window->internal->pending_grab) {
|
||||||
|
X11_SetWindowMouseGrab(_this, window, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2058,6 +2058,7 @@ bool X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool gra
|
|||||||
return SDL_SetError("Invalid window data");
|
return SDL_SetError("Invalid window data");
|
||||||
}
|
}
|
||||||
data->mouse_grabbed = false;
|
data->mouse_grabbed = false;
|
||||||
|
data->pending_grab = false;
|
||||||
|
|
||||||
display = data->videodata->display;
|
display = data->videodata->display;
|
||||||
|
|
||||||
@@ -2075,7 +2076,8 @@ bool X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool gra
|
|||||||
* the confinement grab.
|
* the confinement grab.
|
||||||
*/
|
*/
|
||||||
if (data->xinput2_mouse_enabled && SDL_GetMouseState(NULL, NULL)) {
|
if (data->xinput2_mouse_enabled && SDL_GetMouseState(NULL, NULL)) {
|
||||||
X11_XUngrabPointer(display, CurrentTime);
|
data->pending_grab = true;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to grab the mouse
|
// Try to grab the mouse
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ struct SDL_WindowData
|
|||||||
bool was_shown;
|
bool was_shown;
|
||||||
bool emit_size_move_after_property_notify;
|
bool emit_size_move_after_property_notify;
|
||||||
SDL_HitTestResult hit_test_result;
|
SDL_HitTestResult hit_test_result;
|
||||||
|
bool pending_grab;
|
||||||
|
|
||||||
XPoint xim_spot;
|
XPoint xim_spot;
|
||||||
char *preedit_text;
|
char *preedit_text;
|
||||||
|
|||||||
Reference in New Issue
Block a user