From 3d37f08f38c10923cc8b1e5fcc999b8b76d75533 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 23 Mar 2019 17:18:55 -0400 Subject: [PATCH] Remove gdk_device_warp This was only ever implemented on X11, and is not something we want to encourage apps to do, ever. --- docs/reference/gdk/gdk4-sections.txt | 1 - gdk/broadway/gdkdevice-broadway.c | 11 ----------- gdk/gdkdevice.c | 28 ---------------------------- gdk/gdkdevice.h | 5 ----- gdk/gdkdeviceprivate.h | 3 --- gdk/wayland/gdkdevice-wayland.c | 8 -------- gdk/x11/gdkdevice-core-x11.c | 24 ------------------------ gdk/x11/gdkdevice-xi2.c | 22 ---------------------- gdk/x11/gdkdrag-x11.c | 16 +++++++++++++++- 9 files changed, 15 insertions(+), 103 deletions(-) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index 88b2cd60aa..f6ff941b90 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -502,7 +502,6 @@ gdk_device_get_has_cursor gdk_device_get_n_axes gdk_device_get_n_keys gdk_device_get_axes -gdk_device_warp gdk_device_get_seat diff --git a/gdk/broadway/gdkdevice-broadway.c b/gdk/broadway/gdkdevice-broadway.c index 563002c704..2171ca90f6 100644 --- a/gdk/broadway/gdkdevice-broadway.c +++ b/gdk/broadway/gdkdevice-broadway.c @@ -36,9 +36,6 @@ static void gdk_broadway_device_get_state (GdkDevice *device, static void gdk_broadway_device_set_surface_cursor (GdkDevice *device, GdkSurface *surface, GdkCursor *cursor); -static void gdk_broadway_device_warp (GdkDevice *device, - gdouble x, - gdouble y); static void gdk_broadway_device_query_state (GdkDevice *device, GdkSurface *surface, GdkSurface **child_surface, @@ -73,7 +70,6 @@ gdk_broadway_device_class_init (GdkBroadwayDeviceClass *klass) device_class->get_history = gdk_broadway_device_get_history; device_class->get_state = gdk_broadway_device_get_state; device_class->set_surface_cursor = gdk_broadway_device_set_surface_cursor; - device_class->warp = gdk_broadway_device_warp; device_class->query_state = gdk_broadway_device_query_state; device_class->grab = gdk_broadway_device_grab; device_class->ungrab = gdk_broadway_device_ungrab; @@ -126,13 +122,6 @@ gdk_broadway_device_set_surface_cursor (GdkDevice *device, { } -static void -gdk_broadway_device_warp (GdkDevice *device, - gdouble x, - gdouble y) -{ -} - static void gdk_broadway_device_query_state (GdkDevice *device, GdkSurface *surface, diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c index 54bcc0b344..7544c4e012 100644 --- a/gdk/gdkdevice.c +++ b/gdk/gdkdevice.c @@ -1425,34 +1425,6 @@ gdk_device_ungrab (GdkDevice *device, GDK_DEVICE_GET_CLASS (device)->ungrab (device, time_); } -/** - * gdk_device_warp: - * @device: the device to warp. - * @x: the X coordinate of the destination. - * @y: the Y coordinate of the destination. - * - * Warps @device in @display to the point @x,@y, - * unless the device is confined to a surface by a grab, - * in which case it will be moved - * as far as allowed by the grab. Warping the pointer - * creates events as if the user had moved the mouse - * instantaneously to the destination. - * - * Note that the pointer should normally be under the - * control of the user. This function was added to cover - * some rare use cases like keyboard navigation support - * for the color picker in the #GtkColorSelectionDialog. - **/ -void -gdk_device_warp (GdkDevice *device, - gint x, - gint y) -{ - g_return_if_fail (GDK_IS_DEVICE (device)); - - GDK_DEVICE_GET_CLASS (device)->warp (device, x, y); -} - /* Private API */ void _gdk_device_reset_axes (GdkDevice *device) diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h index c52ddababa..f491189fdf 100644 --- a/gdk/gdkdevice.h +++ b/gdk/gdkdevice.h @@ -236,11 +236,6 @@ GDK_DEPRECATED_FOR(gdk_seat_ungrab) void gdk_device_ungrab (GdkDevice *device, guint32 time_); -GDK_AVAILABLE_IN_ALL -void gdk_device_warp (GdkDevice *device, - gint x, - gint y); - GDK_AVAILABLE_IN_ALL GdkSurface *gdk_device_get_last_event_surface (GdkDevice *device); diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h index 0fef98bb00..70c29b7e85 100644 --- a/gdk/gdkdeviceprivate.h +++ b/gdk/gdkdeviceprivate.h @@ -86,9 +86,6 @@ struct _GdkDeviceClass GdkSurface *surface, GdkCursor *cursor); - void (* warp) (GdkDevice *device, - gdouble x, - gdouble y); void (* query_state) (GdkDevice *device, GdkSurface *surface, GdkSurface **child_surface, diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index f1dab93f1b..317a285f96 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -517,13 +517,6 @@ gdk_wayland_device_set_surface_cursor (GdkDevice *device, gdk_wayland_device_update_surface_cursor (device); } -static void -gdk_wayland_device_warp (GdkDevice *device, - gdouble x, - gdouble y) -{ -} - static void get_coordinates (GdkDevice *device, double *x, @@ -871,7 +864,6 @@ gdk_wayland_device_class_init (GdkWaylandDeviceClass *klass) device_class->get_history = gdk_wayland_device_get_history; device_class->get_state = gdk_wayland_device_get_state; device_class->set_surface_cursor = gdk_wayland_device_set_surface_cursor; - device_class->warp = gdk_wayland_device_warp; device_class->query_state = gdk_wayland_device_query_state; device_class->grab = gdk_wayland_device_grab; device_class->ungrab = gdk_wayland_device_ungrab; diff --git a/gdk/x11/gdkdevice-core-x11.c b/gdk/x11/gdkdevice-core-x11.c index 58196e43e6..0b8bd8d4f7 100644 --- a/gdk/x11/gdkdevice-core-x11.c +++ b/gdk/x11/gdkdevice-core-x11.c @@ -52,9 +52,6 @@ static void gdk_x11_device_core_get_state (GdkDevice *device, static void gdk_x11_device_core_set_surface_cursor (GdkDevice *device, GdkSurface *surface, GdkCursor *cursor); -static void gdk_x11_device_core_warp (GdkDevice *device, - gdouble x, - gdouble y); static void gdk_x11_device_core_query_state (GdkDevice *device, GdkSurface *surface, GdkSurface **child_surface, @@ -88,7 +85,6 @@ gdk_x11_device_core_class_init (GdkX11DeviceCoreClass *klass) device_class->get_history = gdk_x11_device_core_get_history; device_class->get_state = gdk_x11_device_core_get_state; device_class->set_surface_cursor = gdk_x11_device_core_set_surface_cursor; - device_class->warp = gdk_x11_device_core_warp; device_class->query_state = gdk_x11_device_core_query_state; device_class->grab = gdk_x11_device_core_grab; device_class->ungrab = gdk_x11_device_core_ungrab; @@ -223,26 +219,6 @@ gdk_x11_device_core_set_surface_cursor (GdkDevice *device, xcursor); } -static void -gdk_x11_device_core_warp (GdkDevice *device, - gdouble x, - gdouble y) -{ - GdkDisplay *display; - Display *xdisplay; - Window dest; - GdkX11Screen *screen; - - display = gdk_device_get_display (device); - xdisplay = GDK_DISPLAY_XDISPLAY (display); - screen = GDK_X11_DISPLAY (display)->screen; - dest = GDK_SCREEN_XROOTWIN (screen); - - XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, - round (x * screen->surface_scale), - round (y * screen->surface_scale)); -} - static void gdk_x11_device_core_query_state (GdkDevice *device, GdkSurface *surface, diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c index 9abb0e82dd..255cad2ba4 100644 --- a/gdk/x11/gdkdevice-xi2.c +++ b/gdk/x11/gdkdevice-xi2.c @@ -77,9 +77,6 @@ static void gdk_x11_device_xi2_get_state (GdkDevice *device, static void gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device, GdkSurface *surface, GdkCursor *cursor); -static void gdk_x11_device_xi2_warp (GdkDevice *device, - gdouble x, - gdouble y); static void gdk_x11_device_xi2_query_state (GdkDevice *device, GdkSurface *surface, GdkSurface **child_surface, @@ -123,7 +120,6 @@ gdk_x11_device_xi2_class_init (GdkX11DeviceXI2Class *klass) device_class->get_state = gdk_x11_device_xi2_get_state; device_class->set_surface_cursor = gdk_x11_device_xi2_set_surface_cursor; - device_class->warp = gdk_x11_device_xi2_warp; device_class->query_state = gdk_x11_device_xi2_query_state; device_class->grab = gdk_x11_device_xi2_grab; device_class->ungrab = gdk_x11_device_xi2_ungrab; @@ -292,24 +288,6 @@ gdk_x11_device_xi2_set_surface_cursor (GdkDevice *device, GDK_SURFACE_XID (surface)); } -static void -gdk_x11_device_xi2_warp (GdkDevice *device, - gdouble x, - gdouble y) -{ - GdkX11DeviceXI2 *device_xi2 = GDK_X11_DEVICE_XI2 (device); - GdkDisplay *display = gdk_device_get_display (device); - GdkX11Screen *screen = GDK_X11_DISPLAY (display)->screen; - Window dest = GDK_DISPLAY_XROOTWIN (display); - - XIWarpPointer (GDK_SCREEN_XDISPLAY (screen), - device_xi2->device_id, - None, dest, - 0, 0, 0, 0, - round (x * screen->surface_scale), - round (y * screen->surface_scale)); -} - static void gdk_x11_device_xi2_query_state (GdkDevice *device, GdkSurface *surface, diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c index 57fff0c696..db2abcdc5c 100644 --- a/gdk/x11/gdkdrag-x11.c +++ b/gdk/x11/gdkdrag-x11.c @@ -41,6 +41,7 @@ #include "gdkselectioninputstream-x11.h" #include "gdkselectionoutputstream-x11.h" +#include #include #include #include @@ -2342,9 +2343,22 @@ gdk_dnd_handle_key_event (GdkDrag *drag, if (dx != 0 || dy != 0) { + GdkDisplay *display; + Display *xdisplay; + GdkX11Screen *screen; + Window dest; + x11_drag->last_x += dx; x11_drag->last_y += dy; - gdk_device_warp (pointer, x11_drag->last_x, x11_drag->last_y); + + display = gdk_event_get_display ((GdkEvent *)event); + xdisplay = GDK_DISPLAY_XDISPLAY (display); + screen = GDK_X11_DISPLAY (display)->screen; + dest = GDK_SCREEN_XROOTWIN (screen); + + XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, + round (x11_drag->last_x * screen->surface_scale), + round (x11_drag->last_y * screen->surface_scale)); } gdk_drag_update (drag, x11_drag->last_x, x11_drag->last_y, state,