mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
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:
parent
f6eb2a8cf8
commit
c9cc07fd3a
@ -61,10 +61,17 @@
|
|||||||
|
|
||||||
<key name="xwayland-allow-grabs" type="b">
|
<key name="xwayland-allow-grabs" type="b">
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
<summary>Allow grabs with Xwayland</summary>
|
<summary>Allow X11 grabs to lock keyboard focus with Xwayland</summary>
|
||||||
<description>
|
<description>
|
||||||
Allow keyboard grabs issued by X11 applications running in Xwayland
|
Allow all keyboard events to be routed to X11 “override redirect”
|
||||||
to be taken into account.
|
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
|
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
|
also either send a specific X11 ClientMessage to the root window or be
|
||||||
|
@ -193,8 +193,6 @@ meta_xwayland_grab_is_granted (MetaWindow *window)
|
|||||||
|
|
||||||
backend = meta_get_backend ();
|
backend = meta_get_backend ();
|
||||||
settings = meta_backend_get_settings (backend);
|
settings = meta_backend_get_settings (backend);
|
||||||
if (!meta_settings_are_xwayland_grabs_allowed (settings))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Check whether the window is blacklisted */
|
/* Check whether the window is blacklisted */
|
||||||
meta_settings_get_xwayland_grab_patterns (settings, &whitelist, &blacklist);
|
meta_settings_get_xwayland_grab_patterns (settings, &whitelist, &blacklist);
|
||||||
@ -214,6 +212,22 @@ meta_xwayland_grab_is_granted (MetaWindow *window)
|
|||||||
return FALSE;
|
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
|
static void
|
||||||
meta_xwayland_keyboard_grab_activate (MetaXwaylandKeyboardActiveGrab *active_grab)
|
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_verbose ("XWayland window %s has a grab granted", window->desc);
|
||||||
meta_wayland_surface_inhibit_shortcuts (surface, seat);
|
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);
|
meta_wayland_keyboard_start_grab (seat->keyboard, &active_grab->keyboard_grab);
|
||||||
}
|
}
|
||||||
if (active_grab->window_associate_handler)
|
if (active_grab->window_associate_handler)
|
||||||
|
Loading…
Reference in New Issue
Block a user