[gtk/wip/carlosg/more-device-api-cleanup: 5/13] gtkdragsource: Avoid gdk_device_get_associated_device()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/more-device-api-cleanup: 5/13] gtkdragsource: Avoid gdk_device_get_associated_device()
- Date: Thu, 30 Jul 2020 16:20:29 +0000 (UTC)
commit fb9db7fedea031b60672f3248d445146e402e73d
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jul 30 14:28:45 2020 +0200
gtkdragsource: Avoid gdk_device_get_associated_device()
Query the seat for that.
gtk/gtkdragsource.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index 35d107d996..d9675262a4 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -498,7 +498,8 @@ static void
gtk_drag_source_drag_begin (GtkDragSource *source)
{
GtkWidget *widget;
- GdkDevice *device;
+ GdkDevice *device, *pointer;
+ GdkSeat *seat;
double x, y;
GtkNative *native;
GdkSurface *surface;
@@ -508,15 +509,18 @@ gtk_drag_source_drag_begin (GtkDragSource *source)
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
device = gtk_gesture_get_device (GTK_GESTURE (source));
+ seat = gdk_device_get_seat (device);
- if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
- device = gdk_device_get_associated_device (device);
+ if (device == gdk_seat_get_keyboard (seat))
+ pointer = gdk_seat_get_pointer (seat);
+ else
+ pointer = device;
native = gtk_widget_get_native (widget);
surface = gtk_native_get_surface (native);
gtk_widget_translate_coordinates (widget, GTK_WIDGET (native), source->start_x, source->start_y, &x, &y);
- gdk_surface_get_device_position (surface, device, &px, &py, NULL);
+ gdk_surface_get_device_position (surface, pointer, &px, &py, NULL);
dx = round (px - x);
dy = round (py - y);
@@ -525,7 +529,7 @@ gtk_drag_source_drag_begin (GtkDragSource *source)
if (!content)
return;
- source->drag = gdk_drag_begin (surface, device, content, source->actions, dx, dy);
+ source->drag = gdk_drag_begin (surface, pointer, content, source->actions, dx, dy);
g_object_unref (content);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]