summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-05-17 19:15:46 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-05-17 19:15:46 +0000
commitc0faf0c6b60508be67770f23bbbd79acae0bfb89 (patch)
treef1330ec151ca222d68852c88d5acef5d51df73d8
parent34d7e25a1f4388ea461ffe0693cf31c9a13ce822 (diff)
parentb63690aa6bae23397564a4fc409aa71d00d53229 (diff)
downloadgtk+-c0faf0c6b60508be67770f23bbbd79acae0bfb89.tar.gz
Merge branch 'toplevel-move-resize' into 'master'
Toplevel move resize See merge request GNOME/gtk!1923
-rw-r--r--docs/reference/gdk/gdk4-sections.txt4
-rw-r--r--docs/reference/gtk/migrating-3to4.xml4
-rw-r--r--gdk/broadway/gdksurface-broadway.c40
-rw-r--r--gdk/gdkinternals.h15
-rw-r--r--gdk/gdksurface.c65
-rw-r--r--gdk/gdksurface.h17
-rw-r--r--gdk/gdksurfaceprivate.h13
-rw-r--r--gdk/gdktoplevel.c81
-rw-r--r--gdk/gdktoplevel.h17
-rw-r--r--gdk/gdktoplevelprivate.h13
-rw-r--r--gdk/wayland/gdksurface-wayland.c34
-rw-r--r--gdk/win32/gdksurface-win32.c40
-rw-r--r--gdk/x11/gdksurface-x11.c34
-rw-r--r--gtk/gtkwindow.c17
-rw-r--r--gtk/gtkwindowhandle.c36
-rw-r--r--tests/testwindowdrag.c4
16 files changed, 236 insertions, 198 deletions
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index e5ad907320..6f3e87246b 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -185,8 +185,6 @@ gdk_surface_get_display
gdk_surface_hide
gdk_surface_get_mapped
gdk_surface_translate_coordinates
-gdk_surface_begin_resize_drag
-gdk_surface_begin_move_drag
gdk_surface_beep
gdk_surface_get_scale_factor
gdk_surface_set_opaque_region
@@ -673,6 +671,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
diff --git a/docs/reference/gtk/migrating-3to4.xml b/docs/reference/gtk/migrating-3to4.xml
index afca5c4d1b..e65d19befe 100644
--- a/docs/reference/gtk/migrating-3to4.xml
+++ b/docs/reference/gtk/migrating-3to4.xml
@@ -324,7 +324,9 @@
<para>
A number of minor API cleanups have happened in GdkSurface
as well. For example, gdk_surface_input_shape_combine_region()
- has been renamed to gdk_surface_set_input_region().
+ has been renamed to gdk_surface_set_input_region(), and
+ gdk_surface_begin_resize_drag() has been renamed to
+ gdk_toplevel_begin_resize().
</para>
</section>
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c
index 7862e1316f..f8702247f6 100644
--- a/gdk/broadway/gdksurface-broadway.c
+++ b/gdk/broadway/gdksurface-broadway.c
@@ -1192,18 +1192,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;
@@ -1235,17 +1234,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;
@@ -1297,8 +1295,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;
@@ -1648,6 +1644,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
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 12f140b609..9e8d543a69 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -365,6 +365,21 @@ GdkSurface * gdk_surface_new_temp (GdkDisplay *display,
GdkKeymap * gdk_display_get_keymap (GdkDisplay *display);
+void gdk_surface_begin_resize_drag (GdkSurface *surface,
+ GdkSurfaceEdge edge,
+ GdkDevice *device,
+ gint button,
+ gint x,
+ gint y,
+ guint32 timestamp);
+
+void gdk_surface_begin_move_drag (GdkSurface *surface,
+ GdkDevice *device,
+ gint button,
+ gint x,
+ gint y,
+ guint32 timestamp);
+
G_END_DECLS
#endif /* __GDK_INTERNALS_H__ */
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index b5e2a33110..86d6277f7e 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2359,71 +2359,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
diff --git a/gdk/gdksurface.h b/gdk/gdksurface.h
index 109bec5f76..09278a1d69 100644
--- a/gdk/gdksurface.h
+++ b/gdk/gdksurface.h
@@ -206,23 +206,6 @@ GDK_AVAILABLE_IN_ALL
void gdk_surface_beep (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
-void gdk_surface_begin_resize_drag (GdkSurface *surface,
- GdkSurfaceEdge edge,
- GdkDevice *device,
- gint button,
- gint x,
- gint y,
- guint32 timestamp);
-
-GDK_AVAILABLE_IN_ALL
-void gdk_surface_begin_move_drag (GdkSurface *surface,
- GdkDevice *device,
- gint button,
- gint x,
- gint y,
- guint32 timestamp);
-
-GDK_AVAILABLE_IN_ALL
void gdk_surface_queue_expose (GdkSurface *surface);
GDK_AVAILABLE_IN_ALL
diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h
index e6959cf21d..5685d781f9 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -148,19 +148,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,
diff --git a/gdk/gdktoplevel.c b/gdk/gdktoplevel.c
index 96e4982627..49b9b8a6ca 100644
--- a/gdk/gdktoplevel.c
+++ b/gdk/gdktoplevel.c
@@ -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,82 @@ 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: (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
+ * @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)
+{
+ 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);
+}
+
+/**
+ * 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)
+{
+ 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);
+}
diff --git a/gdk/gdktoplevel.h b/gdk/gdktoplevel.h
index 863c26f3e8..20b3fc5d4b 100644
--- a/gdk/gdktoplevel.h
+++ b/gdk/gdktoplevel.h
@@ -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
diff --git a/gdk/gdktoplevelprivate.h b/gdk/gdktoplevelprivate.h
index c54d0ac503..6cdccca8b7 100644
--- a/gdk/gdktoplevelprivate.h
+++ b/gdk/gdktoplevelprivate.h
@@ -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
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 589941aa10..4e66f81c7b 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -3626,14 +3626,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;
@@ -3678,7 +3679,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;
}
@@ -3712,13 +3713,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;
@@ -3901,8 +3903,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;
@@ -4780,6 +4780,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
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index 4b647650b2..2b76ef484c 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -4144,18 +4144,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;
@@ -4181,17 +4180,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;
@@ -4709,8 +4707,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;
@@ -5089,6 +5085,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
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 2350559c95..75a931f16c 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -3709,7 +3709,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;
}
@@ -4269,14 +4269,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))
@@ -4292,13 +4293,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;
@@ -4589,8 +4591,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;
@@ -5044,6 +5044,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 {
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 66068a70f0..a158f23425 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1218,12 +1218,14 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
GdkEventSequence *sequence;
GtkWindowRegion region;
GdkEvent *event;
+ GdkDevice *device;
guint button;
double tx, ty;
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
+ device = gtk_gesture_get_device (GTK_GESTURE (gesture));
if (!event)
return;
@@ -1234,8 +1236,7 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
if (priv->maximized)
return;
- if (gdk_display_device_is_grabbed (gtk_widget_get_display (GTK_WIDGET (window)),
- gtk_gesture_get_device (GTK_GESTURE (gesture))))
+ if (gdk_display_device_is_grabbed (gtk_widget_get_display (GTK_WIDGET (window)), device))
return;
region = get_active_region_type (window, x, y);
@@ -1246,12 +1247,12 @@ click_gesture_pressed_cb (GtkGestureClick *gesture,
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
gdk_event_get_position (event, &tx, &ty);
- gdk_surface_begin_resize_drag (priv->surface,
- (GdkSurfaceEdge) region,
- gdk_event_get_device ((GdkEvent *) event),
- GDK_BUTTON_PRIMARY,
- tx, ty,
- gdk_event_get_time (event));
+ gdk_toplevel_begin_resize (GDK_TOPLEVEL (priv->surface),
+ (GdkSurfaceEdge) region,
+ device,
+ GDK_BUTTON_PRIMARY,
+ tx, ty,
+ gdk_event_get_time (event));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
}
diff --git a/gtk/gtkwindowhandle.c b/gtk/gtkwindowhandle.c
index 6ee052e9a4..7fb0e85ea7 100644
--- a/gtk/gtkwindowhandle.c
+++ b/gtk/gtkwindowhandle.c
@@ -113,11 +113,12 @@ move_window_clicked (GtkModelButton *button,
GtkNative *native = gtk_widget_get_native (GTK_WIDGET (self));
GdkSurface *surface = gtk_native_get_surface (native);
- gdk_surface_begin_move_drag (surface,
- NULL,
- 0, /* 0 means "use keyboard" */
- 0, 0,
- GDK_CURRENT_TIME);
+ if (GDK_IS_TOPLEVEL (surface))
+ gdk_toplevel_begin_move (GDK_TOPLEVEL (surface),
+ NULL,
+ 0, /* 0 means "use keyboard" */
+ 0, 0,
+ GDK_CURRENT_TIME);
}
static void
@@ -127,12 +128,13 @@ resize_window_clicked (GtkModelButton *button,
GtkNative *native = gtk_widget_get_native (GTK_WIDGET (self));
GdkSurface *surface = gtk_native_get_surface (native);
- gdk_surface_begin_resize_drag (surface,
- 0,
- NULL,
- 0, /* 0 means "use keyboard" */
- 0, 0,
- GDK_CURRENT_TIME);
+ if (GDK_IS_TOPLEVEL (surface))
+ gdk_toplevel_begin_resize (GDK_TOPLEVEL (surface),
+ 0,
+ NULL,
+ 0, /* 0 means "use keyboard" */
+ 0, 0,
+ GDK_CURRENT_TIME);
}
static void
@@ -476,6 +478,7 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
native = gtk_widget_get_native (GTK_WIDGET (self));
+
gtk_widget_translate_coordinates (GTK_WIDGET (self),
GTK_WIDGET (native),
start_x, start_y,
@@ -486,11 +489,12 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
window_y += native_y;
surface = gtk_native_get_surface (native);
- gdk_surface_begin_move_drag (surface,
- gtk_gesture_get_device (GTK_GESTURE (gesture)),
- gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
- window_x, window_y,
- gtk_event_controller_get_current_event_time (GTK_EVENT_CONTROLLER (gesture)));
+ if (GDK_IS_TOPLEVEL (surface))
+ gdk_toplevel_begin_move (GDK_TOPLEVEL (surface),
+ gtk_gesture_get_device (GTK_GESTURE (gesture)),
+ gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
+ window_x, window_y,
+ gtk_event_controller_get_current_event_time (GTK_EVENT_CONTROLLER (gesture)));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (self->click_gesture));
diff --git a/tests/testwindowdrag.c b/tests/testwindowdrag.c
index 2f8d1539ac..d53a0c17c5 100644
--- a/tests/testwindowdrag.c
+++ b/tests/testwindowdrag.c
@@ -28,7 +28,7 @@ start_resize (GtkGestureClick *gesture,
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
xx, yy, &xx, &yy);
- gdk_surface_begin_resize_drag (surface, edge, gdk_event_get_device (event), button, xx, yy, timestamp);
+ gdk_toplevel_begin_resize (GDK_TOPLEVEL (surface), edge, gdk_event_get_device (event), button, xx, yy, timestamp);
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
}
@@ -76,7 +76,7 @@ start_move (GtkGestureClick *gesture,
gtk_widget_translate_coordinates (widget, GTK_WIDGET (gtk_widget_get_root (widget)),
xx, yy, &xx, &yy);
- gdk_surface_begin_move_drag (surface, gdk_event_get_device (event), button, xx, yy, timestamp);
+ gdk_toplevel_begin_move (GDK_TOPLEVEL (surface), gdk_event_get_device (event), button, xx, yy, timestamp);
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
}