diff --git a/docs/changelog.rst b/docs/changelog.rst index b6c981fcb..4bbeb250f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -58,6 +58,8 @@ Detailed list of changes - Graphics: Fix aspect ratio of images not being preserved when only a single dimension of the destination rectangle is specified (:iss:`7380`) +- :ac:`focus_visible_window`: Fix selecting with mouse click leaving keyboard in unusable state (:iss:`7390`) + 0.34.1 [2024-04-19] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/boss.py b/kitty/boss.py index 1a87de8b5..ace891547 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -1425,16 +1425,20 @@ class Boss: def visual_window_select_mouse_handler(self, ev: WindowSystemMouseEvent) -> None: tab = self.active_tab + def trigger(window_id: int = 0) -> None: + self.visual_window_select_action_trigger(window_id) + self.mappings.pop_keyboard_mode_if_is('__visual_select__') + if ev.button == GLFW_MOUSE_BUTTON_LEFT and ev.action == GLFW_PRESS and ev.window_id: w = self.window_id_map.get(ev.window_id) if w is not None and tab is not None and w in tab: if self.current_visual_select and self.current_visual_select.tab_id == tab.id: - self.visual_window_select_action_trigger(w.id) + trigger(w.id) else: - self.visual_window_select_action_trigger() + trigger() return if ev.button > -1 and tab is not None: - self.visual_window_select_action_trigger() + trigger() def mouse_event( self, in_tab_bar: bool, window_id: int, action: int, modifiers: int, button: int, diff --git a/kitty/keys.py b/kitty/keys.py index 191088231..51c908946 100644 --- a/kitty/keys.py +++ b/kitty/keys.py @@ -95,6 +95,11 @@ class Mappings: passthrough = False return passthrough + def pop_keyboard_mode_if_is(self, name: str) -> bool: + if self.keyboard_mode_stack and self.keyboard_mode_stack[-1].name == name: + return self.pop_keyboard_mode() + return False + def _push_keyboard_mode(self, mode: KeyboardMode) -> None: self.keyboard_mode_stack.append(mode) self.set_ignore_os_keyboard_processing(True)