diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-05-17 12:35:45 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-17 14:15:06 -0400 |
commit | 1e8a58e36753b1355d7421fb90b2932109de98a2 (patch) | |
tree | 7ac85ed84690f5d5aaf3e6953d4fd632d015cecf | |
parent | eb6edac4bdaeea671a931028307feb79be5f2f9d (diff) | |
download | gtk+-1e8a58e36753b1355d7421fb90b2932109de98a2.tar.gz |
gdk: Move the begin_move/resize_drag vfuncs around
Move these from GdkSurface to GdkToplevel, where they
belong. Update all backends.
-rw-r--r-- | gdk/broadway/gdksurface-broadway.c | 40 | ||||
-rw-r--r-- | gdk/gdksurface.c | 65 | ||||
-rw-r--r-- | gdk/gdksurfaceprivate.h | 13 | ||||
-rw-r--r-- | gdk/gdktoplevel.c | 37 | ||||
-rw-r--r-- | gdk/gdktoplevelprivate.h | 13 | ||||
-rw-r--r-- | gdk/wayland/gdksurface-wayland.c | 34 | ||||
-rw-r--r-- | gdk/win32/gdksurface-win32.c | 40 | ||||
-rw-r--r-- | gdk/x11/gdksurface-x11.c | 34 |
8 files changed, 121 insertions, 155 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 { |