Commit graph

37 commits

Author SHA1 Message Date
Kovid Goyal
87d06354dd
Custom shaders: Fix focus driven groups ending in the wrong state after hide/unhide
Shader animation events are accumulated per OS window and only consumed
when the window is next rendered. A focus-out followed by a focus-in with
no rendered frame in between, as happens when the window is hidden and
shown again, or a brief focus steal within one repaint interval, left both
bits pending. The state machine then treated them as simultaneous, so the
focus-out hard stop prevented os-window-focus-in groups from starting and
groups started by focus-out were turned on while focused.

Now a focus change replaces any pending opposite focus change, so only the
final focus state is reported. Genuinely simultaneous events, such as a
click that moves focus away, still give focus-out priority.

Closes #10871
2026-11-15 08:39:25 +05:30
Kovid Goyal
bc9d0b87e3
Custom shaders: Add command and alternate screen events and uniforms
Add the command-start, command-finish, alternate-screen-enter and
alternate-screen-exit events, which fire for changes in the active window,
and the active_window_command_running, active_window_alternate_screen,
active_window_command_state_age and active_window_alternate_screen_age
fields to KittyCustomShaderData, so shaders can show effects while
commands run and hide them in full screen programs.
2026-11-05 08:43:37 +05:30
Kovid Goyal
f9b57ba283
Allow trailing comments in shader pipeline files\n\nFixes #10718
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
2026-10-22 15:50:55 +05:30
Kovid Goyal
bcc6627322
Custom shaders: Add animation_duration, animation_reverse and animation_loops
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
animation_duration sets how long animation_progress takes to rise to one,
after which it stays there, so effects can fade in and stay on. Previously
groups with no stop duration, such as toggled ones, always had a progress
of zero.

animation_reverse makes a group play its animation in reverse when it stops,
for any reason, instead of turning off immediately. With yes it takes as
long as animation_duration, or a number of milliseconds can be given.
Stopping part way through rising reverses from the current progress and
starting again while reversing rises from there.

animation_loops, used with animation_reverse, plays the animation forwards
and in reverse again after the first reverse, without holding at one, for
effects such as blinking a few times.

Also fix attached groups not having the same animation_progress as the group
they are attached to, as documented, and explain why the per-group values
are in KittyTextures rather than KittyCustomShaderData.

Fixes #10693
2026-10-19 07:57:46 +05:30
Kovid Goyal
a2b7721bfb
Fix #10694 2026-10-18 21:03:47 +05:30
Kovid Goyal
7dbfb0e1ce
Custom shaders: Use pointer_map() of groups turned on and off by events
Groups that are active until an event turns them off, such as those
using animation_toggle, now also move pointer events, while they are
active. The pointer map is recomputed only when the set of active such
groups changes, and pointer events are left alone once all of them have
been turned off.
2026-10-15 21:27:18 +05:30
Kovid Goyal
28aad4345e
Custom shaders: Allow controlling shaders with key presses
Add a shader_event action that sends user:<name> events to the custom
shader pipeline, and an animation_toggle pipeline directive to turn
groups on and off with an event. User events occupy the bits above the
builtin events in a now 64 bit event mask, so firing them costs no more
than any other event and groups that are off are not drawn at all.

Fixes #10667
2026-10-15 20:56:31 +05:30
Jesse Miller
c57495436d Skip foreground samples for blank cells
The cell fragment shader sampled the glyph, underline, strike, cursor, and underline-exclusion texels for every cell. A space is sprite 0, and that sprite is empty, so those samples add nothing. The vertex shader now sets skip_text when the glyph, both decoration indices, and the cursor sprite are all zero. The fragment writes the background it already computed and skips the samples. A block cursor is sprite 0, so its color stays in the background. An underline, strike, URL underline, or beam, underline, or hollow cursor still samples. The foreground-only pass writes zero for a skipped cell.

On Linux, platform text composition is gamma 1 and contrast 0, which is pow(alpha, 1) * 1. TEXT_CONTRAST_IDENTITY compiles that function down to returning the color unchanged. legacy and any other numbers keep the old math. A config reload that crosses that line rebuilds the cell programs. The identity flag is only varied when the new gamma path is on, so the cell programs go from 18 to 27.
2026-10-11 10:38:17 -06:00
Kovid Goyal
be4fef614b
Custom shaders: Query shader source with a parser instead of regexes
Add a small Slang lexer and top level declaration parser to slang.py, and
SlangShaderQuery which runs the slangc preprocessor when an answer could
depend on it. Use it for:

- Detecting pointer_map(), so that comments, #if 0 blocks and calls no
  longer count, macros are honored, and a pointer_map() that is not public
  or does not return float2 is reported instead of failing obscurely. The
  result is cached alongside the pipeline module, so a cached load does
  not run slangc.
