[gtk/wip/chergert/quartz4u] macos: add helper to move/resize



commit 01965987ee2558c1ba06c723f6154c81002f18e4
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 8 14:05:08 2020 -0700

    macos: add helper to move/resize

 gdk/macos/gdkmacossurface-private.h |  8 +++++++
 gdk/macos/gdkmacossurface.c         | 44 +++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
---
diff --git a/gdk/macos/gdkmacossurface-private.h b/gdk/macos/gdkmacossurface-private.h
index 91d2c35a7f..ea4e020ff7 100644
--- a/gdk/macos/gdkmacossurface-private.h
+++ b/gdk/macos/gdkmacossurface-private.h
@@ -90,6 +90,14 @@ CGContextRef       _gdk_macos_surface_acquire_context         (GdkMacosSurface
 void               _gdk_macos_surface_release_context         (GdkMacosSurface    *self,
                                                                CGContextRef        cg_context);
 void               _gdk_macos_surface_synthesize_null_key     (GdkMacosSurface    *self);
+void               _gdk_macos_surface_move                    (GdkMacosSurface    *self,
+                                                               int                 x,
+                                                               int                 y);
+void               _gdk_macos_surface_move_resize             (GdkMacosSurface    *self,
+                                                               int                 x,
+                                                               int                 y,
+                                                               int                 width,
+                                                               int                 height);
 
 G_END_DECLS
 
diff --git a/gdk/macos/gdkmacossurface.c b/gdk/macos/gdkmacossurface.c
index c805961e17..1734b8a627 100644
--- a/gdk/macos/gdkmacossurface.c
+++ b/gdk/macos/gdkmacossurface.c
@@ -869,3 +869,47 @@ _gdk_macos_surface_synthesize_null_key (GdkMacosSurface *self)
                              &no_lock);
   _gdk_event_queue_append (display, event);
 }
+
+void
+_gdk_macos_surface_move (GdkMacosSurface *self,
+                         int              x,
+                         int              y)
+{
+  g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
+
+  _gdk_macos_surface_move_resize (self, x, y, -1, -1);
+}
+
+void
+_gdk_macos_surface_move_resize (GdkMacosSurface *self,
+                                int              x,
+                                int              y,
+                                int              width,
+                                int              height)
+{
+  GdkMacosSurfacePrivate *priv = gdk_macos_surface_get_instance_private (self);
+  GdkSurface *surface = (GdkSurface *)self;
+  GdkDisplay *display;
+
+  g_return_if_fail (GDK_IS_MACOS_SURFACE (self));
+
+  if ((x == -1 || (x == surface->x)) &&
+      (y == -1 || (y == surface->y)) &&
+      (width == -1 || (width == surface->width)) &&
+      (height == -1 || (height == surface->height)))
+    return;
+
+  display = gdk_surface_get_display (surface);
+
+  _gdk_macos_display_to_display_coords (GDK_MACOS_DISPLAY (display),
+                                        x, y, &x, &y);
+
+  if (width == -1)
+    width = surface->width;
+
+  if (height == -1)
+    height = surface->height;
+
+  [priv->window setFrame:NSMakeRect(x, y, width, height)
+                 display:YES];
+}


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