diff --git a/kitty/data-types.h b/kitty/data-types.h index 6f1c9ecbf..278053a59 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -138,7 +138,7 @@ typedef enum MouseShapes { /* end mouse shapes */ } MouseShape; typedef enum { NONE, MENUBAR, WINDOW, ALL } WindowTitleIn; -typedef enum { SCROLLBAR_NEVER, SCROLLBAR_ON_SCROLLED, SCROLLBAR_ON_HOVERED, SCROLLBAR_ON_SCROLL_AND_HOVER, SCROLLBAR_ALWAYS } ScrollbarVisibilityPolicy; +typedef enum { SCROLLBAR_NEVER, SCROLLBAR_ON_SCROLLED, SCROLLBAR_ON_HOVERED, SCROLLBAR_ON_SCROLL_AND_HOVER, SCROLLBAR_ON_SCROLL_OR_HOVER, SCROLLBAR_ALWAYS } ScrollbarVisibilityPolicy; typedef enum { PROGRESS_BAR_HIDDEN, PROGRESS_BAR_LEFT, PROGRESS_BAR_RIGHT, PROGRESS_BAR_TOP, PROGRESS_BAR_BOTTOM } ProgressBarPosition; typedef enum { PROGRESS_STATE_UNSET, PROGRESS_STATE_SET, PROGRESS_STATE_ERROR, PROGRESS_STATE_INDETERMINATE, PROGRESS_STATE_PAUSED } ProgressBarState; typedef enum { TILING, SCALED, MIRRORED, CLAMPED, CENTER_CLAMPED, CENTER_SCALED } BackgroundImageLayout; diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 31b47c54e..9c2531139 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -531,7 +531,7 @@ opt( 'scrollbar', 'scrolled', ctype='scrollbar', - choices=('scrolled', 'always', 'never', 'hovered', 'scrolled-and-hovered'), + choices=('scrolled', 'always', 'never', 'hovered', 'scrolled-and-hovered', 'scrolled-or-hovered'), long_text="""\ Control when the scrollbar is displayed. @@ -541,6 +541,8 @@ Control when the scrollbar is displayed. means when the mouse is hovering on the right edge of the window. :code:`scrolled-and-hovered` means when the mouse is over the scrollbar region *and* scrolling backwards has started. +:code:`scrolled-or-hovered` + means when the mouse is over the scrollbar region *or* scrolling backwards has started. :code:`always` means whenever any scrollback is present :code:`never` diff --git a/kitty/options/parse.py b/kitty/options/parse.py index f40fe848f..fb164cb0b 100644 --- a/kitty/options/parse.py +++ b/kitty/options/parse.py @@ -1278,7 +1278,7 @@ class Parser: raise ValueError(f"The value {val} is not a valid choice for scrollbar") ans["scrollbar"] = val - choices_for_scrollbar = frozenset(('scrolled', 'always', 'never', 'hovered', 'scrolled-and-hovered')) + choices_for_scrollbar = frozenset(('scrolled', 'always', 'never', 'hovered', 'scrolled-and-hovered', 'scrolled-or-hovered')) def scrollbar_gap(self, val: str, ans: dict[str, typing.Any]) -> None: ans['scrollbar_gap'] = positive_float(val) diff --git a/kitty/options/to-c.h b/kitty/options/to-c.h index a02071363..275c82a66 100644 --- a/kitty/options/to-c.h +++ b/kitty/options/to-c.h @@ -79,7 +79,10 @@ scrollbar(PyObject *src) { case 'a': return SCROLLBAR_ALWAYS; case 'n': return SCROLLBAR_NEVER; case 'h': return SCROLLBAR_ON_HOVERED; - case 's': return strcmp(q, "scrolled") == 0 ? SCROLLBAR_ON_SCROLLED : SCROLLBAR_ON_SCROLL_AND_HOVER; + case 's': + if (strcmp(q, "scrolled") == 0) return SCROLLBAR_ON_SCROLLED; + if (strcmp(q, "scrolled-or-hovered") == 0) return SCROLLBAR_ON_SCROLL_OR_HOVER; + return SCROLLBAR_ON_SCROLL_AND_HOVER; } return SCROLLBAR_ON_SCROLLED; } diff --git a/kitty/options/types.py b/kitty/options/types.py index e2e6ff3ad..221e54bd6 100644 --- a/kitty/options/types.py +++ b/kitty/options/types.py @@ -31,7 +31,7 @@ choices_for_palette_generate = typing.Literal['fixed', 'semantic', 'legacy'] choices_for_placement_strategy = typing.Literal['top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right'] choices_for_pointer_shape_when_grabbed = choices_for_default_pointer_shape choices_for_progress_bar = typing.Literal['left', 'right', 'top', 'bottom', 'hidden'] -choices_for_scrollbar = typing.Literal['scrolled', 'always', 'never', 'hovered', 'scrolled-and-hovered'] +choices_for_scrollbar = typing.Literal['scrolled', 'always', 'never', 'hovered', 'scrolled-and-hovered', 'scrolled-or-hovered'] choices_for_strip_trailing_spaces = typing.Literal['always', 'never', 'smart'] choices_for_tab_bar_align = typing.Literal['start', 'center', 'end', 'left', 'right'] choices_for_tab_bar_style = typing.Literal['fade', 'hidden', 'powerline', 'separator', 'slant', 'custom'] diff --git a/kitty/shaders.c b/kitty/shaders.c index 7247d20fc..31ba6cecd 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -1204,6 +1204,7 @@ has_scrollbar(Window *w, Screen *screen) { case SCROLLBAR_ON_SCROLLED: return screen->scrolled_by > 0; case SCROLLBAR_ON_HOVERED: return w->scrollbar.is_hovering; case SCROLLBAR_ON_SCROLL_AND_HOVER: return screen->scrolled_by > 0 && w->scrollbar.is_hovering; + case SCROLLBAR_ON_SCROLL_OR_HOVER: return screen->scrolled_by > 0 || w->scrollbar.is_hovering; } return false; }