Double clicking on empty tab bar area now opens a new tab

Fixes #3201
This commit is contained in:
Kovid Goyal 2021-01-02 11:45:18 +05:30
parent bc86bc91f7
commit 9ae198ef8f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 14 additions and 5 deletions

View File

@ -17,6 +17,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
run. The system-wide PATH is used first, then system specific default paths,
and finally the PATH inside the shell.
- Double clicking on empty tab bar area now opens a new tab (:iss:`3201`)
0.19.3 [2020-12-19]
-------------------

View File

@ -520,10 +520,10 @@ class Boss:
run_update_check(self.opts.update_check_interval * 60 * 60)
self.update_check_started = True
def activate_tab_at(self, os_window_id: int, x: int) -> int:
def activate_tab_at(self, os_window_id: int, x: int, is_double: bool = False) -> int:
tm = self.os_window_map.get(os_window_id)
if tm is not None:
tm.activate_tab_at(x)
tm.activate_tab_at(x, is_double)
def on_window_resize(self, os_window_id: int, w: int, h: int, dpi_changed: bool) -> None:
if dpi_changed:

View File

@ -516,8 +516,12 @@ HANDLER(handle_event) {
static inline void
handle_tab_bar_mouse(int button, int UNUSED modifiers) {
static monotonic_t last_click_at = 0;
if (button != GLFW_MOUSE_BUTTON_LEFT || !global_state.callback_os_window->mouse_button_pressed[button]) return;
call_boss(activate_tab_at, "Kd", global_state.callback_os_window->id, global_state.callback_os_window->mouse_x);
monotonic_t now = monotonic();
bool is_double = now - last_click_at <= OPT(click_interval);
last_click_at = is_double ? 0 : now;
call_boss(activate_tab_at, "KdO", global_state.callback_os_window->id, global_state.callback_os_window->mouse_x, is_double ? Py_True : Py_False);
}
static inline bool

View File

@ -753,9 +753,12 @@ class TabManager: # {{{
))
return ans
def activate_tab_at(self, x: int) -> None:
def activate_tab_at(self, x: int, is_double: bool = False) -> None:
i = self.tab_bar.tab_at(x)
if i is not None:
if i is None:
if is_double:
self.new_tab()
else:
self.set_active_tab_idx(i)
@property