From c460737bed878345a87822cac413b82ebfc92dc6 Mon Sep 17 00:00:00 2001 From: Boris Yumankulov Date: Fri, 6 Jun 2025 13:09:52 +0500 Subject: [PATCH] fix(input_manager): Prioritize tab switching over game card navigation on left arrow key press Signed-off-by: Boris Yumankulov --- portprotonqt/input_manager.py | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/portprotonqt/input_manager.py b/portprotonqt/input_manager.py index 577bb2d..a3aa38b 100644 --- a/portprotonqt/input_manager.py +++ b/portprotonqt/input_manager.py @@ -390,6 +390,20 @@ class InputManager(QObject): focused._show_context_menu(pos) return True + # Tab switching with Left/Right keys (non-GameCard focus or no focus) + idx = self._parent.stackedWidget.currentIndex() + total = len(self._parent.tabButtons) + if key == Qt.Key.Key_Left and (not isinstance(focused, GameCard) or focused is None): + new = (idx - 1) % total + self._parent.switchTab(new) + self._parent.tabButtons[new].setFocus() + return True + if key == Qt.Key.Key_Right and (not isinstance(focused, GameCard) or focused is None): + new = (idx + 1) % total + self._parent.switchTab(new) + self._parent.tabButtons[new].setFocus() + return True + # Library tab navigation if self._parent.stackedWidget.currentIndex() == 0: game_cards = self._parent.gamesListWidget.findChildren(GameCard) @@ -497,20 +511,6 @@ class InputManager(QObject): self._parent.tabButtons[0].setFocus() return True - # Tab switching with Left/Right keys (non-GameCard focus) - idx = self._parent.stackedWidget.currentIndex() - total = len(self._parent.tabButtons) - if key == Qt.Key.Key_Left and not isinstance(focused, GameCard): - new = (idx - 1) % total - self._parent.switchTab(new) - self._parent.tabButtons[new].setFocus() - return True - if key == Qt.Key.Key_Right and not isinstance(focused, GameCard): - new = (idx + 1) % total - self._parent.switchTab(new) - self._parent.tabButtons[new].setFocus() - return True - # Navigate down into tab content if key == Qt.Key.Key_Down: if isinstance(focused, NavLabel): @@ -520,11 +520,6 @@ class InputManager(QObject): if focusables: focusables[0].setFocus() return True - else: - if focused is not None: - focused.focusNextChild() - return True - # Navigate up through tab content if key == Qt.Key.Key_Up: if isinstance(focused, NavLabel): @@ -557,7 +552,6 @@ class InputManager(QObject): return super().eventFilter(obj, event) - def init_gamepad(self) -> None: self.check_gamepad() threading.Thread(target=self.run_udev_monitor, daemon=True).start()