Unify the two drag threshold settings

This commit is contained in:
Kovid Goyal
2026-04-02 13:49:15 +05:30
parent d1d7a442b6
commit 07f4d3c7ae
5 changed files with 23 additions and 41 deletions

View File

@@ -884,6 +884,19 @@ sets the shape when dragging in rectangular selection mode.
'''
)
opt('drag_threshold', '5', option_type='positive_int', long_text='''
The threshold distance the mouse must move to start a drag and drop. Dragging
works for tabs and windows. You can drag tabs to re-order them, detach
them into new OS Windows or move them to another OS Window. Similarly,
by dragging the titlebar of a window (see :ac:`toggle_window_title_bars`)
you can re-order it in its layout, detach it or move it to another tab.
A value of zero disables all dragging.
Note that on Wayland, :link:`because of poor design
<https://gitlab.freedesktop.org/wayland/wayland/-/issues/140>` cancelling
a drag will detach the tab. This is worked around for compositors that support
:link:`xdg-toplevel-drag <https://wayland.app/protocols/xdg-toplevel-drag-v1>`.
''')
# mouse.mousemap {{{
agr('mouse.mousemap', 'Mouse actions', '''
@@ -1580,15 +1593,6 @@ opt('window_title_bar_align', 'center',
long_text='Horizontal alignment of the text in window title bars.'
)
opt('window_title_bar_drag_threshold', '5',
option_type='positive_int',
long_text='''
Pixel distance the mouse must move before a window title bar drag begins.
Zero disables dragging. Drop on a title bar swaps positions; drop on a
window body inserts in the quadrant direction (left/right/top/bottom).
Drop on the tab bar moves the window to that tab; drop outside kitty
detaches it to a new OS window.
''')
egr() # }}}
@@ -1848,23 +1852,6 @@ the window is translucent, in which case the default background is used as it
looks better.
''')
opt(
'tab_bar_drag_threshold',
'5',
option_type='positive_int',
long_text="""
Control when dragging of tabs to re-order them happens.
The value is the drag threshold in pixels, the distance the mouse must move
before a drag begins. A value of zero disables tab dragging entirely.
Dragging a tab to another kitty window moves it there, while dragging
outside any kitty window detaches it into a new OS window.
Note that on Wayland, :link:`because of poor design
<https://gitlab.freedesktop.org/wayland/wayland/-/issues/140>` cancelling
a drag will detach the tab. This is worked around for compositors that support
:link:`xdg-toplevel-drag <https://wayland.app/protocols/xdg-toplevel-drag-v1>`.
""",
)
egr() # }}}

View File

@@ -971,6 +971,9 @@ class Parser:
def disable_ligatures(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['disable_ligatures'] = disable_ligatures(val)
def drag_threshold(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['drag_threshold'] = positive_int(val)
def draw_minimal_borders(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['draw_minimal_borders'] = to_bool(val)
@@ -1346,9 +1349,6 @@ class Parser:
def tab_bar_background(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['tab_bar_background'] = to_color_or_none(val)
def tab_bar_drag_threshold(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['tab_bar_drag_threshold'] = positive_int(val)
def tab_bar_edge(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['tab_bar_edge'] = tab_bar_edge(val)
@@ -1548,9 +1548,6 @@ class Parser:
choices_for_window_title_bar_align = choices_for_tab_bar_align
def window_title_bar_drag_threshold(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['window_title_bar_drag_threshold'] = positive_int(val)
def window_title_bar_inactive_background(self, val: str, ans: dict[str, typing.Any]) -> None:
ans['window_title_bar_inactive_background'] = to_color_or_none(val)

View File

@@ -350,6 +350,7 @@ option_names = (
'detect_urls',
'dim_opacity',
'disable_ligatures',
'drag_threshold',
'draw_minimal_borders',
'draw_window_borders_for_single_window',
'dynamic_background_opacity',
@@ -457,7 +458,6 @@ option_names = (
'tab_activity_symbol',
'tab_bar_align',
'tab_bar_background',
'tab_bar_drag_threshold',
'tab_bar_edge',
'tab_bar_filter',
'tab_bar_margin_color',
@@ -509,7 +509,6 @@ option_names = (
'window_title_bar_active_background',
'window_title_bar_active_foreground',
'window_title_bar_align',
'window_title_bar_drag_threshold',
'window_title_bar_inactive_background',
'window_title_bar_inactive_foreground',
'window_title_bar_min_windows',
@@ -568,6 +567,7 @@ class Options:
detect_urls: bool = True
dim_opacity: float = 0.4
disable_ligatures: int = 0
drag_threshold: int = 5
draw_minimal_borders: bool = True
draw_window_borders_for_single_window: bool = False
dynamic_background_opacity: bool = False
@@ -663,7 +663,6 @@ class Options:
tab_activity_symbol: str = ''
tab_bar_align: choices_for_tab_bar_align = 'left'
tab_bar_background: kitty.fast_data_types.Color | None = None
tab_bar_drag_threshold: int = 5
tab_bar_edge: int = 8
tab_bar_filter: str = ''
tab_bar_margin_color: kitty.fast_data_types.Color | None = None
@@ -714,7 +713,6 @@ class Options:
window_title_bar_active_background: kitty.fast_data_types.Color | None = None
window_title_bar_active_foreground: kitty.fast_data_types.Color | None = None
window_title_bar_align: choices_for_window_title_bar_align = 'center'
window_title_bar_drag_threshold: int = 5
window_title_bar_inactive_background: kitty.fast_data_types.Color | None = None
window_title_bar_inactive_foreground: kitty.fast_data_types.Color | None = None
window_title_bar_min_windows: int = 0