[gtk/wip/chergert/gdk-macos-fixes: 1/2] macos: ensure we have access to a GdkMonitor




commit e089bba4f5830da1173fae5836d6e040f17dfd56
Author: Christian Hergert <chergert redhat com>
Date:   Wed Oct 14 16:26:14 2020 -0700

    macos: ensure we have access to a GdkMonitor

 gdk/macos/gdkmacospopupsurface.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/gdk/macos/gdkmacospopupsurface.c b/gdk/macos/gdkmacospopupsurface.c
index a3ae3f4fda..5729fea338 100644
--- a/gdk/macos/gdkmacospopupsurface.c
+++ b/gdk/macos/gdkmacospopupsurface.c
@@ -55,14 +55,15 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
   g_assert (layout != NULL);
   g_assert (GDK_SURFACE (self)->parent);
 
-  if (layout != self->layout)
-    {
-      g_clear_pointer (&self->layout, gdk_popup_layout_unref);
-      self->layout = gdk_popup_layout_ref (layout);
-    }
+  gdk_popup_layout_ref (layout);
+  g_clear_pointer (&self->layout, gdk_popup_layout_unref);
+  self->layout = layout;
 
-  monitor = gdk_surface_get_layout_monitor (GDK_SURFACE (self), layout,
+  monitor = gdk_surface_get_layout_monitor (GDK_SURFACE (self),
+                                            self->layout,
                                             gdk_macos_monitor_get_workarea);
+  if (monitor == NULL)
+    monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
   gdk_macos_monitor_get_workarea (monitor, &bounds);
 
   gdk_surface_layout_popup_helper (GDK_SURFACE (self),
@@ -70,7 +71,7 @@ gdk_macos_popup_surface_layout (GdkMacosPopupSurface *self,
                                    height,
                                    monitor,
                                    &bounds,
-                                   layout,
+                                   self->layout,
                                    &final_rect);
 
   gdk_surface_get_origin (GDK_SURFACE (self)->parent, &x, &y);


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