wayland: Move Wayland focus synchronization code out of core

Handle focus synchronization in MetaWaylandCompositor itself. This
is so far plumbed so that MetaDisplay still drives focus synchronization
directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3511>
This commit is contained in:
Carlos Garnacho 2023-11-02 14:23:22 +01:00 committed by Marge Bot
parent 17d1d3abd8
commit 9383171958
3 changed files with 37 additions and 12 deletions

View File

@ -1493,19 +1493,8 @@ meta_display_sync_wayland_input_focus (MetaDisplay *display)
{
#ifdef HAVE_WAYLAND
MetaWaylandCompositor *compositor = wayland_compositor_from_display (display);
MetaWindow *focus_window = NULL;
if (!meta_display_windows_are_interactable (display))
focus_window = NULL;
else if (!display->focus_window)
focus_window = NULL;
else if (display->focus_window &&
meta_window_get_wayland_surface (display->focus_window))
focus_window = display->focus_window;
else
meta_topic (META_DEBUG_FOCUS, "Focus change has no effect, because there is no matching wayland surface");
meta_wayland_compositor_set_input_focus (compositor, focus_window);
meta_wayland_compositor_sync_focus (compositor);
#endif
}

View File

@ -1072,3 +1072,37 @@ meta_wayland_compositor_get_text_input (MetaWaylandCompositor *compositor)
{
return compositor->seat->text_input;
}
static void
meta_wayland_compositor_update_focus (MetaWaylandCompositor *compositor,
MetaWindow *window)
{
MetaContext *context = meta_wayland_compositor_get_context (compositor);
MetaDisplay *display = meta_context_get_display (context);
MetaWindow *focus_window = NULL;
/* Compositor not ready yet */
if (!compositor->seat)
return;
if (!display || !meta_display_windows_are_interactable (display))
focus_window = NULL;
else if (!window)
focus_window = NULL;
else if (window && meta_window_get_wayland_surface (window))
focus_window = window;
else
meta_topic (META_DEBUG_FOCUS, "Focus change has no effect, because there is no matching wayland surface");
meta_wayland_compositor_set_input_focus (compositor, focus_window);
}
void
meta_wayland_compositor_sync_focus (MetaWaylandCompositor *compositor)
{
MetaContext *context = meta_wayland_compositor_get_context (compositor);
MetaDisplay *display = meta_context_get_display (context);
meta_wayland_compositor_update_focus (compositor,
display ? display->focus_window : NULL);
}

View File

@ -105,3 +105,5 @@ gboolean meta_wayland_compositor_is_grabbed (MetaWaylandCompositor *compositor);
META_EXPORT_TEST
MetaWaylandFilterManager * meta_wayland_compositor_get_filter_manager (MetaWaylandCompositor *compositor);
void meta_wayland_compositor_sync_focus (MetaWaylandCompositor *compositor);