summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Gutman <cameron.gutman@gmail.com>2021-01-27 19:40:55 -0600
committerCameron Gutman <cameron.gutman@gmail.com>2021-01-27 19:40:55 -0600
commitd1ccd48d6c2c4f93bbba519c9cede3c2bf170c44 (patch)
treef11c3726968d9e763e24d950cb9f3e9493efc69b
parentdc0975c4a52af769d41b6f70ee18278d7f275d95 (diff)
downloadsdl-d1ccd48d6c2c4f93bbba519c9cede3c2bf170c44.tar.gz
X11: Ungrab the keyboard when the mouse leaves the window
GNOME Mutter requires keyboard grab for certain important functionality like window resizing, interaction with the application context menu, and opening the Activites view. To allow Mutter to grab the keyboard as needed, we'll ungrab when the mouse leaves our window. To be safe, we'll do this for all WMs since forks of Mutter and Matacity (and possibly others) may have the same behavior, and we don't want to have to keep track of those.
-rw-r--r--src/video/x11/SDL_x11events.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c
index db0c67988..e93fd7945 100644
--- a/src/video/x11/SDL_x11events.c
+++ b/src/video/x11/SDL_x11events.c
@@ -808,6 +808,9 @@ X11_DispatchEvent(_THIS)
if (!mouse->relative_mode) {
SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y);
}
+
+ /* We ungrab in LeaveNotify, so we may need to grab again here */
+ SDL_UpdateWindowGrab(data->window);
}
break;
/* Losing mouse coverage? */
@@ -829,6 +832,13 @@ X11_DispatchEvent(_THIS)
if (xevent.xcrossing.mode != NotifyGrab &&
xevent.xcrossing.mode != NotifyUngrab &&
xevent.xcrossing.detail != NotifyInferior) {
+
+ /* In order for interaction with the window decorations and menu to work properly
+ on Mutter, we need to ungrab the keyboard when the the mouse leaves. */
+ if (!(data->window->flags & SDL_WINDOW_FULLSCREEN)) {
+ X11_SetWindowKeyboardGrab(_this, data->window, SDL_FALSE);
+ }
+
SDL_SetMouseFocus(NULL);
}
}