All OpenGL calls now live in gpu/opengl, which is built as kitty/opengl.so,
next to the glfw backends. glfw_init() is passed the path to the driver and
loads it. The driver is initialized once the first OpenGL context is
current. fast_data_types no longer links against libGL.
kitty/gpu.c contains the driver loader and the higher level helpers
(programs and their metadata, vertex array objects, viewport stack) that
were previously in kitty/gl.c, implemented on top of the driver API.
shaders.c and the rest of kitty use only the driver API.
Also remove the unused GL_* constants and the unused bind_program,
create_vao, etc. functions exported to Python.
gpu/api.h defines the interface between kitty and dynamically loaded GPU
drivers. It uses only standard C types, with opaque 64 bit handles for all
resources, so that it can be implemented with OpenGL, Vulkan or Metal.
A new panel created via single instance now runs in the working
directory of the invocation, rather than that of the first instance, as
commands run in existing panels and other single instance commands
already do. The environment of the invocation is cleaned up with
process_env() as for other single instance commands, so that variables
such as XDG_ACTIVATION_TOKEN and VTE_VERSION are not passed to the
commands.
Commands sent to an already running panel or quick access terminal, both
in existing panels and in newly created ones, are now user launches
passed to the launch wrapper. They have no source window, since they are
not run from any window in the panel. A new panel without a command runs
the shell instead of the run-shell kitten, so the wrapper sees the actual
shell, as for a panel started without single instance.
Closes#10900
The layout did not reserve space for the border of a single window, so
the border overlapped the margin and, when the margin was narrower than
the border, extended past the edges of the OS window. The negative
coordinates were then parsed as unsigned, which with rounded borders made
the whole window be covered by the corner fill, hiding its contents.
Reserve the border in layout_single_window_group whenever a full border
is drawn around the window, including when a visible dock causes borders
to be drawn, account for it in the initial OS window size in cells, and
parse border rects as signed integers, clipping them to the OS window.
Fixes#10899
The HarfBuzz font was created before the named instance or axis
coordinates were applied to the FreeType face and was only resynced if
the face had a transform matrix. So shaping used the default variation
coordinates, which broke fonts that substitute glyphs based on axis
values via GSUB FeatureVariations, such as the cursive (CRSV) axis of
Annotation Mono.
Adds a test using a small subset of Annotation Mono (SIL OFL 1.1).
Fixes#10897
The fix for CVE-2026-54056 only made remote regular file creation
exclusive. A remote source could still send a symlink and then a
directory with the same name, as names were only de-duplicated on
case insensitive filesystems. CreateDirAt() would then follow the
symlink and the directory's children would be written outside the
staging directory.
Always de-duplicate names, create remote directories exclusively and
never follow symlinks when opening a newly created directory.
Port the CSI tokenizer and SGR grouping logic from vt-parser.c and
cursor.c so that empty parameters terminated by a semicolon are treated
as zero everywhere, not only in extended colors. This fixes stale
attributes being re-applied on wrapped lines for codes such as ;m, ;31m
and 4:;31m. Also match kitty for codes with invalid characters or
private/intermediate bytes (ignored entirely), misplaced sub-parameters,
mixed colon/semicolon colors, out of range color indices, SGR 21 and
clamped underline styles.
Closes#10895
A semicolon commits an empty CSI field as zero. Skip empty fields at a colon or the CSI terminator so that incomplete extended colors keep the current color when wrapping text.
Animations are only scanned in the windows of the active tab, so if the
previously active tab had no animations, scanning stopped and was never
restarted when switching back. Request a rescan when the active tab
changes.
Fixes#10894
On macOS the default shell is run via /usr/bin/login and the run-shell
kitten, with the user wrapper placed inside login, so the expected argv
differs from Linux.
- Treat trailing empty SGR color parameters as zero, matching the terminal
- Ignore the color space id in colon form RGB colors (38:2:id:r:g:b)
- Fix bright colors (90-97, 100-107, 38;5;8-15) being re-emitted off by one
- Handle parse errors explicitly and simplify color target selection
- Add tests for SGR state parsing
A user launch wrapper can start a persistent helper before the command. Use a lone, unmatched child for the current lookup and cache the child only once its command line matches the launch arguments.
A wrapper that runs the command as a child, rather than exec-ing it, can
run other children before, after or alongside it, such as a script that
runs some setup commands first. Re-check that the cached child of a
wrapper is still its live child, so that root_pid does not get stuck on
an exited helper, or on the command after it exits while the wrapper
keeps running. When a wrapper has several children, prefer the one
running the wrapped command, and only cache the choice if it is certain.
Match wrappers specified by name when their argv[0] is the path they
were found at, as is the case when run by the hold kitten, and wrappers
specified by path only by that exact path.
Compare the wrapper argv and the script arguments with empty arguments
dropped, as cmdline_of_pid() does on Linux, in one place, so that
binary wrappers with empty arguments are also matched.
Add tests for wrappers that run other commands, that exec after being
seen, with prefix and empty arguments, run via the hold kitten, and for
matches_cmdline() and runs_command().
The dialog was drawn by writing newlines and relying on the terminal to
wrap long lines, recording clickable ranges assuming nothing scrolled or
wrapped. When the content was taller than the window, the screen
scrolled and every clickable range was off by the scroll amount.
Now the full layout is computed up front, with clickable ranges relative
to it, and rows are drawn with absolute cursor positioning and line
wrapping disabled, so the terminal never scrolls or wraps. The boxed
choice layout is used only if it fits entirely, otherwise the compact
one is used, and if even that does not fit, the content is bottom
aligned so the choices remain visible. Choices too wide for the screen
are truncated with an ellipsis.
Also fix:
- The hidden text placeholder not being clickable when it wraps over
multiple lines, its clickable range going stale after a resize, and
its range including one cell too many.
- Compact choice ranges being computed by iterating over a map, putting
them in random order when several choices share a line.
- An empty box row or compact row being output when the first choice is
wider than the screen.
- truncate_at_space using a cell width as a byte offset, splitting
multi-byte characters, and looping forever when a character is wider
than the available width.
Closes#10883
Drop the redundant v2 prefix from the disk cache key, as the key format
already changed when the inode was added.
Render the file the cache key was computed from, so that retargeting a
symlink while rendering, even if it is restored before AddPath() checks
the key again, cannot store the preview of one file under the key of
another. Renderers that need the selected path, custom preview commands
and calibre, opt out via NeedsSelectedPath(). The selected path is also
used when the target has a different extension, as renderers may detect
the format from it.
Recheck the path key before updating the cache. Include the inode so a replacement with the same size and modification time gets a different key. Version the key to invalidate previously cached previews.
Retry once when a changed path still resolves to a regular file.
A bell in the active window was never marked as needing attention, even
when the OS window did not have keyboard focus, so the tab bar bell
symbol was not shown. Now a window needs attention unless it is both
active and in the focused OS window.
Since the active window can now need attention, also:
- Clear needs_attention when the OS window gains focus, as
focus_changed() is a no-op if the window became active while the OS
window was unfocused, which would leave the indicator stuck.
- Use the bell color for minimal borders of an active group needing
attention, instead of the active color (or the fallback green when
active_border_color is none).
Fixes#10880
Reduce the allowance for cropping glyphs wider than their cell, rather
than rescaling them, to 2/10 of the cell width, since cropping removes
ink, and test that cropped glyphs fill their cell.
FreeType: Move combining marks with their base glyph when it is rescaled
and moved into its cell, so that they stay in place relative to it.
CoreText: Rescale glyphs individually, as with FreeType, so that a
combining mark wider than the cell does not cause its base glyph to be
shrunk. Measure the width of glyphs in whole pixels, as rasterized, as
with FreeType, so that both renderers make the same decision. Never crop
colored glyphs, as with FreeType.
concat_cells: Produce RGBA bytes for 8 bit sprites, as for 32 bit ones,
and handle empty cells.
As with the CoreText renderer, a glyph that is rescaled to fit its cell is
moved so that its ink starts at the left edge of the cell, so that marks that
hang to the left of it, as in polytonic Greek capitals, are no longer cut off.
Port the overhang allowance from the FreeType renderer: a glyph wider than
its single cell by at most 2/9 of the cell width, with a minimum of 2px, is
cropped rather than rescaled. Previously any glyph whose right edge was more
than 1px past the cell was rescaled, shrinking glyphs such as the d with
caron of Cascadia Code and the texture healing alternates of Monaspace.
Widths are measured per glyph, as with FreeType, so that combining marks do
not cause their base glyph to be shrunk.
The left overhang of a glyph is now taken into account, and a glyph that is
rescaled is moved so that its ink starts at the left edge of the cell, so
that marks that hang to the left of it, as in polytonic Greek capitals, are
no longer cut off. Glyphs that extend past the right edge of the cell are
moved left as far as their left bearing allows, as with FreeType.
Also fix the tests for this to run on macOS: face_from_path() ignored the
font size on macOS and the tests treated pixels with only color bits set as
ink.
Fix concat_cells() for 32 bit sprites, broken since the SIMD compositing
change, which treated the 0xRRGGBBAA sprite pixels as RGBA bytes, producing
an opaque white image.
A glyph whose bitmap is wider than its cell is rendered again at a
smaller font size so that it fits, unless it is wider by no more than
two pixels, in which case it is cropped. That allowance is absolute, so
it covers less of the cell as the cell grows, and fonts with glyphs
that overhang their advance by design end up on the wrong side of it:
the texture healing alternates of Monaspace and 0xProto, or the d with
caron of Cascadia Code. Such a glyph is drawn visibly smaller than its
neighbors, at one font size and not at the next.
Make the allowance proportional to the cell width: 2/9 of the cell,
which is the 2px the rule was originally tuned for at the 9px cell of a
typical monospace font at 11pt and 96 dpi, with a minimum of 2px for
smaller cells. That keeps the widest Monaspace alternate, 14% wider
than its cell, at full size. A glyph that overhangs by more, such as a
Greek capital whose breathing mark and accent hang well outside the
cell, is still rescaled, since cropping would remove the marks.
Closes#10879
Timers are dispatched outside the main loop tick, so state changed by
them was not rendered while the OS window was otherwise idle, only
catching up when some other event woke the loop. For example, a custom
tab bar refreshed from add_timer, or actions mapped to mouse clicks,
which are dispatched from a timer after click_interval.
Request a tick after every Python timer callback, after dispatching
pending clicks and when marking the tab bar dirty.
Closes#10878
prepare_to_render_os_window() decided whether a window needs to be rendered
in layers before calling send_cell_data_to_gpu(), which is what updates the
graphics layers. So on the frame in which an image first becomes visible
grman_has_images() returned a stale false, the window was rendered without
the image, and if nothing else triggered a redraw (for example, the cursor
is hidden so not blinking) the image did not appear until some unrelated
event such as mouse movement.
Fixes#10875
The focus state of the decorations comes only from keyboard enter/leave
events, but the decorations were only re-rendered on configure events and
title changes. So they showed a stale focus state whenever focus changed
without a following configure, for example, when switching between tabbed
windows in niri, which keeps all tabs activated.
Re-render the decorations on keyboard enter/leave, looking up the window
again after the focus callbacks have run, since they can close it.
Also:
- Ignore the activated state in the change detection, as focus is tracked
separately, to avoid rendering twice per focus change.
- Never create decoration surfaces in ensure_csd_resources() for windows
that should not be decorated, such as fullscreen windows. Title changes
while fullscreen could previously create them from a stale state.
- Recreate the decoration surfaces when they are missing even if the
window state is unchanged, otherwise the resize borders were not
restored after leaving fullscreen with hide_window_decorations
titlebar-only.
Based on the patch by Ole Jørgen Brønner.
Closes#10873