wayland/xdg-popup: Always use monitor of toplevel
authorJonas Ådahl <jadahl@gmail.com>
Fri, 23 Sep 2016 09:15:56 +0000 (17:15 +0800)
committerSjoerd Simons <sjoerd@debian.org>
Fri, 14 Oct 2016 20:01:14 +0000 (20:01 +0000)
Always use the monitor of the toplevel surface's window, so that the
popup menu and the parent will always have the same scale. This fixes
the dimensions sent in the xdg_popup configure event.

https://bugzilla.gnome.org/show_bug.cgi?id=771841

Gbp-Pq: Name wayland-xdg-popup-Always-use-monitor-of-toplevel.patch

src/wayland/meta-wayland-xdg-shell.c
src/wayland/meta-window-wayland.c

index e9223a9a226c24927aca48af2c749e93e50e724e..591a1ed6c8a811f7db13dcc277b5bf9641432667 100644 (file)
@@ -1463,6 +1463,7 @@ xdg_surface_constructor_get_toplevel (struct wl_client   *client,
 
   window = meta_window_wayland_new (meta_get_display (), surface);
   meta_wayland_surface_set_window (surface, window);
+  meta_window_update_monitor (window, FALSE);
 }
 
 static void
index 1b3e0909b51f987f9672ae8544320ec643e2b057..fd630ca74c23e4e1feba89946da239d4b9f06186 100644 (file)
@@ -334,19 +334,31 @@ scale_rect_size (MetaRectangle *rect,
 static void
 meta_window_wayland_update_main_monitor (MetaWindow *window)
 {
+  MetaWindow *toplevel_window;
   const MetaMonitorInfo *from;
   const MetaMonitorInfo *to;
   const MetaMonitorInfo *scaled_new;
   float scale;
   MetaRectangle rect;
 
-  /* 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
-   * changing main monitor may cause the window to be resized so that it no
-   * longer have that same new main monitor. */
   from = window->monitor;
-  to = meta_screen_calculate_monitor_for_window (window->screen, window);
+
+  /* If the window is not a toplevel window (i.e. it's a popup window) just use
+   * the monitor of the toplevel. */
+  toplevel_window = meta_wayland_surface_get_toplevel_window (window->surface);
+  if (toplevel_window != window)
+    {
+      to = toplevel_window->monitor;
+    }
+  else
+    {
+      /* 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
+       * changing main monitor may cause the window to be resized so that it no
+       * longer have that same new main monitor. */
+      to = meta_screen_calculate_monitor_for_window (window->screen, window);
+    }
 
   if (from == to)
     return;