[nautilus/gnome-3-24] canvas-container: Use rubberband coordinates from original device



commit 36f0d58f0c56af7e4bb1a29ce6b636de2cd7fc93
Author: Jason Gerecke <killertofu gmail com>
Date:   Thu Jun 15 09:04:53 2017 -0700

    canvas-container: Use rubberband coordinates from original device
    
    Nautilus assumes that the pointer returned by gdk_seat_get_pointer will
    return the same GdkDevice which started a rubberband action. This is
    not necessarily the case, however. Under Wayland, for example, tablet
    tools have pointers (and GdkDevice's) which are entirely separate from
    the seat's primary mouse-driven pointer. Attempting to use a pen to
    perform rubberband selection will result in the rectangle being drawn
    with the incorrect coordinates.
    
    This patch has the code store the GdkDevice which generated the event
    and provides it in place of the call to gdk_seat_get_pointer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783797

 src/nautilus-canvas-container.c |   11 +++++------
 src/nautilus-canvas-private.h   |    1 +
 2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-canvas-container.c b/src/nautilus-canvas-container.c
index 65c5c10..4634d5f 100644
--- a/src/nautilus-canvas-container.c
+++ b/src/nautilus-canvas-container.c
@@ -2537,8 +2537,6 @@ rubberband_timeout_callback (gpointer data)
     double world_x, world_y;
     int x_scroll, y_scroll;
     int adj_x, adj_y;
-    GdkDisplay *display;
-    GdkSeat *seat;
     gboolean adj_changed;
     GtkAllocation allocation;
 
@@ -2567,11 +2565,8 @@ rubberband_timeout_callback (gpointer data)
         adj_changed = TRUE;
     }
 
-    display = gtk_widget_get_display (widget);
-    seat = gdk_display_get_default_seat (display);
-
     gdk_window_get_device_position (gtk_widget_get_window (widget),
-                                    gdk_seat_get_pointer (seat),
+                                    band_info->device,
                                     &x, &y, NULL);
 
     if (x < RUBBERBAND_SCROLL_THRESHOLD)
@@ -2762,6 +2757,8 @@ start_rubberbanding (NautilusCanvasContainer *container,
     g_signal_emit (container,
                    signals[BAND_SELECT_STARTED], 0);
 
+    band_info->device = event->device;
+
     for (p = details->icons; p != NULL; p = p->next)
     {
         icon = p->data;
@@ -2828,6 +2825,8 @@ stop_rubberbanding (NautilusCanvasContainer *container)
 
     band_info->active = FALSE;
 
+    band_info->device = NULL;
+
     g_object_get (gtk_settings_get_default (), "gtk-enable-animations", &enable_animation, NULL);
 
     /* Destroy this canvas item; the parent will unref it. */
diff --git a/src/nautilus-canvas-private.h b/src/nautilus-canvas-private.h
index 6b44952..0f3ad70 100644
--- a/src/nautilus-canvas-private.h
+++ b/src/nautilus-canvas-private.h
@@ -75,6 +75,7 @@ typedef struct {
        double start_x, start_y;
 
        EelCanvasItem *selection_rectangle;
+       GdkDevice *device;
 
        guint timer_id;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]