diff --git a/kitty/options/definition.py b/kitty/options/definition.py index e99a6b00e..31b47c54e 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -1795,7 +1795,8 @@ used the text is faded even if only a single window is visible when the OS windo 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. +and this feature to indicate which kitty window is active inside the OS Window. For alternate dimming/highlighting +strategies, you can use :opt:`custom_shaders` for example: :code:`custom_shaders dim-inactive-windows`. """, ) diff --git a/kitty/shaders/custom/demo.py b/kitty/shaders/custom/demo.py index 11399c4ea..dda1105f2 100755 --- a/kitty/shaders/custom/demo.py +++ b/kitty/shaders/custom/demo.py @@ -149,10 +149,10 @@ metadata: dict[str, dict[str, Any]] = { 'cursor-trail-blaze': {'animate': cursor_trail, 'category': 'cursor-trail', 'tagline': 'Set your cursor on fire as it moves around.'}, 'cursor-trail-lightning': {'animate': cursor_trail, 'category': 'cursor-trail', 'tagline': 'Make your cursor shoot lightning as it moves around.'}, # Navigation - 'focus-highlight': { + 'dim-inactive-windows': { 'animate': window_focus, 'category': 'navigation', - 'tagline': 'Highlight the active window on focus change.', + 'tagline': 'Make the active window standout more.', 'session': 'launch kitten run-shell ls -l\nlaunch kitten run-shell bat -P setup.py\nlaunch kitten run-shell echo Hello World', }, 'tab-change': { @@ -161,6 +161,12 @@ metadata: dict[str, dict[str, Any]] = { 'tagline': 'Highlight the active window on focus change.', 'session': 'new_tab My Shell\nlaunch kitten run-shell ls\nnew_tab My Code\nlaunch nvim -R {self}', }, + 'focus-highlight': { + 'animate': window_focus, + 'category': 'navigation', + 'tagline': 'Briefly highlight the active window on focus change.', + 'session': 'launch kitten run-shell ls -l\nlaunch kitten run-shell bat -P setup.py\nlaunch kitten run-shell echo Hello World', + }, # Retro terminals 'crt': {'category': 'retro', 'title': 'Cathode Ray Tube', 'tagline': 'Your terminal deserves to have curves.', 'duration': 2}, 'crt-blue': {'category': 'retro', 'title': 'CRT Blue', 'tagline': 'Do you have the blues?', 'duration': 2}, diff --git a/kitty/shaders/custom/dim-inactive-windows.pipeline b/kitty/shaders/custom/dim-inactive-windows.pipeline new file mode 100644 index 000000000..5e2f448bf --- /dev/null +++ b/kitty/shaders/custom/dim-inactive-windows.pipeline @@ -0,0 +1,5 @@ +startgroup + var float HIGHLIGHT_INTENSITY = 0 + var float BORDER_WIDTH = 0 + shaders focus-highlight +endgroup diff --git a/kitty/shaders/custom/focus-highlight.slang b/kitty/shaders/custom/focus-highlight.slang index 73be828f1..651b9ec57 100644 --- a/kitty/shaders/custom/focus-highlight.slang +++ b/kitty/shaders/custom/focus-highlight.slang @@ -35,6 +35,7 @@ fragment_main(float4 color, KittyTextures t, KittyCustomShaderData d) { bool inWindow = all(uv >= winMin) && all(uv <= winMax); if (inWindow) { + if (HIGHLIGHT_INTENSITY == 0 && BORDER_WIDTH == 0) return color; // Minimum distance from this pixel to any edge of the active window. float2 edgeDists = min(uv - winMin, winMax - uv); float nearestEdge = min(edgeDists.x, edgeDists.y); @@ -44,9 +45,8 @@ fragment_main(float4 color, KittyTextures t, KittyCustomShaderData d) { float boost = (HIGHLIGHT_INTENSITY + borderGlow) * strength; return float4(color.rgb * (1.0 + boost), color.a); - } else { - // Slightly dim inactive areas to draw the eye to the focused window. - float dim = lerp(1.0, INACTIVE_DIM, strength); - return float4(color.rgb * dim, color.a); } + // Slightly dim inactive areas to draw the eye to the focused window. + float dim = lerp(1.0, INACTIVE_DIM, strength); + return float4(color.rgb * dim, color.a); }