[gtk+] bgo#626336 - Don't assume that GtkButton is activated only when a keyboard event is available
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] bgo#626336 - Don't assume that GtkButton is activated only when a keyboard event is available
- Date: Fri, 21 Jan 2011 21:34:01 +0000 (UTC)
commit d07231cb7aad19b94f52e9a8af768a6c39919e6d
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Jan 21 13:36:27 2011 -0600
bgo#626336 - Don't assume that GtkButton is activated only when a keyboard event is available
Buttons may also be activated at any time from gtk_widget_activate()
or related functions. In that case, just do the 'show the button
as pushed for a short amount of time' trick, but don't actually
try to grab the keyboard device.
Signed-off-by: Federico Mena Quintero <federico gnome org>
gtk/gtkbutton.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 3d3bd86..baad6eb 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -1860,20 +1860,24 @@ gtk_real_button_activate (GtkButton *button)
if (device && gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
device = gdk_device_get_associated_device (device);
- g_return_if_fail (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD);
-
if (gtk_widget_get_realized (widget) && !priv->activate_timeout)
{
time = gtk_get_current_event_time ();
- if (gdk_device_grab (device, priv->event_window,
- GDK_OWNERSHIP_WINDOW, TRUE,
- GDK_KEY_PRESS | GDK_KEY_RELEASE,
- NULL, time) == GDK_GRAB_SUCCESS)
- {
- gtk_device_grab_add (widget, device, TRUE);
- priv->grab_keyboard = device;
- priv->grab_time = time;
+ /* bgo#626336 - Only grab if we have a device (from an event), not if we
+ * were activated programmatically when no event is available.
+ */
+ if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+ {
+ if (gdk_device_grab (device, priv->event_window,
+ GDK_OWNERSHIP_WINDOW, TRUE,
+ GDK_KEY_PRESS | GDK_KEY_RELEASE,
+ NULL, time) == GDK_GRAB_SUCCESS)
+ {
+ gtk_device_grab_add (widget, device, TRUE);
+ priv->grab_keyboard = device;
+ priv->grab_time = time;
+ }
}
priv->activate_timeout = gdk_threads_add_timeout (ACTIVATE_TIMEOUT,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]