[mutter/gnome-42] window/wayland: Always update the monitor when updating



commit 16ac9567dbd166746d2368a73dc3b4b417615bba
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Aug 3 23:01:00 2022 +0200

    window/wayland: Always update the monitor when updating
    
    If the window didn't have a size, it would still have a monitor, and
    when we are asked to update, we must update, as the old monitor might
    not be kept around, leaving us vulnerable to use after free.
    
    Avoid not updating the monitor by using the stored IDs (preferred, or
    previous) to find suitable logical monitors, with the primary monitor
    being the last fallback unless we're completely headless.
    
    This fixes the assert
    
      !window->monitor ||
      g_list_find (meta_monitor_manager_get_logical_monitors (monitor_manager),
                   window->monitor)
    
    in meta_window_update_for_monitors_changed() being hit when a Wayland
    window has been created, but not mapped, when a hotplug happens.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>

 src/wayland/meta-window-wayland.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index 53a0078034..d8ece0bd79 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -490,7 +490,10 @@ meta_window_wayland_update_main_monitor (MetaWindow                   *window,
     }
 
   if (window->rect.width == 0 || window->rect.height == 0)
-    return;
+    {
+      window->monitor = meta_window_find_monitor_from_id (window);
+      return;
+    }
 
   /* Require both the current and the new monitor would be the new main monitor,
    * even given the resulting scale the window would end up having. This is


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]