[gtk+/xi2: 142/148] GtkPaned: Use device grab.



commit 2e6a322b5da17414dddd2d8e28db928f3c7eb587
Author: Carlos Garnacho <carlos gnome org>
Date:   Wed Dec 9 23:21:19 2009 +0100

    GtkPaned: Use device grab.
    
    Grab ownership is assigned to the handle, so other pointers can interact
    with other widgets.

 gtk/gtkpaned.c |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 64b0429..d0421e4 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -150,6 +150,7 @@ struct _GtkPanedPrivate
   GtkWidget      *saved_focus;
   GtkPaned       *first_paned;
   guint32         grab_time;
+  GdkDevice      *grab_device;
 };
 
 
@@ -1214,18 +1215,20 @@ gtk_paned_button_press (GtkWidget      *widget,
     {
       /* We need a server grab here, not gtk_grab_add(), since
        * we don't want to pass events on to the widget's children */
-      if (gdk_pointer_grab (paned->handle, FALSE,
-			    GDK_POINTER_MOTION_HINT_MASK
-			    | GDK_BUTTON1_MOTION_MASK
-			    | GDK_BUTTON_RELEASE_MASK
-			    | GDK_ENTER_NOTIFY_MASK
-			    | GDK_LEAVE_NOTIFY_MASK,
-			    NULL, NULL,
-			    event->time) != GDK_GRAB_SUCCESS)
+      if (gdk_device_grab (event->device,
+                           paned->handle,
+                           GDK_OWNERSHIP_WINDOW, FALSE,
+                           GDK_POINTER_MOTION_HINT_MASK
+                           | GDK_BUTTON1_MOTION_MASK
+                           | GDK_BUTTON_RELEASE_MASK
+                           | GDK_ENTER_NOTIFY_MASK
+                           | GDK_LEAVE_NOTIFY_MASK,
+                           NULL, event->time) != GDK_GRAB_SUCCESS)
 	return FALSE;
 
       paned->in_drag = TRUE;
       paned->priv->grab_time = event->time;
+      paned->priv->grab_device = event->device;
 
       if (paned->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
 	paned->drag_pos = event->x;
@@ -1257,8 +1260,10 @@ stop_drag (GtkPaned *paned)
   paned->in_drag = FALSE;
   paned->drag_pos = -1;
   paned->position_set = TRUE;
-  gdk_display_pointer_ungrab (gtk_widget_get_display (GTK_WIDGET (paned)),
-			      paned->priv->grab_time);
+
+  gdk_device_ungrab (paned->priv->grab_device,
+                     paned->priv->grab_time);
+  paned->priv->grab_device = NULL;
 }
 
 static void



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