Ignore GrabBroken events which are caused by overgrabbing inside the

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.
This commit is contained in:
Matthias Clasen 2005-06-27 21:06:33 +00:00 committed by Matthias Clasen
parent f49eab1248
commit b2343762b1
9 changed files with 114 additions and 31 deletions

View 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.

View 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.

View 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.

View 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.

View 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 ##### -->

View File

@ -436,6 +436,7 @@ struct _GdkEventGrabBroken {
GdkWindow *window;
gint8 send_event;
gboolean keyboard;
GdkWindow *grab_window;
};
/* Event types for DND */

View 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);
}

View 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,6 +148,7 @@ 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
if (display_x11->pointer_xgrab_window != NULL &&
display_x11->pointer_xgrab_window != window)
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_xgrab_window),
FALSE);
#endif
}
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
if (display_x11->keyboard_xgrab_window != NULL &&
display_x11->keyboard_xgrab_window != window)
generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
TRUE);
#endif
}
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;
}
}

View 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);
}