[gtk+/multitouch: 111/121] gtk, pah: Don't cancel a ::press-and-hold that's scheduled to be activated



commit 75daab5ae5084537697bf52a4a3d44ba31633c9a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jan 12 02:35:24 2012 +0100

    gtk,pah: Don't cancel a ::press-and-hold that's scheduled to be activated
    
    There was a slight window where the operation could be cancelled, causing
    an assert as the p-a-h data is NULL.

 gtk/gtkwidget.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b3380f7..f74b581 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -550,6 +550,7 @@ typedef struct
   /* animation */
   GtkWidget *popup;
   guint delay_animation_id;
+  guint trigger_id;
   guint size;
 
   gint start_x;
@@ -6989,6 +6990,9 @@ press_and_hold_data_free (PressAndHoldData *data)
   if (data->delay_animation_id)
     g_source_remove (data->delay_animation_id);
 
+  if (data->trigger_id)
+    g_source_remove (data->trigger_id);
+
   g_slice_free (PressAndHoldData, data);
 }
 
@@ -7052,6 +7056,7 @@ _gtk_widget_press_and_hold_check_cancel (GtkWidget      *widget,
   data = gtk_widget_peek_press_and_hold_data (widget);
 
   if (data &&
+      data->trigger_id == 0 &&
       data->device == gdk_event_get_device ((GdkEvent *) event))
     {
       gtk_widget_press_and_hold_cancel (widget);
@@ -7149,8 +7154,9 @@ press_and_hold_animation_draw (GtkWidget *widget,
       /* The animation just finished, so hide the widget
        * and finish the press and hold operation.
        */
-      gdk_threads_add_idle (gtk_widget_press_and_hold_timeout,
-                            user_data);
+      data->trigger_id =
+        gdk_threads_add_idle (gtk_widget_press_and_hold_timeout,
+                              user_data);
       gtk_widget_hide (widget);
       return FALSE;
     }
@@ -7308,6 +7314,8 @@ _gtk_widget_press_and_hold_check_start (GtkWidget      *widget,
                                  gtk_widget_press_and_hold_begin_animation_timeout,
                                  widget);
     }
+  else
+    gtk_widget_set_press_and_hold_data (widget, NULL);
 
   return FALSE;
 }



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