From abdbc14ca8a6dffd452d738c10f3984787cc1d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Thu, 12 Mar 2020 23:35:28 +0100 Subject: [PATCH 1/3] wayland/actor-surface: Update outputs on stage-views changes ClutterActors new "stage-views-changed" signal fits pretty well for the updating of wl_outputs a MetaWaylandActorSurface is on: With that signal we get notified if the surface moved to a different CRTC, of which every output has at least one. So start listening to that signal, which fixes a bug where the wl_output of a surface changes, but its allocation remains the same (which means no signals triggering an update of the outputs will be emitted) and no enter/leave events for the new wl_outputs are sent to the client. This can happen when a monitor is hotplugged but the new allocation is exactly the same as the old one even though it's on a different monitor. Since the "stage-views-on-changed" signal will also get emitted when a parent actor of the surface is moved, this means we can now remove the call to meta_wayland_surface_update_outputs_recursively() on window position changes or the completion of window-effects. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1358 --- src/wayland/meta-wayland-actor-surface.c | 6 ++++++ src/wayland/meta-wayland-shell-surface.c | 16 ---------------- src/wayland/meta-xwayland-surface.c | 16 ---------------- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/wayland/meta-wayland-actor-surface.c b/src/wayland/meta-wayland-actor-surface.c index 47b3c1c3e2f..5d4478253e3 100644 --- a/src/wayland/meta-wayland-actor-surface.c +++ b/src/wayland/meta-wayland-actor-surface.c @@ -76,6 +76,9 @@ clear_surface_actor (MetaWaylandActorSurface *actor_surface) g_signal_handlers_disconnect_by_func (priv->actor, meta_wayland_surface_update_outputs_recursively, surface); + g_signal_handlers_disconnect_by_func (priv->actor, + meta_wayland_surface_update_outputs, + surface); g_clear_object (&priv->actor); } @@ -445,4 +448,7 @@ meta_wayland_actor_surface_reset_actor (MetaWaylandActorSurface *actor_surface) g_signal_connect_swapped (priv->actor, "notify::mapped", G_CALLBACK (meta_wayland_surface_update_outputs_recursively), surface); + g_signal_connect_swapped (priv->actor, "stage-views-changed", + G_CALLBACK (meta_wayland_surface_update_outputs), + surface); } diff --git a/src/wayland/meta-wayland-shell-surface.c b/src/wayland/meta-wayland-shell-surface.c index 12d291043d5..7bad43f34d0 100644 --- a/src/wayland/meta-wayland-shell-surface.c +++ b/src/wayland/meta-wayland-shell-surface.c @@ -37,7 +37,6 @@ typedef struct _MetaWaylandShellSurfacePrivate MetaWindow *window; gulong unmanaging_handler_id; - gulong position_changed_handler_id; gulong effects_completed_handler_id; } MetaWaylandShellSurfacePrivate; @@ -107,8 +106,6 @@ clear_window (MetaWaylandShellSurface *shell_surface) g_clear_signal_handler (&priv->unmanaging_handler_id, priv->window); - g_clear_signal_handler (&priv->position_changed_handler_id, - priv->window); g_clear_signal_handler (&priv->effects_completed_handler_id, meta_window_actor_from_window (priv->window)); priv->window = NULL; @@ -127,18 +124,10 @@ window_unmanaging (MetaWindow *window, clear_window (shell_surface); } -static void -window_position_changed (MetaWindow *window, - MetaWaylandSurface *surface) -{ - meta_wayland_surface_update_outputs_recursively (surface); -} - static void window_actor_effects_completed (MetaWindowActor *window_actor, MetaWaylandSurface *surface) { - meta_wayland_surface_update_outputs_recursively (surface); meta_wayland_compositor_repick (surface->compositor); } @@ -167,11 +156,6 @@ meta_wayland_shell_surface_set_window (MetaWaylandShellSurface *shell_surface, "unmanaging", G_CALLBACK (window_unmanaging), shell_surface); - priv->position_changed_handler_id = - g_signal_connect (window, - "position-changed", - G_CALLBACK (window_position_changed), - surface); priv->effects_completed_handler_id = g_signal_connect (meta_window_actor_from_window (window), "effects-completed", diff --git a/src/wayland/meta-xwayland-surface.c b/src/wayland/meta-xwayland-surface.c index c8625f414c9..11f58012724 100644 --- a/src/wayland/meta-xwayland-surface.c +++ b/src/wayland/meta-xwayland-surface.c @@ -44,7 +44,6 @@ struct _MetaXwaylandSurface MetaWindow *window; gulong unmanaging_handler_id; - gulong position_changed_handler_id; gulong effects_completed_handler_id; }; @@ -67,8 +66,6 @@ clear_window (MetaXwaylandSurface *xwayland_surface) g_clear_signal_handler (&xwayland_surface->unmanaging_handler_id, xwayland_surface->window); - g_clear_signal_handler (&xwayland_surface->position_changed_handler_id, - xwayland_surface->window); window_actor = meta_window_actor_from_window (xwayland_surface->window); g_clear_signal_handler (&xwayland_surface->effects_completed_handler_id, @@ -91,18 +88,10 @@ window_unmanaging (MetaWindow *window, clear_window (xwayland_surface); } -static void -window_position_changed (MetaWindow *window, - MetaWaylandSurface *surface) -{ - meta_wayland_surface_update_outputs_recursively (surface); -} - static void window_actor_effects_completed (MetaWindowActor *window_actor, MetaWaylandSurface *surface) { - meta_wayland_surface_update_outputs_recursively (surface); meta_wayland_compositor_repick (surface->compositor); } @@ -142,11 +131,6 @@ meta_xwayland_surface_associate_with_window (MetaXwaylandSurface *xwayland_surfa "unmanaging", G_CALLBACK (window_unmanaging), xwayland_surface); - xwayland_surface->position_changed_handler_id = - g_signal_connect (window, - "position-changed", - G_CALLBACK (window_position_changed), - surface); xwayland_surface->effects_completed_handler_id = g_signal_connect (meta_window_actor_from_window (window), "effects-completed", -- GitLab From 35f847ac6dc237c23344038294fc0395ce40f718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sun, 3 May 2020 17:55:28 +0200 Subject: [PATCH 2/3] wayland/surface: Don't update outputs on all geometry changes Since we now listen to the "stage-views-on-changed" signal (which "catches" all the changes we want) on MetaWaylandActorSurfaces for updating the wl_outputs the surface is on, we no longer need to call meta_wayland_surface_update_outputs_recursively() on all geometry changes, so remove that signal handler. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1358 --- src/wayland/meta-wayland-surface.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index edc2eb772bc..88e84b396f4 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1613,10 +1613,6 @@ meta_wayland_surface_init (MetaWaylandSurface *surface) surface->subsurface_branch_node = g_node_new (surface); surface->subsurface_leaf_node = g_node_prepend_data (surface->subsurface_branch_node, surface); - - g_signal_connect (surface, "geometry-changed", - G_CALLBACK (meta_wayland_surface_update_outputs_recursively), - NULL); } static void -- GitLab From 0b9a71ea3cb9c752e5748d002b45fd4cdfbf37dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 7 Jul 2020 16:49:31 +0200 Subject: [PATCH 3/3] wayland/surface: Don't update outputs recursively on mapped changes There's no need to update the outputs recursively in case the actor gets mapped or unmapped. That's because mapping happens recursively itself, so if a window with multiple subsurfaces is shown, all subsurfaces will receive a "notify::mapped" signal. Since this was the only remaining user of meta_wayland_surface_update_outputs_recursively(), we can now remove that function. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1358 --- src/wayland/meta-wayland-actor-surface.c | 5 +---- src/wayland/meta-wayland-surface.c | 11 ----------- src/wayland/meta-wayland-surface.h | 2 -- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/wayland/meta-wayland-actor-surface.c b/src/wayland/meta-wayland-actor-surface.c index 5d4478253e3..ed7c45411ef 100644 --- a/src/wayland/meta-wayland-actor-surface.c +++ b/src/wayland/meta-wayland-actor-surface.c @@ -73,9 +73,6 @@ clear_surface_actor (MetaWaylandActorSurface *actor_surface) g_signal_handlers_disconnect_by_func (priv->actor, meta_wayland_surface_notify_geometry_changed, surface); - g_signal_handlers_disconnect_by_func (priv->actor, - meta_wayland_surface_update_outputs_recursively, - surface); g_signal_handlers_disconnect_by_func (priv->actor, meta_wayland_surface_update_outputs, surface); @@ -446,7 +443,7 @@ meta_wayland_actor_surface_reset_actor (MetaWaylandActorSurface *actor_surface) G_CALLBACK (meta_wayland_surface_notify_geometry_changed), surface); g_signal_connect_swapped (priv->actor, "notify::mapped", - G_CALLBACK (meta_wayland_surface_update_outputs_recursively), + G_CALLBACK (meta_wayland_surface_update_outputs), surface); g_signal_connect_swapped (priv->actor, "stage-views-changed", G_CALLBACK (meta_wayland_surface_update_outputs), diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index 88e84b396f4..d1894a8cc43 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -1295,17 +1295,6 @@ meta_wayland_surface_update_outputs (MetaWaylandSurface *surface) surface); } -void -meta_wayland_surface_update_outputs_recursively (MetaWaylandSurface *surface) -{ - MetaWaylandSurface *subsurface_surface; - - meta_wayland_surface_update_outputs (surface); - - META_WAYLAND_SURFACE_FOREACH_SUBSURFACE (surface, subsurface_surface) - meta_wayland_surface_update_outputs_recursively (subsurface_surface); -} - void meta_wayland_surface_notify_unmapped (MetaWaylandSurface *surface) { diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h index c9ed38e306d..0c7298886d8 100644 --- a/src/wayland/meta-wayland-surface.h +++ b/src/wayland/meta-wayland-surface.h @@ -336,8 +336,6 @@ void meta_wayland_surface_notify_subsurface_state_changed (MetaWa void meta_wayland_surface_notify_unmapped (MetaWaylandSurface *surface); -void meta_wayland_surface_update_outputs_recursively (MetaWaylandSurface *surface); - int meta_wayland_surface_get_width (MetaWaylandSurface *surface); int meta_wayland_surface_get_height (MetaWaylandSurface *surface); -- GitLab