mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 18:22:09 +02:00
Cleanup previous PR
Press on titlebar should focus window
This commit is contained in:
@@ -1753,20 +1753,24 @@ class TabManager: # {{{
|
|||||||
|
|
||||||
def handle_window_title_bar_mouse(self, window_id: int, button: int, modifiers: int, action: int) -> None:
|
def handle_window_title_bar_mouse(self, window_id: int, button: int, modifiers: int, action: int) -> None:
|
||||||
now = monotonic()
|
now = monotonic()
|
||||||
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE and len(self.recent_title_bar_mouse_events) > 2:
|
boss = get_boss()
|
||||||
ci = get_click_interval()
|
if button == GLFW_MOUSE_BUTTON_LEFT:
|
||||||
prev, prev2 = self.recent_title_bar_mouse_events[-1], self.recent_title_bar_mouse_events[-2]
|
if action == GLFW_PRESS:
|
||||||
if (
|
if (w := boss.window_id_map.get(window_id)) is not None:
|
||||||
prev.button == button and prev2.button == button and
|
get_boss().set_active_window(w, switch_os_window_if_needed=True)
|
||||||
prev.action == GLFW_PRESS and prev2.action == GLFW_RELEASE and
|
elif action == GLFW_RELEASE and len(self.recent_title_bar_mouse_events) > 2:
|
||||||
prev.tab_id == window_id and prev2.tab_id == window_id and
|
ci = get_click_interval()
|
||||||
now - prev.at <= ci and now - prev2.at <= 2 * ci
|
prev, prev2 = self.recent_title_bar_mouse_events[-1], self.recent_title_bar_mouse_events[-2]
|
||||||
): # double click on window title bar
|
if (
|
||||||
w = get_boss().window_id_map.get(window_id)
|
prev.button == button and prev2.button == button and
|
||||||
if w is not None:
|
prev.action == GLFW_PRESS and prev2.action == GLFW_RELEASE and
|
||||||
w.set_window_title()
|
prev.tab_id == window_id and prev2.tab_id == window_id and
|
||||||
self.recent_title_bar_mouse_events.clear()
|
now - prev.at <= ci and now - prev2.at <= 2 * ci
|
||||||
return
|
): # double click on window title bar
|
||||||
|
if (w := boss.window_id_map.get(window_id)) is not None:
|
||||||
|
w.set_window_title()
|
||||||
|
self.recent_title_bar_mouse_events.clear()
|
||||||
|
return
|
||||||
self.recent_title_bar_mouse_events.append(TabMouseEvent(button, modifiers, action, now, window_id))
|
self.recent_title_bar_mouse_events.append(TabMouseEvent(button, modifiers, action, now, window_id))
|
||||||
if len(self.recent_title_bar_mouse_events) > 5:
|
if len(self.recent_title_bar_mouse_events) > 5:
|
||||||
self.recent_title_bar_mouse_events.popleft()
|
self.recent_title_bar_mouse_events.popleft()
|
||||||
|
|||||||
@@ -1209,7 +1209,7 @@ class Window:
|
|||||||
prefilled = ''
|
prefilled = ''
|
||||||
get_boss().get_line(
|
get_boss().get_line(
|
||||||
_('Enter the new title for this window below. An empty title will cause the default title to be used.'),
|
_('Enter the new title for this window below. An empty title will cause the default title to be used.'),
|
||||||
self.set_title, window=self, initial_value=prefilled)
|
self.set_title, window=self, initial_value=prefilled, window_title=_('Rename window'))
|
||||||
|
|
||||||
def set_user_var(self, key: str, val: str | bytes | None) -> None:
|
def set_user_var(self, key: str, val: str | bytes | None) -> None:
|
||||||
key = sanitize_control_codes(key).replace('\n', ' ')
|
key = sanitize_control_codes(key).replace('\n', ' ')
|
||||||
|
|||||||
Reference in New Issue
Block a user