From f90c26f1d075e1d07e628da33ec7c3554adf4a78 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 6 Sep 2026 06:51:31 +0530 Subject: [PATCH] Fix regression in master that broke text_fg_override_threshold --- kitty/options/definition.py | 1 + kitty/options/to-c-generated.h | 15 +++++++++++++ kitty/shaders/hsluv.slang | 40 +++++++++++++++------------------- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 73329bfae..a9f4ddf31 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -313,6 +313,7 @@ opt( 'text_fg_override_threshold', '0', option_type='text_fg_override_threshold', + ctype='text_fg_override_threshold', long_text=""" A setting to prevent low contrast between foreground and background colors. Useful when working with applications that use colors that do not contrast diff --git a/kitty/options/to-c-generated.h b/kitty/options/to-c-generated.h index e0a75bfa8..21a0ffea7 100644 --- a/kitty/options/to-c-generated.h +++ b/kitty/options/to-c-generated.h @@ -121,6 +121,19 @@ convert_from_opts_text_composition_strategy(PyObject *py_opts, Options *opts) { Py_DECREF(ret); } +static void +convert_from_python_text_fg_override_threshold(PyObject *val, Options *opts) { + opts->text_fg_override_threshold = text_fg_override_threshold(val); +} + +static void +convert_from_opts_text_fg_override_threshold(PyObject *py_opts, Options *opts) { + PyObject *ret = PyObject_GetAttrString(py_opts, "text_fg_override_threshold"); + if (ret == NULL) return; + convert_from_python_text_fg_override_threshold(ret, opts); + Py_DECREF(ret); +} + static void convert_from_python_cursor_shape(PyObject *val, Options *opts) { opts->cursor_shape = PyLong_AsLong(val); @@ -1571,6 +1584,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) { if (PyErr_Occurred()) return false; convert_from_opts_text_composition_strategy(py_opts, opts); if (PyErr_Occurred()) return false; + convert_from_opts_text_fg_override_threshold(py_opts, opts); + if (PyErr_Occurred()) return false; convert_from_opts_cursor_shape(py_opts, opts); if (PyErr_Occurred()) return false; convert_from_opts_cursor_shape_unfocused(py_opts, opts); diff --git a/kitty/shaders/hsluv.slang b/kitty/shaders/hsluv.slang index 2e3d66d46..ccc049583 100644 --- a/kitty/shaders/hsluv.slang +++ b/kitty/shaders/hsluv.slang @@ -34,16 +34,15 @@ hsluv_lengthOfRayUntilIntersect(float theta, float3 x, float3 y) { float hsluv_maxSafeChromaForL(float L) { - // Transposed from GLSL column-major constructor to Slang row-major layout float3x3 m2 = float3x3( 3.2409699419045214, - -1.5373831775700935, - -0.49861076029300328, -0.96924363628087983, - 1.8759675015077207, - 0.041555057407175613, 0.055630079696993609, + -1.5373831775700935, + 1.8759675015077207, -0.20397695888897657, + -0.49861076029300328, + 0.041555057407175613, 1.0569715142428786); float sub0 = L + 16.0; @@ -73,16 +72,15 @@ float hsluv_maxChromaForLH(float L, float H) { float hrad = radians(H); - // Transposed from GLSL column-major constructor to Slang row-major layout float3x3 m2 = float3x3( 3.2409699419045214, - -1.5373831775700935, - -0.49861076029300328, -0.96924363628087983, - 1.8759675015077207, - 0.041555057407175613, 0.055630079696993609, + -1.5373831775700935, + 1.8759675015077207, -0.20397695888897657, + -0.49861076029300328, + 0.041555057407175613, 1.0569715142428786); float sub1 = pow(L + 16.0, 3.0) / 1560896.0; @@ -126,35 +124,33 @@ hsluv_lToY(float L) { float3 xyzToRgb(float3 tuple) { - // Transposed layout from GLSL column-major matrix construction + // GLSL `mat3(args)` and Slang `float3x3(args)` agree: `v * m` in GLSL is + // `mul(m, v)` in Slang with the arguments in the same order. const float3x3 m = float3x3( 3.2409699419045214, - -0.96924363628087983, - 0.055630079696993609, -1.5373831775700935, - 1.8759675015077207, - -0.20397695888897657, -0.49861076029300328, + -0.96924363628087983, + 1.8759675015077207, 0.041555057407175613, + 0.055630079696993609, + -0.20397695888897657, 1.0569715142428786); - // GLSL `tuple * m` is transformed to Slang/HLSL `mul(m, tuple)` return hsluv_fromLinear(mul(m, tuple)); } float3 rgbToXyz(float3 tuple) { - // Transposed layout from GLSL column-major matrix construction const float3x3 m = float3x3( 0.41239079926595948, - 0.21263900587151036, - 0.019330818715591851, 0.35758433938387796, - 0.71516867876775593, - 0.11919477979462599, 0.18048078840183429, + 0.21263900587151036, + 0.71516867876775593, 0.072192315360733715, + 0.019330818715591851, + 0.11919477979462599, 0.95053215224966058); - // GLSL `tuple * m` is transformed to Slang/HLSL `mul(m, tuple)` return mul(m, hsluv_toLinear(tuple)); }