Simplify surface move/drag api
Drop the with_device variants, and always pass a device.
This commit is contained in:
@@ -3408,7 +3408,7 @@ gdk_surface_set_functions (GdkSurface *surface,
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_surface_begin_resize_drag_for_device:
|
||||
* 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
|
||||
@@ -3421,49 +3421,28 @@ gdk_surface_set_functions (GdkSurface *surface,
|
||||
* You might use this function to implement a “window resize grip,”
|
||||
*/
|
||||
void
|
||||
gdk_surface_begin_resize_drag_for_device (GdkSurface *surface,
|
||||
GdkSurfaceEdge edge,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GDK_SURFACE_GET_CLASS (surface)->begin_resize_drag (surface, edge, device, button, x, y, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_surface_begin_resize_drag:
|
||||
* @surface: a toplevel #GdkSurface
|
||||
* @edge: the edge or corner from which the drag is started
|
||||
* @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).
|
||||
*
|
||||
* This function assumes that the drag is controlled by the
|
||||
* client pointer device, use gdk_surface_begin_resize_drag_for_device()
|
||||
* to begin a drag with a different device.
|
||||
*/
|
||||
void
|
||||
gdk_surface_begin_resize_drag (GdkSurface *surface,
|
||||
GdkSurfaceEdge edge,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GdkDevice *device;
|
||||
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);
|
||||
}
|
||||
|
||||
device = gdk_seat_get_pointer (gdk_display_get_default_seat (surface->display));
|
||||
gdk_surface_begin_resize_drag_for_device (surface, edge,
|
||||
device, button, x, y, timestamp);
|
||||
GDK_SURFACE_GET_CLASS (surface)->begin_resize_drag (surface, edge, device, button, x, y, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_surface_begin_move_drag_for_device:
|
||||
* 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
|
||||
@@ -3474,42 +3453,23 @@ gdk_surface_begin_resize_drag (GdkSurface *surface,
|
||||
* Begins a surface move operation (for a toplevel surface).
|
||||
*/
|
||||
void
|
||||
gdk_surface_begin_move_drag_for_device (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GDK_SURFACE_GET_CLASS (surface)->begin_move_drag (surface,
|
||||
device, button, x, y, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_surface_begin_move_drag:
|
||||
* @surface: a toplevel #GdkSurface
|
||||
* @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).
|
||||
*
|
||||
* This function assumes that the drag is controlled by the
|
||||
* client pointer device, use gdk_surface_begin_move_drag_for_device()
|
||||
* to begin a drag with a different device.
|
||||
*/
|
||||
void
|
||||
gdk_surface_begin_move_drag (GdkSurface *surface,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp)
|
||||
{
|
||||
GdkDevice *device;
|
||||
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);
|
||||
}
|
||||
|
||||
device = gdk_seat_get_pointer (gdk_display_get_default_seat (surface->display));
|
||||
gdk_surface_begin_move_drag_for_device (surface, device, button, x, y, timestamp);
|
||||
GDK_SURFACE_GET_CLASS (surface)->begin_move_drag (surface, device, button, x, y, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -539,27 +539,15 @@ void gdk_surface_set_opacity (GdkSurface *surface,
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_begin_resize_drag (GdkSurface *surface,
|
||||
GdkSurfaceEdge edge,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_begin_resize_drag_for_device (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,
|
||||
gint button,
|
||||
gint x,
|
||||
gint y,
|
||||
guint32 timestamp);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_surface_begin_move_drag_for_device (GdkSurface *surface,
|
||||
GdkDevice *device,
|
||||
gint button,
|
||||
gint x,
|
||||
|
||||
@@ -1428,12 +1428,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_for_device (priv->surface,
|
||||
(GdkSurfaceEdge) region,
|
||||
gdk_event_get_device ((GdkEvent *) event),
|
||||
GDK_BUTTON_PRIMARY,
|
||||
tx, ty,
|
||||
gdk_event_get_time (event));
|
||||
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));
|
||||
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (priv->drag_gesture));
|
||||
@@ -1529,11 +1529,11 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
|
||||
|
||||
gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y);
|
||||
|
||||
gdk_surface_begin_move_drag_for_device (priv->surface,
|
||||
gtk_gesture_get_device (GTK_GESTURE (gesture)),
|
||||
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
|
||||
(int)start_x, (int)start_y,
|
||||
gtk_get_current_event_time ());
|
||||
gdk_surface_begin_move_drag (priv->surface,
|
||||
gtk_gesture_get_device (GTK_GESTURE (gesture)),
|
||||
gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture)),
|
||||
(int)start_x, (int)start_y,
|
||||
gtk_get_current_event_time ());
|
||||
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (priv->click_gesture));
|
||||
@@ -6688,6 +6688,7 @@ move_window_clicked (GtkModelButton *button,
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
|
||||
gdk_surface_begin_move_drag (priv->surface,
|
||||
NULL,
|
||||
0, /* 0 means "use keyboard" */
|
||||
0, 0,
|
||||
GDK_CURRENT_TIME);
|
||||
@@ -6702,6 +6703,7 @@ resize_window_clicked (GtkModelButton *button,
|
||||
|
||||
gdk_surface_begin_resize_drag (priv->surface,
|
||||
0,
|
||||
NULL,
|
||||
0, /* 0 means "use keyboard" */
|
||||
0, 0,
|
||||
GDK_CURRENT_TIME);
|
||||
|
||||
@@ -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, button, xx, yy, timestamp);
|
||||
gdk_surface_begin_resize_drag (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, button, xx, yy, timestamp);
|
||||
gdk_surface_begin_move_drag (surface, gdk_event_get_device (event), button, xx, yy, timestamp);
|
||||
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (gesture));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user