gdk: Move the begin_move/resize_drag vfuncs around
authorMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2020 16:35:45 +0000 (12:35 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 May 2020 18:15:06 +0000 (14:15 -0400)
Move these from GdkSurface to GdkToplevel, where they
belong. Update all backends.

gdk/broadway/gdksurface-broadway.c
gdk/gdksurface.c
gdk/gdksurfaceprivate.h
gdk/gdktoplevel.c
gdk/gdktoplevelprivate.h
gdk/wayland/gdksurface-wayland.c
gdk/win32/gdksurface-win32.c
gdk/x11/gdksurface-x11.c

index ac91d2887f1cc4995f66a5c3bd8d2ebdc93f9d07..9720bea77be4074ab7c19ee4e4979151783d72e0 100644 (file)
@@ -1195,18 +1195,17 @@ calculate_unmoving_origin (MoveResizeData *mv_resize)
 }
 
 static void
-gdk_broadway_surface_begin_resize_drag (GdkSurface     *surface,
-                                        GdkSurfaceEdge  edge,
-                                        GdkDevice     *device,
-                                        gint           button,
-                                        gint           x,
-                                        gint           y,
-                                        guint32        timestamp)
+gdk_broadway_toplevel_begin_resize (GdkToplevel    *toplevel,
+                                    GdkSurfaceEdge  edge,
+                                    GdkDevice      *device,
+                                    int             button,
+                                    double          x,
+                                    double          y,
+                                    guint32         timestamp)
 {
+  GdkSurface *surface = GDK_SURFACE (toplevel);
+  GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
   MoveResizeData *mv_resize;
-  GdkBroadwaySurface *impl;
-
-  impl = GDK_BROADWAY_SURFACE (surface);
 
   if (GDK_SURFACE_DESTROYED (surface))
     return;
@@ -1238,17 +1237,16 @@ gdk_broadway_surface_begin_resize_drag (GdkSurface     *surface,
 }
 
 static void
-gdk_broadway_surface_begin_move_drag (GdkSurface *surface,
-                                      GdkDevice *device,
-                                      gint       button,
-                                      gint       x,
-                                      gint       y,
-                                      guint32    timestamp)
+gdk_broadway_toplevel_begin_move (GdkToplevel *toplevel,
+                                  GdkDevice   *device,
+                                  int          button,
+                                  double       x,
+                                  double       y,
+                                  guint32      timestamp)
 {
+  GdkSurface *surface = GDK_SURFACE (toplevel);
+  GdkBroadwaySurface *impl = GDK_BROADWAY_SURFACE (surface);
   MoveResizeData *mv_resize;
-  GdkBroadwaySurface *impl;
-
-  impl = GDK_BROADWAY_SURFACE (surface);
 
   if (GDK_SURFACE_DESTROYED (surface))
     return;
@@ -1309,8 +1307,6 @@ gdk_broadway_surface_class_init (GdkBroadwaySurfaceClass *klass)
   impl_class->set_input_region = gdk_broadway_surface_set_input_region;
   impl_class->destroy = _gdk_broadway_surface_destroy;
   impl_class->beep = gdk_broadway_surface_beep;
-  impl_class->begin_resize_drag = gdk_broadway_surface_begin_resize_drag;
-  impl_class->begin_move_drag = gdk_broadway_surface_begin_move_drag;
   impl_class->destroy_notify = gdk_broadway_surface_destroy_notify;
   impl_class->drag_begin = _gdk_broadway_surface_drag_begin;
   impl_class->get_scale_factor = gdk_broadway_surface_get_scale_factor;
@@ -1665,6 +1661,8 @@ gdk_broadway_toplevel_iface_init (GdkToplevelInterface *iface)
   iface->lower = gdk_broadway_toplevel_lower;
   iface->focus = gdk_broadway_toplevel_focus;
   iface->show_window_menu = gdk_broadway_toplevel_show_window_menu;
+  iface->begin_resize = gdk_broadway_toplevel_begin_resize;
+  iface->begin_move = gdk_broadway_toplevel_begin_move;
 }
 
 typedef struct
index 4835c7ba42fb8136b91e440d777db572065f31fb..aa546b6f6a2ca2d5759816f446edec75cfe50406 100644 (file)
@@ -2400,71 +2400,6 @@ gdk_surface_create_similar_surface (GdkSurface *     surface,
   return similar_surface;
 }
 
-/**
- * gdk_surface_begin_resize_drag:
- * @surface: a toplevel #GdkSurface
- * @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 a surface resize operation (for a toplevel surface).
- * You might use this function to implement a “window resize grip,”
- */
-void
-gdk_surface_begin_resize_drag (GdkSurface     *surface,
-                               GdkSurfaceEdge  edge,
-                               GdkDevice      *device,
-                               gint            button,
-                               gint            x,
-                               gint            y,
-                               guint32         timestamp)
-{
-  if (device == NULL)
-    {
-      GdkSeat *seat = gdk_display_get_default_seat (surface->display);
-      if (button == 0)
-        device = gdk_seat_get_keyboard (seat);
-      else
-        device = gdk_seat_get_pointer (seat);
-    }
-
-  GDK_SURFACE_GET_CLASS (surface)->begin_resize_drag (surface, edge, device, button, x, y, timestamp);
-}
-
-/**
- * gdk_surface_begin_move_drag:
- * @surface: a toplevel #GdkSurface
- * @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 a surface move operation (for a toplevel surface).
- */
-void
-gdk_surface_begin_move_drag (GdkSurface *surface,
-                             GdkDevice  *device,
-                             gint        button,
-                             gint        x,
-                             gint        y,
-                             guint32     timestamp)
-{
-  if (device == NULL)
-    {
-      GdkSeat *seat = gdk_display_get_default_seat (surface->display);
-      if (button == 0)
-        device = gdk_seat_get_keyboard (seat);
-      else
-        device = gdk_seat_get_pointer (seat);
-    }
-
-  GDK_SURFACE_GET_CLASS (surface)->begin_move_drag (surface, device, button, x, y, timestamp);
-}
-
 /* This function is called when the XWindow is really gone.
  */
 void
index cbc6e53094f52a4861035f344c8b2741b7c8757a..c50fd1abfe15da23265b0369d2fa312f25e0427d 100644 (file)
@@ -149,19 +149,6 @@ struct _GdkSurfaceClass
   /* optional */
   gboolean     (* beep)                 (GdkSurface       *surface);
 
-  void         (* begin_resize_drag)    (GdkSurface     *surface,
-                                         GdkSurfaceEdge  edge,
-                                         GdkDevice     *device,
-                                         gint           button,
-                                         gint           root_x,
-                                         gint           root_y,
-                                         guint32        timestamp);
-  void         (* begin_move_drag)      (GdkSurface *surface,
-                                         GdkDevice     *device,
-                                         gint       button,
-                                         gint       root_x,
-                                         gint       root_y,
-                                         guint32    timestamp);
   void         (* destroy_notify)       (GdkSurface *surface);
   GdkDrag *    (* drag_begin)           (GdkSurface        *surface,
                                          GdkDevice        *device,
index 7c10511ca977a4d28343236895194a0d1df9dba5..49b9b8a6caccf815c47926c5d64fc99df5cc181a 100644 (file)
@@ -519,7 +519,7 @@ gdk_toplevel_restore_system_shortcuts (GdkToplevel *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
+ * @device: (nullable): 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
@@ -537,7 +537,23 @@ gdk_toplevel_begin_resize (GdkToplevel    *toplevel,
                            double          y,
                            guint32         timestamp)
 {
-  gdk_surface_begin_resize_drag (GDK_SURFACE (toplevel), edge, device, button, round (x), round (y), timestamp);
+  g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+  if (device == NULL)
+    {
+      GdkSeat *seat = gdk_display_get_default_seat (GDK_SURFACE (toplevel)->display);
+      if (button == 0)
+        device = gdk_seat_get_keyboard (seat);
+      else
+        device = gdk_seat_get_pointer (seat);
+    }
+
+  GDK_TOPLEVEL_GET_IFACE (toplevel)->begin_resize (toplevel,
+                                                   edge,
+                                                   device,
+                                                   button,
+                                                   x, y,
+                                                   timestamp);
 }
 
 /**
@@ -560,5 +576,20 @@ gdk_toplevel_begin_move (GdkToplevel *toplevel,
                          double       y,
                          guint32      timestamp)
 {
-  gdk_surface_begin_move_drag (GDK_SURFACE (toplevel), device, button, round (x), round (y), timestamp);
+  g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+  if (device == NULL)
+    {
+      GdkSeat *seat = gdk_display_get_default_seat (GDK_SURFACE (toplevel)->display);
+      if (button == 0)
+        device = gdk_seat_get_keyboard (seat);
+      else
+        device = gdk_seat_get_pointer (seat);
+    }
+
+  GDK_TOPLEVEL_GET_IFACE (toplevel)->begin_move (toplevel,
+                                                 device,
+                                                 button,
+                                                 x, y,
+                                                 timestamp);
 }
index c54d0ac503d1ffb9f94599150a72f6594d28d550..6cdccca8b7d99dcfcc9312f93e4076fc19cba05e 100644 (file)
@@ -24,6 +24,19 @@ struct _GdkToplevelInterface
   void          (* inhibit_system_shortcuts)  (GdkToplevel *toplevel,
                                                GdkEvent    *event);
   void          (* restore_system_shortcuts)  (GdkToplevel *toplevel);
+  void          (* begin_resize)        (GdkToplevel       *toplevel,
+                                         GdkSurfaceEdge     edge,
+                                         GdkDevice         *device,
+                                         int                button,
+                                         double             x,
+                                         double             y,
+                                         guint32            timestamp);
+  void          (* begin_move)          (GdkToplevel       *toplevel,
+                                         GdkDevice         *device,
+                                         int                button,
+                                         double             x,
+                                         double             y,
+                                         guint32            timestamp);
 };
 
 typedef enum
index 5411e241516eb11e20f12290457a2943d5c91959..0cb40d5a1c2683976cb27cce88f9268d0dac3fd8 100644 (file)
@@ -3620,14 +3620,15 @@ gdk_wayland_surface_unfullscreen (GdkSurface *surface)
 }
 
 static void
-gdk_wayland_surface_begin_resize_drag (GdkSurface     *surface,
-                                       GdkSurfaceEdge  edge,
-                                       GdkDevice      *device,
-                                       gint            button,
-                                       gint            x,
-                                       gint            y,
-                                       guint32         timestamp)
+gdk_wayland_toplevel_begin_resize (GdkToplevel    *toplevel,
+                                   GdkSurfaceEdge  edge,
+                                   GdkDevice      *device,
+                                   int             button,
+                                   double          x,
+                                   double          y,
+                                   guint32         timestamp)
 {
+  GdkSurface *surface = GDK_SURFACE (toplevel);
   GdkWaylandSurface *impl;
   GdkWaylandDisplay *display_wayland;
   GdkEventSequence *sequence;
@@ -3672,7 +3673,7 @@ gdk_wayland_surface_begin_resize_drag (GdkSurface     *surface,
       break;
 
     default:
-      g_warning ("gdk_surface_begin_resize_drag: bad resize edge %d!", edge);
+      g_warning ("gdk_toplevel_begin_resize: bad resize edge %d!", edge);
       return;
     }
 
@@ -3706,13 +3707,14 @@ gdk_wayland_surface_begin_resize_drag (GdkSurface     *surface,
 }
 
 static void
-gdk_wayland_surface_begin_move_drag (GdkSurface *surface,
-                                     GdkDevice  *device,
-                                     gint        button,
-                                     gint        x,
-                                     gint        y,
-                                     guint32     timestamp)
+gdk_wayland_toplevel_begin_move (GdkToplevel *toplevel,
+                                 GdkDevice   *device,
+                                 int          button,
+                                 double       x,
+                                 double       y,
+                                 guint32      timestamp)
 {
+  GdkSurface *surface = GDK_SURFACE (toplevel);
   GdkWaylandSurface *impl;
   GdkWaylandDisplay *display_wayland;
   GdkEventSequence *sequence;
@@ -3895,8 +3897,6 @@ gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass)
   impl_class->destroy = gdk_wayland_surface_destroy;
   impl_class->beep = gdk_wayland_surface_beep;
 
-  impl_class->begin_resize_drag = gdk_wayland_surface_begin_resize_drag;
-  impl_class->begin_move_drag = gdk_wayland_surface_begin_move_drag;
   impl_class->destroy_notify = gdk_wayland_surface_destroy_notify;
   impl_class->drag_begin = _gdk_wayland_surface_drag_begin;
   impl_class->get_scale_factor = gdk_wayland_surface_get_scale_factor;
@@ -4779,6 +4779,8 @@ gdk_wayland_toplevel_iface_init (GdkToplevelInterface *iface)
   iface->supports_edge_constraints = gdk_wayland_toplevel_supports_edge_constraints;
   iface->inhibit_system_shortcuts = gdk_wayland_toplevel_inhibit_system_shortcuts;
   iface->restore_system_shortcuts = gdk_wayland_toplevel_restore_system_shortcuts;
+  iface->begin_resize = gdk_wayland_toplevel_begin_resize;
+  iface->begin_move = gdk_wayland_toplevel_begin_move;
 }
 
 static void
index 196fd2a775638055c9fbe02ac443c6937997430b..b4695523a8de86ec8d0f09678c1d616023cfb8d0 100644 (file)
@@ -4135,18 +4135,17 @@ gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
 }
 
 static void
-gdk_win32_surface_begin_resize_drag (GdkSurface     *window,
-                                    GdkSurfaceEdge  edge,
-                                    GdkDevice     *device,
-                                    gint           button,
-                                    gint           x,
-                                    gint           y,
-                                    guint32        timestamp)
-{
+gdk_win32_toplevel_begin_resize (GdkToplevel    *toplevel,
+                                 GdkSurfaceEdge  edge,
+                                 GdkDevice      *device,
+                                 int             button,
+                                 double          x,
+                                 double          y,
+                                 guint32         timestamp)
+{
+  GdkSurface *window = GDK_SURFACE (toplevel);
   GdkWin32Surface *impl;
 
-  g_return_if_fail (GDK_IS_SURFACE (window));
-
   if (GDK_SURFACE_DESTROYED (window) ||
       IsIconic (GDK_SURFACE_HWND (window)))
     return;
@@ -4172,17 +4171,16 @@ gdk_win32_surface_begin_resize_drag (GdkSurface     *window,
 }
 
 static void
-gdk_win32_surface_begin_move_drag (GdkSurface *window,
-                                  GdkDevice *device,
-                                  gint       button,
-                                  gint       x,
-                                  gint       y,
-                                  guint32    timestamp)
-{
+gdk_win32_toplevel_begin_move (GdkToplevel *toplevel,
+                               GdkDevice   *device,
+                               int          button,
+                               double       x,
+                               double       y,
+                               guint32      timestamp)
+{
+  GdkSurface *window = GDK_SURFACE (toplevel);
   GdkWin32Surface *impl;
 
-  g_return_if_fail (GDK_IS_SURFACE (window));
-
   if (GDK_SURFACE_DESTROYED (window) ||
       IsIconic (GDK_SURFACE_HWND (window)))
     return;
@@ -4700,8 +4698,6 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
 
 
   impl_class->set_shadow_width = gdk_win32_surface_set_shadow_width;
-  impl_class->begin_resize_drag = gdk_win32_surface_begin_resize_drag;
-  impl_class->begin_move_drag = gdk_win32_surface_begin_move_drag;
   impl_class->destroy_notify = gdk_win32_surface_destroy_notify;
   impl_class->drag_begin = _gdk_win32_surface_drag_begin;
   impl_class->create_gl_context = _gdk_win32_surface_create_gl_context;
@@ -5085,6 +5081,8 @@ gdk_win32_toplevel_iface_init (GdkToplevelInterface *iface)
   iface->focus = gdk_win32_toplevel_focus;
   iface->show_window_menu = gdk_win32_toplevel_show_window_menu;
   iface->supports_edge_constraints = gdk_win32_toplevel_supports_edge_constraints;
+  iface->begin_resize = gdk_win32_toplevel_begin_resize;
+  iface->begin_move = gdk_win32_toplevel_begin_move;
 }
 
 typedef struct
index 9353e01f9b7a920ce893cf4617d470c515c02731..224eb1784b5d6ffc71b69889f6eecbe96c0fca45 100644 (file)
@@ -3750,7 +3750,7 @@ wmspec_resize_drag (GdkSurface     *surface,
         break;
 
       default:
-        g_warning ("gdk_surface_begin_resize_drag: bad resize edge %d!",
+        g_warning ("gdk_toplevel_begin_resize: bad resize edge %d!",
                    edge);
         return;
       }
@@ -4310,14 +4310,15 @@ _should_perform_ewmh_drag (GdkSurface *surface,
 }
 
 static void
-gdk_x11_surface_begin_resize_drag (GdkSurface     *surface,
-                                   GdkSurfaceEdge  edge,
-                                   GdkDevice      *device,
-                                   gint            button,
-                                   gint            x,
-                                   gint            y,
-                                   guint32         timestamp)
+gdk_x11_toplevel_begin_resize (GdkToplevel    *toplevel,
+                               GdkSurfaceEdge  edge,
+                               GdkDevice      *device,
+                               int             button,
+                               double          x,
+                               double          y,
+                               guint32         timestamp)
 {
+  GdkSurface *surface = GDK_SURFACE (toplevel);
   int root_x, root_y;
 
   if (GDK_SURFACE_DESTROYED (surface))
@@ -4333,13 +4334,14 @@ gdk_x11_surface_begin_resize_drag (GdkSurface     *surface,
 }
 
 static void
-gdk_x11_surface_begin_move_drag (GdkSurface *surface,
-                                 GdkDevice  *device,
-                                 gint        button,
-                                 gint        x,
-                                 gint        y,
-                                 guint32     timestamp)
+gdk_x11_toplevel_begin_move (GdkToplevel *toplevel,
+                             GdkDevice   *device,
+                             int          button,
+                             double       x,
+                             double       y,
+                             guint32      timestamp)
 {
+  GdkSurface *surface = GDK_SURFACE (toplevel);
   int root_x, root_y;
   gint direction;
 
@@ -4630,8 +4632,6 @@ gdk_x11_surface_class_init (GdkX11SurfaceClass *klass)
   impl_class->destroy = gdk_x11_surface_destroy;
   impl_class->beep = gdk_x11_surface_beep;
 
-  impl_class->begin_resize_drag = gdk_x11_surface_begin_resize_drag;
-  impl_class->begin_move_drag = gdk_x11_surface_begin_move_drag;
   impl_class->destroy_notify = gdk_x11_surface_destroy_notify;
   impl_class->drag_begin = _gdk_x11_surface_drag_begin;
   impl_class->get_scale_factor = gdk_x11_surface_get_scale_factor;
@@ -5094,6 +5094,8 @@ gdk_x11_toplevel_iface_init (GdkToplevelInterface *iface)
   iface->supports_edge_constraints = gdk_x11_toplevel_supports_edge_constraints;
   iface->inhibit_system_shortcuts = gdk_x11_toplevel_inhibit_system_shortcuts;
   iface->restore_system_shortcuts = gdk_x11_toplevel_restore_system_shortcuts;
+  iface->begin_resize = gdk_x11_toplevel_begin_resize;
+  iface->begin_move = gdk_x11_toplevel_begin_move;
 }
 
 typedef struct {