]> Pileus Git - ~andy/gtk/commitdiff
Ignore GrabBroken events which are caused by overgrabbing inside the
authorMatthias Clasen <mclasen@redhat.com>
Mon, 27 Jun 2005 21:06:33 +0000 (21:06 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 27 Jun 2005 21:06:33 +0000 (21:06 +0000)
2005-06-27  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkmenushell.c (gtk_menu_shell_grab_broken): Ignore
GrabBroken events which are caused by overgrabbing inside
the application; menus rely on these for their operation.

* gdk/gdkevents.h (struct _GdkEventGrabBroken): Add a
grab_window field.

* gdk/win32/gdkevents-win32.c (gdk_event_translate): Set
grab_window to NULL when generating GrabBroken events for
WM_KILLFOCUS messages.

* gdk/x11/gdkmain-x11.c (_gdk_xgrab_check_unmap)
(_gdk_xgrab_check_destroy): Set grab_window to NULL when
generating GrabBroken events when the grab window becomes
unviewable or is destroyed.

* gdk/x11/gdkmain-x11.c (gdk_pointer_grab, gdk_keyboard_grab):
Generate GrabBroken events when overriding a grab inside
the application. In this case, set grab_window to the new
grab_window.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
docs/reference/ChangeLog
docs/reference/gdk/tmpl/event_structs.sgml
gdk/gdkevents.h
gdk/win32/gdkevents-win32.c
gdk/x11/gdkmain-x11.c
gtk/gtkmenushell.c

index d37854800dfdd024b0f0106e8f7325be2c961bde..f06c29e4225b8515913efddc4d2f590c9789bd95 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkmenushell.c (gtk_menu_shell_grab_broken): Ignore
+       GrabBroken events which are caused by overgrabbing inside
+       the application; menus rely on these for their operation.
+       
+       * gdk/gdkevents.h (struct _GdkEventGrabBroken): Add a 
+       grab_window field.
+
+       * gdk/win32/gdkevents-win32.c (gdk_event_translate): Set
+       grab_window to NULL when generating GrabBroken events for
+       WM_KILLFOCUS messages.
+
+       * gdk/x11/gdkmain-x11.c (_gdk_xgrab_check_unmap) 
+       (_gdk_xgrab_check_destroy): Set grab_window to NULL when
+       generating GrabBroken events when the grab window becomes
+       unviewable or is destroyed.
+
+       * gdk/x11/gdkmain-x11.c (gdk_pointer_grab, gdk_keyboard_grab): 
+       Generate GrabBroken events when overriding a grab inside
+       the application. In this case, set grab_window to the new
+       grab_window.
+       
 2005-06-27  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkbutton.c (gtk_real_button_activate): Continue
@@ -5,9 +28,13 @@
        (gtk_button_finish_activate): Only ungrab when we have
        a keyboard grab.  (#172998, William Jon McCann)
 
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
        * modules/input/gtkimcontextxim.c (gtk_im_context_xim_finalize): 
        Avoid a segfault. (#309054)
 
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
        * gdk/x11/gdkdisplay-x11.h (struct _GdkDisplayX11): Add
        fields for grab timestamps.
 
index d37854800dfdd024b0f0106e8f7325be2c961bde..f06c29e4225b8515913efddc4d2f590c9789bd95 100644 (file)
@@ -1,3 +1,26 @@
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkmenushell.c (gtk_menu_shell_grab_broken): Ignore
+       GrabBroken events which are caused by overgrabbing inside
+       the application; menus rely on these for their operation.
+       
+       * gdk/gdkevents.h (struct _GdkEventGrabBroken): Add a 
+       grab_window field.
+
+       * gdk/win32/gdkevents-win32.c (gdk_event_translate): Set
+       grab_window to NULL when generating GrabBroken events for
+       WM_KILLFOCUS messages.
+
+       * gdk/x11/gdkmain-x11.c (_gdk_xgrab_check_unmap) 
+       (_gdk_xgrab_check_destroy): Set grab_window to NULL when
+       generating GrabBroken events when the grab window becomes
+       unviewable or is destroyed.
+
+       * gdk/x11/gdkmain-x11.c (gdk_pointer_grab, gdk_keyboard_grab): 
+       Generate GrabBroken events when overriding a grab inside
+       the application. In this case, set grab_window to the new
+       grab_window.
+       
 2005-06-27  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkbutton.c (gtk_real_button_activate): Continue
@@ -5,9 +28,13 @@
        (gtk_button_finish_activate): Only ungrab when we have
        a keyboard grab.  (#172998, William Jon McCann)
 
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
        * modules/input/gtkimcontextxim.c (gtk_im_context_xim_finalize): 
        Avoid a segfault. (#309054)
 
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
        * gdk/x11/gdkdisplay-x11.h (struct _GdkDisplayX11): Add
        fields for grab timestamps.
 
index d37854800dfdd024b0f0106e8f7325be2c961bde..f06c29e4225b8515913efddc4d2f590c9789bd95 100644 (file)
@@ -1,3 +1,26 @@
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkmenushell.c (gtk_menu_shell_grab_broken): Ignore
+       GrabBroken events which are caused by overgrabbing inside
+       the application; menus rely on these for their operation.
+       
+       * gdk/gdkevents.h (struct _GdkEventGrabBroken): Add a 
+       grab_window field.
+
+       * gdk/win32/gdkevents-win32.c (gdk_event_translate): Set
+       grab_window to NULL when generating GrabBroken events for
+       WM_KILLFOCUS messages.
+
+       * gdk/x11/gdkmain-x11.c (_gdk_xgrab_check_unmap) 
+       (_gdk_xgrab_check_destroy): Set grab_window to NULL when
+       generating GrabBroken events when the grab window becomes
+       unviewable or is destroyed.
+
+       * gdk/x11/gdkmain-x11.c (gdk_pointer_grab, gdk_keyboard_grab): 
+       Generate GrabBroken events when overriding a grab inside
+       the application. In this case, set grab_window to the new
+       grab_window.
+       
 2005-06-27  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkbutton.c (gtk_real_button_activate): Continue
@@ -5,9 +28,13 @@
        (gtk_button_finish_activate): Only ungrab when we have
        a keyboard grab.  (#172998, William Jon McCann)
 
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
        * modules/input/gtkimcontextxim.c (gtk_im_context_xim_finalize): 
        Avoid a segfault. (#309054)
 
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
        * gdk/x11/gdkdisplay-x11.h (struct _GdkDisplayX11): Add
        fields for grab timestamps.
 
index 7fc72db2c7ade41c85f47e56c02fdcd17467e3eb..34c178ca58f42ff78b7df2cf799e73fd6183a614 100644 (file)
@@ -1,3 +1,7 @@
+2005-06-27  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/tmpl/event_structs.sgml: Update docs.
+
 2005-06-25  Matthias Clasen  <mclasen@redhat.com>
 
        * gdk/gdk-sections.txt: Add GdkEventGrabBroken.
index 438bb6e39f3625bf7db785caaae2fcec4ca2d89e..ed81d237db0155fdd35caa525088b3f8941e544e 100644 (file)
@@ -438,6 +438,9 @@ again.
 @send_event: %TRUE if the event was sent explicitly (e.g. using <function>XSendEvent</function>).
 @keyboard: %TRUE if a keyboard grab was broken, %FALSE if a pointer 
   grab was broken
+@grab_window: If this event is caused by another grab in the same 
+  application, @grab_window contains the new grab window. Otherwise
+  @grab_window id %NULL.
 @Since: 2.8
 
 <!-- ##### ENUM GdkScrollDirection ##### -->
index 797bee7460e982ed03337c6e5fead1510c8030e8..bf4db6ead107db345f928c43f64c6f4f03d27335 100644 (file)
@@ -436,6 +436,7 @@ struct _GdkEventGrabBroken {
   GdkWindow *window;
   gint8 send_event;
   gboolean keyboard;
+  GdkWindow *grab_window;
 };
 
 /* Event types for DND */
index 23f92a241ed1622580f97cf7615d479018ddca42..b3edd4c2ce2113f790df1a6edc76e1762cdb8c56 100644 (file)
@@ -2926,6 +2926,7 @@ gdk_event_translate (GdkDisplay *display,
          event->grab_broken.window = p_grab_window;
          event->grab_broken.send_event = 0;
          event->grab_broken.keyboard = FALSE;
+         event->grab_broken.grab_window = NULL;
          
           append_event (display, event);
        }
@@ -2936,6 +2937,7 @@ gdk_event_translate (GdkDisplay *display,
          event->grab_broken.window = k_grab_window;
          event->grab_broken.send_event = 0;
          event->grab_broken.keyboard = TRUE;
+         event->grab_broken.grab_window = NULL;
 
           append_event (display, event);
        }
index 366f709fe78eecef28e0b9ff360b40bae7b4903e..b92bd6433042bf149923cc389b0f318e2bc41f85 100644 (file)
@@ -139,6 +139,7 @@ gdk_x11_convert_grab_status (gint status)
 
 static void
 generate_grab_broken_event (GdkWindow *window,
+                           GdkWindow *grab_window,
                            gboolean   keyboard)
 {
   GdkEvent event;
@@ -147,7 +148,8 @@ generate_grab_broken_event (GdkWindow *window,
   event.grab_broken.window = window;
   event.grab_broken.send_event = 0;
   event.grab_broken.keyboard = keyboard;
-  
+  event.grab_broken.grab_window = grab_window;
+
   gdk_event_put (&event);
 }
 
@@ -251,14 +253,10 @@ gdk_pointer_grab (GdkWindow *       window,
   if (return_val == GrabSuccess)
     {
       GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
-      if (display_x11->pointer_xgrab_window != NULL)
-       {
-         g_print ("overgrab pointer\n");
-#if 0
-         generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
-                                     FALSE);
-#endif
-       }
+      if (display_x11->pointer_xgrab_window != NULL &&
+         display_x11->pointer_xgrab_window != window)
+       generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
+                                   window, FALSE);
 
       display_x11->pointer_xgrab_window = (GdkWindowObject *)window;
       display_x11->pointer_xgrab_serial = serial;
@@ -358,14 +356,11 @@ gdk_keyboard_grab (GdkWindow *       window,
   if (return_val == GrabSuccess)
     {
       GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (gdk_drawable_get_display (window));
-      if (display_x11->keyboard_xgrab_window != NULL)
-       {
-         g_print ("overgrab keyboard\n");
-#if 0
-         generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
-                                     TRUE);
-#endif
-       }
+      if (display_x11->keyboard_xgrab_window != NULL &&
+         display_x11->keyboard_xgrab_window != window)
+       generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
+                                   window, TRUE);
+      
       display_x11->keyboard_xgrab_window = (GdkWindowObject *)window;
       display_x11->keyboard_xgrab_serial = serial;
       display_x11->keyboard_xgrab_owner_events = owner_events;
@@ -439,9 +434,8 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
 
       if (tmp)
        {         
-         g_print ("pointer grab broken from check unmap\n");
          generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
-                                     FALSE);
+                                     NULL, FALSE);
          display_x11->pointer_xgrab_window = NULL;  
        }
     }
@@ -458,9 +452,8 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
 
       if (tmp)
        {
-         g_print ("keyboard grab broken from check unmap\n");
          generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
-                                     TRUE);
+                                     NULL, TRUE);
          display_x11->keyboard_xgrab_window = NULL;  
        }
     }
@@ -480,17 +473,15 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
   
   if ((GdkWindowObject *)window == display_x11->pointer_xgrab_window)
     {
-      g_print ("pointer grab broken from check destroy\n");
       generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
-                                 FALSE);
+                                 NULL, FALSE);
       display_x11->pointer_xgrab_window = NULL;
     }
 
   if ((GdkWindowObject *)window ==  display_x11->keyboard_xgrab_window)
     {
-         g_print ("keyboard grab broken from check destroy\n");
       generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
-                                 TRUE);
+                                 NULL, TRUE);
       display_x11->keyboard_xgrab_window = NULL;
     }
 }
index f207da7cb3c13005ca8b95948194b10242248899..afd9c5c31ba5845339dffbb0246aa0b5fa5804a0 100644 (file)
@@ -611,14 +611,15 @@ static gboolean
 gtk_menu_shell_grab_broken (GtkWidget          *widget,
                            GdkEventGrabBroken *event)
 {
-  GtkMenuShell *menu_shell;
+  GtkMenuShell *menu_shell = GTK_MENU_SHELL (widget);
 
-  g_return_val_if_fail (GTK_IS_MENU_SHELL (widget), FALSE);
-  g_return_val_if_fail (event != NULL, FALSE);
-
-  menu_shell = GTK_MENU_SHELL (widget);
-  if (menu_shell->active)
+  if (menu_shell->have_xgrab && event->grab_window == NULL)
     {
+      /* Unset the active menu item so gtk_menu_popdown() doesn't see it.
+       */
+      
+      gtk_menu_shell_deselect (menu_shell);
+      
       gtk_menu_shell_deactivate (menu_shell);
       g_signal_emit (menu_shell, menu_shell_signals[SELECTION_DONE], 0);
     }