diff options
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/gui/gui.zig | 17 | ||||
| -rw-r--r-- | dev/tui/tui.zig | 9 |
2 files changed, 23 insertions, 3 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 76af0ec8..2756f69b 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -809,9 +809,12 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, detached: bool, di var want_w: c_int = 1120; var want_h: c_int = 720; var want_at: ?[2]c_int = null; - // ...or the size an Upgrade's exec says its window had (client.zig + // ...or the size an Upgrade's exec says its window had: a session's in + // its record (upgrade.zig `Record.size`), ahead of the `--geometry` it + // was started with, a client's in PARDES_JOIN_SIZE (client.zig // `execAgain`). - if (opts_in.geometry orelse if (std.c.getenv("PARDES_JOIN_SIZE")) |e| std.mem.span(e) else null) |spec| geometry: { + const kept = if (upgrade.resumed) |rec| rec.size else null; + if (kept orelse opts_in.geometry orelse if (std.c.getenv("PARDES_JOIN_SIZE")) |e| std.mem.span(e) else null) |spec| geometry: { const x_at = std.mem.indexOfScalar(u8, spec, 'x') orelse break :geometry; const plus = std.mem.indexOfAnyPos(u8, spec, x_at, "+-") orelse spec.len; want_w = std.math.clamp(std.fmt.parseInt(c_int, spec[0..x_at], 10) catch break :geometry, 200, 16384); @@ -881,7 +884,8 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, detached: bool, di const cell_w: u32 = @intCast(@max(cw, 1)); const cell_h: u32 = @intCast(@max(chh, 1)); const tagline = taglineRaster(&atlas, px, cell_w, cell_h, config.gui_tagline_font_percent); - if (test_mode) { + // An upgraded window keeps its size in a test too. + if (test_mode and kept == null) { const cols = envU16(env, "PARDES_TEST_COLS") orelse 80; const rows = envU16(env, "PARDES_TEST_ROWS") orelse 24; // PARDES_TEST_PAD: extra pixels past the grid, as a real window has. @@ -2535,6 +2539,13 @@ const Shell = struct { // dials the session again once it is back. s.peers.refuseAll(core); var rec: upgrade.Record = .{ .link = daemon.link, .window = s.gui != null, .exe = path }; + // Its window's size now, the new one's (the user's since its start). + var size_buf: [32]u8 = undefined; + if (s.gui) |g| { + var w: c_int = 0; + var h: c_int = 0; + if (c.SDL_GetWindowSize(g.window, &w, &h)) rec.size = std.fmt.bufPrint(&size_buf, "{d}x{d}", .{ w, h }) catch null; + } s.ptys.record(&rec); var at_buf: [1024:0]u8 = undefined; const failed = upgrade.dumpInto(core, &rec, &at_buf, &why) orelse upgrade.execAs(s.gpa, path, &rec, &at_buf, s.fs, &why); diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index d1bbe140..9320e522 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -2917,6 +2917,15 @@ test "a mouse report at row or column 0, or before it, is the window's edge, nev } } +test "an X10 mouse report with a byte below 32, and one with a button no mouse has, are no event, never a panic" { + // A legacy terminal's `ESC [ M` then a control byte: Alt+[, Shift+M, Enter and two keys. + for ([_][]const u8{ "\x1b[M\x0d\x20\x20", "\x1b[M\x20\x0d\x20", "\x1b[M\x20\x20\x1f", "\x1b[<192;1;1M", "\x1b[<195;5;5m" }) |sequence| { + var parser: vaxis.Parser = .{}; + const result = try parser.parse(sequence, std.testing.allocator); + try std.testing.expect(result.event == null and result.n > 0); + } +} + test "a mouse's side buttons, xterm's 8 and 9, are Back and Forward, as SDL's X1 and X2 are" { for ([_]vaxis.Mouse.Button{ .button_8, .button_9 }, [_]pardes.Mouse.Button{ .back, .forward }) |from, to| { const event = mouseEvent(.{ .col = 3, .row = 2, .button = from, .mods = .{}, .type = .press }).?; |
