1
0
Fork 0

settings: Slack off “xwayland-allow-grabs” setting

To emulate X11 grabs, mutter as a Wayland compositor would disable its
own keyboard shortcuts and when the X11 window is an override redirect
window (which never receives focus), it also forces keyboard focus onto
that X11 O-R window so that all keyboard events are routed to the
window, just like an X11 server would.

But that's a bit of a “all-or-nothing” approach which prevents
applications that would legitimately grab the keyboard under X11 (like
virtual machine viewers) to work by default.

Change “xwayland-allow-grabs” to control whether the keyboard focus
should be locked onto override redirect windows in case of an X11 grab.

For stringent needs, careful users can still use the blacklisting
feature (i.e. a list containing “!*”) to prevent grabs from any X11
applications to affect other Wayland native applications.

https://gitlab.gnome.org/GNOME/mutter/issues/597
This commit is contained in:
Olivier Fourdan 2019-05-13 11:07:29 +02:00
parent f6eb2a8cf8
commit c9cc07fd3a
2 changed files with 28 additions and 7 deletions

View file

@ -61,10 +61,17 @@
<key name="xwayland-allow-grabs" type="b">
<default>false</default>
<summary>Allow grabs with Xwayland</summary>
<summary>Allow X11 grabs to lock keyboard focus with Xwayland</summary>
<description>
Allow keyboard grabs issued by X11 applications running in Xwayland
to be taken into account.
Allow all keyboard events to be routed to X11 “override redirect”
windows with a grab when running in Xwayland.
This option is to support X11 clients which map an “override redirect”
window (which do not receive keyboard focus) and issue a keyboard
grab to force all keyboard events to that window.
This option is seldom used and has no effect on regular X11 windows
which can receive keyboard focus under normal circumstances.
For a X11 grab to be taken into account under Wayland, the client must
also either send a specific X11 ClientMessage to the root window or be

View file

@ -193,8 +193,6 @@ meta_xwayland_grab_is_granted (MetaWindow *window)
backend = meta_get_backend ();
settings = meta_backend_get_settings (backend);
if (!meta_settings_are_xwayland_grabs_allowed (settings))
return FALSE;
/* Check whether the window is blacklisted */
meta_settings_get_xwayland_grab_patterns (settings, &whitelist, &blacklist);
@ -214,6 +212,22 @@ meta_xwayland_grab_is_granted (MetaWindow *window)
return FALSE;
}
static gboolean
meta_xwayland_grab_should_lock_focus (MetaWindow *window)
{
MetaBackend *backend;
MetaSettings *settings;
/* Lock focus applies to O-R windows which never receive keyboard focus otherwise */
if (!window->override_redirect)
return FALSE;
backend = meta_get_backend ();
settings = meta_backend_get_settings (backend);
return meta_settings_are_xwayland_grabs_allowed (settings);
}
static void
meta_xwayland_keyboard_grab_activate (MetaXwaylandKeyboardActiveGrab *active_grab)
{
@ -225,8 +239,8 @@ meta_xwayland_keyboard_grab_activate (MetaXwaylandKeyboardActiveGrab *active_gra
{
meta_verbose ("XWayland window %s has a grab granted", window->desc);
meta_wayland_surface_inhibit_shortcuts (surface, seat);
/* Use a grab for O-R windows which never receive keyboard focus otherwise */
if (window->override_redirect)
if (meta_xwayland_grab_should_lock_focus (window))
meta_wayland_keyboard_start_grab (seat->keyboard, &active_grab->keyboard_grab);
}
if (active_grab->window_associate_handler)