From 01f78e21ff66a56f0836ea5c5c89c49710992550 Mon Sep 17 00:00:00 2001 From: Adrien Plazas Date: Tue, 1 Mar 2022 13:55:02 +0100 Subject: [PATCH 1/2] shell: Activate the correct back button This makes the Alt+Left key binding and the "go back" mouse gestures activate the correct back button instead of both (contrary to what the comments say). --- src/gs-shell.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gs-shell.c b/src/gs-shell.c index ec15c3f13..d8d9254e1 100644 --- a/src/gs-shell.c +++ b/src/gs-shell.c @@ -1000,6 +1000,17 @@ search_bar_search_mode_enabled_changed_cb (GtkSearchBar *search_bar, gs_shell_go_back (shell); } +static void +go_back (GsShell *shell) +{ + if (adw_leaflet_get_adjacent_child (shell->details_leaflet, + ADW_NAVIGATION_DIRECTION_BACK)) { + gtk_widget_activate (shell->button_back2); + } else { + gtk_widget_activate (shell->button_back); + } +} + static gboolean window_key_pressed_cb (GtkEventControllerKey *key_controller, guint keyval, @@ -1012,9 +1023,7 @@ window_key_pressed_cb (GtkEventControllerKey *key_controller, if ((!is_rtl && state == GDK_ALT_MASK && keyval == GDK_KEY_Left) || (is_rtl && state == GDK_ALT_MASK && keyval == GDK_KEY_Right) || keyval == GDK_KEY_Back) { - /* GTK will only actually activate the one which is visible */ - gtk_widget_activate (shell->button_back); - gtk_widget_activate (shell->button_back2); + go_back (shell); return GDK_EVENT_STOP; } @@ -1028,9 +1037,7 @@ window_button_pressed_cb (GtkGestureClick *click_gesture, gdouble y, GsShell *shell) { - /* GTK will only actually activate the one which is visible */ - gtk_widget_activate (shell->button_back); - gtk_widget_activate (shell->button_back2); + go_back (shell); gtk_gesture_set_state (GTK_GESTURE (click_gesture), GTK_EVENT_SEQUENCE_CLAIMED); } -- GitLab From 706337205d171bd575ba29de0cbde0037441832d Mon Sep 17 00:00:00 2001 From: Adrien Plazas Date: Wed, 2 Mar 2022 07:14:06 +0100 Subject: [PATCH 2/2] shell: Correctly check the Alt key is held This allows Alt-based keyboard shortcuts to work even when NumLock is enabled. --- src/gs-shell.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gs-shell.c b/src/gs-shell.c index d8d9254e1..214a201c3 100644 --- a/src/gs-shell.c +++ b/src/gs-shell.c @@ -1019,9 +1019,10 @@ window_key_pressed_cb (GtkEventControllerKey *key_controller, GsShell *shell) { gboolean is_rtl = gtk_widget_get_direction (shell->button_back) == GTK_TEXT_DIR_RTL; + gboolean is_alt = (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_ALT_MASK)) == GDK_ALT_MASK; - if ((!is_rtl && state == GDK_ALT_MASK && keyval == GDK_KEY_Left) || - (is_rtl && state == GDK_ALT_MASK && keyval == GDK_KEY_Right) || + if ((!is_rtl && is_alt && keyval == GDK_KEY_Left) || + (is_rtl && is_alt && keyval == GDK_KEY_Right) || keyval == GDK_KEY_Back) { go_back (shell); return GDK_EVENT_STOP; -- GitLab