summaryrefslogtreecommitdiff
path: root/gtk/gtkmenushell.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/gtkmenushell.c')
-rw-r--r--gtk/gtkmenushell.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index c3e107fa1c..615f9a45c5 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -135,6 +135,9 @@ struct _GtkMenuShellPrivate
GtkMnemonicHash *mnemonic_hash;
GtkKeyHash *key_hash;
+ GdkDevice *grab_keyboard;
+ GdkDevice *grab_pointer;
+
guint take_focus : 1;
guint activated_submenu : 1;
/* This flag is a crutch to keep mnemonics in the same menu
@@ -548,7 +551,9 @@ _gtk_menu_shell_activate (GtkMenuShell *menu_shell)
{
if (!menu_shell->active)
{
- gtk_grab_add (GTK_WIDGET (menu_shell));
+ gtk_device_grab_add (GTK_WIDGET (menu_shell),
+ gtk_get_current_event_device (),
+ TRUE);
menu_shell->have_grab = TRUE;
menu_shell->active = TRUE;
}
@@ -1073,6 +1078,8 @@ gtk_real_menu_shell_deactivate (GtkMenuShell *menu_shell)
{
if (menu_shell->active)
{
+ GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
+
menu_shell->button = 0;
menu_shell->active = FALSE;
menu_shell->activate_time = 0;
@@ -1086,15 +1093,16 @@ gtk_real_menu_shell_deactivate (GtkMenuShell *menu_shell)
if (menu_shell->have_grab)
{
menu_shell->have_grab = FALSE;
- gtk_grab_remove (GTK_WIDGET (menu_shell));
+ gtk_device_grab_remove (GTK_WIDGET (menu_shell), priv->grab_pointer);
}
if (menu_shell->have_xgrab)
{
- GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (menu_shell));
+ gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
+ gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
menu_shell->have_xgrab = FALSE;
- gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
- gdk_display_keyboard_ungrab (display, GDK_CURRENT_TIME);
+ priv->grab_pointer = NULL;
+ priv->grab_keyboard = NULL;
}
menu_shell->keyboard_mode = FALSE;
@@ -1743,6 +1751,39 @@ _gtk_menu_shell_remove_mnemonic (GtkMenuShell *menu_shell,
gtk_menu_shell_reset_key_hash (menu_shell);
}
+void
+_gtk_menu_shell_set_grab_devices (GtkMenuShell *menu_shell,
+ GdkDevice *keyboard,
+ GdkDevice *pointer)
+{
+ GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
+
+ g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
+ g_return_if_fail (!keyboard || GDK_IS_DEVICE (keyboard));
+ g_return_if_fail (!pointer || GDK_IS_DEVICE (pointer));
+
+ priv->grab_keyboard = keyboard;
+ priv->grab_pointer = pointer;
+}
+
+gboolean
+_gtk_menu_shell_get_grab_devices (GtkMenuShell *menu_shell,
+ GdkDevice **keyboard,
+ GdkDevice **pointer)
+{
+ GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
+
+ g_return_val_if_fail (GTK_IS_MENU_SHELL (menu_shell), FALSE);
+
+ if (keyboard)
+ *keyboard = priv->grab_keyboard;
+
+ if (pointer)
+ *pointer = priv->grab_pointer;
+
+ return TRUE;
+}
+
/**
* gtk_menu_shell_get_take_focus:
* @menu_shell: a #GtkMenuShell