[mutter] window: Make a better guess at initial monitor



commit 546b94545e8918f96d3162f28126d89fee9af0e4
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Sat Dec 18 00:03:21 2021 +0100

    window: Make a better guess at initial monitor
    
    We'd guess the initial monitor before it was actually calculated by
    looking at the initial geometry. For Wayland windows, this geometry was
    always 0x0+0+0, thus the selected monitor was always the primary one.
    
    This is problematic if we want to provide initial more likely
    configurations to Wayland clients. While we're not doing that yet, it'll
    be added later, and this is in preparation for that.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2167>

 src/core/window.c                 | 8 +++++++-
 src/wayland/meta-window-wayland.c | 3 +++
 2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/core/window.c b/src/core/window.c
index 595177b9ae..2545a1b5b9 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -964,6 +964,8 @@ _meta_window_shared_new (MetaDisplay         *display,
                          MetaCompEffect       effect,
                          XWindowAttributes   *attrs)
 {
+  MetaContext *context = meta_display_get_context (display);
+  MetaBackend *backend = meta_context_get_backend (context);
   MetaWorkspaceManager *workspace_manager = display->workspace_manager;
   MetaWindow *window;
 
@@ -1157,7 +1159,11 @@ _meta_window_shared_new (MetaDisplay         *display,
 
   window->compositor_private = NULL;
 
-  window->monitor = meta_window_calculate_main_logical_monitor (window);
+  if (window->rect.width > 0 && window->rect.height > 0)
+    window->monitor = meta_window_calculate_main_logical_monitor (window);
+  else
+    window->monitor = meta_backend_get_current_logical_monitor (backend);
+
   if (window->monitor)
     window->preferred_output_winsys_id = window->monitor->winsys_id;
   else
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index 8190a01b46..2a923ef8fa 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -468,6 +468,9 @@ meta_window_wayland_update_main_monitor (MetaWindow                   *window,
       return;
     }
 
+  if (window->rect.width == 0 || window->rect.height == 0)
+    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
    * needed to avoid jumping back and forth between the new and the old, since


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