From 2e84ecccb7c2d749f1bd3b0519dee2b3a7131717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= Date: Wed, 11 Nov 2026 03:02:59 +0100 Subject: [PATCH] Fix keyboard navigation and focus handling in GridView Move key event controllers from the GridView to individual AppButtons to ensure keyboard navigation works correctly without interfering with widget focus handling. Restore focus to the appropriate application after carousel page changes so that keyboard navigation remains consistent when moving between pages. Reset the focused row and column when focus leaves the grid, ensuring that the first application is selected when the launcher is opened again. --- src/Views/GridView.vala | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Views/GridView.vala b/src/Views/GridView.vala index 3c43a57a..119f26d4 100644 --- a/src/Views/GridView.vala +++ b/src/Views/GridView.vala @@ -64,12 +64,19 @@ public class Slingshot.Widgets.Grid : Gtk.Box { var focus_controller = new Gtk.EventControllerFocus (); focus_controller.enter.connect (refocus); + focus_controller.leave.connect (() => { + _focused_column = 1; + _focused_row = 1; + }); + add_controller (focus_controller); - var key_controller = new Gtk.EventControllerKey (); - key_controller.key_pressed.connect (on_key_press); + paginator.page_changed.connect (() => { + if (paginator.get_position () == 0 && _focused_column == 1) { + return; + } - add_controller (focus_controller); - add_controller (key_controller); + refocus (); + }); } public void populate (Backend.AppSystem app_system) { @@ -111,6 +118,9 @@ public class Slingshot.Widgets.Grid : Gtk.Box { unowned var app = apps.nth_data (app_idx); var app_button = new Widgets.AppButton (app); + var key_controller = new Gtk.EventControllerKey (); + key_controller.key_pressed.connect (on_key_press); + app_button.add_controller (key_controller); app_button.app_launched.connect (() => ((Gtk.Popover) get_ancestor (typeof (Gtk.Popover))).popdown ()); widget_to_attach = app_button; @@ -242,6 +252,5 @@ public class Slingshot.Widgets.Grid : Gtk.Box { } paginator.scroll_to (grid, true); - refocus (); } }