From 08d74a6c5651967a31b24cbc11aa71bc5747401a Mon Sep 17 00:00:00 2001 From: pagedown Date: Mon, 21 Nov 2022 12:21:06 +0800 Subject: [PATCH 1/2] Add an option to control background image tinting for window gaps --- docs/changelog.rst | 3 +++ kitty/options/definition.py | 10 +++++++++- kitty/options/parse.py | 3 +++ kitty/options/to-c-generated.h | 15 +++++++++++++++ kitty/options/types.py | 2 ++ kitty/shaders.c | 2 +- kitty/state.h | 2 +- 7 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 9895beedd..54018af3e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -49,6 +49,9 @@ Detailed list of changes - Implement :ref:`edit-in-kitty ` using the new ``kitty-tool`` static executable (:iss:`5546`, :iss:`5630`) +- Add an option :opt:`background_tint_gaps` to control background image tinting for window gaps (:iss:`5596`) + + 0.26.5 [2022-11-07] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/options/definition.py b/kitty/options/definition.py index d2bf84f4e..2dfcff8a2 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -1313,13 +1313,21 @@ this option by reloading the config is not supported. opt('background_tint', '0.0', option_type='unit_float', ctype='float', long_text=''' -How much to tint the background image by the background color. This option +How much to tint the background image by the background color. This option makes it easier to read the text. Tinting is done using the current background color for each window. This option applies only if :opt:`background_opacity` is set and transparent windows are supported or :opt:`background_image` is set. ''' ) +opt('background_tint_gaps', '1.0', + option_type='unit_float', ctype='float', + long_text=''' +How much to tint the background image at the window gaps by the background +color, after applying :opt:`background_tint`. +''' + ) + opt('dim_opacity', '0.75', option_type='unit_float', ctype='float', long_text=''' diff --git a/kitty/options/parse.py b/kitty/options/parse.py index 4dfcf507e..1ac736bbe 100644 --- a/kitty/options/parse.py +++ b/kitty/options/parse.py @@ -84,6 +84,9 @@ class Parser: def background_tint(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: ans['background_tint'] = unit_float(val) + def background_tint_gaps(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: + ans['background_tint_gaps'] = unit_float(val) + def bell_border_color(self, val: str, ans: typing.Dict[str, typing.Any]) -> None: ans['bell_border_color'] = to_color(val) diff --git a/kitty/options/to-c-generated.h b/kitty/options/to-c-generated.h index 60a6d1d45..b2e61caae 100644 --- a/kitty/options/to-c-generated.h +++ b/kitty/options/to-c-generated.h @@ -772,6 +772,19 @@ convert_from_opts_background_tint(PyObject *py_opts, Options *opts) { Py_DECREF(ret); } +static void +convert_from_python_background_tint_gaps(PyObject *val, Options *opts) { + opts->background_tint_gaps = PyFloat_AsFloat(val); +} + +static void +convert_from_opts_background_tint_gaps(PyObject *py_opts, Options *opts) { + PyObject *ret = PyObject_GetAttrString(py_opts, "background_tint_gaps"); + if (ret == NULL) return; + convert_from_python_background_tint_gaps(ret, opts); + Py_DECREF(ret); +} + static void convert_from_python_dim_opacity(PyObject *val, Options *opts) { opts->dim_opacity = PyFloat_AsFloat(val); @@ -1126,6 +1139,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) { if (PyErr_Occurred()) return false; convert_from_opts_background_tint(py_opts, opts); if (PyErr_Occurred()) return false; + convert_from_opts_background_tint_gaps(py_opts, opts); + if (PyErr_Occurred()) return false; convert_from_opts_dim_opacity(py_opts, opts); if (PyErr_Occurred()) return false; convert_from_opts_mark1_foreground(py_opts, opts); diff --git a/kitty/options/types.py b/kitty/options/types.py index f01b4c332..4c97e4437 100644 --- a/kitty/options/types.py +++ b/kitty/options/types.py @@ -63,6 +63,7 @@ option_names = ( # {{{ 'background_image_linear', 'background_opacity', 'background_tint', + 'background_tint_gaps', 'bell_border_color', 'bell_on_tab', 'bell_path', @@ -476,6 +477,7 @@ class Options: background_image_linear: bool = False background_opacity: float = 1.0 background_tint: float = 0 + background_tint_gaps: float = 1.0 bell_border_color: Color = Color(255, 90, 0) bell_on_tab: str = '🔔 ' bell_path: typing.Optional[str] = None diff --git a/kitty/shaders.c b/kitty/shaders.c index 17c41866e..90a7f9b53 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -980,7 +980,7 @@ draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_bu draw_bg(w); BLEND_ONTO_OPAQUE; background_opacity = 1.0f; - tint_opacity = OPT(background_tint); + tint_opacity = OPT(background_tint) * OPT(background_tint_gaps); tint_premult = w->is_semi_transparent ? OPT(background_tint) : 1.0f; } diff --git a/kitty/state.h b/kitty/state.h index 895225338..06939acf2 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -52,7 +52,7 @@ typedef struct { BackgroundImageLayout background_image_layout; ImageAnchorPosition window_logo_position; bool background_image_linear; - float background_tint, window_logo_alpha; + float background_tint, background_tint_gaps, window_logo_alpha; bool dynamic_background_opacity; float inactive_text_alpha; From 73b585791683fbd9d1e0bbbeb08cd87479c35388 Mon Sep 17 00:00:00 2001 From: pagedown Date: Mon, 21 Nov 2022 12:21:13 +0800 Subject: [PATCH 2/2] Keep two blank lines between each version in the changelog --- docs/changelog.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 54018af3e..8b936ef37 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -73,6 +73,7 @@ Detailed list of changes - Remote control: When matching window by `state:focused` and no window currently has keyboard focus, match the window belonging to the OS window that was last focused (:iss:`5602`) + 0.26.4 [2022-10-17] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -145,6 +146,7 @@ Detailed list of changes code execution if the user clicked on a notification popup from a malicious source. Thanks to Carter Sande for discovering this vulnerability. + 0.26.1 [2022-08-30] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -154,6 +156,7 @@ Detailed list of changes - Allow specifying a title when using the :ac:`set_tab_title` action (:iss:`5441`) + 0.26.0 [2022-08-29] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1640,6 +1643,7 @@ Detailed list of changes - Fix :option:`--title` not being applied at window creation time (:iss:`2570`) + 0.17.2 [2020-03-29] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1824,6 +1828,7 @@ Detailed list of changes - When windows are semi-transparent and all contain graphics, correctly render them. (:iss:`2310`) + 0.15.1 [2019-12-21] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1932,6 +1937,7 @@ Detailed list of changes - Use selection foreground color for underlines as well (:iss:`1982`) + 0.14.4 [2019-08-31] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2238,6 +2244,7 @@ Detailed list of changes - Mouse selection: When extending by word, fix extending selection to non-word characters not working well (:iss:`1616`) + 0.13.3 [2019-01-19] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2331,6 +2338,7 @@ Detailed list of changes - Fix resizing window smaller and then restoring causing some wrapped lines to not be properly unwrapped (:iss:`1206`) + 0.13.0 [2018-12-05] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2428,6 +2436,7 @@ Detailed list of changes - Fix hover detection of URLs not working when hovering over the first colon and slash characters in short URLs (:iss:`1201`) + 0.12.3 [2018-09-29] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2504,6 +2513,7 @@ Detailed list of changes - Fix using :opt:`focus_follows_mouse` causing text selection with the mouse to malfunction when using multiple kitty windows (:iss:`1002`) + 0.12.1 [2018-09-08] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2547,6 +2557,7 @@ Detailed list of changes - macOS: Diff kitten: Fix syntax highlighting not working because of a bug in the 0.12.0 macOS package + 0.12.0 [2018-09-01] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3057,6 +3068,7 @@ Detailed list of changes - Fix a crash when getting the contents of the scrollback buffer as text + 0.8.1 [2018-03-09] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -3134,6 +3146,7 @@ Detailed list of changes - Browsing the scrollback buffer now happens in an overlay window instead of a new window/tab. + 0.7.1 [2018-01-31] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~