- Applying pipeline var directives, which now work for declarations
  spanning multiple lines and match by name as documented.
- Parsing the builtin shaders, with identical results for all of them.

Also cleanup minor issues form previous PR

- Ignore pointer_map() in groups that only draw to part of the screen
- Share the pointer position conversion between glfw.c and mouse.c
- Pass POINTER_MAP_SIZE to the pipeline as a define instead of
  duplicating it
- Do not free the pointer map render target on every pipeline reload
- Document what pointer_map() may depend on and when d.mouse_pos lines
  up with the pointer
2026-10-10 11:04:08 +05:30
Iurii Lunev
30e07a5b09 Custom shaders: Allow shaders that move content to remap pointer events
A shader that draws content away from where kitty put it, such as crt
curving the screen, makes clicks and selections land on the wrong cells,
since kitty maps the pointer to the unmodified cell grid. Up to several
columns near the edges with the bundled crt shader.

Shaders can now define pointer_map(pos, d), returning where the content
shown at pos actually is. kitty renders it into a 64x64 grid when the
pipeline or viewport size changes, reads it back once, and uses it to
move all pointer events. Only always active groups that draw to the
screen are used, since only they move content permanently.

The crt shader defines it, sharing its warp function with fragment_main().
2026-10-09 23:31:29 +03:00
Kovid Goyal
79c2efd8ce
Particle effects for cursor trail shaders
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Fixes #10587
2026-10-02 10:05:57 +05:30
Kovid Goyal
03c278a661
also fix pipeline file retention in frozen builds and add test for it 2026-09-24 09:49:33 +05:30
Kovid Goyal
d37f845293
cleanup previous PR fixing one regression and doing code cleanups 2026-09-16 12:57:51 +05:30
白鸽
18023eaafa Custom shaders: Clear cached programs when disabling shaders 2026-09-14 22:41:26 +08:00
白鸽
7b41e33399 Custom shaders: Redraw static effects only on demand 2026-09-14 22:41:26 +08:00
白鸽
cf33820973 Custom shaders: Support tinting complete inactive windows 2026-09-14 22:41:26 +08:00
Kovid Goyal
953ac19e77
Autoformat slang code 2026-08-10 22:29:18 +05:30
Kovid Goyal
28b7c238dc
Use a fresh cache dir for shader compilation test 2026-08-10 12:51:11 +05:30
Kovid Goyal
c97b71e66b
Nicer test cache dir name 2026-08-10 12:38:15 +05:30
Kovid Goyal
e7d41ff7f4
Fix loading of pipeline files by absolute path 2026-08-10 10:16:37 +05:30
Kovid Goyal
17e577f75b
Add a test to check that all custom shaders build 2026-08-07 18:49:56 +05:30
Kovid Goyal
ed025b37af
fix specialisation not working 2026-08-05 08:17:05 +05:30
Kovid Goyal
d6712dc695
... 2026-08-05 08:05:40 +05:30
Kovid Goyal
dd2c59d255
autoformat 2026-08-05 07:16:05 +05:30
Kovid Goyal
81e7d4f1a7
Test to insure that custom shader compilation uses its cache 2026-08-05 05:33:00 +05:30
Kovid Goyal
ae347ec014
allow specialisation of custom shaders at link time 2026-08-05 05:32:59 +05:30
Kovid Goyal
98e2de1a98
move to using a pipeline definition file for custom shaders 2026-08-05 05:32:58 +05:30
Kovid Goyal
5431baa422
More work on custom shaders 2026-08-05 05:32:57 +05:30
Kovid Goyal
16297903f6
test for compiling custom shader to glsl 2026-08-05 05:32:57 +05:30
Kovid Goyal
4b15314267
compile builtin shaders in dependency layers 2026-08-05 05:32:56 +05:30
Kovid Goyal
7f0b072f0d
autoformat 2026-08-05 05:32:56 +05:30
copilot-swe-agent[bot]
a31f9e52f2
Refactor kitty_tests: move __init__.py code to base.py, update all imports 2026-08-05 05:32:54 +05:30
Kovid Goyal
879697e4c5
Move specialisations into compiler code
Allows for dynamic specialisations
2026-08-05 05:32:49 +05:30
Kovid Goyal
9261295448
Fix failing tests 2026-08-05 05:32:49 +05:30
copilot-swe-agent[bot]
a36b259d45
Fix parser to strip semicolons from module/import names; update tests 2026-08-05 05:32:49 +05:30
copilot-swe-agent[bot]
d8041066bf
Add slang parser corner case tests and implement test_slang_ordering 2026-08-05 05:32:49 +05:30
Kovid Goyal
dbfa720387
Work on generating build tree for slang files 2026-08-05 05:32:49 +05:30