x11: Don't try to grab the pointer on an unmapped window (thanks, Lee!)

Fixes Bugzilla #5352.
This commit is contained in:
Ryan C. Gordon 2020-11-23 21:07:28 -05:00
parent 04b45b5581
commit 0ff5d55a07
2 changed files with 13 additions and 2 deletions

View File

@ -433,8 +433,12 @@ X11_DispatchFocusOut(_THIS, SDL_WindowData *data)
static void
X11_DispatchMapNotify(SDL_WindowData *data)
{
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0);
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
SDL_Window *window = data->window;
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0);
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0);
if (!(window->flags & SDL_WINDOW_HIDDEN) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
SDL_UpdateWindowGrab(window);
}
}
static void

View File

@ -1576,6 +1576,13 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
oldstyle_fullscreen = X11_IsWindowLegacyFullscreen(_this, window);
if (oldstyle_fullscreen || grabbed) {
/* If the window is unmapped, XGrab calls return GrabNotViewable,
so when we get a MapNotify later, we'll try to update the grab as
appropriate. */
if (window->flags & SDL_WINDOW_HIDDEN) {
return;
}
/* Try to grab the mouse */
if (!data->videodata->broken_pointer_grab) {
const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask;