Problem
-------
In update_dest_rect() when both num_cols and num_rows are 0
(auto-computed, ``a=T``), the first block computes num_cols with
cell_x_offset, but, then the second block mismatches num_cols, causing
it to compute width_px from num_cols and adds cell_x_offset a second
time. The returned value is large enough that it often causes scrolling,
depending on size and location of the screen.
A sample visual program:
```python
import zlib, base64, time
from functools import partial
echo = partial(print, end='', flush=True)
echo('\033[H\033[J')
base = bytes([0, 128, 0, 255]) * 640 * 576
k = zlib.compress(keyframe, 3)
echo(f'\033[8;60H\033_Ga=T,i=1,q=1,f=32,s=640,v=576,o=z,N=1;{base64.b64encode(k).decode()}\033\\')
time.sleep(1)
delta = bytes([200, 0, 0, 255]) * 32 * 512
d = zlib.compress(delta, 3)
echo(f'\033[9;67H\033_Ga=T,i=100,q=1,f=32,s=32,v=512,o=z,N=1,X=9,Y=25;{base64.b64encode(d).decode()}\033\\')
time.sleep(1)
print()
```
Solution
--------
Add 'auto_cols' and 'auto_rows' to remember the original read-only
values before exercising their auto-calculated size. 'auto_rows' isn't
technically necessary given the logic branching but it describes in code
better.
Before and After video
----------------------
A video will be attached shortly, here.
Add a benchmark stream containing 262,144 distinct base-plus-combining-mark cells per repetition so TextCache collection cost remains visible instead of collapsing into cache hits.
Co-Authored-By: Claude <noreply@anthropic.com>
Move the periodic collection check to PREPARE_FOR_DRAW_TEXT so ordinary and fixed-width text share one safe integration point, while tab handling no longer initiates collection.
Reset the additions counter only after the live-cell remap completes successfully.
Co-Authored-By: Claude <noreply@anthropic.com>
Programs that hide the cursor with DECTCEM but keep moving it causes
the trail to run a full animation after every cursor move, which is
unnecessary since the cursor is invisible.
When the cursor is hidden and the trail has fully faded out, snap the
trail corners to the cursor position instead of animating them. The
trail still tracks the hidden cursor, so switching focus to or away
from such a window still animates the trail.
glibc can raise its dynamic mmap threshold above these MB-scale allocations, routing later scrollback segments through brk. Closing windows then leaves the freed segments stranded in allocator bins and grows the long-lived kitty process.
Back the existing batched segment layout with anonymous mappings instead. This preserves zero-initialization and pointer layout while ensuring the memory is returned to the OS when a history buffer is cleared or destroyed.
Co-Authored-By: Claude <noreply@anthropic.com>
_glfwPlatformCreateWindow() ignored the return value of
attach_opengl_context_to_window(), so when EGL is unavailable (for
example libEGL cannot be loaded) it reported success with
window->context left zeroed. glfwCreateWindow() then proceeded to
_glfwRefreshContextAttribs() -> glfwMakeContextCurrent(), which calls
the NULL context.makeCurrent pointer: kitty crashes with SIGSEGV
instead of reporting "Failed to create GLFWwindow. This usually
happens because of old/broken OpenGL drivers." as intended. The X11
backend already propagates these failures.
Co-Authored-By: Claude <noreply@anthropic.com>
The TextCache interns every unique multi-codepoint cell text for the
lifetime of the window with no eviction, so a stream of unique texts
(for example random combining mark sequences) grows memory without
bound, several hundred MB/hour at moderate throughput.
Mirror the existing hyperlink pool garbage collection: every 8192
newly interned entries, steal the cache contents and have the Screen
remap the index in every live cell (history buffer, main and alt line
buffers, paused rendering snapshot and overlay line), re-interning
only entries still referenced by some cell. Entries whose last
reference scrolled out of the history buffer are freed.
See #10249
Co-Authored-By: Claude <noreply@anthropic.com>
When a kitty window regains text-input focus (e.g. switching back to a
workspace in sway, unminimizing, or unlocking the screen), the
zwp_text_input_v3::enter event is fired. However, text_input_enter()
only called enable + set_content_type without restoring the cursor
rectangle. If the compositor does not re-send wl_keyboard.enter at the
same time, kitty never updates the IME position, causing the popup to
appear at the top-left corner.
Restore the last known cursor rectangle in text_input_enter() so the
IME popup immediately appears at the correct position.
If smooth scrolling has reached its target, scroll_animation_tick()
clears the timer ID in the animation object. However, the timer
was not removed, which resulted in the timers potentially accumulating
and preventing the creation of new timers eventually. This caused smooth
scrolling to stop working in the terminal.
* Switches to "positional notation" to fix the bug.
* Consolidates `encode_hint` and `generate_prefix_free_hint` into `encode_hint`.
* Moves prefix_free_hints.go to hints_generator.go; `encode_hint` and `decode_hint` were moved here too.
* The "prefix-free" logic was made 0-index based instead of 1-index based for two reasons:
1. To simplify 1-off discrepancies.
2. To keep backwards compatibility with the old usage of `encode_hint`.
* Slight perfomance improvement added by reusing the runt-to-index map instead of rebuilding for each call to `decode_hint`.
* Unit tests added; for all new logic and old affected logic.
Fixes#10231
Allow the first mouse click on an inactive Cocoa OS window to be delivered to kitty instead of only activating the window.
Make the matching kitty-internal behavior consistent by forwarding clicks that switch focus to another kitty window in the currently focused OS window. This lets the same first click both focus the target kitty window and perform the click action, including forwarding to mouse-tracking applications.