[gtk/wip/chergert/gdk-macos-gl-renderer: 5/6] macos: tweak gravity while resizing




commit d8dde61f99fe6869e7ae47f33ed2df615935bb09
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 29 10:30:41 2020 -0700

    macos: tweak gravity while resizing
    
    This helps a situation where the window contents has not changed
    in time for a drawing. Setting the texture gravity helps that side or
    corner to be less jittery while moving.
    
    Ideally, we can get to a point where we are synchronized and keeping
    up with drawing fast enough to not need this. That may require some
    work to drive frame clocks from drawRect: though.

 gdk/macos/GdkMacosWindow.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
---
diff --git a/gdk/macos/GdkMacosWindow.c b/gdk/macos/GdkMacosWindow.c
index c4a133afcc..b511233cdf 100644
--- a/gdk/macos/GdkMacosWindow.c
+++ b/gdk/macos/GdkMacosWindow.c
@@ -25,6 +25,7 @@
 
 #import "GdkMacosBaseView.h"
 #import "GdkMacosCairoView.h"
+#import "GdkMacosGLView.h"
 #import "GdkMacosWindow.h"
 
 #include "gdkmacosdisplay-private.h"
@@ -140,6 +141,10 @@
 
       _gdk_macos_display_break_all_grabs (GDK_MACOS_DISPLAY (display), time);
 
+      /* Reset gravity */
+      if (GDK_IS_MACOS_GL_VIEW ([self contentView]))
+        [[[self contentView] layer] setContentsGravity:kCAGravityBottomLeft];
+
       break;
     }
 
@@ -543,6 +548,43 @@
   inManualResize = YES;
   resizeEdge = edge;
 
+  if (GDK_IS_MACOS_GL_VIEW ([self contentView]))
+    {
+      CALayerContentsGravity gravity = kCAGravityBottomLeft;
+
+      switch (edge)
+        {
+        default:
+        case GDK_SURFACE_EDGE_NORTH:
+          gravity = kCAGravityTopLeft;
+          break;
+
+        case GDK_SURFACE_EDGE_NORTH_WEST:
+          gravity = kCAGravityTopRight;
+          break;
+
+        case GDK_SURFACE_EDGE_SOUTH_WEST:
+        case GDK_SURFACE_EDGE_WEST:
+          gravity = kCAGravityBottomRight;
+          break;
+
+        case GDK_SURFACE_EDGE_SOUTH:
+        case GDK_SURFACE_EDGE_SOUTH_EAST:
+          gravity = kCAGravityBottomLeft;
+          break;
+
+        case GDK_SURFACE_EDGE_EAST:
+          gravity = kCAGravityBottomLeft;
+          break;
+
+        case GDK_SURFACE_EDGE_NORTH_EAST:
+          gravity = kCAGravityTopLeft;
+          break;
+        }
+
+      [[[self contentView] layer] setContentsGravity:gravity];
+    }
+
   initialResizeFrame = [self frame];
   initialResizeLocation = [self convertPointToScreen:[self mouseLocationOutsideOfEventStream]];
 }


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