x11: Hook X11 focus management to MetaDisplay signal

This makes the MetaX11Display indirectly react to MetaDisplay changes,
rather than having the MetaDisplay also drive the MetaX11Display focus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3269>
This commit is contained in:
Carlos Garnacho 2023-09-05 14:13:46 +02:00 committed by Georges Basile Stavracas Neto
parent 24344d8141
commit 7fbc0ccc01
3 changed files with 19 additions and 12 deletions

View File

@ -1628,14 +1628,6 @@ meta_display_set_input_focus (MetaDisplay *display,
g_signal_emit (display, display_signals[FOCUS_WINDOW], 0, window, ms2us (timestamp)); g_signal_emit (display, display_signals[FOCUS_WINDOW], 0, window, ms2us (timestamp));
#ifdef HAVE_X11_CLIENT
if (display->x11_display)
{
meta_x11_display_set_input_focus (display->x11_display, window,
timestamp);
}
#endif
meta_display_update_focus_window (display, window); meta_display_update_focus_window (display, window);
display->last_focus_time = timestamp; display->last_focus_time = timestamp;

View File

@ -245,9 +245,6 @@ void meta_x11_display_update_focus_window (MetaX11Display *x11_display,
Window xwindow, Window xwindow,
gulong serial, gulong serial,
gboolean focused_by_us); gboolean focused_by_us);
void meta_x11_display_set_input_focus (MetaX11Display *x11_display,
MetaWindow *window,
uint32_t timestamp);
MetaDisplay * meta_x11_display_get_display (MetaX11Display *x11_display); MetaDisplay * meta_x11_display_get_display (MetaX11Display *x11_display);

View File

@ -105,6 +105,9 @@ static void meta_x11_display_init_frames_client (MetaX11Display *x11_display);
static void meta_x11_display_remove_cursor_later (MetaX11Display *x11_display); static void meta_x11_display_remove_cursor_later (MetaX11Display *x11_display);
static void meta_x11_display_set_input_focus (MetaX11Display *x11_display,
MetaWindow *window,
uint32_t timestamp);
static MetaBackend * static MetaBackend *
backend_from_x11_display (MetaX11Display *x11_display) backend_from_x11_display (MetaX11Display *x11_display)
@ -1168,6 +1171,15 @@ on_stage_key_focus_changed (MetaX11Display *x11_display)
} }
#endif #endif
static void
focus_window_cb (MetaX11Display *x11_display,
MetaWindow *window,
int64_t timestamp_us)
{
meta_x11_display_set_input_focus (x11_display, window,
us2ms (timestamp_us));
}
static void static void
meta_x11_display_init_frames_client (MetaX11Display *x11_display) meta_x11_display_init_frames_client (MetaX11Display *x11_display)
{ {
@ -1319,6 +1331,12 @@ meta_x11_display_new (MetaDisplay *display,
G_CONNECT_SWAPPED); G_CONNECT_SWAPPED);
update_cursor_theme (x11_display); update_cursor_theme (x11_display);
g_signal_connect_object (display,
"focus-window",
G_CALLBACK (focus_window_cb),
x11_display,
G_CONNECT_SWAPPED);
#ifdef HAVE_XWAYLAND #ifdef HAVE_XWAYLAND
if (!meta_is_wayland_compositor ()) if (!meta_is_wayland_compositor ())
#endif #endif
@ -2067,7 +2085,7 @@ meta_x11_display_set_input_focus_internal (MetaX11Display *x11_display,
meta_x11_error_trap_pop (x11_display); meta_x11_error_trap_pop (x11_display);
} }
void static void
meta_x11_display_set_input_focus (MetaX11Display *x11_display, meta_x11_display_set_input_focus (MetaX11Display *x11_display,
MetaWindow *window, MetaWindow *window,
uint32_t timestamp) uint32_t timestamp)