From 309a7aa253b0e6d4721a8eafb6ce035787df7b88 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 May 2020 11:45:37 -0400 Subject: [PATCH 1/5] gdk: Add gdk_toplevel_begin_move/resize 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 | 2 ++ gdk/gdktoplevel.c | 50 ++++++++++++++++++++++++++++ gdk/gdktoplevel.h | 17 ++++++++++ 3 files changed, 69 insertions(+) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index b753ee9ece..b526e2a879 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -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 GDK_TYPE_TOPLEVEL gdk_toplevel_get_type diff --git a/gdk/gdktoplevel.c b/gdk/gdktoplevel.c index 96e4982627..7c10511ca9 100644 --- a/gdk/gdktoplevel.c +++ b/gdk/gdktoplevel.c @@ -23,6 +23,8 @@ #include "gdk-private.h" #include "gdktoplevelprivate.h" +#include + /** * 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); +} 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 From f316fe0f58014d6fa24dcc62df01a4a2c1e7d4f7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 May 2020 12:06:26 -0400 Subject: [PATCH 2/5] window: Use toplevel begin_move/resize api The GdkSurface api for this is going away. --- gtk/gtkwindow.c | 17 +++++++++-------- gtk/gtkwindowhandle.c | 36 ++++++++++++++++++++---------------- tests/testwindowdrag.c | 4 ++-- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index ddfb38792f..eb572e5486 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 3e411465b5..ef1964e433 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 @@ -475,17 +477,19 @@ 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, &window_x, &window_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)); } From eb6edac4bdaeea671a931028307feb79be5f2f9d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 May 2020 12:14:18 -0400 Subject: [PATCH 3/5] gdk: Drop gdk_surface_begin_move/resize_drag These have been replaced by GdkToplevel api. --- docs/reference/gdk/gdk4-sections.txt | 2 -- gdk/gdkinternals.h | 15 +++++++++++++++ gdk/gdksurface.h | 17 ----------------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index b526e2a879..824d7f7680 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -187,8 +187,6 @@ gdk_surface_hide gdk_surface_is_viewable 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 diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index 5357bd6b1b..0ab5aea023 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -366,6 +366,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.h b/gdk/gdksurface.h index 75d6d9eba1..74aea4ca38 100644 --- a/gdk/gdksurface.h +++ b/gdk/gdksurface.h @@ -208,23 +208,6 @@ cairo_surface_t * 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); From 1e8a58e36753b1355d7421fb90b2932109de98a2 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 May 2020 12:35:45 -0400 Subject: [PATCH 4/5] gdk: Move the begin_move/resize_drag vfuncs around Move these from GdkSurface to GdkToplevel, where they belong. Update all backends. --- gdk/broadway/gdksurface-broadway.c | 40 +++++++++--------- gdk/gdksurface.c | 65 ------------------------------ gdk/gdksurfaceprivate.h | 13 ------ gdk/gdktoplevel.c | 37 +++++++++++++++-- gdk/gdktoplevelprivate.h | 13 ++++++ gdk/wayland/gdksurface-wayland.c | 34 ++++++++-------- gdk/win32/gdksurface-win32.c | 36 ++++++++--------- gdk/x11/gdksurface-x11.c | 34 ++++++++-------- 8 files changed, 119 insertions(+), 153 deletions(-) diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c index ac91d2887f..9720bea77b 100644 --- a/gdk/broadway/gdksurface-broadway.c +++ b/gdk/broadway/gdksurface-broadway.c @@ -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 diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 4835c7ba42..aa546b6f6a 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -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 diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h index cbc6e53094..c50fd1abfe 100644 --- a/gdk/gdksurfaceprivate.h +++ b/gdk/gdksurfaceprivate.h @@ -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, diff --git a/gdk/gdktoplevel.c b/gdk/gdktoplevel.c index 7c10511ca9..49b9b8a6ca 100644 --- a/gdk/gdktoplevel.c +++ b/gdk/gdktoplevel.c @@ -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); } 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 5411e24151..0cb40d5a1c 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -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 diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 196fd2a775..b4695523a8 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -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 diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c index 9353e01f9b..224eb1784b 100644 --- a/gdk/x11/gdksurface-x11.c +++ b/gdk/x11/gdksurface-x11.c @@ -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 { From b63690aa6bae23397564a4fc409aa71d00d53229 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 17 May 2020 14:38:10 -0400 Subject: [PATCH 5/5] docs: Mention begin_resize_drag in the migration guide --- docs/reference/gtk/migrating-3to4.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/reference/gtk/migrating-3to4.xml b/docs/reference/gtk/migrating-3to4.xml index 217f69e73a..5c34aadbfe 100644 --- a/docs/reference/gtk/migrating-3to4.xml +++ b/docs/reference/gtk/migrating-3to4.xml @@ -324,7 +324,9 @@ 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().