[gtk+/xi2] GtkMenu[Shell]: Use GTK+ device grabs.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/xi2] GtkMenu[Shell]: Use GTK+ device grabs.
- Date: Tue, 9 Mar 2010 17:54:18 +0000 (UTC)
commit 15c6785b99ee2f45e4c77590b36f50ab38c63c67
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Mar 9 18:29:18 2010 +0100
GtkMenu[Shell]: Use GTK+ device grabs.
gtk/gtkmenu.c | 30 ++++++++++++++++++++++--------
gtk/gtkmenushell.c | 10 ++++++----
2 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 0e234c6..eed2feb 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1652,7 +1652,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
if (xgrab_shell == widget)
popup_grab_on_window (widget->window, keyboard, pointer, activate_time); /* Should always succeed */
- gtk_grab_add (GTK_WIDGET (menu));
+ gtk_device_grab_add (GTK_WIDGET (menu), pointer, TRUE);
if (parent_menu_shell)
{
@@ -1737,6 +1737,7 @@ gtk_menu_popdown (GtkMenu *menu)
{
GtkMenuPrivate *private;
GtkMenuShell *menu_shell;
+ GdkDevice *pointer;
g_return_if_fail (GTK_IS_MENU (menu));
@@ -1803,8 +1804,13 @@ gtk_menu_popdown (GtkMenu *menu)
gtk_widget_hide (GTK_WIDGET (menu));
menu_shell->have_xgrab = FALSE;
+
+ _gtk_menu_shell_get_grab_devices (menu_shell, NULL, &pointer);
+
+ if (pointer)
+ gtk_device_grab_remove (GTK_WIDGET (menu), pointer);
+
_gtk_menu_shell_set_grab_devices (menu_shell, NULL, NULL);
- gtk_grab_remove (GTK_WIDGET (menu));
menu_grab_transfer_window_destroy (menu);
}
@@ -5439,16 +5445,24 @@ gtk_menu_grab_notify (GtkWidget *widget,
GtkWidget *toplevel;
GtkWindowGroup *group;
GtkWidget *grab;
+ GdkDevice *pointer;
+
+ _gtk_menu_shell_get_grab_devices (GTK_MENU_SHELL (widget), NULL, &pointer);
+
+ if (!pointer ||
+ !gtk_widget_device_is_shadowed (widget, pointer))
+ return;
toplevel = gtk_widget_get_toplevel (widget);
+
+ if (!GTK_IS_WINDOW (toplevel))
+ return;
+
group = gtk_window_get_group (GTK_WINDOW (toplevel));
- grab = _gtk_window_group_get_current_grab (group);
+ grab = gtk_window_group_get_current_device_grab (group, pointer);
- if (!was_grabbed)
- {
- if (GTK_MENU_SHELL (widget)->active && !GTK_IS_MENU_SHELL (grab))
- gtk_menu_shell_cancel (GTK_MENU_SHELL (widget));
- }
+ if (GTK_MENU_SHELL (widget)->active && !GTK_IS_MENU_SHELL (grab))
+ gtk_menu_shell_cancel (GTK_MENU_SHELL (widget));
}
/**
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index ea686a4..da94b60 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -547,7 +547,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;
}
@@ -1054,6 +1056,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;
@@ -1067,12 +1071,10 @@ 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)
{
- GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
-
gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]