[gtk+/multitouch: 38/121] gtk, scrolledwindow: Unset dragging device on ::grab-notify



commit 9e86500bd5979eb780f66254277bb2190f7abeda
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Nov 22 21:00:44 2011 +0100

    gtk,scrolledwindow: Unset dragging device on ::grab-notify
    
    The child widget may still call gtk_(device_)grab_add, which left
    the scrolled window in an inconsistent state.

 gtk/gtkscrolledwindow.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 469ee97..e77e904 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -276,6 +276,8 @@ static void  gtk_scrolled_window_realize               (GtkWidget           *wid
 static void  gtk_scrolled_window_unrealize             (GtkWidget           *widget);
 static void  gtk_scrolled_window_map                   (GtkWidget           *widget);
 static void  gtk_scrolled_window_unmap                 (GtkWidget           *widget);
+static void  gtk_scrolled_window_grab_notify           (GtkWidget           *widget,
+                                                        gboolean             was_grabbed);
 
 static void     gtk_scrolled_window_auto_hide_scrollbars_start (GtkScrolledWindow *scrolled_window,
                                                                 guint              delay);
@@ -351,6 +353,7 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
   widget_class->unrealize = gtk_scrolled_window_unrealize;
   widget_class->map = gtk_scrolled_window_map;
   widget_class->unmap = gtk_scrolled_window_unmap;
+  widget_class->grab_notify = gtk_scrolled_window_grab_notify;
 
   container_class->add = gtk_scrolled_window_add;
   container_class->remove = gtk_scrolled_window_remove;
@@ -3339,6 +3342,32 @@ gtk_scrolled_window_unmap (GtkWidget *widget)
   GTK_WIDGET_CLASS (gtk_scrolled_window_parent_class)->unmap (widget);
 }
 
+static void
+gtk_scrolled_window_grab_notify (GtkWidget *widget,
+                                 gboolean   was_grabbed)
+{
+  GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
+  GtkScrolledWindowPrivate *priv = scrolled_window->priv;
+
+  if (priv->drag_device &&
+      gtk_widget_device_is_shadowed (widget,
+                                     priv->drag_device))
+    {
+      gdk_device_ungrab (priv->drag_device,
+                         gtk_get_current_event_time ());
+      priv->drag_device = NULL;
+      priv->in_drag = FALSE;
+
+      if (priv->release_timeout_id)
+        {
+          g_source_remove (priv->release_timeout_id);
+          priv->release_timeout_id = 0;
+        }
+
+      gtk_scrolled_window_cancel_deceleration (scrolled_window);
+    }
+}
+
 /**
  * gtk_scrolled_window_get_min_content_width:
  * @scrolled_window: a #GtkScrolledWindow



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