GNOME Bugzilla – Bug 758076
Moving/resizing windows with keyboard does not work on wayland
Last modified: 2016-04-19 07:17:39 UTC
Steps to reproduce this: 1. Open up any window. 2. Hit Alt+F7 for moving, or Alt+F8 for resizing 3. Try to move window around using arrow keys Expected behavior: Windows should resize/move around in response to the keystrokes. Hitting escape should move the window back to the original position, modifiers should make windows stick to borders, etc. Actual behavior: Mutter seems to ignore all of the keypresses once we start trying to move the window with the keyboard
Hm, I definitely got this working at one point. The code to handle that is here: https://git.gnome.org/browse/mutter/tree/src/core/keybindings.c#n1911
Downstream bug: https://bugzilla.redhat.com/show_bug.cgi?id=1300173 From what I can see, once the keyboard move/resize is triggered, neither process_keyboard_move_grab() nor process_keyboard_resize_grab() get called from process_key_event(), that's because "all_keys_grabbed" is FALSE. all_keys_grabbed = window ? window->all_keys_grabbed : FALSE; (gdb) p all_keys_grabbed $3 = 0 (gdb) p *window $4 = {parent_instance = {g_type_instance = {g_class = 0x5605b33ef740}, ref_count = 4, qdata = 0x5605b39ba251}, display = 0x5605b00e1130 [MetaDisplay], ... unmanaging = 0, constructing = 0, is_in_queues = 0, keys_grabbed = 0, grab_on_frame = 0, all_keys_grabbed = 0, withdrawn = 0, calc_placement = 0,
Not sure how this is supposed to work on Wayland because: 1522 gboolean 1523 meta_window_grab_all_keys (MetaWindow *window, 1524 guint32 timestamp) 1525 { ... 1530 if (!META_IS_BACKEND_X11 (backend)) 1531 return TRUE; 1532 ... 1551 retval = grab_keyboard (grabwindow, timestamp, XIGrabModeAsync); 1552 if (retval) 1553 { 1554 window->keys_grabbed = FALSE; 1555 window->all_keys_grabbed = TRUE; 1556 window->grab_on_frame = window->frame != NULL; 1557 } 1558 1559 return retval; 1560 } So on Wayland, we never to window->all_keys_grabbed = TRUE, do we?
So probably on the right track, because setting "window->all_keys_grabbed = TRUE;" in the !X11 case does fix the issue. Too bad it then triggers a segfault on ungrab, while trying to use an X11 extension on Wayland... XQueryExtension (dpy=dpy@entry=0x40, name=name@entry=0x7efe832169a4 "XInputExtension", major_opcode=major_opcode@entry=0x7ffea373ba34, first_event=first_event@entry=0x7ffea373ba38, first_error=first_error@entry=0x7ffea373ba3c) at QuExt.c:43 43 LockDisplay(dpy); (gdb) bt
+ Trace 236188
1514 ungrab_keyboard (guint32 timestamp) 1515 { 1516 MetaBackendX11 *backend = META_BACKEND_X11 (meta_get_backend ()); 1517 Display *xdisplay = meta_backend_x11_get_xdisplay (backend); 1518 1519 XIUngrabDevice (xdisplay, META_VIRTUAL_CORE_KEYBOARD_ID, timestamp); 1520 }
Created attachment 326255 [details] [review] [PATCH] keybindings: Fix keyboard move/resize on Wayland On Wayland, grabbing all keys is irrelevant, yet the specific move/resize key bindings rely on all_keys_grabbed to be TRUE, preventing the interactive move/resize to work with keys on Wayland. Set "all_keys_grabbed" to TRUE when the backend is not X11 as well so that process_keyboard_move_grab() and process_keyboard_resize_grab() can be invoked.
Review of attachment 326255 [details] [review]: I think we should change the meta_is_wayland_compositor() usage in this file. Instead of doing this check on entry points and exiting early, I think we should run as much of the existing code as possible to reduce the chance of breaking the existing logic or having to add even more checks and special casing. E.g. instead of returning early on meta_display_grab_window_buttons(), move the check to meta_change_button_grab(), etc.
Created attachment 326284 [details] [review] [PATCH] keybindings: Fix keyboard move/resize on Wayland Updated patch as per comment 6
Review of attachment 326284 [details] [review]: s/even on Wayland backend/when running as a Wayland compositor/ (backends in mutter are either native or X11) With that and the comment below addressed this looks good ::: src/core/keybindings.c @@ +1439,3 @@ guint32 index_key; + meta_change_keygrab (keys, display->screen->xroot, FALSE, &binding->resolved_combo); There's a similar line in meta_display_grab_accelerator() that should be changed like this too
Comment on attachment 326284 [details] [review] [PATCH] keybindings: Fix keyboard move/resize on Wayland attachment 326284 [details] [review] pushed with changes as per comment 8 as commit 5d6af70 - keybindings: Fix keyboard move/resize on Wayland