[gtk+] Make GTK+ device grabs take precedence over GTK+ grabs



commit b238c0124ae0ff49548a80f55a449eeb14fb7559
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jun 15 19:06:51 2010 +0200

    Make GTK+ device grabs take precedence over GTK+ grabs
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=620440 (Reported by
    Marek Kašík), where the print dialog modality would impair the pop-up
    window from getting events. Device GTK+ grabs gain in specificness.

 gtk/gtkmain.c |   34 ++++++++++++----------------------
 1 files changed, 12 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index c8c769f..017d000 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1466,31 +1466,21 @@ gtk_main_do_event (GdkEvent *event)
   window_group = gtk_main_get_window_group (event_widget);
   device = gdk_event_get_device (event);
 
-  /* If there is a grab in effect...
+  /* check whether there is a (device) grab in effect...
    */
-  if (window_group->grabs)
-    {
-      grab_widget = window_group->grabs->data;
-      
-      /* If the grab widget is an ancestor of the event widget
-       *  then we send the event to the original event widget.
-       *  This is the key to implementing modality.
-       */
-      if (gtk_widget_is_sensitive (event_widget) &&
-	  gtk_widget_is_ancestor (event_widget, grab_widget))
-	grab_widget = event_widget;
-    }
-  else if (device)
-    {
-      grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
+  if (device)
+    grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
 
-      if (grab_widget &&
-          gtk_widget_get_sensitive (event_widget) &&
-          gtk_widget_is_ancestor (event_widget, grab_widget))
-        grab_widget = event_widget;
-    }
+  if (!grab_widget && window_group->grabs)
+    grab_widget = window_group->grabs->data;
 
-  if (!grab_widget)
+  /* If the grab widget is an ancestor of the event widget
+   *  then we send the event to the original event widget.
+   *  This is the key to implementing modality.
+   */
+  if (!grab_widget ||
+      (gtk_widget_is_sensitive (event_widget) &&
+       gtk_widget_is_ancestor (event_widget, grab_widget)))
     grab_widget = event_widget;
 
   /* If the widget receiving events is actually blocked by another device GTK+ grab */



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