Cleanup previous PR
Press on titlebar should focus window
This commit is contained in:
parent
5e5243a52a
commit
917616d09b
2 changed files with 19 additions and 15 deletions
|
|
@ -1753,20 +1753,24 @@ def handle_tab_bar_mouse(self, x: float, y: float, button: int, modifiers: int,
|
|||
|
||||
def handle_window_title_bar_mouse(self, window_id: int, button: int, modifiers: int, action: int) -> None:
|
||||
now = monotonic()
|
||||
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE and len(self.recent_title_bar_mouse_events) > 2:
|
||||
ci = get_click_interval()
|
||||
prev, prev2 = self.recent_title_bar_mouse_events[-1], self.recent_title_bar_mouse_events[-2]
|
||||
if (
|
||||
prev.button == button and prev2.button == button and
|
||||
prev.action == GLFW_PRESS and prev2.action == GLFW_RELEASE and
|
||||
prev.tab_id == window_id and prev2.tab_id == window_id and
|
||||
now - prev.at <= ci and now - prev2.at <= 2 * ci
|
||||
): # double click on window title bar
|
||||
w = get_boss().window_id_map.get(window_id)
|
||||
if w is not None:
|
||||
w.set_window_title()
|
||||
self.recent_title_bar_mouse_events.clear()
|
||||
return
|
||||
boss = get_boss()
|
||||
if button == GLFW_MOUSE_BUTTON_LEFT:
|
||||
if action == GLFW_PRESS:
|
||||
if (w := boss.window_id_map.get(window_id)) is not None:
|
||||
get_boss().set_active_window(w, switch_os_window_if_needed=True)
|
||||
elif action == GLFW_RELEASE and len(self.recent_title_bar_mouse_events) > 2:
|
||||
ci = get_click_interval()
|
||||
prev, prev2 = self.recent_title_bar_mouse_events[-1], self.recent_title_bar_mouse_events[-2]
|
||||
if (
|
||||
prev.button == button and prev2.button == button and
|
||||
prev.action == GLFW_PRESS and prev2.action == GLFW_RELEASE and
|
||||
prev.tab_id == window_id and prev2.tab_id == window_id and
|
||||
now - prev.at <= ci and now - prev2.at <= 2 * ci
|
||||
): # 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))
|
||||
if len(self.recent_title_bar_mouse_events) > 5:
|
||||
self.recent_title_bar_mouse_events.popleft()
|
||||
|
|
|
|||
|
|
@ -1209,7 +1209,7 @@ def set_window_title(self, title: str | None = None) -> None:
|
|||
prefilled = ''
|
||||
get_boss().get_line(
|
||||
_('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:
|
||||
key = sanitize_control_codes(key).replace('\n', ' ')
|
||||
|
|
|
|||
Loading…
Reference in a new issue