a73x

109a4daa

Wire SurfaceState into Window

a73x   2026-04-16 10:47

Commit message
Wire SurfaceState into Window

Replaces the bare Window.configured flag with a SurfaceState embedded
on the Window. Visibility queries now go through state.visible(), which
is a no-op change today but will gate rendering once FrameLoop lands.

src/wayland.zig
Old New
@@ -21,6 +21,7 @@ pub const Output = struct {
21 pub const SurfaceState = struct { 21 pub const SurfaceState = struct {
22 configured: bool = false, 22 configured: bool = false,
23 suspended: bool = false, 23 suspended: bool = false,
24 /// Must outlive this SurfaceState.
24 tracker: *ScaleTracker, 25 tracker: *ScaleTracker,
25 26
26 pub fn visible(self: *const SurfaceState) bool { 27 pub fn visible(self: *const SurfaceState) bool {
@@ -563,7 +564,7 @@ pub const Window = struct {
563 outputs: *std.ArrayListUnmanaged(*Output), 564 outputs: *std.ArrayListUnmanaged(*Output),
564 scale_generation: u64 = 0, 565 scale_generation: u64 = 0,
565 applied_buffer_scale: i32 = 1, 566 applied_buffer_scale: i32 = 1,
566 configured: bool = false, 567 state: SurfaceState,
567 should_close: bool = false, 568 should_close: bool = false,
568 width: u32 = 800, 569 width: u32 = 800,
569 height: u32 = 600, 570 height: u32 = 600,
@@ -681,6 +682,7 @@ pub const Connection = struct {
681 .xdg_toplevel = undefined, 682 .xdg_toplevel = undefined,
682 .tracker = &self.scale_tracker, 683 .tracker = &self.scale_tracker,
683 .outputs = &self.outputs, 684 .outputs = &self.outputs,
685 .state = .{ .tracker = &self.scale_tracker },
684 }; 686 };
685 errdefer window.surface.destroy(); 687 errdefer window.surface.destroy();
686 688
@@ -1054,7 +1056,7 @@ fn xdgSurfaceListener(surface: *xdg.Surface, event: xdg.Surface.Event, window: *
1054 switch (event) { 1056 switch (event) {
1055 .configure => |cfg| { 1057 .configure => |cfg| {
1056 surface.ackConfigure(cfg.serial); 1058 surface.ackConfigure(cfg.serial);
1057 window.configured = true; 1059 window.state.configured = true;
1058 }, 1060 },
1059 } 1061 }
1060 } 1062 }