diff --git a/docs/changelog.rst b/docs/changelog.rst index 84f23cd6e..7f5f9e4ca 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -231,6 +231,9 @@ Detailed list of changes - Fix copy/paste dropping spaces at soft-wrap boundaries when :opt:`strip_trailing_spaces` is set (:iss:`9834`) +- Allow setting negative values for :opt:`inactive_text_alpha` to control + whether to only fade inactive windows or unfocused windows (:pull:`9837`) + 0.46.2 [2026-03-21] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/options/definition.py b/kitty/options/definition.py index b9725dc06..e2e46e988 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -1400,12 +1400,14 @@ opt('inactive_text_alpha', '1.0', option_type='signed_unit_float', ctype='float', long_text=''' Fade the text in inactive windows by the specified amount. This must be a -number between negative one and one. The absolute value controls the actual -opacity, with zero being fully faded and one being fully opaque. Negative -values cause fading to be applied based only on whether the current window is -active, ignoring the extra single-window unfocused case. -''' - ) +number between -1 and 1. The absolute value controls the actual +opacity, with zero being fully faded and one being fully opaque. When a positive number is +used the text is faded even if only a single window is visible when the OS window +is not focused. Negative numbers means that text is only faded when more than one kitty window +is visible in an OS Window. Fading happens in all but the active window, even if the OS Window +is not focused. Thus this is useful if you want to rely on the window manager to indicate OS Window focus +and this feature to indicate which kitty window is active insidethe OS Window. +''') opt('hide_window_decorations', 'no', option_type='hide_window_decorations', ctype='uint', diff --git a/kitty/options/to-c-generated.h b/kitty/options/to-c-generated.h index fdbe17478..bee66f6ae 100644 --- a/kitty/options/to-c-generated.h +++ b/kitty/options/to-c-generated.h @@ -733,6 +733,19 @@ convert_from_opts_pointer_shape_when_dragging(PyObject *py_opts, Options *opts) Py_DECREF(ret); } +static void +convert_from_python_drag_threshold(PyObject *val, Options *opts) { + opts->drag_threshold = PyLong_AsLong(val); +} + +static void +convert_from_opts_drag_threshold(PyObject *py_opts, Options *opts) { + PyObject *ret = PyObject_GetAttrString(py_opts, "drag_threshold"); + if (ret == NULL) return; + convert_from_python_drag_threshold(ret, opts); + Py_DECREF(ret); +} + static void convert_from_python_repaint_delay(PyObject *val, Options *opts) { opts->repaint_delay = parse_ms_long_to_monotonic_t(val); @@ -1575,6 +1588,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) { if (PyErr_Occurred()) return false; convert_from_opts_pointer_shape_when_dragging(py_opts, opts); if (PyErr_Occurred()) return false; + convert_from_opts_drag_threshold(py_opts, opts); + if (PyErr_Occurred()) return false; convert_from_opts_repaint_delay(py_opts, opts); if (PyErr_Occurred()) return false; convert_from_opts_input_delay(py_opts, opts); diff --git a/kitty/shaders.c b/kitty/shaders.c index 93aa5d025..c541f84c8 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -1403,17 +1403,13 @@ draw_cells(const WindowRenderData *srd, OSWindow *os_window, bool is_active_wind Screen *screen = srd->screen; CELL_BUFFERS; bind_vertex_array(srd->vao_idx); - // We draw with inactive text alpha if: - // - We're not drawing the tab bar - // - There are multiple windows and the current window is not active // When inactive_text_alpha is negative, its absolute value is used as the // opacity and fading is based only on whether the current window is active. - float configured_inactive_text_alpha = (float)OPT(inactive_text_alpha); - bool use_active_window_only = configured_inactive_text_alpha < 0.f; - if (configured_inactive_text_alpha < 0.f) configured_inactive_text_alpha = -configured_inactive_text_alpha; + const float inactive_text_alpha = fabsf(OPT(inactive_text_alpha)); + const bool use_active_window_only = OPT(inactive_text_alpha) < 0.f; float current_inactive_text_alpha = use_active_window_only ? - (is_tab_bar || is_active_window ? 1.0f : configured_inactive_text_alpha) : - (is_tab_bar || (!is_single_window && is_active_window) || (is_single_window && screen->cursor_render_info.is_focused) ? 1.0f : configured_inactive_text_alpha); + (is_tab_bar || is_active_window ? 1.0f : inactive_text_alpha) : + (is_tab_bar || (!is_single_window && is_active_window) || (is_single_window && screen->cursor_render_info.is_focused) ? 1.0f : inactive_text_alpha); float bg_alpha = effective_os_window_alpha(os_window); color_type default_bg = cell_update_uniform_block(