diff --git a/data/org.gnome.mutter.wayland.gschema.xml.in b/data/org.gnome.mutter.wayland.gschema.xml.in index 48241296e..bd41e9f18 100644 --- a/data/org.gnome.mutter.wayland.gschema.xml.in +++ b/data/org.gnome.mutter.wayland.gschema.xml.in @@ -61,10 +61,17 @@ false - Allow grabs with Xwayland + Allow X11 grabs to lock keyboard focus with Xwayland - 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 diff --git a/src/wayland/meta-xwayland-grab-keyboard.c b/src/wayland/meta-xwayland-grab-keyboard.c index db2d5f0bd..5724e63a2 100644 --- a/src/wayland/meta-xwayland-grab-keyboard.c +++ b/src/wayland/meta-xwayland-grab-keyboard.c @@ -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)