Commit 2218b5a1 authored by Carlos Garnacho's avatar Carlos Garnacho

gtkbutton: Avoid keyboard grabs

Seems to be there for the sole purpose of ensuring the button
shall receive the key release on keyboard-triggered activation.

For the cases where this makes sense (eg. comboboxes, menubuttons,
...) gtk+ already does ensure the menu is popup after key release.
This makes the grab pretty useless, and there's many other cases
where it doesn't make sense (eg. button being activated
programmatically from an event handler in another widget).

Fixes button activation unintendedly triggering shortcut inhibition
on wayland.
parent d17aeec0
......@@ -1990,7 +1990,6 @@ gtk_real_button_activate (GtkButton *button)
GtkWidget *widget = GTK_WIDGET (button);
GtkButtonPrivate *priv = button->priv;
GdkDevice *device;
guint32 time;
device = gtk_get_current_event_device ();
......@@ -1999,21 +1998,13 @@ gtk_real_button_activate (GtkButton *button)
if (gtk_widget_get_realized (widget) && !priv->activate_timeout)
time = gtk_get_current_event_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_seat_grab (gdk_device_get_seat (device), priv->event_window,
gtk_device_grab_add (widget, device, TRUE);
priv->grab_keyboard = device;
priv->grab_time = time;
gtk_device_grab_add (widget, device, TRUE);
priv->grab_keyboard = device;
priv->activate_timeout = gdk_threads_add_timeout (ACTIVATE_TIMEOUT,
......@@ -2037,7 +2028,6 @@ gtk_button_finish_activate (GtkButton *button,
if (priv->grab_keyboard)
gdk_seat_ungrab (gdk_device_get_seat (priv->grab_keyboard));
gtk_device_grab_remove (widget, priv->grab_keyboard);
priv->grab_keyboard = NULL;
......@@ -48,7 +48,6 @@ struct _GtkButtonPrivate
gfloat baseline_align;
guint activate_timeout;
guint32 grab_time;
GtkPositionType image_position;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment