[gtk+/xi2] GtkWindowGroup: Also clean up device grabs.



commit 08af272c367eee5123abd7f143399ec107d319e2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 9 18:01:07 2010 +0100

    GtkWindowGroup: Also clean up device grabs.

 gtk/gtkwindow.c |   40 +++++++++++++++++++++++++++++++++-------
 1 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 43d841c..d36f454 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -211,7 +211,7 @@ struct _GtkDeviceGrabInfo
 
 struct _GtkWindowGroupPrivate
 {
-  GList *device_grabs;
+  GSList *device_grabs;
 };
 
 static void gtk_window_dispose            (GObject           *object);
@@ -7668,6 +7668,8 @@ static void
 window_group_cleanup_grabs (GtkWindowGroup *group,
 			    GtkWindow      *window)
 {
+  GtkWindowGroupPrivate *priv;
+  GtkDeviceGrabInfo *info;
   GSList *tmp_list;
   GSList *to_remove = NULL;
 
@@ -7685,6 +7687,27 @@ window_group_cleanup_grabs (GtkWindowGroup *group,
       g_object_unref (to_remove->data);
       to_remove = g_slist_delete_link (to_remove, to_remove);
     }
+
+  priv = GTK_WINDOW_GROUP_GET_PRIVATE (group);
+  tmp_list = priv->device_grabs;
+
+  while (tmp_list)
+    {
+      info = tmp_list->data;
+
+      if (gtk_widget_get_toplevel (info->widget) == (GtkWidget *) window)
+        to_remove = g_slist_prepend (to_remove, info);
+
+      tmp_list = tmp_list->next;
+    }
+
+  while (to_remove)
+    {
+      info = to_remove->data;
+
+      gtk_device_grab_remove (info->widget, info->device);
+      to_remove = g_slist_delete_link (to_remove, to_remove);
+    }
 }
 
 /**
@@ -7827,7 +7850,7 @@ _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
   info->device = device;
   info->block_others = block_others;
 
-  priv->device_grabs = g_list_prepend (priv->device_grabs, info);
+  priv->device_grabs = g_slist_prepend (priv->device_grabs, info);
 }
 
 void
@@ -7837,9 +7860,11 @@ _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
 {
   GtkWindowGroupPrivate *priv;
   GtkDeviceGrabInfo *info;
-  GList *list, *node = NULL;
+  GSList *list, *node = NULL;
+  GdkDevice *other_device;
 
   priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
+  other_device = gdk_device_get_associated_device (device);
   list = priv->device_grabs;
 
   while (list)
@@ -7847,7 +7872,8 @@ _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
       info = list->data;
 
       if (info->widget == widget &&
-          info->device == device)
+          (info->device == device ||
+           info->device == other_device))
         {
           node = list;
           break;
@@ -7860,8 +7886,8 @@ _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
     {
       info = node->data;
 
+      priv->device_grabs = g_slist_delete_link (priv->device_grabs, node);
       g_slice_free (GtkDeviceGrabInfo, info);
-      priv->device_grabs = g_list_delete_link (priv->device_grabs, node);
     }
 }
 
@@ -7872,7 +7898,7 @@ _gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group,
   GtkWindowGroupPrivate *priv;
   GtkDeviceGrabInfo *info;
   GdkDevice *other_device;
-  GList *list;
+  GSList *list;
 
   priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
   list = priv->device_grabs;
@@ -7899,7 +7925,7 @@ _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
   GtkWindowGroupPrivate *priv;
   GtkDeviceGrabInfo *info;
   GdkDevice *other_device;
-  GList *list;
+  GSList *list;
 
   priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
   other_device = gdk_device_get_associated_device (device);



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