[nautilus] canvas-container: Cancel active rubberband if a new one is started



commit 5bca20de257c0a3724a21dcc5e0972aee1058617
Author: Jason Gerecke <killertofu gmail com>
Date:   Wed Jun 14 13:39:53 2017 -0700

    canvas-container: Cancel active rubberband if a new one is started
    
    Wayland allows multiple pointers to be active at the same time, e.g. when
    a Wacom tablet and mouse are both connected to a system. This means that
    it is possible to recieve a "rubberband start" event from a second tool
    while a rubberband is already active. At the moment, this results in stray
    selection rectangles since the canvas does not properly perform cleanup.
    
    To prevent these graphical glitches from occuring, we can simply cancel
    any existing rubberband operation if a second one attempts to start. The
    only additional minor complication is ensuring that the new rubberband
    is not stopped when the first tool sends a button-up event.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783797

 src/nautilus-canvas-container.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-canvas-container.c b/src/nautilus-canvas-container.c
index 321c221..b85a2ad 100644
--- a/src/nautilus-canvas-container.c
+++ b/src/nautilus-canvas-container.c
@@ -2741,6 +2741,10 @@ get_rubber_color (NautilusCanvasContainer *container,
 }
 
 static void
+stop_rubberbanding (NautilusCanvasContainer *container,
+                    GdkEventButton          *event);
+
+static void
 start_rubberbanding (NautilusCanvasContainer *container,
                      GdkEventButton          *event)
 {
@@ -2754,6 +2758,12 @@ start_rubberbanding (NautilusCanvasContainer *container,
     details = container->details;
     band_info = &details->rubberband_info;
 
+    if (band_info->active)
+    {
+        g_debug ("Canceling active rubberband by device %s", gdk_device_get_name (band_info->device));
+        stop_rubberbanding (container, NULL);
+    }
+
     g_signal_emit (container,
                    signals[BAND_SELECT_STARTED], 0);
 
@@ -2811,7 +2821,8 @@ start_rubberbanding (NautilusCanvasContainer *container,
 }
 
 static void
-stop_rubberbanding (NautilusCanvasContainer *container)
+stop_rubberbanding (NautilusCanvasContainer *container,
+                    GdkEventButton          *event)
 {
     NautilusCanvasRubberbandInfo *band_info;
     GList *icons;
@@ -2819,6 +2830,11 @@ stop_rubberbanding (NautilusCanvasContainer *container)
 
     band_info = &container->details->rubberband_info;
 
+    if (event != NULL && event->device != band_info->device)
+    {
+        return;
+    }
+
     g_assert (band_info->timer_id != 0);
     g_source_remove (band_info->timer_id);
     band_info->timer_id = 0;
@@ -4960,7 +4976,7 @@ button_release_event (GtkWidget      *widget,
 
     if (event->button == RUBBERBAND_BUTTON && details->rubberband_info.active)
     {
-        stop_rubberbanding (container);
+        stop_rubberbanding (container, event);
         return TRUE;
     }
 
@@ -5288,7 +5304,7 @@ grab_notify_cb  (GtkWidget *widget,
          * up (e.g. authentication or an error). Stop
          * the rubberbanding so that we can handle the
          * dialog. */
-        stop_rubberbanding (container);
+        stop_rubberbanding (container, NULL);
     }
 }
 


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