gdk: Add gdk_toplevel_begin_move/resize
authorMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2020 15:45:37 +0000 (11:45 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2020 16:41:16 +0000 (12:41 -0400)
For now, these are wrappers around the surface apis,
but they are going to replace them, since this operation
is only available on toplevels.

docs/reference/gdk/gdk4-sections.txt
gdk/gdktoplevel.c
gdk/gdktoplevel.h

index b753ee9ece158dddae72061a6b0e92ca242eda7d..b526e2a879b0bf7211cb7611a7c0651f5a1482ff 100644 (file)
@@ -675,6 +675,8 @@ gdk_toplevel_set_deletable
 gdk_toplevel_supports_edge_constraints
 gdk_toplevel_inhibit_system_shortcuts
 gdk_toplevel_restore_system_shortcuts
+gdk_toplevel_begin_resize
+gdk_toplevel_begin_move
 <SUBSECTION Standard>
 GDK_TYPE_TOPLEVEL
 gdk_toplevel_get_type
index 96e49826273af9c0b277f3708cd609621350336a..7c10511ca977a4d28343236895194a0d1df9dba5 100644 (file)
@@ -23,6 +23,8 @@
 #include "gdk-private.h"
 #include "gdktoplevelprivate.h"
 
+#include <math.h>
+
 /**
  * SECTION:gdktoplevel
  * @Short_description: Interface for toplevel surfaces
@@ -512,3 +514,51 @@ gdk_toplevel_restore_system_shortcuts (GdkToplevel *toplevel)
 
   GDK_TOPLEVEL_GET_IFACE (toplevel)->restore_system_shortcuts (toplevel);
 }
+
+/**
+ * gdk_toplevel_begin_resize:
+ * @toplevel: a #GdkToplevel
+ * @edge: the edge or corner from which the drag is started
+ * @device: the device used for the operation
+ * @button: the button being used to drag, or 0 for a keyboard-initiated drag
+ * @x: surface X coordinate of mouse click that began the drag
+ * @y: surface Y coordinate of mouse click that began the drag
+ * @timestamp: timestamp of mouse click that began the drag (use gdk_event_get_time())
+ *
+ * Begins an interactive resize operation (for a toplevel surface).
+ * You might use this function to implement a “window resize grip.”
+ */
+void
+gdk_toplevel_begin_resize (GdkToplevel    *toplevel,
+                           GdkSurfaceEdge  edge,
+                           GdkDevice      *device,
+                           int             button,
+                           double          x,
+                           double          y,
+                           guint32         timestamp)
+{
+  gdk_surface_begin_resize_drag (GDK_SURFACE (toplevel), edge, device, button, round (x), round (y), timestamp);
+}
+
+/**
+ * gdk_toplevel_begin_move:
+ * @toplevel: a #GdkToplevel
+ * @device: the device used for the operation
+ * @button: the button being used to drag, or 0 for a keyboard-initiated drag
+ * @x: surface X coordinate of mouse click that began the drag
+ * @y: surface Y coordinate of mouse click that began the drag
+ * @timestamp: timestamp of mouse click that began the drag
+ *
+ * Begins an interactive move operation (for a toplevel surface).
+ * You might use this function to implement draggable titlebars.
+ */
+void
+gdk_toplevel_begin_move (GdkToplevel *toplevel,
+                         GdkDevice   *device,
+                         int          button,
+                         double       x,
+                         double       y,
+                         guint32      timestamp)
+{
+  gdk_surface_begin_move_drag (GDK_SURFACE (toplevel), device, button, round (x), round (y), timestamp);
+}
index 863c26f3e8e982b1c9d5b4fdf54861034bf0aeb9..20b3fc5d4b93f3593e45bf89fca91ffc32c701ef 100644 (file)
@@ -95,6 +95,23 @@ void          gdk_toplevel_inhibit_system_shortcuts  (GdkToplevel *toplevel,
 GDK_AVAILABLE_IN_ALL
 void          gdk_toplevel_restore_system_shortcuts  (GdkToplevel *toplevel);
 
+GDK_AVAILABLE_IN_ALL
+void          gdk_toplevel_begin_resize              (GdkToplevel    *toplevel,
+                                                      GdkSurfaceEdge  edge,
+                                                      GdkDevice      *device,
+                                                      int             button,
+                                                      double          x,
+                                                      double          y,
+                                                      guint32         timestamp);
+
+GDK_AVAILABLE_IN_ALL
+void          gdk_toplevel_begin_move                (GdkToplevel    *toplevel,
+                                                      GdkDevice      *device,
+                                                      int             button,
+                                                      double          x,
+                                                      double          y,
+                                                      guint32         timestamp);
+
 
 G_END_DECLS