[gtk/wip/chergert/quartz4u: 71/116] macos: clamp toplevel present to workarea for first present



commit bd0947fc1f29a15221faada8c9593f97c413c166
Author: Christian Hergert <chergert redhat com>
Date:   Thu May 21 09:45:33 2020 -0700

    macos: clamp toplevel present to workarea for first present
    
    This helps ensure that CSD windows do not fall outside the workarea
    for their first present. SSD windows already seem to get that so we
    don't need to deal with them specially.

 gdk/macos/gdkmacostoplevelsurface.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gdk/macos/gdkmacostoplevelsurface.c b/gdk/macos/gdkmacostoplevelsurface.c
index 7734b20420..bc5c398916 100644
--- a/gdk/macos/gdkmacostoplevelsurface.c
+++ b/gdk/macos/gdkmacostoplevelsurface.c
@@ -156,8 +156,25 @@ _gdk_macos_toplevel_surface_present (GdkToplevel       *toplevel,
           (GDK_MACOS_SURFACE (self)->shadow_left ||
            GDK_MACOS_SURFACE (self)->shadow_top))
         {
-          int x = GDK_SURFACE (self)->x - GDK_MACOS_SURFACE (self)->shadow_left;
-          int y = GDK_SURFACE (self)->y - GDK_MACOS_SURFACE (self)->shadow_top;
+          GdkMonitor *monitor = _gdk_macos_surface_get_best_monitor (GDK_MACOS_SURFACE (self));
+          int x = GDK_SURFACE (self)->x;
+          int y = GDK_SURFACE (self)->y;
+
+          if (monitor != NULL)
+            {
+              GdkRectangle visible;
+
+              gdk_monitor_get_workarea (monitor, &visible);
+
+              if (x < visible.x)
+                x = visible.x;
+
+              if (y < visible.y)
+                y = visible.y;
+            }
+
+          x -= GDK_MACOS_SURFACE (self)->shadow_left;
+          y -= GDK_MACOS_SURFACE (self)->shadow_top;
 
           _gdk_macos_surface_move (GDK_MACOS_SURFACE (self), x, y);
         }


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