summaryrefslogtreecommitdiff
path: root/gtk/gtkmenushell.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2010-06-16 01:09:41 +0200
committerCarlos Garnacho <carlosg@gnome.org>2010-06-16 15:04:27 +0200
commit404f4c5d40c2ebf31da41144154abbc27de642a5 (patch)
treeb9de33b765564e7798c9459458bdcb1a53bf39ba /gtk/gtkmenushell.c
parentdfc9c87a4671b8aff7a89fb71bdc64e805c93205 (diff)
downloadgtk+-404f4c5d40c2ebf31da41144154abbc27de642a5.tar.gz
GtkMenuShell: take a single device for grabs.
The other device will always be the associated device.
Diffstat (limited to 'gtk/gtkmenushell.c')
-rw-r--r--gtk/gtkmenushell.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index 615f9a45c5..f4cdc46de7 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -135,7 +135,6 @@ struct _GtkMenuShellPrivate
GtkMnemonicHash *mnemonic_hash;
GtkKeyHash *key_hash;
- GdkDevice *grab_keyboard;
GdkDevice *grab_pointer;
guint take_focus : 1;
@@ -1097,12 +1096,16 @@ gtk_real_menu_shell_deactivate (GtkMenuShell *menu_shell)
}
if (menu_shell->have_xgrab)
{
+ GdkDevice *keyboard;
+
gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
- gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
+ keyboard = gdk_device_get_associated_device (priv->grab_pointer);
+
+ if (keyboard)
+ gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
- menu_shell->have_xgrab = FALSE;
- priv->grab_pointer = NULL;
- priv->grab_keyboard = NULL;
+ menu_shell->have_xgrab = FALSE;
+ _gtk_menu_shell_set_grab_device (menu_shell, NULL);
}
menu_shell->keyboard_mode = FALSE;
@@ -1752,36 +1755,34 @@ _gtk_menu_shell_remove_mnemonic (GtkMenuShell *menu_shell,
}
void
-_gtk_menu_shell_set_grab_devices (GtkMenuShell *menu_shell,
- GdkDevice *keyboard,
- GdkDevice *pointer)
+_gtk_menu_shell_set_grab_device (GtkMenuShell *menu_shell,
+ GdkDevice *device)
{
- GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
+ GtkMenuShellPrivate *priv;
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));
+ g_return_if_fail (!device || GDK_IS_DEVICE (device));
- priv->grab_keyboard = keyboard;
- priv->grab_pointer = pointer;
+ priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
+
+ if (!device)
+ priv->grab_pointer = NULL;
+ else if (device->source == GDK_SOURCE_KEYBOARD)
+ priv->grab_pointer = gdk_device_get_associated_device (device);
+ else
+ priv->grab_pointer = device;
}
-gboolean
-_gtk_menu_shell_get_grab_devices (GtkMenuShell *menu_shell,
- GdkDevice **keyboard,
- GdkDevice **pointer)
+GdkDevice *
+_gtk_menu_shell_get_grab_device (GtkMenuShell *menu_shell)
{
- GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
+ GtkMenuShellPrivate *priv;
g_return_val_if_fail (GTK_IS_MENU_SHELL (menu_shell), FALSE);
- if (keyboard)
- *keyboard = priv->grab_keyboard;
-
- if (pointer)
- *pointer = priv->grab_pointer;
+ priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
- return TRUE;
+ return priv->grab_pointer;
}
/**