summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-04-01 18:36:23 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-04-01 18:38:11 -0400
commit00923615f42ddf8eccb5df715ecfc68fb94d4a96 (patch)
tree5ea61d42d52949e5e384a4efe7f36c83e468a7aa
parent8e9effcc1e217dfbc8fa8a743df6360c175b466b (diff)
downloadgtk+-00923615f42ddf8eccb5df715ecfc68fb94d4a96.tar.gz
button: Add back visual feedback for keynavbutton-activate-feedback
We lost the visual feedback for activating a button via Space or Enter when the :active pseudo-state became managed. Bring it back with a style class. Fixes: #3813
-rw-r--r--gtk/gtkbutton.c6
-rw-r--r--gtk/theme/Adwaita/_common.scss1
2 files changed, 7 insertions, 0 deletions
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 3b2aad8f34..1acc35d569 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -39,6 +39,8 @@
* `GtkButton` has a single CSS node with name button. The node will get the
* style classes .image-button or .text-button, if the content is just an
* image or label, respectively. It may also receive the .flat style class.
+ * When activating a button via the keyboard, the button will temporarily
+ * gain the .keyboard-activating style class.
*
* Other style classes that are commonly used with `GtkButton` include
* .suggested-action and .destructive-action. In special cases, buttons
@@ -780,6 +782,8 @@ gtk_real_button_activate (GtkButton *button)
{
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");
+
+ gtk_widget_add_css_class (GTK_WIDGET (button), "keyboard-activating");
priv->button_down = TRUE;
}
}
@@ -790,6 +794,8 @@ gtk_button_finish_activate (GtkButton *button,
{
GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
+ gtk_widget_remove_css_class (GTK_WIDGET (button), "keyboard-activating");
+
g_source_remove (priv->activate_timeout);
priv->activate_timeout = 0;
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index c5baa58518..ea4c31f6d1 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -492,6 +492,7 @@ button {
-gtk-icon-filter: brightness(1.2);
}
+ &.keyboard-activating,
&:active,
&:checked {
@include button(active);