mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Fix drop on + tab creating a spurious extra tab
This commit is contained in:
@@ -1751,12 +1751,13 @@ class TabManager: # {{{
|
|||||||
return
|
return
|
||||||
|
|
||||||
tab_id_at_x = self.tab_bar.tab_id_at(int(x))
|
tab_id_at_x = self.tab_bar.tab_id_at(int(x))
|
||||||
if tab_id_at_x < 0: # synthetic tab (e.g. "+" new-tab button)
|
|
||||||
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE:
|
|
||||||
self.new_tab()
|
|
||||||
return
|
|
||||||
tab = self.tab_for_id(tab_id_at_x)
|
|
||||||
now = monotonic()
|
now = monotonic()
|
||||||
|
if tab_id_at_x < 0: # synthetic tab (e.g. "+" new-tab button)
|
||||||
|
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE and self.recent_mouse_events:
|
||||||
|
if (prev := self.recent_mouse_events[-1]).button == button and prev.action == GLFW_PRESS and prev.tab_id == tab_id_at_x:
|
||||||
|
self.new_tab()
|
||||||
|
else:
|
||||||
|
tab = self.tab_for_id(tab_id_at_x)
|
||||||
if tab is None:
|
if tab is None:
|
||||||
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE and len(self.recent_mouse_events) > 2:
|
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE and len(self.recent_mouse_events) > 2:
|
||||||
ci = get_click_interval()
|
ci = get_click_interval()
|
||||||
@@ -1798,7 +1799,7 @@ class TabManager: # {{{
|
|||||||
p = self.recent_mouse_events[-1]
|
p = self.recent_mouse_events[-1]
|
||||||
if p.button == button and p.action == GLFW_PRESS and p.tab_id == tab.id:
|
if p.button == button and p.action == GLFW_PRESS and p.tab_id == tab.id:
|
||||||
get_boss().close_tab(tab)
|
get_boss().close_tab(tab)
|
||||||
self.recent_mouse_events.append(TabMouseEvent(button, modifiers, action, now, tab.id if tab else 0))
|
self.recent_mouse_events.append(TabMouseEvent(button, modifiers, action, now, tab_id_at_x))
|
||||||
if len(self.recent_mouse_events) > 5:
|
if len(self.recent_mouse_events) > 5:
|
||||||
self.recent_mouse_events.popleft()
|
self.recent_mouse_events.popleft()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user