[gtk+/xi2] GtkScaleButton: Use GTK+ device grabs.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/xi2] GtkScaleButton: Use GTK+ device grabs.
- Date: Tue, 9 Mar 2010 17:54:23 +0000 (UTC)
commit d8019c14aa7db89c3e6ce4b9d295e45995f92562
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Mar 9 18:29:40 2010 +0100
GtkScaleButton: Use GTK+ device grabs.
gtk/gtkscalebutton.c | 36 +++++++++++++++++++++++-------------
1 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index c99b99a..fa5da41 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -1055,14 +1055,14 @@ gtk_scale_popup (GtkWidget *widget,
}
/* grab focus */
- gtk_grab_add (priv->dock);
+ gtk_device_grab_add (priv->dock, pointer, TRUE);
if (gdk_device_grab (pointer, priv->dock->window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK, NULL, time) != GDK_GRAB_SUCCESS)
{
- gtk_grab_remove (priv->dock);
+ gtk_device_grab_remove (priv->dock, pointer);
gtk_widget_hide (priv->dock);
return FALSE;
}
@@ -1073,7 +1073,7 @@ gtk_scale_popup (GtkWidget *widget,
NULL, time) != GDK_GRAB_SUCCESS)
{
gdk_device_ungrab (pointer, time);
- gtk_grab_remove (priv->dock);
+ gtk_device_grab_remove (priv->dock, pointer);
gtk_widget_hide (priv->dock);
return FALSE;
}
@@ -1168,22 +1168,32 @@ gtk_scale_button_grab_notify (GtkScaleButton *button,
{
GdkDisplay *display;
GtkScaleButtonPrivate *priv;
-
- if (was_grabbed != FALSE)
- return;
+ GtkWidget *toplevel, *grab_widget;
+ GtkWindowGroup *group;
priv = button->priv;
- if (!gtk_widget_has_grab (priv->dock))
+ if (!priv->grab_pointer ||
+ !gtk_widget_device_is_shadowed (GTK_WIDGET (button), priv->grab_pointer))
return;
- if (gtk_widget_is_ancestor (gtk_grab_get_current (), priv->dock))
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+
+ if (GTK_IS_WINDOW (toplevel))
+ group = gtk_window_get_group (GTK_WINDOW (toplevel));
+ else
+ group = gtk_window_get_group (NULL);
+
+ grab_widget = gtk_window_group_get_current_device_grab (group, priv->grab_pointer);
+
+ if (grab_widget &&
+ gtk_widget_is_ancestor (grab_widget, priv->dock))
return;
display = gtk_widget_get_display (priv->dock);
gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
- gtk_grab_remove (priv->dock);
+ gtk_device_grab_remove (priv->dock, priv->grab_pointer);
priv->grab_keyboard = NULL;
priv->grab_pointer = NULL;
@@ -1326,7 +1336,7 @@ gtk_scale_button_release_grab (GtkScaleButton *button,
display = gtk_widget_get_display (GTK_WIDGET (button));
gdk_device_ungrab (priv->grab_keyboard, event->time);
gdk_device_ungrab (priv->grab_pointer, event->time);
- gtk_grab_remove (priv->dock);
+ gtk_device_grab_remove (priv->dock, priv->grab_pointer);
priv->grab_keyboard = NULL;
priv->grab_pointer = NULL;
@@ -1373,7 +1383,7 @@ gtk_scale_button_popdown (GtkWidget *widget)
display = gtk_widget_get_display (widget);
gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
- gtk_grab_remove (priv->dock);
+ gtk_device_grab_remove (priv->dock, priv->grab_pointer);
priv->grab_keyboard = NULL;
priv->grab_pointer = NULL;
@@ -1495,7 +1505,7 @@ gtk_scale_button_scale_press (GtkWidget *widget,
/* the scale will grab input; if we have input grabbed, all goes
* horribly wrong, so let's not do that.
*/
- gtk_grab_remove (priv->dock);
+ gtk_device_grab_remove (priv->dock, event->device);
return GTK_WIDGET_CLASS (_gtk_scale_button_scale_parent_class)->button_press_event (widget, event);
}
@@ -1530,7 +1540,7 @@ gtk_scale_button_scale_release (GtkWidget *widget,
* find that, so we do this complex 'first-call-parent-then-do-actual-
* action' thingy...
*/
- gtk_grab_add (button->priv->dock);
+ gtk_device_grab_add (button->priv->dock, event->device, TRUE);
return res;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]