core: Avoid focusing window in presence of Clutter grabs

This is the same circumstance than the event_route not being NORMAL,
since events may or may not eventually reach the window. It should not
attempt to get focus out of the stage in that situation. This used
to be covered by META_EVENT_ROUTE_COMPOSITOR_GRAB, but this is no longer
set when ClutterGrab came in to replace it.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4858
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2433>
This commit is contained in:
Carlos Garnacho 2022-05-27 14:14:31 +02:00 committed by Marge Bot
parent 1e95710c52
commit 50e89e3760

View File

@ -4502,6 +4502,8 @@ meta_window_focus (MetaWindow *window,
{
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
MetaWindow *modal_transient;
MetaBackend *backend;
ClutterStage *stage;
g_return_if_fail (!window->override_redirect);
@ -4548,12 +4550,12 @@ meta_window_focus (MetaWindow *window,
META_WINDOW_GET_CLASS (window)->focus (window, timestamp);
if (window->display->event_route == META_EVENT_ROUTE_NORMAL)
{
MetaBackend *backend = meta_get_backend ();
ClutterStage *stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
backend = meta_get_backend ();
stage = CLUTTER_STAGE (meta_backend_get_stage (backend));
if (window->display->event_route == META_EVENT_ROUTE_NORMAL &&
clutter_stage_get_grab_actor (stage) == NULL)
clutter_stage_set_key_focus (stage, NULL);
}
if (window->close_dialog &&
meta_close_dialog_is_visible (window->close_dialog))