Compare commits

...

2 Commits

Author SHA1 Message Date
Carlos Garnacho
835a97a66c core: Ensure passive key grabs are only set up on X11
We don't strictly need it for wayland compositors, yet there are
paths where we try to trigger those passive grabs there. Just
skip those on the high level code (where "is it x11" decisions
are taken) like we do with passive button grabs.
2019-05-24 19:40:07 +02:00
Carlos Garnacho
9367cd2d66 core: Shuffle wayland checks on passive button grabs
We used to bail out at the very bottom of it, but it seems better to
do that at a higher level so that we don't have to pass "invalid"
X11 data as arguments (e.g. None for windows, etc)
2019-05-24 19:30:34 +02:00
2 changed files with 38 additions and 29 deletions

View File

@ -1171,9 +1171,6 @@ meta_change_button_grab (MetaKeyBindingManager *keys,
int button,
int modmask)
{
if (meta_is_wayland_compositor ())
return;
MetaBackendX11 *backend = META_BACKEND_X11 (keys->backend);
Display *xdisplay = meta_backend_x11_get_xdisplay (backend);
@ -1300,12 +1297,8 @@ meta_display_grab_focus_window_button (MetaDisplay *display,
return;
}
/* FIXME If we ignored errors here instead of spewing, we could
* put one big error trap around the loop and avoid a bunch of
* XSync()
*/
meta_change_buttons_grab (keys, window->xwindow, TRUE, TRUE, XIAnyModifier);
if (window->xwindow && !meta_is_wayland_compositor ())
meta_change_buttons_grab (keys, window->xwindow, TRUE, TRUE, XIAnyModifier);
window->have_focus_click_grab = TRUE;
}
@ -1320,7 +1313,8 @@ meta_display_ungrab_focus_window_button (MetaDisplay *display,
if (!window->have_focus_click_grab)
return;
meta_change_buttons_grab (keys, window->xwindow, FALSE, FALSE, XIAnyModifier);
if (window->xwindow && !meta_is_wayland_compositor ())
meta_change_buttons_grab (keys, window->xwindow, FALSE, FALSE, XIAnyModifier);
window->have_focus_click_grab = FALSE;
}
@ -1348,7 +1342,8 @@ prefs_changed_callback (MetaPreference pref,
for (l = windows; l; l = l->next)
{
MetaWindow *w = l->data;
meta_display_ungrab_window_buttons (display, w->xwindow);
if (!meta_is_wayland_compositor ())
meta_display_ungrab_window_buttons (display, w->xwindow);
}
update_window_grab_modifiers (keys);
@ -1356,7 +1351,7 @@ prefs_changed_callback (MetaPreference pref,
for (l = windows; l; l = l->next)
{
MetaWindow *w = l->data;
if (w->type != META_WINDOW_DOCK)
if (!meta_is_wayland_compositor () && w->type != META_WINDOW_DOCK)
meta_display_grab_window_buttons (display, w->xwindow);
}
@ -1531,6 +1526,8 @@ meta_window_grab_keys (MetaWindow *window)
MetaDisplay *display = window->display;
MetaKeyBindingManager *keys = &display->key_binding_manager;
if (!meta_is_wayland_compositor ())
return;
if (window->all_keys_grabbed)
return;
@ -1565,7 +1562,7 @@ meta_window_grab_keys (MetaWindow *window)
void
meta_window_ungrab_keys (MetaWindow *window)
{
if (window->keys_grabbed)
if (!meta_is_wayland_compositor () && window->keys_grabbed)
{
MetaDisplay *display = window->display;
MetaKeyBindingManager *keys = &display->key_binding_manager;
@ -1624,7 +1621,11 @@ meta_display_grab_accelerator (MetaDisplay *display,
return META_KEYBINDING_ACTION_NONE;
}
meta_change_keygrab (keys, display->x11_display->xroot, TRUE, &resolved_combo);
if (!meta_is_wayland_compositor ())
{
meta_change_keygrab (keys, display->x11_display->xroot,
TRUE, &resolved_combo);
}
grab = g_new0 (MetaKeyGrab, 1);
grab->action = next_dynamic_keybinding_action ();
@ -1670,8 +1671,11 @@ meta_display_ungrab_accelerator (MetaDisplay *display,
{
int i;
meta_change_keygrab (keys, display->x11_display->xroot,
FALSE, &binding->resolved_combo);
if (!meta_is_wayland_compositor ())
{
meta_change_keygrab (keys, display->x11_display->xroot,
FALSE, &binding->resolved_combo);
}
for (i = 0; i < binding->resolved_combo.len; i++)
{
@ -1749,7 +1753,7 @@ meta_window_grab_all_keys (MetaWindow *window,
guint32 timestamp)
{
Window grabwindow;
gboolean retval;
gboolean retval = TRUE;
if (window->all_keys_grabbed)
return FALSE;
@ -1765,25 +1769,29 @@ meta_window_grab_all_keys (MetaWindow *window,
window->desc);
meta_window_focus (window, timestamp);
grabwindow = meta_window_x11_get_toplevel_xwindow (window);
meta_topic (META_DEBUG_KEYBINDINGS,
"Grabbing all keys on window %s\n", window->desc);
retval = grab_keyboard (grabwindow, timestamp, XIGrabModeAsync);
if (retval)
if (!meta_is_wayland_compositor ())
{
window->keys_grabbed = FALSE;
window->all_keys_grabbed = TRUE;
window->grab_on_frame = window->frame != NULL;
grabwindow = meta_window_x11_get_toplevel_xwindow (window);
meta_topic (META_DEBUG_KEYBINDINGS,
"Grabbing all keys on window %s\n", window->desc);
retval = grab_keyboard (grabwindow, timestamp, XIGrabModeAsync);
if (retval)
{
window->keys_grabbed = FALSE;
window->all_keys_grabbed = TRUE;
window->grab_on_frame = window->frame != NULL;
}
}
return retval;
}
void
meta_window_ungrab_all_keys (MetaWindow *window, guint32 timestamp)
meta_window_ungrab_all_keys (MetaWindow *window,
guint32 timestamp)
{
if (window->all_keys_grabbed)
if (!meta_is_wayland_compositor () && window->all_keys_grabbed)
{
ungrab_keyboard (timestamp);

View File

@ -5283,7 +5283,8 @@ meta_window_set_focused_internal (MetaWindow *window,
meta_display_ungrab_focus_window_button (window->display, window);
/* Since we ungrab with XIAnyModifier above, all button
grabs go way so we need to re-grab the window buttons. */
meta_display_grab_window_buttons (window->display, window->xwindow);
if (!meta_is_wayland_compositor ())
meta_display_grab_window_buttons (window->display, window->xwindow);
}
g_signal_emit (window, window_signals[FOCUS], 0);