gtkbutton: remove keyboard device GTK+ grab
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 5 Jun 2018 13:57:53 +0000 (15:57 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 21 Jun 2018 10:50:57 +0000 (12:50 +0200)
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

index 50b26fc5639a5df20935b16ab2a42f16b3df0e75..ddb4382711b99c30ffa980ea794ebdd575c9cc11 100644 (file)
@@ -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)