From 7bf07d2980dc9e36eb3f8d830eaeed1ce6b4ee44 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Mon, 21 Nov 2022 13:13:07 +0100 Subject: [PATCH] core/window: Implement GInitable Currently, we will notify the display about a new window being created during the constructed phase of the GObject. During this time, property-change notifications are frozen by GObject, so we'll emit a few ::notify signals only after the window-created signal, although the actual property change happened before that. This caused confusion in gnome-shell code where a notify::skip-taskbar = true emission was seen when the property already was true inside a window-created handler before. In order to fix that that, we notify the window creation post-construction of the GObject on GInitable.init vfunc Details https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6119#note_1598983 Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6119 Part-of: --- src/core/window.c | 24 +++++++++++++++++++++++- src/wayland/meta-window-wayland.c | 11 ++++++----- src/x11/window-x11.c | 26 ++++++++++++++------------ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/core/window.c b/src/core/window.c index 7faa3e95c..12121b455 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -158,12 +158,17 @@ static MetaWindow * meta_window_find_tile_match (MetaWindow *window, MetaTileMode mode); static void update_edge_constraints (MetaWindow *window); +static void initable_iface_init (GInitableIface *initable_iface); + typedef struct _MetaWindowPrivate { MetaQueueType queued_types; } MetaWindowPrivate; -G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaWindow, meta_window, G_TYPE_OBJECT) +G_DEFINE_ABSTRACT_TYPE_WITH_CODE (MetaWindow, meta_window, G_TYPE_OBJECT, + G_ADD_PRIVATE (MetaWindow) + G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, + initable_iface_init)) enum { @@ -1366,11 +1371,28 @@ meta_window_constructed (GObject *object) unminimize_window_and_all_transient_parents (window); window->constructing = FALSE; +} + +static gboolean +meta_window_initable_init (GInitable *initable, + GCancellable *cancellable, + GError **error) +{ + MetaWindow *window = META_WINDOW (initable); + MetaDisplay *display = window->display; meta_display_notify_window_created (display, window); if (window->wm_state_demands_attention) g_signal_emit_by_name (display, "window-demands-attention", window); + + return TRUE; +} + +static void +initable_iface_init (GInitableIface *initable_iface) +{ + initable_iface->init = meta_window_initable_init; } static gboolean diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index 3be11de40..b31d11d46 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -908,11 +908,12 @@ meta_window_wayland_new (MetaDisplay *display, MetaWindowWayland *wl_window; MetaWindow *window; - window = g_object_new (META_TYPE_WINDOW_WAYLAND, - "display", display, - "effect", META_COMP_EFFECT_CREATE, - "surface", surface, - NULL); + window = g_initable_new (META_TYPE_WINDOW_WAYLAND, + NULL, NULL, + "display", display, + "effect", META_COMP_EFFECT_CREATE, + "surface", surface, + NULL); wl_window = META_WINDOW_WAYLAND (window); set_geometry_scale_for_window (wl_window, wl_window->geometry_scale); diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index d69e2310b..1566e1e4a 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -3890,22 +3890,24 @@ meta_window_x11_new (MetaDisplay *display, #ifdef HAVE_XWAYLAND if (meta_is_wayland_compositor ()) { - window = g_object_new (META_TYPE_WINDOW_XWAYLAND, - "display", display, - "effect", effect, - "attributes", &attrs, - "xwindow", xwindow, - NULL); + window = g_initable_new (META_TYPE_WINDOW_XWAYLAND, + NULL, NULL, + "display", display, + "effect", effect, + "attributes", &attrs, + "xwindow", xwindow, + NULL); } else #endif { - window = g_object_new (META_TYPE_WINDOW_X11, - "display", display, - "effect", effect, - "attributes", &attrs, - "xwindow", xwindow, - NULL); + window = g_initable_new (META_TYPE_WINDOW_X11, + NULL, NULL, + "display", display, + "effect", effect, + "attributes", &attrs, + "xwindow", xwindow, + NULL); } if (existing_wm_state == IconicState) {