From 2d007737eb6f7f8e48bf6500e19ed44e62df5aa7 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 17:18:36 -0300 Subject: The terminal's capabilities are taken up when its answer comes, not at the first key after it --- src/tty/tty.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/tty') diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 97c720ea..efccd98e 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -178,6 +178,13 @@ fn readInput(loop: *Loop, tty: anytype, cache: *vaxis.GraphemeCache) !void { if (event == .paste) if (loop.vaxis.opts.system_clipboard_allocator) |gpa| gpa.free(@constCast(event.paste)); return err; }; + // The last answer to the startup queries is no event of its + // own: wake the loop so it takes the capabilities up (pollFrame) + // now. Left to the first key, that key paid for the full redraw + // they cost, and kitty's keys came in the legacy way till then. + if (result.event) |event| if (event == .cap_da1) { + _ = loop.tryPostEvent(.nop) catch {}; + }; } carried = end - consumed; std.mem.copyForwards(u8, buf[0..carried], buf[consumed..end]); @@ -276,6 +283,8 @@ test "terminal input preserves fragmented keys queries paste and text after EOF" try std.testing.expectEqualStrings("clip", bytes); clipboard = true; }, + // The device attributes' wake (a capability answer). + .nop => try std.testing.expect(vx.queries_done.load(.unordered)), else => return error.UnexpectedInputEvent, }; try std.testing.expectEqualStrings("plain café 界 😀tail", text.items); @@ -358,6 +367,7 @@ test "terminal replies and malformed sequences never become typed text" { try std.testing.expectEqual(@as(i16, 0), mouse.col); clicked = true; }, + .nop => {}, // the device attributes' wake else => return error.UnexpectedInputEvent, }; try std.testing.expectEqualStrings("abc", text.items); @@ -1420,6 +1430,7 @@ const Shell = struct { s.core.native_images = s.vx.caps.kitty_graphics; if (s.vx.caps.kitty_graphics) kittyShmProbe(s.tty.writer()); s.vx.queueRefresh(); + s.core.needs_frame = true; } } -- cgit v1.3