After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 758076 - Moving/resizing windows with keyboard does not work on wayland
Moving/resizing windows with keyboard does not work on wayland
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
3.18.x
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2015-11-13 20:26 UTC by Lyude
Modified: 2016-04-19 07:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] keybindings: Fix keyboard move/resize on Wayland (1.54 KB, patch)
2016-04-18 13:36 UTC, Olivier Fourdan
none Details | Review
[PATCH] keybindings: Fix keyboard move/resize on Wayland (5.07 KB, patch)
2016-04-18 17:03 UTC, Olivier Fourdan
committed Details | Review

Description Lyude 2015-11-13 20:26:25 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
Comment 1 Jasper St. Pierre (not reading bugmail) 2015-11-13 20:36:44 UTC
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
Comment 2 Olivier Fourdan 2016-04-18 12:48:46 UTC
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,
Comment 3 Olivier Fourdan 2016-04-18 12:52:38 UTC
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?
Comment 4 Olivier Fourdan 2016-04-18 13:11:06 UTC
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
  • #0 XQueryExtension
    at QuExt.c line 43
  • #1 XInput_find_display
    at XExtInt.c line 171
  • #2 XInput_find_display
    at XExtInt.c line 221
  • #3 XIUngrabDevice
    at XIGrabDevice.c line 104
  • #4 ungrab_keyboard
    at core/keybindings.c line 1519

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	}
Comment 5 Olivier Fourdan 2016-04-18 13:36:33 UTC
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.
Comment 6 Rui Matos 2016-04-18 15:52:58 UTC
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.
Comment 7 Olivier Fourdan 2016-04-18 17:03:52 UTC
Created attachment 326284 [details] [review]
[PATCH] keybindings: Fix keyboard move/resize on Wayland

Updated patch as per comment 6
Comment 8 Rui Matos 2016-04-18 19:40:07 UTC
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 9 Olivier Fourdan 2016-04-19 07:17:24 UTC
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