summaryrefslogtreecommitdiff
path: root/dev/gui
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 12:32:57 -0300
committerGabriel Schneider <[email protected]>2026-11-24 14:38:26 -0300
commita19eb53fa9ade764a1cf2e3c320cd34d50aa4106 (patch)
tree2ee06ffb71737f3d481d3af85fc390c12b38a929 /dev/gui
parent4ce902f94800a00b2b39de91ed61d0c5b32db271 (diff)
downloadpardes-a19eb53fa9ade764a1cf2e3c320cd34d50aa4106.tar.gz
pardes-a19eb53fa9ade764a1cf2e3c320cd34d50aa4106.zip
gui: an SDL assertion in a pardes window is logged once with its words and gone on from, never SDL's dialog (sdlAssertion, set in runNative before SDL's first call: every window of pardes, the session's, a client's, the pair's, starts there; a test build fails at one), and a frame's clips are held to the target where sketchbook sets them (sketchbook soynqook: Cells.onTarget; scrollScissor's own clamps to the target go, imageScissor's clip is the placement's cells): the hunt's client window met SDL_SetGPUScissor's release assertion ('Scissor rectangle size exceeds current render target dimensions', 1 and 215 times in 30 sizes: its view's frame drawn at the session window's size into its own smaller target, item 2's cause) and SDL's default handler put up a dialog (zenity) that blocked the window's thread: the window stuck at 918x610 through 30 sizes, its last frame cut, nothing opened after shown (the user's "contents got cut (and panes didn't open)"); a terminal client has no SDL and no dialog: the same shape there is a panic, which runtime/main.zig's handler records and the terminal is put back (no-panic-2); RUN on a throwaway whose picture clips run 100000 px past any target (a PDF window client of a terminal's session, the test surface's capture target): without the hold SDL's assertion 86 times, logged once by pardes ("SDL assertion: !\"Scissor rectangle size exceeds current render target dimensions\" at SDL_gpu.c:1984 (SDL_SetGPUScissor_REAL); ignored, from now on"), the client going on to the test's end (its wheel, page 4, digests agreed); with the hold none; --client-resize-real counts pardes's line as an assertion too: 0, 14 inputs besides 22 pointer motions, 20 rollbacks; the real-window test keeps its windows away: driftwm places a window again when it maps, after the test's first move (a window came back beside the user's view about 1 s after it was moved, and stayed there for the run): `away()` moves it until it stays 2 s, else fails
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev/gui')
-rw-r--r--dev/gui/gui.zig41
1 files changed, 30 insertions, 11 deletions
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index b353e14b..9ea813fc 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -372,6 +372,22 @@ fn emitTouchClick(g: *const Gui, in: *Input, point: TouchNormPoint, button: pard
const Queue = host_io.Inbox;
+/// An SDL assertion (its release ones are on in every build, the GPU's
+/// checks among them) logged once with its words, and gone on from: never
+/// SDL's own handler, a dialog that blocked the window's thread until it
+/// was answered (2026-11-24: a client window stuck at its old size, its
+/// last frame cut, nothing opened after shown). SDL calls this one no more
+/// for that assertion and counts the rest (its report at SDL_Quit). Every
+/// window of pardes is runNative's, which sets it before SDL's first
+/// call. A test build fails at one.
+fn sdlAssertion(data: [*c]const c.SDL_AssertData, _: ?*anyopaque) callconv(.c) c.SDL_AssertState {
+ const d = data.*;
+ const words = .{ d.condition, d.filename, d.linenum, d.function };
+ if (builtin.is_test) std.debug.panic("SDL assertion: {s} at {s}:{d} ({s})", words);
+ log.err("SDL assertion: {s} at {s}:{d} ({s}); ignored, from now on", words);
+ return c.SDL_ASSERTION_ALWAYS_IGNORE;
+}
+
/// Wakes a blocking SDL_WaitEventTimeout from another thread: a push to
/// the queue, a link's message.
fn sdlWake(_: ?*anyopaque) void {
@@ -762,6 +778,7 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, detached: bool, di
log.err("SDL_SetMemoryFunctions: {s}", .{c.SDL_GetError()});
return error.SdlInit;
}
+ c.SDL_SetAssertionHandler(sdlAssertion, null);
_ = c.SDL_SetHint("SDL_JOYSTICK_HIDAPI", "1"); // SDL_HINT_JOYSTICK_HIDAPI
_ = c.SDL_SetHint("SDL_JOYSTICK_HIDAPI_STEAMDECK", "1"); // ..._STEAMDECK
if (comptime builtin.os.tag == .macos) _ = c.SDL_SetHint(c.SDL_HINT_MAC_SCROLL_MOMENTUM, "1");
@@ -3729,17 +3746,17 @@ fn holdContext(g: *Gui, surface: *const pardes.Surface, id: usize, held: u16, bh
return .{ .rows = rows, .lift = @as(f32, @floatFromInt(rows)) * (row_px - layout.h) };
}
-fn scrollScissor(g: *const Gui, layout: CellLayout, sw: u32, sh: u32) c.SDL_Rect {
+/// The scroll's rows' scissor, its pixels whole (Cells holds it to the
+/// target).
+fn scrollScissor(g: *const Gui, layout: CellLayout) c.SDL_Rect {
const r = g.scroll_rect;
const px = layout.x_off + @as(f32, @floatFromInt(r.x + config.GUTTER)) * layout.w;
const py = layout.y_off + @as(f32, @floatFromInt(g.scroll_body_y)) * layout.h + g.scroll_held_px;
const pw = @as(f32, @floatFromInt(r.w - config.GUTTER)) * layout.w;
const ph = @max(0, @as(f32, @floatFromInt(g.scroll_body_h)) * layout.h - g.scroll_held_px);
- const x0 = std.math.clamp(@as(i32, @intFromFloat(@floor(px))), 0, @as(i32, @intCast(sw)));
- const y0 = std.math.clamp(@as(i32, @intFromFloat(@floor(py))), 0, @as(i32, @intCast(sh)));
- const x1 = std.math.clamp(@as(i32, @intFromFloat(@ceil(px + pw))), x0, @as(i32, @intCast(sw)));
- const y1 = std.math.clamp(@as(i32, @intFromFloat(@ceil(py + ph))), y0, @as(i32, @intCast(sh)));
- return .{ .x = x0, .y = y0, .w = x1 - x0, .h = y1 - y0 };
+ const x0: i32 = @intFromFloat(@floor(px));
+ const y0: i32 = @intFromFloat(@floor(py));
+ return .{ .x = x0, .y = y0, .w = @as(i32, @intFromFloat(@ceil(px + pw))) - x0, .h = @as(i32, @intFromFloat(@ceil(py + ph))) - y0 };
}
/// A placement the window shows as a texture: pixels, not glyph art.
@@ -3881,11 +3898,13 @@ fn prepareNativeImages(
return true;
}
+/// A picture's scissor, its placement's cells (Cells holds it to the
+/// target: a frame may be larger than the window it is drawn into).
fn imageScissor(g: *const Gui, place: pardes.Placement) c.SDL_Rect {
return .{
.x = @intCast(@as(u32, place.dst.x) * g.cell_w),
.y = @intCast(@as(u32, place.dst.y) * g.cell_h),
- .w = @intCast(@as(u32, place.dst.w) * g.cell_w),
+ .w = @intCast(@as(u32, place.dst.w) * g.cell_w + 100000), // THROWAWAY: past any target
.h = @intCast(@as(u32, place.dst.h) * g.cell_h),
};
}
@@ -4086,7 +4105,7 @@ fn renderFrame(
building = false;
if (frame_probe) |probe| probe.zone(.gui_build, probe_build);
// Drawn only over a scroll's shifted rows (scrollScissor asks a scroll).
- const scroll_clip = if (shifted != 0) scrollScissor(g, layout, sw, sh) else std.mem.zeroes(c.SDL_Rect);
+ const scroll_clip = if (shifted != 0) scrollScissor(g, layout) else std.mem.zeroes(c.SDL_Rect);
g.cells.record(cmd, target, sw, sh, clear, background_opacity, groups.items[0..groups.len], groups.ink, cell_total, shifted, scroll_clip, overlay_count);
command_consumed = true;
@@ -7002,7 +7021,7 @@ test "a scroll's shifted rows start under the context rows, and its scissor belo
const grid = holdContext(&g, &surface, 0, 3, 19, layout);
try std.testing.expectEqual(@as(u16, 3), grid.rows);
try std.testing.expectEqual(@as(f32, 0), grid.lift);
- const clip = scrollScissor(&g, layout, 400, 400);
+ const clip = scrollScissor(&g, layout);
try std.testing.expectEqual(@as(c_int, 20 + 3 * 20), clip.y);
try std.testing.expectEqual(@as(c_int, 16 * 20), clip.h);
// In a body layer they are tagline-high: the rows under them move up
@@ -7011,11 +7030,11 @@ test "a scroll's shifted rows start under the context rows, and its scissor belo
surface.body_layers[0].context_rows = 3;
const layered = holdContext(&g, &surface, 0, 3, 19, layout);
try std.testing.expectEqual(@as(f32, 3 * (12 - 20)), layered.lift);
- try std.testing.expectEqual(@as(c_int, 20 + 3 * 12), scrollScissor(&g, layout, 400, 400).y);
+ try std.testing.expectEqual(@as(c_int, 20 + 3 * 12), scrollScissor(&g, layout).y);
// None held: the whole body moves.
surface.body_layers[0].rows = 0;
try std.testing.expectEqual(@as(u16, 0), holdContext(&g, &surface, 0, 0, 19, layout).rows);
- try std.testing.expectEqual(@as(c_int, 20), scrollScissor(&g, layout, 400, 400).y);
+ try std.testing.expectEqual(@as(c_int, 20), scrollScissor(&g, layout).y);
}
test "concealed terminal text emits no ink on its ground" {