From 7048362e6e0bdda3b7925d3b4eeb01c85870f4bc Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 5 Jun 2018 15:57:53 +0200 Subject: [PATCH] gtkbutton: remove keyboard device GTK+ grab This isn't really necessary, if keyboard focus forcibly goes somewhere else we will get ::grab-notify, which is sufficient to deactivate the button again. --- gtk/gtkbutton.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 50b26fc563..ddb4382711 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -85,8 +85,6 @@ struct _GtkButtonPrivate { GtkActionHelper *action_helper; - GdkDevice *grab_keyboard; - GtkGesture *gesture; GtkEventController *key_controller; @@ -814,15 +812,6 @@ gtk_real_button_activate (GtkButton *button) if (gtk_widget_get_realized (widget) && !priv->activate_timeout) { - /* 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) - { - gtk_device_grab_add (widget, device, TRUE); - priv->grab_keyboard = device; - } - priv->activate_timeout = g_timeout_add (ACTIVATE_TIMEOUT, button_activate_timeout, button); g_source_set_name_by_id (priv->activate_timeout, "[gtk+] button_activate_timeout"); priv->button_down = TRUE; @@ -840,13 +829,6 @@ gtk_button_finish_activate (GtkButton *button, g_source_remove (priv->activate_timeout); priv->activate_timeout = 0; - 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; - } - priv->button_down = FALSE; gtk_button_update_state (button); @@ -1041,9 +1023,7 @@ gtk_button_grab_notify (GtkWidget *widget, GTK_WIDGET_CLASS (gtk_button_parent_class)->grab_notify (widget, was_grabbed); - if (priv->activate_timeout && - priv->grab_keyboard && - gtk_widget_device_is_shadowed (widget, priv->grab_keyboard)) + if (was_grabbed && priv->activate_timeout) gtk_button_finish_activate (button, FALSE); if (!was_grabbed) -- 2.30.2