gdk: Move the begin_move/resize_drag vfuncs around

Move these from GdkSurface to GdkToplevel, where they
belong. Update all backends.
This commit is contained in:
Matthias Clasen 2020-05-17 12:35:45 -04:00
parent eb6edac4bd
commit 1e8a58e367
8 changed files with 119 additions and 153 deletions

View File

@ -1195,18 +1195,17 @@ calculate_unmoving_origin (MoveResizeData *mv_resize)
}
static void
gdk_broadway_surface_begin_resize_drag (GdkSurface *surface,
gdk_broadway_toplevel_begin_resize (GdkToplevel *toplevel,
GdkSurfaceEdge edge,
GdkDevice *device,
gint button,
gint x,
gint y,
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,
gdk_broadway_toplevel_begin_move (GdkToplevel *toplevel,
GdkDevice *device,
gint button,
gint x,
gint y,
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

View 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

View 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,

View 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);
}

View 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

View File

@ -3620,14 +3620,15 @@ gdk_wayland_surface_unfullscreen (GdkSurface *surface)
}
static void
gdk_wayland_surface_begin_resize_drag (GdkSurface *surface,
gdk_wayland_toplevel_begin_resize (GdkToplevel *toplevel,
GdkSurfaceEdge edge,
GdkDevice *device,
gint button,
gint x,
gint y,
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,
gdk_wayland_toplevel_begin_move (GdkToplevel *toplevel,
GdkDevice *device,
gint button,
gint x,
gint y,
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

View File

@ -4135,18 +4135,17 @@ gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
}
static void
gdk_win32_surface_begin_resize_drag (GdkSurface *window,
gdk_win32_toplevel_begin_resize (GdkToplevel *toplevel,
GdkSurfaceEdge edge,
GdkDevice *device,
gint button,
gint x,
gint y,
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,
gdk_win32_toplevel_begin_move (GdkToplevel *toplevel,
GdkDevice *device,
gint button,
gint x,
gint y,
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

View 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,
gdk_x11_toplevel_begin_resize (GdkToplevel *toplevel,
GdkSurfaceEdge edge,
GdkDevice *device,
gint button,
gint x,
gint y,
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,
gdk_x11_toplevel_begin_move (GdkToplevel *toplevel,
GdkDevice *device,
gint button,
gint x,
gint y,
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 {