Skip to content

RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process

scene graph plan, stage 4e (wip): owned pass only, legacy chrome deleted

oxydizer0e876c7e600e
diff --git a/src/Input.zig b/src/Input.zig
index 32dbf2a..f464ac6 100644
--- a/src/Input.zig
+++ b/src/Input.zig
@@ -975,10 +975,7 @@ pub fn finishSettlement(input: *Input, generation: u64) void {
if (session.generation == generation) {
const toplevel = session.toplevel;
input.resize_session = null;
- // Invalidations during the grab were deferred; sample even if this
- // settling commit reports no further edge damage.
- toplevel.pending_edge_sample = true;
- toplevel.syncChrome(true, false, Toplevel.nowMs()) catch {};
+ toplevel.syncChrome(false, Toplevel.nowMs()) catch {};
}
}
}
@@ -1575,10 +1572,7 @@ fn passthroughMotion(input: *Input, time_msec: u32) void {
const local = toplevel.frameLocal(input.cursor.x, input.cursor.y);
const has_control = toplevel.controlAt(hit_chrome.sx, hit_chrome.sy) != null or toplevel.tabAt(hit_chrome.sx, hit_chrome.sy) != .none;
toplevel.hoverTab(hit_chrome.sx, hit_chrome.sy);
- const radius: f32 = toplevel.cornerRadius();
- const footer = chrome.footerHeight(radius);
-
- if (resize.detectResizeEdges(local.x, local.y, toplevel.chrome_width, toplevel.chrome_height, toplevel.titlebarHeight(), chrome.frame_border, footer, has_control)) |edges| {
+ if (resize.detectResizeEdges(local.x, local.y, toplevel.chrome_width, toplevel.chrome_height, toplevel.titlebarHeight(), chrome.frame_border, chrome.frame_border, has_control)) |edges| {
input.hovered_resize_edges = edges;
input.setHover(toplevel, null);
input.setNamedCursor(edges.cursorName());
@@ -2077,9 +2071,7 @@ fn processClientButton(
if (button == btn_left) {
const local = res.toplevel.frameLocal(input.cursor.x, input.cursor.y);
const has_control = res.toplevel.controlAt(res.sx, res.sy) != null or res.toplevel.tabAt(res.sx, res.sy) != .none;
- const radius: f32 = res.toplevel.cornerRadius();
- const footer = chrome.footerHeight(radius);
- if (resize.detectResizeEdges(local.x, local.y, res.toplevel.chrome_width, res.toplevel.chrome_height, res.toplevel.titlebarHeight(), chrome.frame_border, footer, has_control)) |edges| {
+ if (resize.detectResizeEdges(local.x, local.y, res.toplevel.chrome_width, res.toplevel.chrome_height, res.toplevel.titlebarHeight(), chrome.frame_border, chrome.frame_border, has_control)) |edges| {
input.startResize(res.toplevel, edges.toWlr(), device, button);
return;
}
diff --git a/src/KdeDecoration.zig b/src/KdeDecoration.zig
index e772791..a80a239 100644
--- a/src/KdeDecoration.zig
+++ b/src/KdeDecoration.zig
@@ -156,5 +156,5 @@ fn handleDestroy(_: *Resource, self: *Decoration) void {
if (self.surface != null) self.surface_destroy.link.remove();
self.link.remove();
gpa.destroy(self);
- if (toplevel) |top| top.syncChrome(true, true, Toplevel.nowMs()) catch {};
+ if (toplevel) |top| top.syncChrome(true, Toplevel.nowMs()) catch {};
}
diff --git a/src/Server.zig b/src/Server.zig
index f64432e..e5ead5a 100644
--- a/src/Server.zig
+++ b/src/Server.zig
@@ -99,7 +99,7 @@ gpu_timer_used_ns: u64 = 0,
allocator: *wlr.Allocator,
scene: *wlr.Scene,
glass_engine: ?*glass.Engine = null,
-output_renderer: ?*scene_output_mod.Renderer = null,
+output_renderer: *scene_output_mod.Renderer = undefined,
// Set when wp_linux_drm_syncobj_v1 is advertised: release points for client
// buffers the glass and window capture passes read (see explicit_sync.c).
read_fence: ?*explicit_sync.ReadFence = null,
@@ -338,8 +338,17 @@ pub fn init(server: *Server, scale: ?f32, icon_theme_cfg: icon_theme.Config, io:
const backend = wlr.Backend.autocreate(wl_server.getEventLoop(), &session) catch return error.BackendCreateFailed;
errdefer backend.destroy();
- const renderer = wlr.Renderer.autocreate(backend) catch return error.RendererInitFailed;
+ const renderer = wlr.Renderer.autocreate(backend) catch {
+ log.err("init: no renderer (GLES2 is required; with several GPUs pick one with WLR_RENDER_DRM_DEVICE=/dev/dri/renderD*)", .{});
+ return error.RendererInitFailed;
+ };
errdefer renderer.destroy();
+ // The output pass is GLES2 only (docs/plans/scene-graph.md, renderer policy).
+ // A machine without a GPU runs Mesa's llvmpipe: WLR_RENDERER_ALLOW_SOFTWARE=1.
+ if (!renderer.isGles2()) {
+ log.err("init: RediWM needs the GLES2 renderer (set WLR_RENDERER=gles2; without a GPU also WLR_RENDERER_ALLOW_SOFTWARE=1)", .{});
+ return error.RendererInitFailed;
+ }
const renderer_name: []const u8 = if (renderer.isGles2()) "gles2" else if (renderer.isPixman()) "pixman" else "unknown";
startup.markRendererReady(renderer_name, scale orelse 1);
@@ -458,20 +467,16 @@ pub fn init(server: *Server, scale: ?f32, icon_theme_cfg: icon_theme.Config, io:
// measurements; every glass call already accepts a null engine.
server.glass_engine = if (environ.getPosix("REDIWM_NO_GLASS") != null) null else glass.Engine.create(renderer, wlr_allocator, scene, server.read_fence);
errdefer glass.Engine.destroy(server.glass_engine);
- if (loaded.compositor.scene_renderer == .owned) {
- server.output_renderer = scene_output_mod.Renderer.create(renderer) orelse return error.RendererInitFailed;
- log.info("scene renderer: owned GLES2 output pass", .{});
- // Rounded shapes are what lets the frame drop its CPU corners, skirt and
- // border rects. Decided here, before any window exists: the height of
- // every frame depends on it.
- if (server.output_renderer.?.enableShapes()) {
- @import("chrome.zig").analytic_frames = true;
- log.info("window frames: rounded shapes drawn by the output pass", .{});
- } else {
- log.warn("window frames: shaped programs unavailable, keeping CPU corners", .{});
- }
- }
+ server.output_renderer = scene_output_mod.Renderer.create(renderer) orelse return error.RendererInitFailed;
errdefer scene_output_mod.Renderer.destroy(server.output_renderer);
+ log.info("scene renderer: owned GLES2 output pass", .{});
+ // The window shapes: rounded clip, ring and shadow. Built here, before any
+ // window exists. Without them windows are square, with no ring or shadow.
+ if (server.output_renderer.enableShapes()) {
+ @import("chrome.zig").shapes = true;
+ } else {
+ log.err("window frames: shaped programs unavailable, windows are drawn square", .{});
+ }
server.outputs.init();
server.layer_surfaces.init();
try server.world.init(server, world_tree, world_view);
@@ -1047,18 +1052,14 @@ pub fn deinit(server: *Server) void {
log.info("compositor session teardown complete", .{});
}
-/// All output builds, including capture between frames, use the selected
-/// presenter and the same swapchain/damage history. Commits stay on Output.
+/// All output builds, including capture between frames, use the owned pass and
+/// the same swapchain/damage history. Commits stay on Output.
pub fn buildOutputState(server: *Server, output: *wlr.SceneOutput, state: *wlr.Output.State) bool {
- if (server.output_renderer) |renderer|
- return renderer.buildState(server.world.projection, output, state);
- return output.buildState(state, null);
+ return server.output_renderer.buildState(server.world.projection, output, state);
}
pub fn beginRenderPass(server: *Server, buffer: *wlr.Buffer, options: ?*const wlr.Renderer.BufferPassOptions) !*wlr.RenderPass {
- if (server.output_renderer) |renderer|
- return renderer.beginPass(buffer, options) orelse error.RenderPassFailed;
- return server.renderer.beginBufferPass(buffer, options);
+ return server.output_renderer.beginPass(buffer, options) orelse error.RenderPassFailed;
}
pub fn maxOutputScale(server: *Server) f32 {
@@ -1659,7 +1660,7 @@ fn handleIconWake(fd: c_int, mask: wl.EventMask, server: *Server) c_int {
const now = @import("Toplevel.zig").nowMs();
var toplevel_it = server.world.toplevels.iterator(.forward);
while (toplevel_it.next()) |toplevel| {
- toplevel.syncChrome(false, false, now) catch |err| {
+ toplevel.syncChrome(false, now) catch |err| {
log.warn("handleIconWake: syncChrome failed: {}", .{err});
};
}
diff --git a/src/Toplevel.zig b/src/Toplevel.zig
index c6d42cd..eb8b98e 100644
--- a/src/Toplevel.zig
+++ b/src/Toplevel.zig
@@ -142,14 +142,14 @@ backend: Backend,
// Keeping it separate lets the client remain entirely undecorated.
frame_tree: *wlr.SceneTree,
shadow_tree: *wlr.SceneTree,
-shadow_corners: [4]*wlr.SceneBuffer,
-shadow_edges: [4]*wlr.SceneBuffer,
-shadow_fallback: *wlr.SceneBuffer,
+// The analytic shadow's leaf: no buffer, only footprint, opacity and input.
+shadow_node: *wlr.SceneBuffer,
resize_grab: *wlr.SceneBuffer,
glass_effect: ?*glass.Effect = null,
titlebar_buffer: *wlr.SceneBuffer,
-footer_buffer: *wlr.SceneBuffer,
-side_fills: [2]*wlr.SceneRect,
+// Body under the border ring beside and below the client (left, right, bottom).
+frame_fills: [3]*wlr.SceneRect,
+// The outline of a window that draws its own decorations.
border_rects: [4]*wlr.SceneRect,
content_tree: *wlr.SceneTree,
scene_tree: *wlr.SceneTree,
@@ -235,28 +235,13 @@ hover_anim: anim.Anim = .{},
chip_pos: anim.Anim = .{},
chip_alpha: anim.Anim = .{ .property = .opacity },
last_painted_hover: f32 = 0,
-skirt_fill: ?[4]f32 = null,
/// The window opacity the border colour of the shape was last given, so a
/// hover or focus repaint keeps the ring as faded as the body.
shape_opacity: f32 = 1,
-edge_kind: chrome.EdgeSampleKind = .uninitialized,
-edge_mapping: ?chrome.EdgeMapping = null,
-pending_edge_sample: bool = false,
-edge_sampled_seq: u32 = 0,
-// `wlr_texture_preferred_read_format` binds the GL context and an FBO, so
-// it is asked once per client texture rather than on every commit.
-edge_format_texture: ?*wlr.Texture = null,
-edge_format: u32 = 0,
-edge_row_scratch: []u32 = &.{},
-// Explicit-sync clients commit before their GPU finishes the buffer; a sample
-// of an unsignalled buffer is retried from here once it signals.
-edge_acquire_wait: ?*explicit_sync.AcquireWait = null,
// Inputs that produced the buffers currently attached to the scene nodes.
// syncChrome / syncShadow skip a re-raster when these still match.
last_titlebar: ?chrome.TitlebarMemo = null,
-last_footer: ?chrome.FooterMemo = null,
cached_titlebar: ?*chrome.ChromeBuffer = null,
-cached_footer: ?*chrome.ChromeBuffer = null,
last_shadow: ?chrome.ShadowMemo = null,
// xdg-shell has no minimized state of its own; this is purely a
// compositor-side hint that hides the frame while the client stays mapped.
@@ -307,14 +292,11 @@ pub const RestoreGeometry = @import("undo.zig").Geometry;
const ChromeNodes = struct {
frame_tree: *wlr.SceneTree,
shadow_tree: *wlr.SceneTree,
- shadow_corners: [4]*wlr.SceneBuffer,
- shadow_edges: [4]*wlr.SceneBuffer,
- shadow_fallback: *wlr.SceneBuffer,
+ shadow_node: *wlr.SceneBuffer,
resize_grab: *wlr.SceneBuffer,
glass_effect: ?*glass.Effect,
titlebar_buffer: *wlr.SceneBuffer,
- footer_buffer: *wlr.SceneBuffer,
- side_fills: [2]*wlr.SceneRect,
+ frame_fills: [3]*wlr.SceneRect,
border_rects: [4]*wlr.SceneRect,
content_tree: *wlr.SceneTree,
};
@@ -341,33 +323,17 @@ fn createChromeNodes(server: *Server) !ChromeNodes {
const shadow_tree = try frame_tree.createSceneTree();
// The shadow is outside the shape by definition.
_ = @import("projection.zig").setTreeUnclipped(&shadow_tree.node, true);
- var shadow_corners: [4]*wlr.SceneBuffer = undefined;
- for (&shadow_corners) |*buf| {
- buf.* = try shadow_tree.createSceneBuffer(null);
- buf.*.point_accepts_input = chromeAcceptsInput;
- }
-
- var shadow_edges: [4]*wlr.SceneBuffer = undefined;
- for (&shadow_edges) |*buf| {
- buf.* = try shadow_tree.createSceneBuffer(null);
- buf.*.point_accepts_input = chromeAcceptsInput;
- buf.*.setFilterMode(.bilinear);
- }
-
- const shadow_fallback = try shadow_tree.createSceneBuffer(null);
- shadow_fallback.point_accepts_input = chromeAcceptsInput;
+ const shadow_node = try shadow_tree.createSceneBuffer(null);
+ shadow_node.point_accepts_input = chromeAcceptsInput;
const titlebar_buffer = try frame_tree.createSceneBuffer(null);
const glass_effect = glass.Engine.attach(server.glass_engine, titlebar_buffer, &shadow_tree.node, .titlebar);
titlebar_buffer.setFilterMode(.bilinear);
- const footer_buffer = try frame_tree.createSceneBuffer(null);
- footer_buffer.setFilterMode(.nearest);
-
- // The title/footer buffers already back their borders with a fill. Carry
- // that same chrome underneath the stroke beside the client, too.
- var side_fills: [2]*wlr.SceneRect = undefined;
- for (&side_fills) |*rect| {
+ // The titlebar backs the ring at the top with its fill. Carry that same
+ // chrome under the ring beside and below the client.
+ var frame_fills: [3]*wlr.SceneRect = undefined;
+ for (&frame_fills) |*rect| {
rect.* = try col.createRect(frame_tree, 1, 1, chrome.fillColor());
}
const border_color = chrome.borderColor(0);
@@ -380,14 +346,11 @@ fn createChromeNodes(server: *Server) !ChromeNodes {
return .{
.frame_tree = frame_tree,
.shadow_tree = shadow_tree,
- .shadow_corners = shadow_corners,
- .shadow_edges = shadow_edges,
- .shadow_fallback = shadow_fallback,
+ .shadow_node = shadow_node,
.resize_grab = resize_grab,
.glass_effect = glass_effect,
.titlebar_buffer = titlebar_buffer,
- .footer_buffer = footer_buffer,
- .side_fills = side_fills,
+ .frame_fills = frame_fills,
.border_rects = border_rects,
.content_tree = content_tree,
};
@@ -396,20 +359,16 @@ fn createChromeNodes(server: *Server) !ChromeNodes {
fn finishCreate(toplevel: *Toplevel, nodes: ChromeNodes, scene_tree: *wlr.SceneTree) void {
toplevel.frame_tree = nodes.frame_tree;
toplevel.shadow_tree = nodes.shadow_tree;
- toplevel.shadow_corners = nodes.shadow_corners;
- toplevel.shadow_edges = nodes.shadow_edges;
- toplevel.shadow_fallback = nodes.shadow_fallback;
+ toplevel.shadow_node = nodes.shadow_node;
toplevel.resize_grab = nodes.resize_grab;
toplevel.glass_effect = nodes.glass_effect;
toplevel.titlebar_buffer = nodes.titlebar_buffer;
- toplevel.footer_buffer = nodes.footer_buffer;
- toplevel.side_fills = nodes.side_fills;
+ toplevel.frame_fills = nodes.frame_fills;
toplevel.border_rects = nodes.border_rects;
toplevel.content_tree = nodes.content_tree;
toplevel.scene_tree = scene_tree;
toplevel.attachSceneData();
nodes.titlebar_buffer.point_accepts_input = chromeAcceptsInput;
- nodes.footer_buffer.point_accepts_input = footerAcceptsInput;
}
pub fn create(server: *Server, xdg_toplevel: *wlr.XdgToplevel) !void {
@@ -431,14 +390,11 @@ pub fn create(server: *Server, xdg_toplevel: *wlr.XdgToplevel) !void {
} },
.frame_tree = nodes.frame_tree,
.shadow_tree = nodes.shadow_tree,
- .shadow_corners = nodes.shadow_corners,
- .shadow_edges = nodes.shadow_edges,
- .shadow_fallback = nodes.shadow_fallback,
+ .shadow_node = nodes.shadow_node,
.resize_grab = nodes.resize_grab,
.glass_effect = nodes.glass_effect,
.titlebar_buffer = nodes.titlebar_buffer,
- .footer_buffer = nodes.footer_buffer,
- .side_fills = nodes.side_fills,
+ .frame_fills = nodes.frame_fills,
.border_rects = nodes.border_rects,
.content_tree = nodes.content_tree,
.scene_tree = scene_tree,
@@ -476,14 +432,11 @@ pub fn createXwayland(server: *Server, xsurface: *wlr.XwaylandSurface) !void {
.fullscreen = xsurface.fullscreen,
.frame_tree = nodes.frame_tree,
.shadow_tree = nodes.shadow_tree,
- .shadow_corners = nodes.shadow_corners,
- .shadow_edges = nodes.shadow_edges,
- .shadow_fallback = nodes.shadow_fallback,
+ .shadow_node = nodes.shadow_node,
.resize_grab = nodes.resize_grab,
.glass_effect = nodes.glass_effect,
.titlebar_buffer = nodes.titlebar_buffer,
- .footer_buffer = nodes.footer_buffer,
- .side_fills = nodes.side_fills,
+ .frame_fills = nodes.frame_fills,
.border_rects = nodes.border_rects,
.content_tree = nodes.content_tree,
.scene_tree = scene_tree,
@@ -611,14 +564,11 @@ pub fn createPlaceholder(
.rules_resolved = true,
.frame_tree = nodes.frame_tree,
.shadow_tree = nodes.shadow_tree,
- .shadow_corners = nodes.shadow_corners,
- .shadow_edges = nodes.shadow_edges,
- .shadow_fallback = nodes.shadow_fallback,
+ .shadow_node = nodes.shadow_node,
.resize_grab = nodes.resize_grab,
.glass_effect = nodes.glass_effect,
.titlebar_buffer = nodes.titlebar_buffer,
- .footer_buffer = nodes.footer_buffer,
- .side_fills = nodes.side_fills,
+ .frame_fills = nodes.frame_fills,
.border_rects = nodes.border_rects,
.content_tree = nodes.content_tree,
.scene_tree = scene_tree,
@@ -643,7 +593,7 @@ pub fn createPlaceholder(
toplevel.maximized = true;
if (target_out) |out| {
const usable = out.usableBox();
- const footer = chrome.footerHeight(0);
+ const footer = chrome.frame_border;
const mw = usable.width - 2 * chrome.frame_border;
const mh = usable.height - toplevel.titlebarHeight() - footer;
toplevel.backend.placeholder.client_width = @max(1, mw);
@@ -654,8 +604,7 @@ pub fn createPlaceholder(
toplevel.placed = true;
}
} else if (target_out) |out| {
- const radius: f32 = toplevel.cornerRadius();
- const footer = chrome.footerHeight(radius);
+ const footer = chrome.frame_border;
const natural_w = init_w + 2 * chrome.frame_border;
const natural_h = init_h + toplevel.titlebarHeight() + footer;
const geom = pickInitialPlacement(server, out, open_rules, null, natural_w, natural_h);
@@ -663,7 +612,7 @@ pub fn createPlaceholder(
toplevel.placed = true;
}
- try toplevel.syncChrome(false, true, nowMs());
+ try toplevel.syncChrome(true, nowMs());
server.world.toplevels.prepend(toplevel);
toplevel.in_world = true;
@@ -724,14 +673,11 @@ pub fn createShell(server: *Server, cc: *ControlCenter, width: i32, height: i32)
} },
.frame_tree = nodes.frame_tree,
.shadow_tree = nodes.shadow_tree,
- .shadow_corners = nodes.shadow_corners,
- .shadow_edges = nodes.shadow_edges,
- .shadow_fallback = nodes.shadow_fallback,
+ .shadow_node = nodes.shadow_node,
.resize_grab = nodes.resize_grab,
.glass_effect = nodes.glass_effect,
.titlebar_buffer = nodes.titlebar_buffer,
- .footer_buffer = nodes.footer_buffer,
- .side_fills = nodes.side_fills,
+ .frame_fills = nodes.frame_fills,
.border_rects = nodes.border_rects,
.content_tree = nodes.content_tree,
.scene_tree = scene_tree,
@@ -1154,7 +1100,7 @@ pub fn setActivated(toplevel: *Toplevel, activated: bool) void {
.placeholder => {},
.shell => |*sw| if (sw.control_center) |cc| cc.setActivated(activated),
}
- if (changed and toplevel.in_world) toplevel.syncChrome(false, false, nowMs()) catch |err| {
+ if (changed and toplevel.in_world) toplevel.syncChrome(false, nowMs()) catch |err| {
log.warn("activation: could not repaint title: {}", .{err});
};
}
@@ -1218,7 +1164,7 @@ pub fn requestSize(toplevel: *Toplevel, width: i32, height: i32) ConfigureWait {
.placeholder => |*ph| {
ph.client_width = width;
ph.client_height = height;
- toplevel.syncChrome(false, true, nowMs()) catch {};
+ toplevel.syncChrome(true, nowMs()) catch {};
return .none;
},
.shell => |*sw| {
@@ -1227,7 +1173,7 @@ pub fn requestSize(toplevel: *Toplevel, width: i32, height: i32) ConfigureWait {
if (sw.control_center) |cc| cc.resize(sw.client_width, sw.client_height);
toplevel.positionDuringResize();
// Shell windows have no client commit to update their shadow.
- toplevel.syncChrome(false, true, nowMs()) catch {};
+ toplevel.syncChrome(true, nowMs()) catch {};
return .none;
},
};
@@ -1301,17 +1247,10 @@ fn attachSceneData(toplevel: *Toplevel) void {
toplevel.chrome_data = .{ .role = .{ .chrome = toplevel } };
scene_data.SceneData.attach(&toplevel.frame_data, &toplevel.frame_tree.node);
scene_data.SceneData.attach(&toplevel.chrome_data, &toplevel.shadow_tree.node);
- for (toplevel.shadow_corners) |buf| {
- scene_data.SceneData.attach(&toplevel.chrome_data, &buf.node);
- }
- for (toplevel.shadow_edges) |buf| {
- scene_data.SceneData.attach(&toplevel.chrome_data, &buf.node);
- }
- scene_data.SceneData.attach(&toplevel.chrome_data, &toplevel.shadow_fallback.node);
+ scene_data.SceneData.attach(&toplevel.chrome_data, &toplevel.shadow_node.node);
scene_data.SceneData.attach(&toplevel.chrome_data, &toplevel.resize_grab.node);
scene_data.SceneData.attach(&toplevel.chrome_data, &toplevel.titlebar_buffer.node);
- scene_data.SceneData.attach(&toplevel.chrome_data, &toplevel.footer_buffer.node);
- for (toplevel.side_fills) |rect| {
+ for (toplevel.frame_fills) |rect| {
scene_data.SceneData.attach(&toplevel.chrome_data, &rect.node);
}
for (toplevel.border_rects) |rect| {
@@ -1561,7 +1500,7 @@ pub fn requestSizeAnimated(toplevel: *Toplevel, width: i32, height: i32) Configu
fn chromeSizeForClient(toplevel: *const Toplevel, client_w: i32, client_h: i32) struct { w: i32, h: i32 } {
if (!toplevel.hasServerDecorations()) return .{ .w = client_w, .h = client_h };
- const footer = chrome.footerHeight(toplevel.cornerRadius());
+ const footer = chrome.frame_border;
return .{
.w = client_w + 2 * chrome.frame_border,
.h = client_h + toplevel.titlebarHeight() + footer,
@@ -1655,7 +1594,7 @@ pub fn tickSize(toplevel: *Toplevel, now_ms: i64) bool {
const w_changed = toplevel.size_w.sampleChanged(now_ms, quantum);
const h_changed = toplevel.size_h.sampleChanged(now_ms, quantum);
if (w_changed or h_changed) {
- toplevel.syncChrome(false, true, now_ms) catch |err| {
+ toplevel.syncChrome(true, now_ms) catch |err| {
log.err("tickSize: could not update window decoration: {}", .{err});
};
}
@@ -1736,7 +1675,7 @@ fn applySizeClip(toplevel: *Toplevel) void {
const decorated = toplevel.hasServerDecorations();
const cw = if (decorated) @max(toplevel.chrome_width - 2 * chrome.frame_border, 0) else toplevel.chrome_width;
const ch = if (decorated)
- @max(toplevel.chrome_height - toplevel.titlebarHeight() - chrome.footerHeight(toplevel.cornerRadius()), 0)
+ @max(toplevel.chrome_height - toplevel.titlebarHeight() - chrome.frame_border, 0)
else
toplevel.chrome_height;
const n = toplevel.surfaceScale();
@@ -1888,7 +1827,7 @@ fn borderColor(toplevel: *const Toplevel) col.Premul {
pub fn footerHeight(toplevel: *const Toplevel) i32 {
if (!toplevel.hasServerDecorations()) return 0;
- return chrome.footerHeight(toplevel.cornerRadius());
+ return chrome.frame_border;
}
pub fn frameLocal(toplevel: *const Toplevel, lx: f64, ly: f64) geometry.Vec2 {
@@ -1969,7 +1908,7 @@ pub fn finishZoomAnimation(toplevel: *Toplevel) void {
const target_x = toplevel.zoom_anchor.x - toplevel.zoom_local.x * target_ws;
const target_y = toplevel.zoom_anchor.y - toplevel.zoom_local.y * target_ws;
toplevel.setPosition(@intFromFloat(@round(target_x)), @intFromFloat(@round(target_y)));
- toplevel.syncChrome(false, false, nowMs()) catch {};
+ toplevel.syncChrome(false, nowMs()) catch {};
}
pub fn tickZoom(toplevel: *Toplevel, now_ms: i64) bool {
@@ -1991,7 +1930,7 @@ pub fn tickZoom(toplevel: *Toplevel, now_ms: i64) bool {
if (settled) {
toplevel.zoom_anim = .{ .from = @floatCast(target_scale), .to = @floatCast(target_scale) };
toplevel.setPosition(@intFromFloat(@round(nx)), @intFromFloat(@round(ny)));
- toplevel.syncChrome(false, false, now_ms) catch {};
+ toplevel.syncChrome(false, now_ms) catch {};
toplevel.server.input.processCursorMotion(0);
return false;
} else {
@@ -2131,7 +2070,7 @@ pub fn handleSurfaceCommit(toplevel: *Toplevel) void {
}
}
- toplevel.syncChrome(true, true, nowMs()) catch |err| {
+ toplevel.syncChrome(true, nowMs()) catch |err| {
log.err("handleCommit: could not update window decoration: {}", .{err});
};
if (toplevel.in_world) if (toplevel.server.layout_autosave) |autosave| {
@@ -2141,7 +2080,7 @@ pub fn handleSurfaceCommit(toplevel: *Toplevel) void {
@import("auto_tiling.zig").observe(toplevel);
toplevel.server.window_tabs.reconcile(toplevel);
if (toplevel.tab_hidden) {
- if (@import("window_tabs.zig").active(toplevel.server, toplevel.tab_group)) |active_tab| active_tab.syncChrome(false, false, nowMs()) catch {};
+ if (@import("window_tabs.zig").active(toplevel.server, toplevel.tab_group)) |active_tab| active_tab.syncChrome(false, nowMs()) catch {};
}
if (toplevel.isMapped()) {
toplevel.syncForeign();
@@ -2158,8 +2097,7 @@ pub fn handleMapped(toplevel: *Toplevel) void {
if (toplevel.closing) toplevel.cancelClose();
toplevel.minimized = false;
toplevel.needs_attention = false;
- toplevel.pending_edge_sample = true;
- toplevel.syncChrome(true, true, nowMs()) catch |err| {
+ toplevel.syncChrome(true, nowMs()) catch |err| {
log.err("handleMap: could not update window decoration: {}", .{err});
};
@@ -2312,7 +2250,7 @@ pub fn handleMapped(toplevel: *Toplevel) void {
toplevel.server.window_tabs.mapped(toplevel);
toplevel.server.window_tabs.mappedToken(toplevel);
if (toplevel.server.layout_autosave) |autosave| autosave.finishMapped(toplevel);
- toplevel.syncChrome(false, false, nowMs()) catch {};
+ toplevel.syncChrome(false, nowMs()) catch {};
toplevel.frame_tree.node.setEnabled(@import("window_tabs.zig").visible(toplevel));
// A newly focused app must not open behind the camera's current depth.
if (want_focus and toplevel.server.config.compositor.focus_zoom == .camera) {
@@ -2338,7 +2276,6 @@ pub fn handleUnmapped(toplevel: *Toplevel) void {
toplevel.in_world = false;
toplevel.needs_attention = false;
toplevel.detachInput();
- toplevel.resetEdgeSample();
const keep_scene = if (was_tab or !@import("workspaces.zig").visible(toplevel)) false else toplevel.beginCloseAnimation();
if (!keep_scene) {
toplevel.clearChromeCache();
@@ -2487,15 +2424,12 @@ pub fn destroyNow(toplevel: *Toplevel) void {
}
toplevel.clearChromeCache();
toplevel.frame_tree.node.destroy();
- if (toplevel.edge_row_scratch.len != 0) gpa.free(toplevel.edge_row_scratch);
- explicit_sync.AcquireWait.destroy(toplevel.edge_acquire_wait);
toplevel.releaseIcon();
gpa.destroy(toplevel);
}
-// Both chrome bands are cut from the same rounded rectangle, so a point is
-// theirs only if it falls inside the frame's shape. The coordinates are
-// frame-local: the skirt's node knows its own offset.
+// A point is the frame's only if it falls inside the window's shape. The
+// coordinates are frame-local.
fn insideFrame(toplevel: *Toplevel, px: f32, py: f32) bool {
if (!toplevel.hasServerDecorations()) return false;
const width = toplevel.chrome_width;
@@ -2539,11 +2473,8 @@ pub fn chromeAcceptsInput(buffer: *wlr.SceneBuffer, sx: *f64, sy: *f64) callconv
var fy: i32 = 0;
_ = toplevel.frame_tree.node.coords(&fx, &fy);
const local = geometry.toLocal(@as(f64, @floatFromInt(ox)) + sx.*, @as(f64, @floatFromInt(oy)) + sy.*, fx, fy);
- const radius: f32 = toplevel.cornerRadius();
- const footer = chrome.footerHeight(radius);
-
const has_control = toplevel.controlAt(local.x, local.y) != null or toplevel.tabAt(local.x, local.y) != .none;
- if (resize.detectResizeEdges(local.x, local.y, toplevel.chrome_width, toplevel.chrome_height, toplevel.titlebarHeight(), chrome.frame_border, footer, has_control) != null) {
+ if (resize.detectResizeEdges(local.x, local.y, toplevel.chrome_width, toplevel.chrome_height, toplevel.titlebarHeight(), chrome.frame_border, chrome.frame_border, has_control) != null) {
return true;
}
@@ -2554,212 +2485,7 @@ pub fn chromeAcceptsInput(buffer: *wlr.SceneBuffer, sx: *f64, sy: *f64) callconv
return local.y < @as(f64, @floatFromInt(toplevel.titlebarHeight()));
}
-pub fn footerAcceptsInput(buffer: *wlr.SceneBuffer, sx: *f64, sy: *f64) callconv(.c) bool {
- const data = scene_data.SceneData.fromNode(&buffer.node) orelse return false;
- if (data.role == .chrome and data.role.chrome.closing) return false;
- const toplevel = switch (data.role) {
- .chrome => |t| t,
- else => return false,
- };
- const radius: f32 = toplevel.cornerRadius();
- const footer_top: f32 = @floatFromInt(toplevel.chrome_height - chrome.footerHeight(radius));
- const px = @as(f32, @floatCast(sx.*)) + 0.5;
- const py = footer_top + @as(f32, @floatCast(sy.*)) + 0.5;
- return toplevel.insideFrame(px, py);
-}
-
-const EdgeProbe = struct {
- mapping: chrome.EdgeMapping,
- texture: ?*wlr.Texture,
- row: wlr.Box,
-};
-
-fn resetEdgeSample(toplevel: *Toplevel) void {
- toplevel.skirt_fill = null;
- toplevel.edge_kind = .uninitialized;
- toplevel.edge_mapping = null;
- toplevel.pending_edge_sample = true;
- toplevel.edge_sampled_seq = 0;
- toplevel.edge_format_texture = null;
- explicit_sync.AcquireWait.cancel(toplevel.edge_acquire_wait);
-}
-
-// glReadPixels does not wait for the client's acquire point, so reading an
-// explicit-sync buffer early samples stale or half-drawn pixels.
-fn edgeAcquireReady(toplevel: *Toplevel, owned: *wlr.Surface) bool {
- if (!explicit_sync.surfaceUsesIt(owned)) {
- explicit_sync.AcquireWait.cancel(toplevel.edge_acquire_wait);
- return true;
- }
- if (toplevel.edge_acquire_wait == null) {
- toplevel.edge_acquire_wait = explicit_sync.AcquireWait.create(toplevel.server.wl_server.getEventLoop(), handleEdgeAcquired, toplevel);
- }
- return explicit_sync.AcquireWait.ready(toplevel.edge_acquire_wait, owned);
-}
-
-fn handleEdgeAcquired(data: ?*anyopaque) callconv(.c) void {
- const toplevel: *Toplevel = @ptrCast(@alignCast(data.?));
- if (!toplevel.in_world or toplevel.backend_gone) return;
- toplevel.pending_edge_sample = true;
- toplevel.syncChrome(true, false, nowMs()) catch {};
-}
-
-// A client texture keeps its format for its lifetime: a buffer that changes
-// format gets a new texture, created before the old one is released, so two
-// consecutive commits never see different textures at one address.
-fn readFormat(toplevel: *Toplevel, texture: *wlr.Texture) u32 {
- if (toplevel.edge_format_texture != texture) {
- toplevel.edge_format_texture = texture;
- toplevel.edge_format = texture.preferredReadFormat();
- }
- return toplevel.edge_format;
-}
-
-// Locates the client's last row of pixels in its buffer. The surface's logical
-// size, its buffer size and the window's geometry can all differ (buffer scale,
-// a viewport, a geometry that is a sub-box of the surface), so the row is
-// derived from the surface's own source box rather than assumed.
-fn probeClientEdge(toplevel: *Toplevel) EdgeProbe {
- const owned = toplevel.surface() orelse return .{
- .mapping = .{},
- .texture = null,
- .row = .{ .x = 0, .y = 0, .width = 0, .height = 0 },
- };
- const state = &owned.current;
- const texture = if (@import("extra_protocols.zig").rediwm_surface_edge_is_srgb(owned)) owned.getTexture() else null;
- const geometry_box = toplevel.clientSurfaceGeometry();
-
- var source: wlr.FBox = .{ .x = 0, .y = 0, .width = 0, .height = 0 };
- owned.getBufferSourceBox(&source);
-
- var mapping = chrome.EdgeMapping{
- .source_x = source.x,
- .source_y = source.y,
- .source_w = source.width,
- .source_h = source.height,
- .scale = state.scale,
- .transform_normal = state.transform == .normal,
- .buffer_width = state.buffer_width,
- .buffer_height = state.buffer_height,
- .format = if (texture) |tex| toplevel.readFormat(tex) else 0,
- .surface_width = state.width,
- .surface_height = state.height,
- .geom_x = geometry_box.x,
- .geom_y = geometry_box.y,
- .geom_w = geometry_box.width,
- .geom_h = geometry_box.height,
- .has_texture = texture != null,
- };
-
- var row = wlr.Box{ .x = 0, .y = 0, .width = 0, .height = 0 };
- // A rotated or flipped buffer has no "bottom row" to speak of; those
- // windows keep the glass fill.
- if (mapping.transform_normal and texture != null and state.width > 0 and state.height > 0 and
- source.width > 0 and source.height > 0)
- {
- const tex = texture.?;
- const per_x = source.width / @as(f64, @floatFromInt(state.width));
- const per_y = source.height / @as(f64, @floatFromInt(state.height));
-
- const left = source.x + @as(f64, @floatFromInt(geometry_box.x)) * per_x;
- const right = left + @as(f64, @floatFromInt(geometry_box.width)) * per_x;
- const bottom = source.y + @as(f64, @floatFromInt(geometry_box.y + geometry_box.height)) * per_y;
-
- const max_x: i32 = @intCast(tex.width);
- const max_y: i32 = @intCast(tex.height);
- if (max_x > 0 and max_y > 0) {
- const x0 = std.math.clamp(@as(i32, @intFromFloat(@floor(left))), 0, max_x - 1);
- const x1 = std.math.clamp(@as(i32, @intFromFloat(@ceil(right))), x0 + 1, max_x);
- const y = std.math.clamp(@as(i32, @intFromFloat(@ceil(bottom))) - 1, 0, max_y - 1);
- row = .{ .x = x0, .y = y, .width = x1 - x0, .height = 1 };
- mapping.row_x = row.x;
- mapping.row_y = row.y;
- mapping.row_w = row.width;
- mapping.row_h = row.height;
- mapping.row_valid = row.width > 0 and row.height > 0;
- }
- }
-
- return .{ .mapping = mapping, .texture = texture, .row = row };
-}
-
-fn classifyEdgeDamage(toplevel: *Toplevel, row: wlr.Box, row_valid: bool) chrome.EdgeDamage {
- if (!row_valid) return .unknown;
- const owned = toplevel.surface() orelse return .unknown;
- const region = &owned.buffer_damage;
- if (!region.notEmpty()) return .none;
- for (region.rectangles()) |box| {
- if (chrome.rectsOverlap(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1, row.x, row.y, row.width, row.height)) {
- return .intersects_row;
- }
- }
- return .misses_row;
-}
-
-fn applyEdgeSample(toplevel: *Toplevel) void {
- const owned = toplevel.surface() orelse return;
- const seq = owned.current.seq;
- if (seq != 0 and toplevel.edge_sampled_seq == seq) return;
-
- const probe = toplevel.probeClientEdge();
- const damage = toplevel.classifyEdgeDamage(probe.row, probe.mapping.row_valid);
- const action = chrome.decideEdgeSample(
- toplevel.edge_kind,
- toplevel.edge_mapping,
- probe.mapping,
- damage,
- toplevel.pending_edge_sample,
- );
-
- if (toplevel.isResizing()) {
- if (action != .skip) {
- toplevel.pending_edge_sample = true;
- stats.recordEdgeSampleSkip();
- }
- return;
- }
-
- switch (action) {
- .skip => stats.recordEdgeSampleSkip(),
- .fallback => {
- toplevel.skirt_fill = null;
- toplevel.edge_kind = .fallback;
- toplevel.edge_mapping = probe.mapping;
- toplevel.pending_edge_sample = false;
- toplevel.edge_sampled_seq = seq;
- },
- .sample => {
- if (!toplevel.edgeAcquireReady(owned)) {
- toplevel.pending_edge_sample = true;
- stats.recordEdgeSampleSkip();
- return;
- }
- stats.recordEdgeSampleAttempt();
- const started = stats.nowNs();
- const color = if (probe.texture) |tex|
- chrome.sampleEdge(tex, probe.row, &toplevel.edge_row_scratch)
- else
- null;
- const elapsed = stats.nowNs() -% started;
- if (color) |fill| {
- stats.recordEdgeSampleSuccess(elapsed);
- toplevel.skirt_fill = fill;
- toplevel.edge_kind = .color;
- } else {
- // Transient read failure: show glass, retry on the next
- // invalidating commit rather than every frame.
- toplevel.skirt_fill = null;
- toplevel.edge_kind = .fallback;
- }
- toplevel.edge_mapping = probe.mapping;
- toplevel.pending_edge_sample = false;
- toplevel.edge_sampled_seq = seq;
- },
- }
-}
-
-/// Repaint theme-dependent chrome without reading the client texture again.
-/// `rebuild_shadow` is true here: a theme edit can change the shadow's
+/// Repaint theme-dependent chrome. `rebuild_shadow` is true here: a theme edit can change the shadow's
/// color/size, so already-open windows must pick it up immediately, same as
/// border/titlebar colors already do.
pub fn refreshTheme(toplevel: *Toplevel) void {
@@ -2770,7 +2496,7 @@ pub fn refreshTheme(toplevel: *Toplevel) void {
.shell => |*sw| if (sw.control_center) |cc| cc.requestRepaint(),
else => {},
}
- syncChrome(toplevel, false, true, nowMs()) catch |err| {
+ syncChrome(toplevel, true, nowMs()) catch |err| {
log.warn("refreshTheme: could not rebuild chrome: {}", .{err});
};
// A changed titlebar height must keep tiled frames inside their tile.
@@ -2781,10 +2507,6 @@ pub fn refreshTheme(toplevel: *Toplevel) void {
}
}
-// `rebuild_shadow` is kept separate from `sample_edge`: both are false on a
-// pure hover repaint, but a theme refresh needs sample_edge=false (no new
-// client content to sample) and rebuild_shadow=true (theme may have
-// changed) — the two aren't the same signal.
/// Keeps `IconService`'s refcount in sync with whatever icon this titlebar
/// last displayed (`toplevel.last_titlebar.?.icon`), so a future eviction
/// pass can tell a live titlebar's icon apart from an unreferenced one.
@@ -2828,37 +2550,33 @@ pub fn syncOutputScale(toplevel: *Toplevel) void {
}
if (scale == 0 or scale == toplevel.render_scale) return;
toplevel.render_scale = scale;
- toplevel.syncChrome(false, true, nowMs()) catch |err| {
+ toplevel.syncChrome(true, nowMs()) catch |err| {
log.warn("output scale: could not rebuild chrome: {}", .{err});
};
}
fn clearChromeCache(toplevel: *Toplevel) void {
if (toplevel.cached_titlebar) |buffer| buffer.base.drop();
- if (toplevel.cached_footer) |buffer| buffer.base.drop();
toplevel.cached_titlebar = null;
- toplevel.cached_footer = null;
}
-pub fn syncChrome(toplevel: *Toplevel, sample_edge: bool, rebuild_shadow: bool, now_ms: i64) !void {
+/// `rebuild_shadow` is false on a pure hover repaint, which cannot change the
+/// shadow; geometry and theme changes pass true.
+pub fn syncChrome(toplevel: *Toplevel, rebuild_shadow: bool, now_ms: i64) !void {
defer toplevel.server.scheduleFrames();
const geometry_box = toplevel.clientGeometry();
if (geometry_box.width <= 0 or geometry_box.height <= 0) return;
const decorated = toplevel.hasServerDecorations();
toplevel.titlebar_buffer.node.setEnabled(decorated);
- toplevel.footer_buffer.node.setEnabled(decorated);
- for (toplevel.side_fills) |rect| rect.node.setEnabled(decorated);
- // With a shape the border is the shader's; the rects only outline windows
- // that draw their own decorations.
- const shaped = chrome.analytic_frames and decorated;
- for (toplevel.border_rects) |rect| rect.node.setEnabled(!shaped and (decorated or toplevel.hasWorkspaceFocusBorder()));
+ for (toplevel.frame_fills) |rect| rect.node.setEnabled(decorated);
+ // A decorated window's border is the shape's ring; the rects only outline
+ // windows that draw their own decorations.
+ for (toplevel.border_rects) |rect| rect.node.setEnabled(!decorated and toplevel.hasWorkspaceFocusBorder());
if (!decorated) {
- toplevel.resetEdgeSample();
toplevel.releaseIcon();
toplevel.clearChromeCache();
toplevel.last_titlebar = null;
- toplevel.last_footer = null;
toplevel.shadow_tree.node.setEnabled(false);
toplevel.resize_grab.node.setEnabled(false);
toplevel.content_tree.node.setPosition(0, 0);
@@ -2877,9 +2595,8 @@ pub fn syncChrome(toplevel: *Toplevel, sample_edge: bool, rebuild_shadow: bool,
}
const radius: f32 = toplevel.cornerRadius();
- const footer = chrome.footerHeight(radius);
const natural_w = geometry_box.width + 2 * chrome.frame_border;
- const natural_h = geometry_box.height + toplevel.titlebarHeight() + footer;
+ const natural_h = geometry_box.height + toplevel.titlebarHeight() + chrome.frame_border;
const animated = visualChromeSize(toplevel, now_ms, natural_w, natural_h);
const width = animated.w;
const height = animated.h;
@@ -2891,23 +2608,16 @@ pub fn syncChrome(toplevel: *Toplevel, sample_edge: bool, rebuild_shadow: bool,
.pending, .missing => null,
};
toplevel.updateHeldIcon(icon);
- // A shape clips the client itself, so there is no skirt to colour.
- if (sample_edge and !chrome.analytic_frames) toplevel.applyEdgeSample();
- // The settings body is one opaque colour: the skirt continues it exactly.
- if (toplevel.backend == .shell and !chrome.analytic_frames) toplevel.skirt_fill = @import("control_center/panel.zig").bodyColor();
const hover = toplevel.hover_anim.value(now_ms);
const chip_alpha = toplevel.chip_alpha.value(now_ms);
var tab_storage: [@import("window_tabs.zig").max_tabs]@import("chrome_tabs.zig").Tab = undefined;
const state: chrome.ChromeState = .{
.tabs = toplevel.tabStrip(&tab_storage),
- // The shader draws the corners and the border; the raster is a plain band.
- .radius = if (chrome.analytic_frames) 0 else radius,
.active = toplevel.activated,
.workspace_focus = toplevel.hasWorkspaceFocusBorder(),
.maximized = toplevel.isMaximized(),
.density = toplevel.chromeDensity(),
.title = window_title,
- .skirt_fill = toplevel.skirt_fill,
.scale = toplevel.render_scale,
.hover = hover,
// An invisible chip has no position: keeps the raster memo stable.
@@ -2920,38 +2630,21 @@ pub fn syncChrome(toplevel: *Toplevel, sample_edge: bool, rebuild_shadow: bool,
toplevel.chrome_height = height;
const title_memo = chrome.TitlebarMemo.capture(width, height, toplevel.titlePtr(), state);
- const footer_memo = chrome.FooterMemo.capture(width, height, state);
const skip_titlebar = if (toplevel.last_titlebar) |prev| prev.eql(title_memo) else false;
- const skip_footer = if (toplevel.last_footer) |prev| prev.eql(footer_memo) else false;
if (!skip_titlebar) {
const titlebar = if (toplevel.cached_titlebar != null and toplevel.last_titlebar != null and toplevel.last_titlebar.?.reusableFor(title_memo))
try chrome.ChromeBuffer.createUpdated(toplevel.cached_titlebar.?, state, toplevel.last_titlebar.?.title_ptr != title_memo.title_ptr)
else
- try chrome.ChromeBuffer.create(width, height, .titlebar, state);
+ try chrome.ChromeBuffer.create(width, state);
toplevel.titlebar_buffer.setBuffer(&titlebar.base);
if (toplevel.cached_titlebar) |previous| previous.base.drop();
toplevel.cached_titlebar = titlebar;
stats.recordTitlebarPaint();
toplevel.last_titlebar = title_memo;
}
- if (!skip_footer) {
- // The skirt carries the bottom corner arcs: the client's own surface has
- // square corners, so the frame keeps this band of chrome below it.
- const skirt = if (toplevel.cached_footer != null and toplevel.last_footer != null and toplevel.last_footer.?.stableEql(footer_memo))
- try chrome.ChromeBuffer.createUpdated(toplevel.cached_footer.?, state, false)
- else
- try chrome.ChromeBuffer.create(width, height, .footer, state);
- toplevel.footer_buffer.setBuffer(&skirt.base);
- if (toplevel.cached_footer) |previous| previous.base.drop();
- toplevel.cached_footer = skirt;
- stats.recordFooterPaint();
- toplevel.last_footer = footer_memo;
- }
toplevel.titlebar_buffer.setDestSize(width, toplevel.titlebarHeight());
glass.Effect.configure(toplevel.glass_effect, radius, 1);
- toplevel.footer_buffer.node.setPosition(0, height - footer);
- toplevel.footer_buffer.setDestSize(width, footer);
toplevel.syncBorders(width, height);
toplevel.applyShape();
@@ -2981,14 +2674,12 @@ fn visualChromeSize(toplevel: *Toplevel, now_ms: i64, natural_w: i32, natural_h:
return .{ .w = @max(w, 1), .h = @max(h, 1) };
}
-// Not tied to the hover-repaint path (applyHover/tickHover): the shadow
-// canvas covers the whole frame rather than a thin band, so re-rasterizing
-// it on every hover-animation frame would be wasteful and the shadow
-// doesn't change with hover anyway. Only called where geometry or theme may
-// actually have changed.
+// The output pass draws the shadow from the window's shape; the node, without a
+// buffer, carries only its footprint, the window's opacity and input. Called
+// where geometry or theme may have changed, never on a hover repaint.
fn syncShadow(toplevel: *Toplevel, width: i32, height: i32, radius: f32) !void {
const t = theme.global;
- const disabled = toplevel.isMaximized() or t.shadow[3] <= 0 or t.shadow_size <= 0;
+ const disabled = !chrome.shapes or toplevel.isMaximized() or t.shadow[3] <= 0 or t.shadow_size <= 0;
const memo = chrome.ShadowMemo.capture(width, height, radius, toplevel.render_scale, disabled);
if (disabled) {
@@ -2998,101 +2689,25 @@ fn syncShadow(toplevel: *Toplevel, width: i32, height: i32, radius: f32) !void {
}
toplevel.shadow_tree.node.setEnabled(true);
- // Every client commit lands here. The memo holds everything the shadow
- // nodes' buffers and geometry derive from, so an unchanged one means
- // nothing to redo; the nodes keep their own locks on the buffers.
+ // Every client commit lands here; an unchanged memo means nothing to redo.
if (toplevel.last_shadow) |prev| {
if (prev.eql(memo)) return;
}
const margin: i32 = @intFromFloat(@ceil(t.shadow_size));
const offset_y: i32 = @intFromFloat(t.shadow_offset_y);
- const c_size: i32 = @intFromFloat(@ceil(radius + t.shadow_size));
-
- if (chrome.analytic_frames) {
- // The owned pass draws the shadow from the shape; the fallback node,
- // without a buffer, only carries its footprint, opacity and input.
- for (toplevel.shadow_corners) |node| node.node.setEnabled(false);
- for (toplevel.shadow_edges) |node| node.node.setEnabled(false);
- toplevel.shadow_fallback.node.setEnabled(true);
- toplevel.shadow_fallback.node.setPosition(-margin, -margin + offset_y);
- toplevel.shadow_fallback.setDestSize(width + 2 * margin, height + 2 * margin);
- const r: f64 = radius;
- if (!projection.setTreeShadow(&toplevel.shadow_tree.node, .{
- .width = width,
- .height = height,
- .radii = .{ r, r, r, r },
- .offset_x = 0,
- .offset_y = @floatFromInt(offset_y),
- .softness = t.shadow_size,
- .color = col.Straight.fromRgba(t.shadow).premultiply().rgba,
- })) log.warn("could not set the window shadow ({d}x{d})", .{ width, height });
- toplevel.last_shadow = memo;
- return;
- }
-
- if (width < 2 * c_size or height < 2 * c_size) {
- for (toplevel.shadow_corners) |node| node.node.setEnabled(false);
- for (toplevel.shadow_edges) |node| node.node.setEnabled(false);
- toplevel.shadow_fallback.node.setEnabled(true);
-
- const skip_raster = if (toplevel.last_shadow) |prev| prev.eql(memo) else false;
- if (!skip_raster) {
- const shadow = try chrome.ShadowBuffer.create(width, height, .{
- .radius = radius,
- .scale = toplevel.render_scale,
- .color = t.shadow,
- .softness = t.shadow_size,
- .offset_y = @floatFromInt(offset_y),
- });
- toplevel.shadow_fallback.setBuffer(&shadow.base);
- shadow.base.drop();
- }
- toplevel.shadow_fallback.node.setPosition(-margin, -margin + offset_y);
- toplevel.shadow_fallback.setDestSize(width + 2 * margin, height + 2 * margin);
- toplevel.last_shadow = memo;
- return;
- }
-
- toplevel.shadow_fallback.node.setEnabled(false);
- for (toplevel.shadow_corners) |node| node.node.setEnabled(true);
- for (toplevel.shadow_edges) |node| node.node.setEnabled(true);
-
- const patch_set = try chrome.getOrMakeShadowPatchSet(.{
- .radius = radius,
- .scale = toplevel.render_scale,
- .color = t.shadow,
- .softness = t.shadow_size,
+ toplevel.shadow_node.node.setPosition(-margin, -margin + offset_y);
+ toplevel.shadow_node.setDestSize(width + 2 * margin, height + 2 * margin);
+ const r: f64 = radius;
+ if (!projection.setTreeShadow(&toplevel.shadow_tree.node, .{
+ .width = width,
+ .height = height,
+ .radii = .{ r, r, r, r },
+ .offset_x = 0,
.offset_y = @floatFromInt(offset_y),
- });
-
- for (toplevel.shadow_corners, 0..) |node, i| node.setBuffer(&patch_set.corners[i].base);
- for (toplevel.shadow_edges, 0..) |node, i| node.setBuffer(&patch_set.edges[i].base);
-
- toplevel.shadow_corners[0].node.setPosition(-margin, -margin + offset_y);
- toplevel.shadow_corners[0].setDestSize(c_size, c_size);
-
- toplevel.shadow_corners[1].node.setPosition(width + margin - c_size, -margin + offset_y);
- toplevel.shadow_corners[1].setDestSize(c_size, c_size);
-
- toplevel.shadow_corners[2].node.setPosition(-margin, height + margin - c_size + offset_y);
- toplevel.shadow_corners[2].setDestSize(c_size, c_size);
-
- toplevel.shadow_corners[3].node.setPosition(width + margin - c_size, height + margin - c_size + offset_y);
- toplevel.shadow_corners[3].setDestSize(c_size, c_size);
-
- toplevel.shadow_edges[0].node.setPosition(-margin + c_size, -margin + offset_y);
- toplevel.shadow_edges[0].setDestSize(width + 2 * margin - 2 * c_size, c_size);
-
- toplevel.shadow_edges[1].node.setPosition(-margin + c_size, height + margin - c_size + offset_y);
- toplevel.shadow_edges[1].setDestSize(width + 2 * margin - 2 * c_size, c_size);
-
- toplevel.shadow_edges[2].node.setPosition(-margin, -margin + offset_y + c_size);
- toplevel.shadow_edges[2].setDestSize(c_size, height + 2 * margin - 2 * c_size);
-
- toplevel.shadow_edges[3].node.setPosition(width + margin - c_size, -margin + offset_y + c_size);
- toplevel.shadow_edges[3].setDestSize(c_size, height + 2 * margin - 2 * c_size);
-
+ .softness = t.shadow_size,
+ .color = col.Straight.fromRgba(t.shadow).premultiply().rgba,
+ })) log.warn("could not set the window shadow ({d}x{d})", .{ width, height });
toplevel.last_shadow = memo;
}
@@ -3106,11 +2721,11 @@ fn syncResizeGrab(toplevel: *Toplevel, width: i32, height: i32) void {
}
/// The shape that clips the whole window, titlebar, client and subsurfaces, in
-/// the output pass (see `chrome.analytic_frames`). Windows that draw their own
+/// the output pass (see `chrome.shapes`). Windows that draw their own
/// decorations, and fullscreen ones, have none; a maximized one has a square one,
/// for its border. Nothing changes if the shape is the one already set.
fn applyShape(toplevel: *Toplevel) void {
- if (!chrome.analytic_frames) return;
+ if (!chrome.shapes) return;
const node = &toplevel.frame_tree.node;
if (!toplevel.hasServerDecorations() or toplevel.chrome_width <= 0 or toplevel.chrome_height <= 0) {
_ = projection.setTreeClip(node, null);
@@ -3130,11 +2745,11 @@ fn applyShape(toplevel: *Toplevel) void {
}
fn syncBorders(toplevel: *Toplevel, width: i32, height: i32) void {
- const color = toplevel.borderColor();
- for (toplevel.border_rects) |rect| col.setRect(rect, color);
if (!toplevel.hasServerDecorations()) {
// Outline CSD frames outside their content. Client geometry and input
// coordinates stay unchanged, and the content remains above the stroke.
+ const color = toplevel.borderColor();
+ for (toplevel.border_rects) |rect| col.setRect(rect, color);
const edge = chrome.frame_border;
toplevel.border_rects[0].node.setPosition(-edge, -edge);
toplevel.border_rects[0].setSize(width + 2 * edge, edge);
@@ -3146,33 +2761,19 @@ fn syncBorders(toplevel: *Toplevel, width: i32, height: i32) void {
toplevel.border_rects[3].setSize(width + 2 * edge, edge);
return;
}
- const inset: i32 = if (toplevel.isMaximized())
- 0
- else
- @intFromFloat(@ceil(toplevel.cornerRadius()));
-
- // Only back the client-height gap: overlapping the retained bands would
- // apply the translucent chrome twice at the joins.
+ // Only back the gap the titlebar leaves: overlapping it would apply the
+ // translucent chrome twice at the joins. The ring over the fills, the
+ // titlebar and the client's edge is the shape's.
const body_top = toplevel.titlebarHeight();
- const body_height = @max(0, height - body_top - chrome.footerHeight(toplevel.cornerRadius()));
- for (toplevel.side_fills, 0..) |rect, i| {
- col.setRect(rect, chrome.fillColor());
- rect.node.setPosition(if (i == 0) 0 else width - chrome.frame_border, body_top);
- rect.setSize(chrome.frame_border, body_height);
- }
- // The ring over the fills, the titlebar and the client's edge is the shape's.
- if (chrome.analytic_frames) return;
-
- // Every straight edge runs between two rasterized corner arcs, so all four
- // are inset at both ends.
- toplevel.border_rects[0].node.setPosition(inset, 0);
- toplevel.border_rects[0].setSize(@max(1, width - 2 * inset), chrome.frame_border);
- toplevel.border_rects[1].node.setPosition(0, inset);
- toplevel.border_rects[1].setSize(chrome.frame_border, @max(1, height - 2 * inset));
- toplevel.border_rects[2].node.setPosition(width - chrome.frame_border, inset);
- toplevel.border_rects[2].setSize(chrome.frame_border, @max(1, height - 2 * inset));
- toplevel.border_rects[3].node.setPosition(inset, height - chrome.frame_border);
- toplevel.border_rects[3].setSize(@max(1, width - 2 * inset), chrome.frame_border);
+ const edge = chrome.frame_border;
+ const body_height = @max(0, height - body_top - edge);
+ for (toplevel.frame_fills) |rect| col.setRect(rect, chrome.fillColor());
+ toplevel.frame_fills[0].node.setPosition(0, body_top);
+ toplevel.frame_fills[0].setSize(edge, body_height);
+ toplevel.frame_fills[1].node.setPosition(width - edge, body_top);
+ toplevel.frame_fills[1].setSize(edge, body_height);
+ toplevel.frame_fills[2].node.setPosition(0, height - edge);
+ toplevel.frame_fills[2].setSize(width, edge);
}
pub fn detachInput(toplevel: *Toplevel) void {
@@ -3206,7 +2807,7 @@ pub fn applyOpacity(toplevel: *Toplevel, now_ms: i64) void {
}.iter, &opacity);
const color = toplevel.borderColor().scale(opacity);
for (toplevel.border_rects) |rect| col.setRect(rect, color);
- for (toplevel.side_fills) |rect| col.setRect(rect, chrome.fillColor().scale(opacity));
+ for (toplevel.frame_fills) |rect| col.setRect(rect, chrome.fillColor().scale(opacity));
toplevel.shape_opacity = opacity;
toplevel.applyShape();
glass.Effect.configure(toplevel.glass_effect, toplevel.cornerRadius(), opacity);
@@ -3219,7 +2820,7 @@ pub fn applyOpacity(toplevel: *Toplevel, now_ms: i64) void {
pub fn applyHover(toplevel: *Toplevel, hovered: bool, control: ?chrome.ControlKind) void {
if (!hovered and toplevel.tab_hover != 0) {
toplevel.tab_hover = 0;
- toplevel.syncChrome(false, false, nowMs()) catch {};
+ toplevel.syncChrome(false, nowMs()) catch {};
}
const hover_changed = toplevel.hovered != hovered;
const control_changed = toplevel.hovered_control != control;
@@ -3236,7 +2837,7 @@ pub fn applyHover(toplevel: *Toplevel, hovered: bool, control: ?chrome.ControlKi
toplevel.server.scheduleFrames();
}
if (control_changed or !hover_changed) {
- toplevel.syncChrome(false, false, nowMs()) catch |err| {
+ toplevel.syncChrome(false, nowMs()) catch |err| {
log.err("applyHover: could not update window decoration: {}", .{err});
};
}
@@ -3270,7 +2871,7 @@ pub fn tickHover(toplevel: *Toplevel, now_ms: i64) bool {
const glide = toplevel.chip_pos.sampleChanged(now_ms, anim.rasterPixelQuantum(toplevel.render_scale) / chip_slot_px);
const fade = toplevel.chip_alpha.sampleChanged(now_ms, anim.rasterAlphaQuantum());
if (border or glide or fade) {
- toplevel.syncChrome(false, false, now_ms) catch |err| {
+ toplevel.syncChrome(false, now_ms) catch |err| {
log.err("tickHover: could not update window decoration: {}", .{err});
};
}
@@ -3647,7 +3248,7 @@ pub fn configureInitialXdgState(toplevel: *Toplevel) void {
toplevel.maximized = true;
if (target_out) |out| {
const usable = out.usableBox();
- const footer = if (toplevel.hasServerDecorations()) chrome.footerHeight(0) else 0;
+ const footer = if (toplevel.hasServerDecorations()) chrome.frame_border else 0;
const mw = usable.width - 2 * toplevel.borderWidth();
const mh = usable.height - toplevel.titlebarHeight() - footer;
_ = adapter.xdg_toplevel.setSize(@max(1, mw), @max(1, mh));
@@ -3692,7 +3293,7 @@ pub fn setMaximizedOn(toplevel: *Toplevel, output: *Output) void {
const usable = output.usableBox();
if (usable.width <= 0 or usable.height <= 0) return;
- const footer = if (toplevel.hasServerDecorations()) chrome.footerHeight(0) else 0;
+ const footer = if (toplevel.hasServerDecorations()) chrome.frame_border else 0;
const scale = toplevel.zoom();
const width = @as(i32, @intFromFloat(@floor(@as(f64, @floatFromInt(usable.width)) / scale))) - 2 * toplevel.borderWidth();
const height = @as(i32, @intFromFloat(@floor(@as(f64, @floatFromInt(usable.height)) / scale))) - toplevel.titlebarHeight() - footer;
@@ -3823,7 +3424,7 @@ pub fn setTiledOn(toplevel: *Toplevel, output: *Output, tile: tiling.Tile) void
const rect = tiling.tileRect(usable, tile, toplevel.server.config.compositor.windowGap());
// cornerRadius() still reads maximized until an xdg client acks leaving it.
- const footer = if (toplevel.hasServerDecorations()) chrome.footerHeight(chrome.frameRadius() * toplevel.chromeDensity()) else 0;
+ const footer = if (toplevel.hasServerDecorations()) chrome.frame_border else 0;
const scale = toplevel.zoom();
const width = @as(i32, @intFromFloat(@floor(@as(f64, @floatFromInt(rect.width)) / scale))) - 2 * toplevel.borderWidth();
const height = @as(i32, @intFromFloat(@floor(@as(f64, @floatFromInt(rect.height)) / scale))) - toplevel.titlebarHeight() - footer;
@@ -3852,7 +3453,7 @@ pub fn setTiledOn(toplevel: *Toplevel, output: *Output, tile: tiling.Tile) void
/// replies to an earlier configure never trigger another layout pass.
pub fn setAutoTile(toplevel: *Toplevel, rect: wlr.Box) void {
if (!toplevel.in_world or toplevel.fullscreen or toplevel.maximized) return;
- const footer = if (toplevel.hasServerDecorations()) chrome.footerHeight(chrome.frameRadius() * toplevel.chromeDensity()) else 0;
+ const footer = if (toplevel.hasServerDecorations()) chrome.frame_border else 0;
const target: RestoreGeometry = .{
.x = rect.x,
.y = rect.y,
@@ -4048,7 +3649,7 @@ pub fn handleIdentityChanged(toplevel: *Toplevel) void {
if (toplevel.live_rules.decorations != prev_rules.decorations) {
if (toplevel.decoration) |d| d.applyMode();
if (toplevel.kde_decoration) |d| d.applyMode(false);
- toplevel.syncChrome(true, true, nowMs()) catch {};
+ toplevel.syncChrome(true, nowMs()) catch {};
}
if (toplevel.in_world) if (toplevel.server.layout_autosave) |autosave| {
@@ -4058,9 +3659,9 @@ pub fn handleIdentityChanged(toplevel: *Toplevel) void {
@import("auto_tiling.zig").observe(toplevel);
toplevel.server.window_tabs.reconcile(toplevel);
if (toplevel.tab_hidden) {
- if (@import("window_tabs.zig").active(toplevel.server, toplevel.tab_group)) |active_tab| active_tab.syncChrome(false, false, nowMs()) catch {};
+ if (@import("window_tabs.zig").active(toplevel.server, toplevel.tab_group)) |active_tab| active_tab.syncChrome(false, nowMs()) catch {};
}
- toplevel.syncChrome(false, true, nowMs()) catch |err| {
+ toplevel.syncChrome(true, nowMs()) catch |err| {
log.err("handleIdentityChanged: could not update window title: {}", .{err});
};
if (toplevel.foreign_handle) |handle| {
@@ -4105,7 +3706,7 @@ pub fn hoverTab(toplevel: *Toplevel, x: f64, y: f64) void {
const next = @import("chrome_tabs.zig").key(toplevel.tabAt(x, y));
if (next == toplevel.tab_hover) return;
toplevel.tab_hover = next;
- toplevel.syncChrome(false, false, nowMs()) catch {};
+ toplevel.syncChrome(false, nowMs()) catch {};
}
pub fn stepTab(toplevel: *Toplevel, forward: bool) void {
diff --git a/src/auto_tiling.zig b/src/auto_tiling.zig
index 1fa14c5..ee2924a 100644
--- a/src/auto_tiling.zig
+++ b/src/auto_tiling.zig
@@ -36,7 +36,7 @@ fn state(top: *Top) State {
.constraints = c,
.horizontal = 2 * top.borderWidth(),
// Fullscreen/maximize decoration suppression must not alter the saved tile.
- .vertical = top.titlebarHeight() + if (top.hasServerDecorations()) @import("chrome.zig").footerHeight(@import("chrome.zig").frameRadius() * top.chromeDensity()) else @as(i32, 0),
+ .vertical = top.titlebarHeight() + if (top.hasServerDecorations()) @import("chrome.zig").frame_border else @as(i32, 0),
.excluded = isFloating(top) or top.tile != null or top.currentIdentity().dialog or fixed,
.suspended = top.minimized or top.fullscreen or top.maximized,
.hidden = top.tab_hidden,
diff --git a/src/capture/window_source.zig b/src/capture/window_source.zig
index 21c8386..e30b08b 100644
--- a/src/capture/window_source.zig
+++ b/src/capture/window_source.zig
@@ -37,7 +37,7 @@ const chrome = @import("../chrome.zig");
const DRM_FORMAT_ARGB8888: u32 = 0x34325241;
-/// The window's rounded shape in capture pixels (see `chrome.analytic_frames`
+/// The window's rounded shape in capture pixels (see `chrome.shapes`
/// and scene_pass.h). The capture is of the client alone, so the shape only
/// matters where it cuts the client: its two bottom corners, which stay
/// transparent here as they are on screen.
@@ -171,7 +171,7 @@ pub const WindowCaptureSource = struct {
/// The frame's shape relative to the capture: the frame's origin lies up and
/// left of the content by the content's own offset in it.
fn frameShape(self: *WindowCaptureSource, off_x: i32, off_y: i32) ?PassShape {
- if (!chrome.analytic_frames) return null;
+ if (!chrome.shapes) return null;
const toplevel = self.manager.server.findToplevelById(self.window_id) orelse return null;
const radius = toplevel.cornerRadius();
if (!toplevel.hasServerDecorations() or radius <= 0 or toplevel.chrome_width <= 0 or toplevel.chrome_height <= 0) return null;
diff --git a/src/chrome.zig b/src/chrome.zig
index 7d5fb6e..dfa3fc2 100644
--- a/src/chrome.zig
+++ b/src/chrome.zig
@@ -35,239 +35,25 @@ const title_inset = window_chrome.title_inset;
pub const title_icon_size = window_chrome.title_icon_size;
const title_icon_gap = window_chrome.title_icon_gap;
-/// Set once at startup, before any window exists, when the owned output pass can
-/// draw rounded shapes (stage 4c of docs/plans/scene-graph-stage4.md). Then the
-/// compositor gives every decorated window a shape that clips the titlebar, the
-/// client and its subsurfaces together, draws the corners and the border in the
-/// shader, and the frame needs no band of chrome below the client: the footer is
-/// the border. Otherwise the legacy frame is drawn: CPU arcs, a skirt, border rects.
-pub var analytic_frames: bool = false;
-
-// Without a shape the client's surface has square corners of its own, so the
-// frame reserves a band of chrome below it deep enough to hold the bottom arcs.
-pub fn footerHeight(radius: f32) i32 {
- if (analytic_frames) return frame_border;
- return @max(frame_border, @as(i32, @intFromFloat(@ceil(radius))));
-}
+/// Set once at startup, before any window exists, when the output pass built its
+/// shaped programs (docs/plans/scene-graph-stage4.md). Then every decorated window
+/// has a shape that clips the titlebar, the client and its subsurfaces together,
+/// and the pass draws its corners, border ring and shadow. Without them (a driver
+/// that cannot link the programs) windows are square, with no ring or shadow.
+pub var shapes: bool = false;
pub const ControlKind = window_chrome.ControlKind;
-// The two horizontal bands of chrome the compositor draws. The client surface
-// fills the gap between them.
-pub const Band = enum { titlebar, footer };
-
-fn bandHeight(band: Band, radius: f32, density: f32) i32 {
- return switch (band) {
- .titlebar => (Metrics{ .density = density }).titlebarHeight(),
- .footer => footerHeight(radius),
- };
-}
-
-// Little-endian packed 32-bit DRM formats. Byte 0 holds the low-order channel,
-// so `index` gives the byte offset of red, green, blue and alpha in that order.
const drm_format_argb8888: u32 = 0x34325241;
-const drm_format_xrgb8888: u32 = 0x34325258;
-const drm_format_abgr8888: u32 = 0x34324241;
-const drm_format_xbgr8888: u32 = 0x34324258;
-
-const PixelLayout = struct { index: [4]usize, has_alpha: bool };
-
-fn pixelLayout(format: u32) ?PixelLayout {
- return switch (format) {
- drm_format_argb8888 => .{ .index = .{ 2, 1, 0, 3 }, .has_alpha = true },
- drm_format_xrgb8888 => .{ .index = .{ 2, 1, 0, 3 }, .has_alpha = false },
- drm_format_abgr8888 => .{ .index = .{ 0, 1, 2, 3 }, .has_alpha = true },
- drm_format_xbgr8888 => .{ .index = .{ 0, 1, 2, 3 }, .has_alpha = false },
- else => null,
- };
-}
-
-/// Cached result of sampling a client's bottom edge. `fallback` is a known
-/// glass fill; it is not the same as never having sampled.
-pub const EdgeSampleKind = enum { uninitialized, color, fallback };
-
-/// Buffer-space mapping used to decide whether a cached edge sample is still
-/// valid. Pointers to buffers or textures are intentionally absent: reuse
-/// does not prove the pixels are unchanged, and a new swapchain buffer does
-/// not by itself prove they are.
-pub const EdgeMapping = struct {
- source_x: f64 = 0,
- source_y: f64 = 0,
- source_w: f64 = 0,
- source_h: f64 = 0,
- scale: i32 = 1,
- transform_normal: bool = true,
- buffer_width: i32 = 0,
- buffer_height: i32 = 0,
- format: u32 = 0,
- surface_width: i32 = 0,
- surface_height: i32 = 0,
- geom_x: i32 = 0,
- geom_y: i32 = 0,
- geom_w: i32 = 0,
- geom_h: i32 = 0,
- has_texture: bool = false,
- row_x: i32 = 0,
- row_y: i32 = 0,
- row_w: i32 = 0,
- row_h: i32 = 0,
- row_valid: bool = false,
-
- pub fn canSample(self: EdgeMapping) bool {
- return self.transform_normal and self.has_texture and self.row_valid;
- }
-
- pub fn eql(a: EdgeMapping, b: EdgeMapping) bool {
- return a.source_x == b.source_x and a.source_y == b.source_y and
- a.source_w == b.source_w and a.source_h == b.source_h and
- a.scale == b.scale and a.transform_normal == b.transform_normal and
- a.buffer_width == b.buffer_width and a.buffer_height == b.buffer_height and
- a.format == b.format and
- a.surface_width == b.surface_width and a.surface_height == b.surface_height and
- a.geom_x == b.geom_x and a.geom_y == b.geom_y and
- a.geom_w == b.geom_w and a.geom_h == b.geom_h and
- a.has_texture == b.has_texture and
- a.row_x == b.row_x and a.row_y == b.row_y and
- a.row_w == b.row_w and a.row_h == b.row_h and
- a.row_valid == b.row_valid;
- }
-};
-
-/// Effective committed damage in the same buffer coordinates as `EdgeMapping.row_*`.
-pub const EdgeDamage = enum {
- /// No damage reported for this commit.
- none,
- /// Damage exists and intersects the sampled row.
- intersects_row,
- /// Damage exists but misses the sampled row.
- misses_row,
- /// Damage or its mapping cannot be trusted; resample.
- unknown,
-};
-
-pub const SampleAction = enum {
- /// Read the client's bottom row.
- sample,
- /// Keep the cached colour or fallback; do not read.
- skip,
- /// Use the glass fill without reading. Must replace a previously sampled colour.
- fallback,
-};
-
-pub fn rectsOverlap(ax: i32, ay: i32, aw: i32, ah: i32, bx: i32, by: i32, bw: i32, bh: i32) bool {
- if (aw <= 0 or ah <= 0 or bw <= 0 or bh <= 0) return false;
- return ax < bx + bw and ax + aw > bx and ay < by + bh and ay + ah > by;
-}
-
-/// Decide whether this commit needs a texture read, a glass fallback, or nothing.
-/// `force` covers first sample after map, re-enabling SSD, and a pending sample
-/// remembered across resize-skipped commits.
-pub fn decideEdgeSample(
- cached: EdgeSampleKind,
- last: ?EdgeMapping,
- current: EdgeMapping,
- damage: EdgeDamage,
- force: bool,
-) SampleAction {
- if (!current.canSample()) {
- if (!force and cached == .fallback) {
- if (last) |prev| {
- if (prev.eql(current)) return .skip;
- }
- }
- return .fallback;
- }
-
- if (force or cached == .uninitialized) return .sample;
-
- const mapping_changed = if (last) |prev| !prev.eql(current) else true;
- if (mapping_changed) return .sample;
-
- return switch (damage) {
- .intersects_row, .unknown => .sample,
- .none, .misses_row => .skip,
- };
-}
-
-fn growScratch(scratch: *[]u32, count: usize) ?[]u32 {
- if (scratch.len >= count) return scratch.*[0..count];
- if (scratch.len == 0) {
- scratch.* = gpa.alloc(u32, count) catch return null;
- } else {
- scratch.* = gpa.realloc(scratch.*, count) catch return null;
- }
- return scratch.*[0..count];
-}
-
-// The skirt butts straight against the client's last row of pixels, so a glass
-// fill leaves a visible seam against any window that is not glass-coloured.
-// Reading that row and filling the band with it makes the skirt read as part of
-// the window. `row` is in buffer pixels. Returns straight-alpha RGBA, or null
-// when the row cannot be read and the caller should keep the glass.
-// `scratch` is grown to the row width and owned by the caller.
-pub fn sampleEdge(texture: *wlr.Texture, row: wlr.Box, scratch: *[]u32) ?[4]f32 {
- if (row.width <= 0 or row.height <= 0) return null;
- const format = texture.preferredReadFormat();
- const layout = pixelLayout(format) orelse return null;
-
- const count: usize = @intCast(row.width);
- const pixels = growScratch(scratch, count) orelse {
- log.err("sampleEdge: could not allocate {d} pixels", .{count});
- return null;
- };
-
- if (!texture.readPixels(&.{
- .data = @ptrCast(pixels.ptr),
- .format = format,
- .stride = @intCast(count * @sizeOf(u32)),
- .dst_x = 0,
- .dst_y = 0,
- .src_box = row,
- })) return null;
-
- // Per-channel median: exact for the uniform background that dominates a
- // window's bottom row, and unmoved by a cursor or scrollbar sitting in it.
- var histogram = [_][256]u32{[_]u32{0} ** 256} ** 4;
- for (pixels) |pixel| {
- const bytes: [4]u8 = @bitCast(pixel);
- for (&histogram, layout.index) |*channel, index| channel[bytes[index]] += 1;
- }
-
- var median: [4]f32 = .{ 0, 0, 0, 0 };
- for (&median, &histogram) |*value, *channel| {
- var seen: usize = 0;
- for (channel, 0..) |bucket, level| {
- seen += bucket;
- if (seen * 2 >= count) {
- value.* = @as(f32, @floatFromInt(level)) / 255.0;
- break;
- }
- }
- }
-
- // wl_shm's 8888 formats carry premultiplied alpha; Color wants straight.
- const alpha: f32 = if (layout.has_alpha) median[3] else 1;
- if (alpha == 0) return null;
- return .{
- @min(1, median[0] / alpha),
- @min(1, median[1] / alpha),
- @min(1, median[2] / alpha),
- alpha,
- };
-}
// Everything the rasterizer needs to reproduce a window's current appearance.
pub const ChromeState = struct {
tabs: @import("chrome_tabs.zig").Strip = .{},
- radius: f32,
active: bool = false,
workspace_focus: bool = false,
maximized: bool = false,
density: f32 = 1,
title: []const u8 = "",
- // Fill for the skirt, sampled from the client's own bottom row. Straight
- // alpha; null keeps the same glass the titlebar uses.
- skirt_fill: ?[4]f32 = null,
// Device pixels per logical pixel. Every metric here is logical; only the
// sampling grid and the antialiasing ramp change with it.
scale: f32 = 1,
@@ -288,17 +74,13 @@ pub const ChromeState = struct {
}
};
-// Inputs that produced the titlebar currently on screen. Skirt colour is
-// intentionally absent so a changed edge sample can repaint only the footer.
-// `rasterize` also reads `theme.global`; those are snapshotted here so a live
-// reskin cannot be skipped. Width/height/radius stay full-frame because the
-// SDF is evaluated against the whole rounded rectangle.
+// Inputs that produced the titlebar currently on screen. `rasterize` also reads
+// `theme.global`; those are snapshotted here so a live reskin cannot be skipped.
pub const TitlebarMemo = struct {
font_generation: u32 = 0,
tabs_hash: u64 = 0,
width: i32,
height: i32,
- radius: f32,
density: f32 = 1,
active: bool = false,
workspace_focus: bool = false,
@@ -333,7 +115,6 @@ pub const TitlebarMemo = struct {
.font_generation = text.font_generation,
.width = width,
.height = height,
- .radius = state.radius,
.density = state.density,
.active = state.active,
.workspace_focus = state.workspace_focus,
@@ -386,7 +167,7 @@ pub const TitlebarMemo = struct {
if (a.font_generation != b.font_generation) return false;
if (a.width != b.width) return false;
if (a.height != b.height) return false;
- if (a.radius != b.radius or a.density != b.density) return false;
+ if (a.density != b.density) return false;
if (a.active != b.active) return false;
if (a.workspace_focus != b.workspace_focus) return false;
if (a.title_ptr != b.title_ptr or a.tabs_hash != b.tabs_hash) return false;
@@ -402,72 +183,10 @@ pub const TitlebarMemo = struct {
}
};
-// Footer raster inputs. Title, icon, and control hover do not appear in the
-// skirt; the rounded-rectangle SDF still needs the full frame size.
-pub const FooterMemo = struct {
- width: i32,
- height: i32,
- radius: f32,
- density: f32 = 1,
- skirt_fill: ?[4]f32,
- scale: f32,
- hover: f32,
- workspace_focus: bool = false,
- workspace_active_border: [4]f32 = @splat(0),
- glass: [4]f32,
- border: [4]f32,
- border_hover: [4]f32,
-
- pub fn capture(width: i32, height: i32, state: ChromeState) FooterMemo {
- const t = theme.global;
- return .{
- .width = width,
- .height = height,
- .radius = state.radius,
- .density = state.density,
- .skirt_fill = state.skirt_fill,
- .scale = state.scale,
- .hover = state.hover,
- .workspace_focus = state.workspace_focus,
- .workspace_active_border = t.workspace_active_border,
- .glass = t.window_bg,
- .border = t.window_border,
- .border_hover = t.window_border_hover,
- };
- }
-
- pub fn stableEql(a: FooterMemo, b: FooterMemo) bool {
- var normalized = a;
- normalized.hover = b.hover;
- normalized.workspace_focus = b.workspace_focus;
- return normalized.eql(b);
- }
-
- pub fn eql(a: FooterMemo, b: FooterMemo) bool {
- if (a.width != b.width) return false;
- if (a.height != b.height) return false;
- if (a.radius != b.radius or a.density != b.density) return false;
- if (!optionalRgbaEql(a.skirt_fill, b.skirt_fill)) return false;
- if (a.scale != b.scale) return false;
- if (a.hover != b.hover) return false;
- if (a.workspace_focus != b.workspace_focus) return false;
- inline for (.{ "glass", "border", "border_hover", "workspace_active_border" }) |field| {
- if (!rgbaEql(@field(a, field), @field(b, field))) return false;
- }
- return true;
- }
-};
-
fn rgbaEql(a: [4]f32, b: [4]f32) bool {
return std.mem.eql(f32, &a, &b);
}
-fn optionalRgbaEql(a: ?[4]f32, b: ?[4]f32) bool {
- const left = a orelse return b == null;
- const right = b orelse return false;
- return rgbaEql(left, right);
-}
-
fn iconEql(a: ?icon_service.Entry, b: ?icon_service.Entry) bool {
const left = a orelse return b == null;
const right = b orelse return false;
@@ -495,21 +214,15 @@ inline fn mix(a: f32, b: f32, t: f32) f32 {
pub const controlRect = window_chrome.controlRect;
pub const controlRectScaled = window_chrome.controlRectScaled;
+// The titlebar: a plain band. The window's shape gives it its corners and the
+// output pass draws the border ring over it, so no pixel here is shaped.
pub const ChromeBuffer = struct {
// wlroots imports this data-pointer buffer as a texture for the scene.
- // The pixel coverage is the CPU equivalent of shaders/rounded_frame.frag;
- // it avoids a separate render pass while preserving the SDF edge quality.
base: wlr.Buffer,
// The buffer is device pixels; the frame it draws is logical ones.
width: i32,
height: i32,
logical_width: i32,
- logical_height: i32,
- // Which band of the frame this buffer holds, and where that band starts in
- // frame coordinates. The rasterizer measures everything against the whole
- // frame, so both bands are cut from one rounded rectangle.
- band: Band,
- band_y: i32,
state: ChromeState,
pixels: []u32,
// Logical width from the title rect's left edge that the drawn title can
@@ -531,18 +244,12 @@ pub const ChromeBuffer = struct {
.end_data_ptr_access = endDataPtrAccess,
};
- pub fn create(
- logical_width: i32,
- logical_height: i32,
- band: Band,
- state: ChromeState,
- ) !*ChromeBuffer {
+ pub fn create(logical_width: i32, state: ChromeState) !*ChromeBuffer {
const frame = try gpa.create(ChromeBuffer);
errdefer gpa.destroy(frame);
- const band_h = bandHeight(band, state.radius, state.density);
const width = devicePixels(logical_width, state.scale);
- const height = devicePixels(band_h, state.scale);
+ const height = devicePixels((Metrics{ .density = state.density }).titlebarHeight(), state.scale);
const length: usize = @intCast(width * height);
const pixels = try gpa.alloc(u32, length);
errdefer gpa.free(pixels);
@@ -552,12 +259,6 @@ pub const ChromeBuffer = struct {
.width = width,
.height = height,
.logical_width = logical_width,
- .logical_height = logical_height,
- .band = band,
- .band_y = switch (band) {
- .titlebar => 0,
- .footer => logical_height - band_h,
- },
.state = state,
.pixels = pixels,
};
@@ -585,12 +286,9 @@ pub const ChromeBuffer = struct {
frame.pixels = pixels;
frame.state = state;
frame.base.init(&impl, frame.width, frame.height);
- const corners: i32 = @min(frame.logical_width, @as(i32, @intFromFloat(@ceil(state.radius))) + 1);
- // The border is the shader's with a shape: nothing in the raster changes.
- const border_changed = !analytic_frames and (previous.state.hover != state.hover or previous.state.workspace_focus != state.workspace_focus);
- if (state.tabs.tabs.len > 0 and frame.band == .titlebar) {
+ if (state.tabs.tabs.len > 0) {
const tabs = @import("chrome_tabs.zig");
- if (!border_changed and previous.tabs_layout_hash == tabs.layoutHash(state.tabs) and
+ if (previous.tabs_layout_hash == tabs.layoutHash(state.tabs) and
previous.state.hover == state.hover and previous.state.chip_pos == state.chip_pos and previous.state.chip_alpha == state.chip_alpha and previous.state.maximized == state.maximized)
{
const geom = tabs.geometry(frame.logical_width, state.density, state.tabs);
@@ -607,15 +305,11 @@ pub const ChromeBuffer = struct {
frame.state.title = "";
return frame;
}
- const controls_changed = frame.band == .titlebar and (previous.state.chip_pos != state.chip_pos or previous.state.chip_alpha != state.chip_alpha or previous.state.maximized != state.maximized);
+ const controls_changed = previous.state.chip_pos != state.chip_pos or previous.state.chip_alpha != state.chip_alpha or previous.state.maximized != state.maximized;
const Span = struct { x0: i32, x1: i32 };
- var spans: [3]Span = undefined;
+ var spans: [2]Span = undefined;
var count: usize = 0;
- if (border_changed) {
- spans[count] = .{ .x0 = 0, .x1 = corners };
- count += 1;
- }
- if ((title_changed or previous.state.active != state.active) and frame.band == .titlebar) {
+ if (title_changed or previous.state.active != state.active) {
frame.title_extent = frame.titleExtent();
const rect = titleRect(frame.logical_width, state);
const extent = @max(previous.title_extent, frame.title_extent);
@@ -624,7 +318,7 @@ pub const ChromeBuffer = struct {
count += 1;
}
}
- var right = if (border_changed) frame.logical_width - corners else frame.logical_width;
+ var right = frame.logical_width;
if (controls_changed) right = @min(right, @max(0, controlRectScaled(frame.logical_width, .minimize, frame.state.density).x - 1));
if (right < frame.logical_width) {
spans[count] = .{ .x0 = right, .x1 = frame.logical_width };
@@ -637,7 +331,7 @@ pub const ChromeBuffer = struct {
}.less);
// A narrow frame can make the regions overlap. Rasterize their union
// once, so text coverage is never composited twice.
- const band_h = bandHeight(frame.band, state.radius, state.density);
+ const band_h = (Metrics{ .density = state.density }).titlebarHeight();
var i: usize = 0;
while (i < count) {
var span = spans[i];
@@ -662,7 +356,7 @@ pub const ChromeBuffer = struct {
/// rect's left edge: its advance plus a margin for glyph overhang and
/// antialiasing, capped by the rect (long titles are ellipsized to it).
fn titleExtent(frame: *const ChromeBuffer) i32 {
- if (frame.band != .titlebar or frame.state.title.len == 0) return 0;
+ if (frame.state.title.len == 0) return 0;
const rect = titleRect(frame.logical_width, frame.state);
const m: Metrics = .{ .density = frame.state.density };
const width = text.measureWidth(frame.state.title, frame.state.titleFont(), theme.global.title_size * m.density, frame.state.scale) catch return rect.w;
@@ -694,12 +388,6 @@ pub const ChromeBuffer = struct {
fn rasterize(frame: *ChromeBuffer, clip: ?Rect) !void {
const scale = frame.state.scale;
const m: Metrics = .{ .density = frame.state.density };
- const fw: f32 = @floatFromInt(frame.logical_width);
- const fh: f32 = @floatFromInt(frame.logical_height);
- const band_top: f32 = @floatFromInt(frame.band_y);
- const radius = frame.state.radius;
- const border: f32 = @floatFromInt(frame_border);
- const inner_r = @max(radius - border, 0);
const min_btn = controlRectScaled(frame.logical_width, .minimize, frame.state.density);
const max_btn = controlRectScaled(frame.logical_width, .maximize, frame.state.density);
const close_btn = controlRectScaled(frame.logical_width, .close, frame.state.density);
@@ -712,109 +400,68 @@ pub const ChromeBuffer = struct {
const diag = std.math.sqrt1_2;
const icon_left: f32 = @floatFromInt(m.length(title_inset));
const icon_top: f32 = @floatFromInt(@divTrunc(m.titlebarHeight() - m.iconSize(), 2));
- // Hover gently brightens the same border used by the straight edges.
- const edge_color = windowBorderFill(frame.state.hover, frame.state.workspace_focus);
- // The titlebar uses the window tint. The
- // skirt continues the client, so it takes the client's own edge colour.
- const base = switch (frame.band) {
- .titlebar => Color.chrome(),
- .footer => if (frame.state.skirt_fill) |fill| Color.fromRgba(fill) else Color.chrome(),
- };
- // Away from the corners and the side antialiasing ramp, every pixel
- // in a row has the same fill and outer coverage. Pack that colour once
- // instead of repeating four rounded float conversions across the bar.
- // With a shape the buffer is plain: the shader gives it its corners, edge
- // and border, so no pixel is shaped (or anti-aliased) here a second time.
- const flat_inset = if (analytic_frames) 0 else @max(radius, 1 / scale);
+ const base = Color.chrome();
+ // Away from the controls and the icon every pixel in a row has the same
+ // fill. Pack that colour once instead of repeating four rounded float
+ // conversions across the bar.
const stride: usize = @intCast(frame.width);
const x0: usize = if (clip) |box| @intCast(@min(frame.width, @max(0, @as(i32, @intFromFloat(@round(@as(f32, @floatFromInt(box.x)) * scale)))))) else 0;
const x1: usize = if (clip) |box| @intCast(@min(frame.width, @max(0, @as(i32, @intFromFloat(@round(@as(f32, @floatFromInt(box.x + box.w)) * scale)))))) else stride;
for (0..@intCast(frame.height)) |device_y| {
- // Rows are band-local device pixels; py is a frame-local logical
- // coordinate, so the shape below is the whole frame's.
- const py = band_top + (@as(f32, @floatFromInt(device_y)) + 0.5) / scale;
+ const py = (@as(f32, @floatFromInt(device_y)) + 0.5) / scale;
const yi: i32 = @intFromFloat(@floor(py));
const row = device_y * stride;
var row_color = base;
- if (frame.band == .titlebar and yi == m.titlebarHeight() - 1) row_color = Color.divider().over(row_color);
- const flat_color = row_color.scaled(if (analytic_frames) 1 else edgeCoverage(sdRoundedBox(fw / 2, py, 0, 0, fw, fh, radius), scale)).argb();
- const control_row = frame.band == .titlebar and py >= control_top and py <= control_bottom;
- const icon_row = frame.band == .titlebar and frame.state.tabs.tabs.len == 0 and frame.state.icon != null and
+ if (yi == m.titlebarHeight() - 1) row_color = Color.divider().over(row_color);
+ const flat_color = row_color.argb();
+ const control_row = py >= control_top and py <= control_bottom;
+ const icon_row = frame.state.tabs.tabs.len == 0 and frame.state.icon != null and
py >= icon_top and py < icon_top + @as(f32, @floatFromInt(m.iconSize()));
for (x0..x1) |x| {
const px = (@as(f32, @floatFromInt(x)) + 0.5) / scale;
const in_controls = control_row and px >= control_left and px <= control_right;
const in_icon = icon_row and px >= icon_left and px < icon_left + @as(f32, @floatFromInt(m.iconSize()));
- if (px >= flat_inset and px < fw - flat_inset and !in_controls and !in_icon) {
+ if (!in_controls and !in_icon) {
frame.pixels[row + x] = flat_color;
continue;
}
- const outer_cov = if (analytic_frames) 1 else edgeCoverage(sdRoundedBox(px, py, 0, 0, fw, fh, radius), scale);
- if (outer_cov == 0) {
- frame.pixels[row + x] = 0;
- continue;
- }
-
var color = row_color;
+ if (in_controls) {
+ color = paintControls(
+ color,
+ px,
+ py,
+ min_btn,
+ max_btn,
+ close_btn,
+ frame.state.chip_pos,
+ frame.state.chip_alpha,
+ diag,
+ scale,
+ m.contentScale(),
+ frame.state.maximized,
+ );
+ }
- if (frame.band == .titlebar) {
- if (in_controls) {
- color = paintControls(
- color,
- px,
- py,
- min_btn,
- max_btn,
- close_btn,
- frame.state.chip_pos,
- frame.state.chip_alpha,
- diag,
- scale,
- m.contentScale(),
- frame.state.maximized,
- );
- }
-
- if (if (frame.state.tabs.tabs.len == 0) frame.state.icon else null) |icon| {
- if (px >= icon_left and px < icon_left + @as(f32, @floatFromInt(m.iconSize())) and
- py >= icon_top and py < icon_top + @as(f32, @floatFromInt(m.iconSize())))
- {
- const ix: i32 = @intFromFloat(@floor((px - icon_left) * scale));
- const iy: i32 = @intFromFloat(@floor((py - icon_top) * scale));
- if (ix >= 0 and ix < icon.size and iy >= 0 and iy < icon.size) {
- const sample = icon.pixels[@intCast(iy * icon.size + ix)];
- color = Color.fromPremultiplied(sample).over(color);
- }
+ if (if (frame.state.tabs.tabs.len == 0) frame.state.icon else null) |icon| {
+ if (px >= icon_left and px < icon_left + @as(f32, @floatFromInt(m.iconSize())) and
+ py >= icon_top and py < icon_top + @as(f32, @floatFromInt(m.iconSize())))
+ {
+ const ix: i32 = @intFromFloat(@floor((px - icon_left) * scale));
+ const iy: i32 = @intFromFloat(@floor((py - icon_top) * scale));
+ if (ix >= 0 and ix < icon.size and iy >= 0 and iy < icon.size) {
+ const sample = icon.pixels[@intCast(iy * icon.size + ix)];
+ color = Color.fromPremultiplied(sample).over(color);
}
}
}
- // Scene rects draw the straight frame edges. Retain only the
- // curved border, of which each band holds two corners.
- const in_corner = (px < radius or px >= fw - radius) and
- (py < radius or py >= fh - radius);
- if (in_corner) {
- const inner_cov = edgeCoverage(
- sdRoundedBox(px, py, border, border, fw - 2 * border, fh - 2 * border, inner_r),
- scale,
- );
- // Match the straight scene rects: border over the fill.
- // Interpolating straight RGB and alpha independently
- // produces a bright fringe and removes the fill under
- // the border. Normalize the stroke coverage because the
- // outer coverage is applied to the whole pixel below.
- const stroke_cov = clamp01(1 - inner_cov / outer_cov);
- color = edge_color.scaled(stroke_cov).over(color);
- }
- color.a *= outer_cov;
frame.pixels[row + x] = color.argb();
}
}
- if (frame.band != .titlebar) return;
-
if (frame.state.tabs.tabs.len > 0) {
@import("chrome_tabs.zig").paint(Color, frame.pixels, frame.width, frame.height, frame.logical_width, frame.state.density, scale, frame.state.tabs, frame.state.icon, clip);
return;
@@ -842,16 +489,7 @@ pub const ChromeBuffer = struct {
}
};
-// The node is offset by the caller. The cutout must compensate for that
-// offset so the outer shadow never darkens the translucent frame interior.
-pub const ShadowState = struct {
- radius: f32,
- scale: f32 = 1,
- color: [4]f32,
- softness: f32,
- offset_y: f32 = 0,
-};
-
+// What the window's analytic shadow was last set from (Toplevel.syncShadow).
pub const ShadowMemo = struct {
width: i32,
height: i32,
@@ -889,350 +527,6 @@ pub const ShadowMemo = struct {
}
};
-// A soft drop shadow behind the frame, cut from the same sdRoundedBox shape
-// as ChromeBuffer so it always matches the window's actual corner radius.
-// There's no blur primitive in this rasterizer (see shadowCoverage below);
-// this is a single full-canvas raster, unlike ChromeBuffer's thin bands, so
-// its cost scales with window area rather than titlebar/footer height — see
-// the plan doc's note on a possible future 9-slice if that shows up as
-// resize stutter on large windows.
-pub const ShadowBuffer = struct {
- base: wlr.Buffer,
- width: i32,
- height: i32,
- frame_w: i32,
- frame_h: i32,
- margin: i32,
- state: ShadowState,
- pixels: []u32,
-
- const impl = wlr.Buffer.Impl{
- .destroy = destroy,
- .get_dmabuf = null,
- .get_shm = null,
- .begin_data_ptr_access = beginDataPtrAccess,
- .end_data_ptr_access = endDataPtrAccess,
- };
-
- pub fn create(frame_w: i32, frame_h: i32, state: ShadowState) !*ShadowBuffer {
- const shadow = try gpa.create(ShadowBuffer);
- errdefer gpa.destroy(shadow);
-
- const margin: i32 = @intFromFloat(@ceil(state.softness));
- const width = devicePixels(frame_w + 2 * margin, state.scale);
- const height = devicePixels(frame_h + 2 * margin, state.scale);
- const length: usize = @intCast(width * height);
- const pixels = try gpa.alloc(u32, length);
- errdefer gpa.free(pixels);
-
- shadow.* = .{
- .base = undefined,
- .width = width,
- .height = height,
- .frame_w = frame_w,
- .frame_h = frame_h,
- .margin = margin,
- .state = state,
- .pixels = pixels,
- };
- shadow.base.init(&impl, width, height);
- shadow.rasterize();
- return shadow;
- }
-
- fn destroy(base: *wlr.Buffer) callconv(.c) void {
- const shadow: *ShadowBuffer = @fieldParentPtr("base", base);
- gpa.free(shadow.pixels);
- gpa.destroy(shadow);
- }
-
- fn beginDataPtrAccess(
- base: *wlr.Buffer,
- _: u32,
- data: **anyopaque,
- format: *u32,
- stride: *usize,
- ) callconv(.c) bool {
- const shadow: *ShadowBuffer = @fieldParentPtr("base", base);
- data.* = @ptrCast(shadow.pixels.ptr);
- format.* = drm_format_argb8888;
- stride.* = @as(usize, @intCast(shadow.width)) * @sizeOf(u32);
- return true;
- }
-
- fn endDataPtrAccess(_: *wlr.Buffer) callconv(.c) void {}
-
- fn rasterize(shadow: *ShadowBuffer) void {
- const scale = shadow.state.scale;
- const margin_f: f32 = @floatFromInt(shadow.margin);
- const fw: f32 = @floatFromInt(shadow.frame_w);
- const fh: f32 = @floatFromInt(shadow.frame_h);
- const softness = shadow.state.softness;
- const color = Color.fromRgba(shadow.state.color);
- const stride: usize = @intCast(shadow.width);
-
- for (0..@intCast(shadow.height)) |device_y| {
- const py = (@as(f32, @floatFromInt(device_y)) + 0.5) / scale;
- const row = device_y * stride;
- for (0..stride) |x| {
- const px = (@as(f32, @floatFromInt(x)) + 0.5) / scale;
- const d = sdRoundedBox(px, py, margin_f, margin_f, fw, fh, shadow.state.radius);
- const frame_d = sdRoundedBox(px, py, margin_f, margin_f - shadow.state.offset_y, fw, fh, shadow.state.radius);
- const cov = shadowCoverage(d, softness) * (1 - edgeCoverage(frame_d, scale));
- if (cov <= 0) {
- shadow.pixels[row + x] = 0;
- continue;
- }
- var c = color;
- c.a *= cov;
- shadow.pixels[row + x] = c.argb();
- }
- }
- }
-};
-
-pub const ShadowPatchKind = enum {
- top_left,
- top_right,
- bottom_left,
- bottom_right,
- top_edge,
- bottom_edge,
- left_edge,
- right_edge,
-};
-
-pub const ShadowPatchBuffer = struct {
- base: wlr.Buffer,
- width: i32,
- height: i32,
- pixels: []u32,
-
- const impl = wlr.Buffer.Impl{
- .destroy = destroy,
- .get_dmabuf = null,
- .get_shm = null,
- .begin_data_ptr_access = beginDataPtrAccess,
- .end_data_ptr_access = endDataPtrAccess,
- };
-
- pub fn create(kind: ShadowPatchKind, state: ShadowState) !*ShadowPatchBuffer {
- const patch = try gpa.create(ShadowPatchBuffer);
- errdefer gpa.destroy(patch);
-
- const margin: i32 = @intFromFloat(@ceil(state.softness));
- const c_size: i32 = @intFromFloat(@ceil(state.radius + state.softness));
- const scale = state.scale;
-
- var logical_w: i32 = c_size;
- var logical_h: i32 = c_size;
-
- switch (kind) {
- .top_left, .top_right, .bottom_left, .bottom_right => {
- logical_w = c_size;
- logical_h = c_size;
- },
- .top_edge, .bottom_edge => {
- logical_w = 1;
- logical_h = c_size;
- },
- .left_edge, .right_edge => {
- logical_w = c_size;
- logical_h = 1;
- },
- }
-
- const dev_w = devicePixels(logical_w, scale);
- const dev_h = devicePixels(logical_h, scale);
- const length: usize = @intCast(dev_w * dev_h);
- const pixels = try gpa.alloc(u32, length);
- errdefer gpa.free(pixels);
-
- patch.* = .{
- .base = undefined,
- .width = dev_w,
- .height = dev_h,
- .pixels = pixels,
- };
- patch.base.init(&impl, dev_w, dev_h);
- patch.rasterize(kind, state, c_size, margin);
- return patch;
- }
-
- fn destroy(base: *wlr.Buffer) callconv(.c) void {
- const patch: *ShadowPatchBuffer = @fieldParentPtr("base", base);
- gpa.free(patch.pixels);
- gpa.destroy(patch);
- }
-
- fn beginDataPtrAccess(
- base: *wlr.Buffer,
- _: u32,
- data: **anyopaque,
- format: *u32,
- stride: *usize,
- ) callconv(.c) bool {
- const patch: *ShadowPatchBuffer = @fieldParentPtr("base", base);
- data.* = @ptrCast(patch.pixels.ptr);
- format.* = drm_format_argb8888;
- stride.* = @as(usize, @intCast(patch.width)) * @sizeOf(u32);
- return true;
- }
-
- fn endDataPtrAccess(_: *wlr.Buffer) callconv(.c) void {}
-
- fn rasterize(patch: *ShadowPatchBuffer, kind: ShadowPatchKind, state: ShadowState, c_size: i32, margin: i32) void {
- const scale = state.scale;
- const margin_f: f32 = @floatFromInt(margin);
- const ref_fw: f32 = @floatFromInt(2 * c_size);
- const ref_fh: f32 = @floatFromInt(2 * c_size);
- const softness = state.softness;
- const color = Color.fromRgba(state.color);
- const stride: usize = @intCast(patch.width);
-
- for (0..@intCast(patch.height)) |dev_y| {
- const row = dev_y * stride;
- for (0..stride) |dev_x| {
- var px: f32 = undefined;
- var py: f32 = undefined;
-
- const lx = (@as(f32, @floatFromInt(dev_x)) + 0.5) / scale;
- const ly = (@as(f32, @floatFromInt(dev_y)) + 0.5) / scale;
-
- switch (kind) {
- .top_left => {
- px = lx;
- py = ly;
- },
- .top_right => {
- px = (ref_fw + 2.0 * margin_f) - (@as(f32, @floatFromInt(patch.width)) / scale) + lx;
- py = ly;
- },
- .bottom_left => {
- px = lx;
- py = (ref_fh + 2.0 * margin_f) - (@as(f32, @floatFromInt(patch.height)) / scale) + ly;
- },
- .bottom_right => {
- px = (ref_fw + 2.0 * margin_f) - (@as(f32, @floatFromInt(patch.width)) / scale) + lx;
- py = (ref_fh + 2.0 * margin_f) - (@as(f32, @floatFromInt(patch.height)) / scale) + ly;
- },
- .top_edge => {
- px = margin_f + @as(f32, @floatFromInt(c_size));
- py = ly;
- },
- .bottom_edge => {
- px = margin_f + @as(f32, @floatFromInt(c_size));
- py = (ref_fh + 2.0 * margin_f) - (@as(f32, @floatFromInt(patch.height)) / scale) + ly;
- },
- .left_edge => {
- px = lx;
- py = margin_f + @as(f32, @floatFromInt(c_size));
- },
- .right_edge => {
- px = (ref_fw + 2.0 * margin_f) - (@as(f32, @floatFromInt(patch.width)) / scale) + lx;
- py = margin_f + @as(f32, @floatFromInt(c_size));
- },
- }
-
- const d = sdRoundedBox(px, py, margin_f, margin_f, ref_fw, ref_fh, state.radius);
- const frame_d = sdRoundedBox(px, py, margin_f, margin_f - state.offset_y, ref_fw, ref_fh, state.radius);
- const cov = shadowCoverage(d, softness) * (1 - edgeCoverage(frame_d, scale));
- if (cov <= 0) {
- patch.pixels[row + dev_x] = 0;
- continue;
- }
- var c = color;
- c.a *= cov;
- patch.pixels[row + dev_x] = c.argb();
- }
- }
- }
-};
-
-pub const ShadowPatchSet = struct {
- corners: [4]*ShadowPatchBuffer,
- edges: [4]*ShadowPatchBuffer,
- state: ShadowState,
-
- pub fn create(state: ShadowState) !*ShadowPatchSet {
- const set = try gpa.create(ShadowPatchSet);
- errdefer gpa.destroy(set);
-
- set.state = state;
- set.corners[0] = try ShadowPatchBuffer.create(.top_left, state);
- errdefer set.corners[0].base.drop();
- set.corners[1] = try ShadowPatchBuffer.create(.top_right, state);
- errdefer set.corners[1].base.drop();
- set.corners[2] = try ShadowPatchBuffer.create(.bottom_left, state);
- errdefer set.corners[2].base.drop();
- set.corners[3] = try ShadowPatchBuffer.create(.bottom_right, state);
- errdefer set.corners[3].base.drop();
-
- set.edges[0] = try ShadowPatchBuffer.create(.top_edge, state);
- errdefer set.edges[0].base.drop();
- set.edges[1] = try ShadowPatchBuffer.create(.bottom_edge, state);
- errdefer set.edges[1].base.drop();
- set.edges[2] = try ShadowPatchBuffer.create(.left_edge, state);
- errdefer set.edges[2].base.drop();
- set.edges[3] = try ShadowPatchBuffer.create(.right_edge, state);
- errdefer set.edges[3].base.drop();
-
- return set;
- }
-
- pub fn destroy(set: *ShadowPatchSet) void {
- for (set.corners) |b| b.base.drop();
- for (set.edges) |b| b.base.drop();
- gpa.destroy(set);
- }
-};
-
-var global_shadow_patch_set: ?*ShadowPatchSet = null;
-
-pub fn getOrMakeShadowPatchSet(state: ShadowState) !*ShadowPatchSet {
- if (global_shadow_patch_set) |set| {
- if (set.state.radius == state.radius and
- set.state.scale == state.scale and
- rgbaEql(set.state.color, state.color) and
- set.state.softness == state.softness and
- set.state.offset_y == state.offset_y)
- {
- return set;
- }
- set.destroy();
- global_shadow_patch_set = null;
- }
- const new_set = try ShadowPatchSet.create(state);
- global_shadow_patch_set = new_set;
- return new_set;
-}
-
-pub fn clearShadowPatchCache() void {
- if (global_shadow_patch_set) |set| {
- set.destroy();
- global_shadow_patch_set = null;
- }
-}
-
-// Unlike edgeCoverage's fixed one-device-pixel-wide AA ramp, this fades over
-// `softness` logical pixels — an analytic stand-in for a real Gaussian blur,
-// which this CPU rasterizer has no primitive for.
-fn shadowCoverage(distance: f32, softness: f32) f32 {
- if (softness <= 0) return if (distance <= 0) 1 else 0;
- const t = clamp01(1 - distance / softness);
- return t * t * (3 - 2 * t); // smoothstep
-}
-
-test "shadowCoverage fades from opaque to transparent over softness" {
- try std.testing.expectEqual(@as(f32, 1), shadowCoverage(-5, 24));
- try std.testing.expectEqual(@as(f32, 1), shadowCoverage(0, 24));
- try std.testing.expectApproxEqAbs(@as(f32, 0.5), shadowCoverage(12, 24), 1e-6);
- try std.testing.expectEqual(@as(f32, 0), shadowCoverage(24, 24));
- try std.testing.expectEqual(@as(f32, 0), shadowCoverage(30, 24));
- try std.testing.expectEqual(@as(f32, 1), shadowCoverage(-5, 0));
- try std.testing.expectEqual(@as(f32, 0), shadowCoverage(5, 0));
-}
-
test "titlebar glass holds only while the titlebar is at least 98% opaque" {
const saved = theme.global.window_bg;
defer theme.global.window_bg = saved;
@@ -1245,47 +539,6 @@ test "titlebar glass holds only while the titlebar is at least 98% opaque" {
try std.testing.expect(!titlebarGlassMayHold(1));
}
-test "outer shadow leaves the unshifted glass frame transparent" {
- for ([_]f32{ 1, 1.5, 2 }) |scale| {
- const shadow = try ShadowBuffer.create(120, 100, .{
- .radius = 10,
- .scale = scale,
- .color = .{ 0, 0, 0, 0.35 },
- .softness = 24,
- .offset_y = 8,
- });
- defer shadow.base.drop();
- // Node origin is (-24, -16): these points are well inside the
- // actual frame, including the strip above the shifted shadow.
- for ([_]i32{ 2, 20, 60, 98 }) |y| {
- const ix: usize = @intFromFloat(84 * scale);
- const iy: usize = @intFromFloat(@as(f32, @floatFromInt(y + 16)) * scale);
- try std.testing.expectEqual(@as(u32, 0), shadow.pixels[iy * @as(usize, @intCast(shadow.width)) + ix]);
- }
- const outside_x: usize = @intFromFloat(20 * scale);
- const outside_y: usize = @intFromFloat(60 * scale);
- try std.testing.expect(shadow.pixels[outside_y * @as(usize, @intCast(shadow.width)) + outside_x] >> 24 > 0);
- }
-}
-
-test "ShadowBuffer rasterizes a soft rounded shadow behind the frame" {
- const shadow = try ShadowBuffer.create(200, 120, .{ .radius = 10, .scale = 1, .color = .{ 0, 0, 0, 0.35 }, .softness = 24 });
- defer shadow.base.drop();
-
- try std.testing.expectEqual(@as(i32, 200 + 48), shadow.width);
- try std.testing.expectEqual(@as(i32, 120 + 48), shadow.height);
-
- // CSS outer shadows are clipped out under the frame, including glass.
- const stride: usize = @intCast(shadow.width);
- const center_x: usize = @intCast(@divTrunc(shadow.width, 2));
- const center_y: usize = @intCast(@divTrunc(shadow.height, 2));
- try std.testing.expectEqual(@as(u32, 0), shadow.pixels[center_y * stride + center_x]);
-
- // The canvas corner sits diagonally past the falloff radius: fully
- // transparent.
- try std.testing.expectEqual(@as(u32, 0), shadow.pixels[0]);
-}
-
fn borderFill(hover: f32) Color {
const t = clamp01(hover);
if (t <= 0) return Color.border();
@@ -1514,7 +767,6 @@ fn sampleTitlebarMemo() TitlebarMemo {
return .{
.width = 200,
.height = 100,
- .radius = 10,
.title_ptr = null,
.scale = 1,
.hover = 0,
@@ -1534,46 +786,6 @@ fn sampleTitlebarMemo() TitlebarMemo {
};
}
-fn sampleFooterMemo() FooterMemo {
- return .{
- .width = 200,
- .height = 100,
- .radius = 10,
- .skirt_fill = null,
- .scale = 1,
- .hover = 0,
- .glass = .{ 0, 0, 0, 1 },
- .border = .{ 1, 1, 1, 0.09 },
- .border_hover = .{ 1, 1, 1, 0.22 },
- };
-}
-
-fn sampleMapping() EdgeMapping {
- return .{
- .source_x = 0,
- .source_y = 0,
- .source_w = 400,
- .source_h = 260,
- .scale = 1,
- .transform_normal = true,
- .buffer_width = 400,
- .buffer_height = 260,
- .format = drm_format_argb8888,
- .surface_width = 400,
- .surface_height = 260,
- .geom_x = 0,
- .geom_y = 0,
- .geom_w = 400,
- .geom_h = 260,
- .has_texture = true,
- .row_x = 0,
- .row_y = 259,
- .row_w = 400,
- .row_h = 1,
- .row_valid = true,
- };
-}
-
test "TitlebarMemo.eql is true for identical inputs" {
try std.testing.expect(sampleTitlebarMemo().eql(sampleTitlebarMemo()));
const inactive = sampleTitlebarMemo();
@@ -1613,28 +825,6 @@ test "TitlebarMemo.eql compares icon identity by id, not pixel pointer" {
try std.testing.expect(!left.eql(right));
}
-test "TitlebarMemo.eql ignores sampled skirt colour" {
- const title = sampleTitlebarMemo();
- try std.testing.expect(title.eql(sampleTitlebarMemo()));
-}
-
-test "FooterMemo.eql is false when the sampled skirt colour changes" {
- var left = sampleFooterMemo();
- var right = sampleFooterMemo();
- left.skirt_fill = .{ 0.1, 0.2, 0.3, 1 };
- right.skirt_fill = .{ 0.1, 0.2, 0.3, 1 };
- try std.testing.expect(left.eql(right));
- right.skirt_fill = .{ 0.1, 0.2, 0.4, 1 };
- try std.testing.expect(!left.eql(right));
- right.skirt_fill = null;
- try std.testing.expect(!left.eql(right));
-}
-
-test "FooterMemo.eql ignores title and control hover" {
- const footer = sampleFooterMemo();
- try std.testing.expect(footer.eql(sampleFooterMemo()));
-}
-
test "TitlebarMemo.eql detects font, title size and close control appearance" {
var left = sampleTitlebarMemo();
var right = sampleTitlebarMemo();
@@ -1656,25 +846,25 @@ test "TitlebarMemo.capture reads title_size from theme.global" {
const saved = theme.global;
defer theme.global = saved;
theme.global.title_size = 19.25;
- const memo = TitlebarMemo.capture(10, 10, null, .{ .radius = 0, .scale = 1 });
+ const memo = TitlebarMemo.capture(10, 10, null, .{ .scale = 1 });
try std.testing.expectEqual(@as(f32, 19.25), memo.title_size);
}
test "chrome geometry changes invalidate retained titlebar pixels" {
const saved = theme.global;
defer theme.global = saved;
- const before = TitlebarMemo.capture(400, 320, null, .{ .radius = 10 });
+ const before = TitlebarMemo.capture(400, 320, null, .{});
theme.global.chrome_control_gap += 1;
- const spaced = TitlebarMemo.capture(400, 320, null, .{ .radius = 10 });
+ const spaced = TitlebarMemo.capture(400, 320, null, .{});
try std.testing.expect(!before.eql(spaced));
try std.testing.expect(!before.reusableFor(spaced));
theme.global.chrome_control_gap = saved.chrome_control_gap;
theme.global.chrome_height += 1;
- const taller = TitlebarMemo.capture(400, 320, null, .{ .radius = 10 });
+ const taller = TitlebarMemo.capture(400, 320, null, .{});
try std.testing.expect(!before.reusableFor(taller));
theme.global.chrome_height = saved.chrome_height;
theme.global.chrome_round_buttons = !saved.chrome_round_buttons;
- const round = TitlebarMemo.capture(400, 320, null, .{ .radius = 10 });
+ const round = TitlebarMemo.capture(400, 320, null, .{});
try std.testing.expect(!before.eql(round));
try std.testing.expect(!before.reusableFor(round));
}
@@ -1702,85 +892,6 @@ test "chrome controls fit and stay centered at every supported height and densit
}
}
-test "rectsOverlap treats touching edges as disjoint" {
- try std.testing.expect(!rectsOverlap(0, 0, 10, 10, 10, 0, 10, 10));
- try std.testing.expect(rectsOverlap(0, 259, 400, 1, 0, 259, 400, 1));
- try std.testing.expect(!rectsOverlap(0, 0, 400, 259, 0, 259, 400, 1));
- try std.testing.expect(rectsOverlap(0, 0, 400, 260, 0, 259, 400, 1));
-}
-
-test "decideEdgeSample samples the first commit and skips later misses" {
- const mapping = sampleMapping();
- try std.testing.expectEqual(SampleAction.sample, decideEdgeSample(.uninitialized, null, mapping, .none, false));
- try std.testing.expectEqual(SampleAction.skip, decideEdgeSample(.color, mapping, mapping, .misses_row, false));
- try std.testing.expectEqual(SampleAction.skip, decideEdgeSample(.color, mapping, mapping, .none, false));
-}
-
-test "decideEdgeSample resamples one-pixel edge damage and full damage" {
- const mapping = sampleMapping();
- try std.testing.expectEqual(SampleAction.sample, decideEdgeSample(.color, mapping, mapping, .intersects_row, false));
- try std.testing.expectEqual(SampleAction.sample, decideEdgeSample(.color, mapping, mapping, .unknown, false));
-}
-
-test "decideEdgeSample ignores buffer pointer rotation when damage misses the row" {
- const mapping = sampleMapping();
- try std.testing.expectEqual(SampleAction.skip, decideEdgeSample(.color, mapping, mapping, .misses_row, false));
-}
-
-test "decideEdgeSample resamples when the source viewport or scale changes" {
- const mapping = sampleMapping();
- var cropped = mapping;
- cropped.source_y = 10;
- cropped.source_h = 240;
- cropped.row_y = 249;
- try std.testing.expectEqual(SampleAction.sample, decideEdgeSample(.color, mapping, cropped, .none, false));
-
- var scaled = mapping;
- scaled.scale = 2;
- scaled.buffer_width = 800;
- scaled.buffer_height = 520;
- scaled.row_y = 519;
- scaled.row_w = 800;
- try std.testing.expectEqual(SampleAction.sample, decideEdgeSample(.color, mapping, scaled, .misses_row, false));
-}
-
-test "decideEdgeSample resamples when xdg geometry offsets the row" {
- const mapping = sampleMapping();
- var inset = mapping;
- inset.geom_y = 10;
- inset.geom_h = 240;
- inset.row_y = 249;
- try std.testing.expectEqual(SampleAction.sample, decideEdgeSample(.color, mapping, inset, .none, false));
-}
-
-test "decideEdgeSample falls back on unsupported transforms and does not keep a colour" {
- const mapping = sampleMapping();
- var rotated = mapping;
- rotated.transform_normal = false;
- rotated.row_valid = false;
- try std.testing.expectEqual(SampleAction.fallback, decideEdgeSample(.color, mapping, rotated, .none, false));
- try std.testing.expectEqual(SampleAction.skip, decideEdgeSample(.fallback, rotated, rotated, .none, false));
- try std.testing.expectEqual(SampleAction.sample, decideEdgeSample(.fallback, rotated, mapping, .none, false));
-}
-
-test "decideEdgeSample falls back when the texture is missing" {
- const mapping = sampleMapping();
- var empty = mapping;
- empty.has_texture = false;
- empty.row_valid = false;
- try std.testing.expectEqual(SampleAction.fallback, decideEdgeSample(.uninitialized, null, empty, .unknown, false));
- try std.testing.expectEqual(SampleAction.skip, decideEdgeSample(.fallback, empty, empty, .none, false));
-}
-
-test "decideEdgeSample force overrides a valid cache" {
- const mapping = sampleMapping();
- try std.testing.expectEqual(SampleAction.sample, decideEdgeSample(.color, mapping, mapping, .misses_row, true));
- var empty = mapping;
- empty.has_texture = false;
- empty.row_valid = false;
- try std.testing.expectEqual(SampleAction.fallback, decideEdgeSample(.fallback, empty, empty, .none, true));
-}
-
test "ShadowMemo.eql ignores geometry while the shadow is disabled" {
const a = ShadowMemo{
.width = 10,
@@ -1816,93 +927,42 @@ test "ShadowMemo.eql is false when softness changes" {
try std.testing.expect(!a.eql(b));
}
-test "corner antialiasing stays between the fill and the composited straight border" {
- const saved_theme = theme.global;
- defer theme.global = saved_theme;
- for ([_]f32{ 0.4, 0.98, 1 }) |alpha| {
- theme.global.window_bg = .{ 16.0 / 255.0, 18.0 / 255.0, 21.0 / 255.0, alpha };
- for ([_]f32{ 0, 0.35, 1 }) |hover| {
- for ([_]f32{ 0.75, 1, 1.25, 1.5, 2 }) |scale| {
- for ([_]f32{ 7.5, 10 }) |radius| {
- for ([_]Band{ .titlebar, .footer }) |band| {
- const skirt: [4]f32 = .{ 0.2, 0.3, 0.4, alpha };
- const frame = try ChromeBuffer.create(400, 300, band, .{
- .radius = radius,
- .scale = scale,
- .hover = hover,
- .skirt_fill = skirt,
- });
- defer frame.base.drop();
- const fill = if (band == .titlebar) Color.chrome() else Color.fromRgba(skirt);
- const bordered = borderFill(hover).over(fill);
- const stride: usize = @intCast(frame.width);
- var samples: usize = 0;
- for (frame.pixels, 0..) |pixel, i| {
- const px = (@as(f32, @floatFromInt(i % stride)) + 0.5) / scale;
- const py = @as(f32, @floatFromInt(frame.band_y)) + (@as(f32, @floatFromInt(i / stride)) + 0.5) / scale;
- if (!(px < radius or px >= 400 - radius) or !(py < radius or py >= 300 - radius)) continue;
- const outer = edgeCoverage(sdRoundedBox(px, py, 0, 0, 400, 300, radius), scale);
- // Coverage may blend the fill towards the same
- // border-over-fill as the scene rects, never make
- // it brighter or punch a transparent hole in it.
- const a = fill.scaled(outer).argb();
- const b = bordered.scaled(outer).argb();
- inline for (.{ 0, 8, 16, 24 }) |shift| {
- const channel = (pixel >> shift) & 0xff;
- const lo = @min((a >> shift) & 0xff, (b >> shift) & 0xff);
- const hi = @max((a >> shift) & 0xff, (b >> shift) & 0xff);
- try std.testing.expect(channel + 1 >= lo and channel <= hi + 1);
- }
- if (outer > 0 and outer < 1) samples += 1;
- }
- try std.testing.expect(samples > 0);
- }
- }
- }
- }
- }
-}
-
test "cached chrome updates exactly match complete rasters across hover controls and scales" {
for ([_]i32{ 20, 200, 640 }) |width| {
for ([_]f32{ 1, 1.25, 1.5, 2 }) |scale| {
for ([_]f32{ 1, 0.75, 1.0 / 1.7 }) |density| {
- for ([_]f32{ 0, 12 }) |radius| {
- for ([_]Band{ .titlebar, .footer }) |band| {
- var state: ChromeState = .{ .radius = radius * density, .density = density, .scale = scale, .title = "Cached window title", .skirt_fill = .{ 0.2, 0.3, 0.4, 0.7 } };
- var previous = try ChromeBuffer.create(width, 350, band, state);
- defer previous.base.drop();
- // Titles change alone and together with hover and
- // controls: growing, shrinking, ellipsized, fallback
- // glyphs (a terminal spinner) and empty.
- const titles = [_][]const u8{
- "Cached window title",
- "\u{280b} Working on a task that is long enough to be ellipsized before the controls",
- "Short",
- "Short",
- "",
- "\u{2819} Working \u{2014} claude",
- };
- var step: usize = 0;
- for ([_]f32{ 0.35, 1, 0 }) |hover| {
- for ([_]?ControlKind{ .minimize, .maximize, .close, null }) |control| {
- const previous_title = state.title;
- state.hover = hover;
- state.chip_pos = if (control) |kind| controlSlot(kind) else 0.5;
- state.chip_alpha = if (control == null) 0.35 else 1;
- state.title = titles[step % titles.len];
- state.active = step % 2 == 0;
- state.workspace_focus = step % 3 == 0;
- step += 1;
- const expected = try ChromeBuffer.create(width, 350, band, state);
- defer expected.base.drop();
- const updated = try ChromeBuffer.createUpdated(previous, state, !std.mem.eql(u8, previous_title, state.title));
- errdefer updated.base.drop();
- try std.testing.expectEqualSlices(u32, expected.pixels, updated.pixels);
- previous.base.drop();
- previous = updated;
- }
- }
+ var state: ChromeState = .{ .density = density, .scale = scale, .title = "Cached window title" };
+ var previous = try ChromeBuffer.create(width, state);
+ defer previous.base.drop();
+ // Titles change alone and together with hover and
+ // controls: growing, shrinking, ellipsized, fallback
+ // glyphs (a terminal spinner) and empty.
+ const titles = [_][]const u8{
+ "Cached window title",
+ "\u{280b} Working on a task that is long enough to be ellipsized before the controls",
+ "Short",
+ "Short",
+ "",
+ "\u{2819} Working \u{2014} claude",
+ };
+ var step: usize = 0;
+ for ([_]f32{ 0.35, 1, 0 }) |hover| {
+ for ([_]?ControlKind{ .minimize, .maximize, .close, null }) |control| {
+ const previous_title = state.title;
+ state.hover = hover;
+ state.chip_pos = if (control) |kind| controlSlot(kind) else 0.5;
+ state.chip_alpha = if (control == null) 0.35 else 1;
+ state.title = titles[step % titles.len];
+ state.active = step % 2 == 0;
+ state.workspace_focus = step % 3 == 0;
+ step += 1;
+ const expected = try ChromeBuffer.create(width, state);
+ defer expected.base.drop();
+ const updated = try ChromeBuffer.createUpdated(previous, state, !std.mem.eql(u8, previous_title, state.title));
+ errdefer updated.base.drop();
+ try std.testing.expectEqualSlices(u32, expected.pixels, updated.pixels);
+ previous.base.drop();
+ previous = updated;
}
}
}
@@ -1914,15 +974,15 @@ test "tab title updates preserve neighbouring pixels and match a full raster" {
const Tab = @import("chrome_tabs.zig").Tab;
for ([_]f32{ 1, 1.5, 2 }) |scale| {
const before = [_]Tab{ .{ .id = 1, .title = "A longer title", .active = true, .attention = false }, .{ .id = 2, .title = "Untouched", .active = false, .attention = false } };
- var state: ChromeState = .{ .radius = 10, .scale = scale, .tabs = .{ .tabs = &before } };
- const old = try ChromeBuffer.create(600, 300, .titlebar, state);
+ var state: ChromeState = .{ .scale = scale, .tabs = .{ .tabs = &before } };
+ const old = try ChromeBuffer.create(600, state);
defer old.base.drop();
var after = before;
after[0].title = "Short";
state.tabs.tabs = &after;
const updated = try ChromeBuffer.createUpdated(old, state, true);
defer updated.base.drop();
- const full = try ChromeBuffer.create(600, 300, .titlebar, state);
+ const full = try ChromeBuffer.create(600, state);
defer full.base.drop();
try std.testing.expectEqualSlices(u32, full.pixels, updated.pixels);
const geom = @import("chrome_tabs.zig").geometry(600, 1, state.tabs);
diff --git a/src/config/loader.zig b/src/config/loader.zig
index aeac7b3..7e29469 100644
--- a/src/config/loader.zig
+++ b/src/config/loader.zig
@@ -120,8 +120,6 @@ pub const TaskbarItems = @import("taskbar_items.zig").Config;
pub const DesktopMode = enum { canvas, workspaces };
pub const CompositorConfig = struct {
- /// Temporary stage 3 comparison switch; takes effect after restart.
- scene_renderer: enum { legacy, owned } = .legacy,
desktop_mode: DesktopMode = .canvas,
floating_apps: []const []const u8 = &.{},
default_file_manager: []const u8 = "",
@@ -984,7 +982,6 @@ const region_rules: std.enums.EnumFieldStruct(std.meta.FieldEnum(RegionConfig),
};
const compositor_rules: std.enums.EnumFieldStruct(std.meta.FieldEnum(CompositorConfig), FieldRule, null) = .{
- .scene_renderer = .enumeration,
.desktop_mode = .enumeration,
.floating_apps = .json_string_list,
.taskbar_items = .taskbar_items,
@@ -1486,7 +1483,6 @@ test "documented default parses all sections" {
try std.testing.expectEqual(@as(f32, 10.0), cfg.input.accel_max_speed);
try std.testing.expectEqual(@as(u32, 10), cfg.compositor.border_radius);
try std.testing.expect(cfg.compositor.xwayland);
- try std.testing.expectEqual(.legacy, cfg.compositor.scene_renderer);
try std.testing.expectEqualStrings("Manrope", cfg.theme.font);
const q = try keybinds.parseKeybind("super+q");
diff --git a/src/config_runtime/apply.zig b/src/config_runtime/apply.zig
index ab23a40..acd492c 100644
--- a/src/config_runtime/apply.zig
+++ b/src/config_runtime/apply.zig
@@ -23,8 +23,6 @@ const themeEql = loader.themeEql;
const wheelAccel = loader.wheelAccel;
pub const applyInactiveOpacity = applyWindowOpacity;
pub fn applyDiff(server: *Server, old: Config, new: Config) void {
- if (old.compositor.scene_renderer != new.compositor.scene_renderer)
- log.warn("[compositor] scene_renderer takes effect after restart", .{});
server.world.workspaces.setMode(server, new.compositor.desktop_mode == .workspaces);
server.window_tabs.reconfigure(server);
if (old.compositor.window_gap != new.compositor.window_gap) server.world.workspaces.tiler.schedule(server);
@@ -118,7 +116,7 @@ pub fn applyDiff(server: *Server, old: Config, new: Config) void {
if (toplevel.live_rules.decorations != prev_rules.decorations) {
if (toplevel.decoration) |d| d.applyMode();
if (toplevel.kde_decoration) |d| d.applyMode(false);
- toplevel.syncChrome(true, true, @import("../Toplevel.zig").nowMs()) catch {};
+ toplevel.syncChrome(true, @import("../Toplevel.zig").nowMs()) catch {};
}
if (toplevel.live_rules.skip_taskbar != prev_rules.skip_taskbar) {
any_taskbar_changed = true;
diff --git a/src/ipc/handlers.zig b/src/ipc/handlers.zig
index 00fe2f9..55d23b0 100644
--- a/src/ipc/handlers.zig
+++ b/src/ipc/handlers.zig
@@ -161,7 +161,7 @@ pub fn handleRequest(
const geometry_box = toplevel.clientGeometry();
const decorated = toplevel.hasServerDecorations();
const radius: f32 = toplevel.cornerRadius();
- const footer = chrome.footerHeight(radius);
+ const footer = chrome.frame_border;
const client_box: protocol.RectData = .{
.x = toplevel.x + if (decorated) chrome.frame_border else 0,
@@ -221,8 +221,10 @@ pub fn handleRequest(
.configure_serial = toplevel.scheduledSerial(),
.ack_serial = toplevel.ackSerial(),
.outputs = try out_names.toOwnedSlice(allocator),
- .skirt_fill = toplevel.skirt_fill,
- .edge_sample = @tagName(toplevel.edge_kind),
+ // Kept for the wire format: frames have had no skirt to
+ // sample since the window shapes (stage 4e).
+ .skirt_fill = null,
+ .edge_sample = "none",
},
},
};
@@ -767,7 +769,7 @@ fn handleAction(
_ = toplevel.requestSize(saved.width, saved.height);
}
}
- toplevel.syncChrome(false, false, Toplevel.nowMs()) catch {};
+ toplevel.syncChrome(false, Toplevel.nowMs()) catch {};
return .{ .ok = .handled };
},
.spawn => |p| {
@@ -1153,12 +1155,12 @@ fn handleAction(
const target = std.meta.stringToEnum(DumpTarget, p.target) orelse return .{ .err = "UnknownTarget" };
switch (target) {
- .titlebar, .skirt => {
- const win_id = p.window_id orelse return .{ .err = "InvalidRequest: titlebar/skirt requires window_id" };
+ .titlebar => {
+ const win_id = p.window_id orelse return .{ .err = "InvalidRequest: titlebar requires window_id" };
const toplevel = findToplevelById(server, win_id) orelse return .{ .err = "UnknownWindow" };
if (!toplevel.hasServerDecorations()) return .{ .err = "WindowHasNoServerDecorations" };
scale = toplevel.render_scale;
- target_buf = if (target == .titlebar) toplevel.titlebar_buffer.buffer else toplevel.footer_buffer.buffer;
+ target_buf = toplevel.titlebar_buffer.buffer;
},
// Each tag names the Output field holding that panel.
.control_center => {
@@ -1849,7 +1851,6 @@ pub const PanelRegistryEntry = struct {
/// `dump_buffer` targets; the panel tags double as `Output` field names.
const DumpTarget = enum {
titlebar,
- skirt,
taskbar,
start_menu,
control_center,
@@ -1861,7 +1862,7 @@ const DumpTarget = enum {
.start_menu => "StartMenuNotOpen",
.control_center => "ControlCenterNotOpen",
.power_menu => "PowerMenuNotOpen",
- .titlebar, .skirt => @compileError("window targets have no panel"),
+ .titlebar => @compileError("window targets have no panel"),
};
}
};
diff --git a/src/ipc/protocol.zig b/src/ipc/protocol.zig
index e0d7ac6..638aec4 100644
--- a/src/ipc/protocol.zig
+++ b/src/ipc/protocol.zig
@@ -659,7 +659,7 @@ pub const WaitForFrameResult = struct {
};
pub const DumpBufferParams = struct {
- target: []const u8, // "titlebar", "skirt", "start_menu", "control_center", "power_menu", "taskbar"
+ target: []const u8, // "titlebar", "start_menu", "control_center", "power_menu", "taskbar"
window_id: ?u64 = null,
output: ?[]const u8 = null,
};
diff --git a/src/ipc/stats.zig b/src/ipc/stats.zig
index e816271..ec969b2 100644
--- a/src/ipc/stats.zig
+++ b/src/ipc/stats.zig
@@ -36,6 +36,8 @@ pub const PerformanceStats = struct {
/// Frames whose output commit was skipped because nothing on screen changed.
output_skipped_commits: u64 = 0,
titlebar_paints: u64 = 0,
+ // Always 0 since the window shapes (no footer raster, no edge sample); kept
+ // so the PerformanceStats wire format and its readers stay unchanged.
footer_paints: u64 = 0,
edge_samples_attempted: u64 = 0,
edge_samples_succeeded: u64 = 0,
@@ -226,10 +228,6 @@ pub fn recordTitlebarPaint() void {
global_stats.titlebar_paints +%= 1;
}
-pub fn recordFooterPaint() void {
- global_stats.footer_paints +%= 1;
-}
-
pub const TaskbarPaintCause = struct {
pub const start: u8 = 1 << 0;
pub const chip: u8 = 1 << 1;
@@ -265,19 +263,6 @@ pub fn recordTaskbarClockFrameRequest() void {
global_stats.taskbar_clock_frame_requests +%= 1;
}
-pub fn recordEdgeSampleAttempt() void {
- global_stats.edge_samples_attempted +%= 1;
-}
-
-pub fn recordEdgeSampleSuccess(ns: u64) void {
- global_stats.edge_samples_succeeded +%= 1;
- global_stats.edge_sample_ns +%= ns;
-}
-
-pub fn recordEdgeSampleSkip() void {
- global_stats.edge_samples_skipped +%= 1;
-}
-
pub fn recordIconCacheHit() void {
global_stats.icon_cache_hits +%= 1;
}
diff --git a/src/main.zig b/src/main.zig
index b268bdb..14ad7e5 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -94,7 +94,6 @@ fn start(init: std.process.Init) !bool {
// Process-lifetime caches, emptied after the scene has dropped its buffers.
defer @import("ui").text.deinit();
defer @import("panel_buffer.zig").PanelBuffer.drainPool();
- defer @import("chrome.zig").clearShadowPatchCache();
defer @import("ui").shell_icons.deinit();
defer server.deinit();
diff --git a/src/resize.zig b/src/resize.zig
index 9357087..8fac5d0 100644
--- a/src/resize.zig
+++ b/src/resize.zig
@@ -187,9 +187,9 @@ pub fn selectEdgesFromQuadrant(
/// How far a grab reaches past the frame. `Toplevel.resize_grab` covers this
/// band whether or not a shadow is drawn there.
pub const reach_outside: f64 = 10.0;
-/// How far it reaches into the frame, where chrome (titlebar, footer skirt)
-/// is exposed. Beside the client the frame border is 1 px and the client
-/// surface is above it, so `inside_client` keeps those pixels the client's.
+/// How far it reaches into the frame, where the titlebar is exposed. Beside and
+/// below the client the frame border is 1 px and the client surface is above
+/// it, so `inside_client` keeps those pixels the client's.
pub const reach_inside: f64 = 4.0;
pub fn detectResizeEdges(
diff --git a/src/window_tabs.zig b/src/window_tabs.zig
index 764b795..389bd2e 100644
--- a/src/window_tabs.zig
+++ b/src/window_tabs.zig
@@ -168,7 +168,7 @@ pub fn reconfigure(self: *Self, server: *Server) void {
var it = server.world.toplevels.iterator(.forward);
while (it.next()) |top| {
self.reconcile(top);
- top.syncChrome(false, false, Top.nowMs()) catch {};
+ top.syncChrome(false, Top.nowMs()) catch {};
}
var pending_index: usize = 0;
while (pending_index < self.pending.items.len) {
@@ -276,7 +276,7 @@ pub fn select(self: *Self, top: *Top) void {
top.minimized = minimized;
top.map_motion.cancel(1);
top.map_opacity.cancel(1);
- top.syncChrome(false, false, Top.nowMs()) catch {};
+ top.syncChrome(false, Top.nowMs()) catch {};
old.syncForeign();
top.syncForeign();
if (top.server.ipc) |ipc| {
@@ -325,7 +325,7 @@ pub fn remove(self: *Self, top: *Top, restore: bool) void {
const focused = top.server.world.toplevels.first();
if (focused == top or (focused != null and focused.?.parentWindow() == top)) top.server.world.focus(other);
};
- if (active(top.server, group)) |other| other.syncChrome(false, false, Top.nowMs()) catch {};
+ if (active(top.server, group)) |other| other.syncChrome(false, Top.nowMs()) catch {};
refreshVisibility(top.server);
}
@@ -339,7 +339,7 @@ pub fn closeGroup(top: *Top) void {
fn notice(server: *Server, group: u64, value: Notice) void {
if (active(server, group)) |top| {
top.tab_notice = value;
- top.syncChrome(false, false, Top.nowMs()) catch {};
+ top.syncChrome(false, Top.nowMs()) catch {};
}
}
diff --git a/src/workspaces.zig b/src/workspaces.zig
index 45ca44e..bd2112d 100644
--- a/src/workspaces.zig
+++ b/src/workspaces.zig
@@ -169,7 +169,7 @@ pub fn setMode(self: *Self, server: *Server, enabled: bool) void {
self.refresh(server);
focusFallback(server, null);
var tops = server.world.toplevels.iterator(.forward);
- while (tops.next()) |top| if (top.in_world) top.syncChrome(false, false, Top.nowMs()) catch {};
+ while (tops.next()) |top| if (top.in_world) top.syncChrome(false, Top.nowMs()) catch {};
server.world.applyCamera();
if (server.input.open_control_center) |cc| {
cc.shortcuts.cancel();
diff --git a/src/xwayland_surface.zig b/src/xwayland_surface.zig
index 3e8aafc..df1a10f 100644
--- a/src/xwayland_surface.zig
+++ b/src/xwayland_surface.zig
@@ -456,7 +456,7 @@ fn handleSetSizeHints(listener: *wl.Listener(void)) void {
fn handleSetDecorations(listener: *wl.Listener(void)) void {
const adapter: *Adapter = @fieldParentPtr("set_decorations", listener);
- adapter.window.syncChrome(false, true, Toplevel.nowMs()) catch {};
+ adapter.window.syncChrome(true, Toplevel.nowMs()) catch {};
}
fn handleSetOverrideRedirect(listener: *wl.Listener(void)) void {
diff --git a/tests/appearance_chrome.py b/tests/appearance_chrome.py
index c31bd51..7f31b94 100644
--- a/tests/appearance_chrome.py
+++ b/tests/appearance_chrome.py
@@ -41,7 +41,7 @@ def run(scale, external_theme=False):
env_extra["REDIWM_THEME"] = str(theme_path)
process, log = spawn_compositor(
tmp, scale=str(scale), config_content=config,
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra=env_extra)
client = None
focus_client = None
diff --git a/tests/battery_popup.py b/tests/battery_popup.py
index 63eee43..b0e1365 100644
--- a/tests/battery_popup.py
+++ b/tests/battery_popup.py
@@ -26,7 +26,7 @@ def run(scale):
(supply / "uevent").write_text(f"POWER_SUPPLY_TYPE=Battery\nPOWER_SUPPLY_CAPACITY={percent}\nPOWER_SUPPLY_STATUS={state}\n" + (
"POWER_SUPPLY_ENERGY_FULL=57000000\nPOWER_SUPPLY_ENERGY_FULL_DESIGN=90000000\nPOWER_SUPPLY_CYCLE_COUNT=482\n" if details else ""))
fake = start_fake()
- process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"), config_content='[compositor]\nxwayland = false\n', env_extra={
+ process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"), config_content='[compositor]\nxwayland = false\n', env_extra={
"LD_PRELOAD": str(hook), "REDIWM_TEST_BATTERY_DIR": str(supply.parent),
"DBUS_SYSTEM_BUS_ADDRESS": os.environ["DBUS_SESSION_BUS_ADDRESS"],
"DBUS_SESSION_BUS_ADDRESS": "", "XDG_CACHE_HOME": str(tmp),
diff --git a/tests/bluetooth.py b/tests/bluetooth.py
index fc62ba5..4b52e5e 100644
--- a/tests/bluetooth.py
+++ b/tests/bluetooth.py
@@ -112,7 +112,7 @@ def run(scale):
fake = start_fake()
with tempfile.TemporaryDirectory(prefix='rediwm-bluetooth-') as directory:
tmp = Path(directory)
- process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER','pixman'), config_content='[compositor]\nxwayland = false\n', env_extra={
+ process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER','gles2'), config_content='[compositor]\nxwayland = false\n', env_extra={
'DBUS_SYSTEM_BUS_ADDRESS': os.environ['DBUS_SESSION_BUS_ADDRESS'], 'DBUS_SESSION_BUS_ADDRESS': '',
'XDG_CACHE_HOME': str(tmp), 'PIPEWIRE_RUNTIME_DIR': str(tmp), 'PULSE_SERVER': 'unix:/nonexistent-rediwm-test-pulse',
})
diff --git a/tests/brave_input.py b/tests/brave_input.py
index 19fa164..cfcebd0 100644
--- a/tests/brave_input.py
+++ b/tests/brave_input.py
@@ -20,7 +20,7 @@ def run():
browser = os.environ.get("REDIWM_TEST_BRAVE") or shutil.which("brave")
if not browser:
raise SystemExit("Brave not found; set REDIWM_TEST_BRAVE to its executable")
- renderer = os.environ.get("REDIWM_TEST_RENDERER", "pixman")
+ renderer = os.environ.get("REDIWM_TEST_RENDERER", "gles2")
with tempfile.TemporaryDirectory(prefix="rediwm-brave-input-") as directory:
tmp = Path(directory)
# Report DOM changes through the ordinary window title: no devtools
diff --git a/tests/calendar_popup.py b/tests/calendar_popup.py
index ef5dae2..1b1624c 100644
--- a/tests/calendar_popup.py
+++ b/tests/calendar_popup.py
@@ -19,7 +19,7 @@ def run(scale):
with tempfile.TemporaryDirectory(prefix="rediwm-calendar-") as directory:
tmp = Path(directory)
# Pixel equality checks need a settled popup, not its opening slide.
- process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"), config_content='[compositor]\nxwayland = false\n[animations]\nenabled = false\n',
+ process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"), config_content='[compositor]\nxwayland = false\n[animations]\nenabled = false\n',
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "XDG_CACHE_HOME": directory, "TZ": "Pacific/Auckland", "LC_ALL": "C", "LANGUAGE": "en"})
try:
with IPCClient(tmp, timeout=15) as ipc:
diff --git a/tests/capture.py b/tests/capture.py
index dcbe7a0..cda99cd 100644
--- a/tests/capture.py
+++ b/tests/capture.py
@@ -194,9 +194,8 @@ def run_window_capture_case(client_binary):
"""
with tempfile.TemporaryDirectory(prefix="rediwm-window-capture-") as directory:
tmp = Path(directory)
- owned = os.environ.get("REDIWM_TEST_SCENE_RENDERER") == "owned"
compositor, log = spawn_compositor(
- tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
config_content="[compositor]\nxwayland = false\n[animations]\nenabled = false\n",
env_extra={"XDG_CACHE_HOME": str(tmp / "cache"), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
client = None
@@ -205,8 +204,7 @@ def run_window_capture_case(client_binary):
socket_path = wait_for(lambda: next(tmp.glob("rediwm-*.sock"), None), "IPC unavailable")
display = next(p.name for p in tmp.glob("wayland-*") if not p.name.endswith(".lock"))
env = dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WAYLAND_DISPLAY=display)
- if owned:
- env["CAPTURE_DECORATE"] = "1"
+ env["CAPTURE_DECORATE"] = "1"
with client_log.open("w") as output:
client = subprocess.Popen([str(client_binary)], stdin=subprocess.PIPE,
stdout=output, stderr=output, text=True, env=env)
@@ -215,11 +213,8 @@ def run_window_capture_case(client_binary):
win = wait_for(lambda: next((w for w in ipc.get_windows()
if w["app_id"] == "rediwm.capture-fixture"), None),
"capture-fixture toplevel did not map")
- if owned:
- box = ipc.get_window_debug(win["id"])["client_box"]
- assert (box["width"], box["height"]) == (200, 150), (win, box)
- else:
- assert (win["width"], win["height"]) == (200, 150), win
+ box = ipc.get_window_debug(win["id"])["client_box"]
+ assert (box["width"], box["height"]) == (200, 150), (win, box)
wait_for(lambda: "presented\n" in client_log.read_text(), "first frame not presented")
before = client_log.read_text()
@@ -264,16 +259,15 @@ def run_window_capture_case(client_binary):
if fmt in (SHM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_ABGR8888):
assert a == 255, a
- if owned:
- # The window's rounded shape clips the client, so a captured window keeps
- # transparent bottom corners (premultiplied: black) and an intact interior.
- for cx in (0, buf_w - 1):
- r, g, b, a = sample(cx, buf_h - 1)
- assert (r, g, b) == (0, 0, 0), ("window capture corner is not transparent", cx, (r, g, b, a))
- if fmt in (SHM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_ABGR8888):
- assert a == 0, ("window capture corner has alpha", cx, a)
- r, g, b, a = sample(20, buf_h - 20)
- assert (r, g, b) == (255, 0, 0), ("window capture interior near the corner", (r, g, b, a))
+ # The window's rounded shape clips the client, so a captured window keeps
+ # transparent bottom corners (premultiplied: black) and an intact interior.
+ for cx in (0, buf_w - 1):
+ r, g, b, a = sample(cx, buf_h - 1)
+ assert (r, g, b) == (0, 0, 0), ("window capture corner is not transparent", cx, (r, g, b, a))
+ if fmt in (SHM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_ABGR8888):
+ assert a == 0, ("window capture corner has alpha", cx, a)
+ r, g, b, a = sample(20, buf_h - 20)
+ assert (r, g, b) == (255, 0, 0), ("window capture interior near the corner", (r, g, b, a))
print(f"capture: window session returned real pixels at its own {buf_w}x{buf_h} "
f"content size, not the monitor's (fmt={fmt:#x})")
@@ -318,7 +312,7 @@ def run_window_occlusion_case(client_binary):
with tempfile.TemporaryDirectory(prefix="rediwm-window-occlusion-") as directory:
tmp = Path(directory)
compositor, log = spawn_compositor(
- tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
config_content="[compositor]\nxwayland = false\n[animations]\nenabled = false\n",
env_extra={"XDG_CACHE_HOME": str(tmp / "cache"), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
bottom = top = None
@@ -441,7 +435,7 @@ def run_window_camera_case(client_binary):
with tempfile.TemporaryDirectory(prefix="rediwm-window-camera-") as directory:
tmp = Path(directory)
compositor, log = spawn_compositor(
- tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
config_content="[compositor]\nxwayland = false\n[animations]\nenabled = false\n",
env_extra={"XDG_CACHE_HOME": str(tmp / "cache"), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
client = None
@@ -539,7 +533,7 @@ def run_window_minimize_case(client_binary):
with tempfile.TemporaryDirectory(prefix="rediwm-window-minimize-") as directory:
tmp = Path(directory)
compositor, log = spawn_compositor(
- tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
config_content="[compositor]\nxwayland = false\n[animations]\nenabled = false\n",
env_extra={"XDG_CACHE_HOME": str(tmp / "cache"), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
client = None
@@ -627,7 +621,7 @@ def run_window_resize_case(client_binary):
with tempfile.TemporaryDirectory(prefix="rediwm-window-resize-") as directory:
tmp = Path(directory)
compositor, log = spawn_compositor(
- tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
config_content="[compositor]\nxwayland = false\n[animations]\nenabled = false\n",
env_extra={"XDG_CACHE_HOME": str(tmp / "cache"), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
client = None
@@ -727,7 +721,7 @@ def run_window_destroy_case(client_binary):
with tempfile.TemporaryDirectory(prefix="rediwm-window-destroy-") as directory:
tmp = Path(directory)
compositor, log = spawn_compositor(
- tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ tmp, scale="1", outputs="1", renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
config_content="[compositor]\nxwayland = false\n[animations]\nenabled = false\n",
env_extra={"XDG_CACHE_HOME": str(tmp / "cache"), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
owner = watcher = None
@@ -1267,7 +1261,7 @@ def run():
build_client(build_tmp)
client_binary = build_tmp / "client"
- run_case(client_binary, os.environ.get("REDIWM_TEST_RENDERER", "pixman"), "capture",
+ run_case(client_binary, os.environ.get("REDIWM_TEST_RENDERER", "gles2"), "capture",
CAPTURE_FORMATS, SHM_FORMAT_ARGB8888, "ext-image-copy-capture-v1 shm")
run_window_capture_case(client_binary)
diff --git a/tests/control_center.py b/tests/control_center.py
index cf079b0..9f7d2b0 100644
--- a/tests/control_center.py
+++ b/tests/control_center.py
@@ -43,7 +43,7 @@ print(f'fixture,backlight,{value},{value}%,100')
# A translucent window background: only the chrome may show it.
(tmp / "theme.toml").write_text('[theme]\nwindow_bg = "rgba(16,18,21,0.5)"\napp_bg = "#101215"\n')
env.update(PATH=str(helpers) + os.pathsep + os.environ["PATH"], SETTINGS_TEST_DIR=str(tmp), REDIWM_THEME=str(tmp / "theme.toml"))
- process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"), config_content="[input]\ninvert_scroll = false\n", env_extra=env)
+ process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"), config_content="[input]\ninvert_scroll = false\n", env_extra=env)
try:
with IPCClient(tmp, timeout=15) as ipc:
ipc.wait_for("wallpaper_presented", timeout_ms=10000)
@@ -287,7 +287,7 @@ def unavailable_services(scale):
helper = tmp / "brightnessctl"
helper.write_text("#!/bin/sh\nexit 1\n")
helper.chmod(0o755)
- process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"), env_extra={
+ process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"), env_extra={
"PULSE_SERVER": "unix:" + str(tmp / "no-audio"), "DBUS_SESSION_BUS_ADDRESS": "",
"PATH": str(tmp) + os.pathsep + os.environ["PATH"],
})
@@ -696,7 +696,7 @@ def systemd_services(scale):
assert select.select([result.stdout], [], [], 10)[0], 'fake systemd startup'
assert result.stdout.readline().strip() == 'ready'
return result
- process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'), env_extra={'DBUS_SYSTEM_BUS_ADDRESS': os.environ['DBUS_SESSION_BUS_ADDRESS'], 'GIO_USE_VFS': 'local', 'LD_PRELOAD': str(hook), 'SYSTEMD_TEST_EDITOR': str(editor), 'SYSTEMD_TEST_ROOT': str(root), 'SYSTEMD_TEST_LOG': str(calls)}, config_content='[input]\ninvert_scroll = false\n')
+ process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'), env_extra={'DBUS_SYSTEM_BUS_ADDRESS': os.environ['DBUS_SESSION_BUS_ADDRESS'], 'GIO_USE_VFS': 'local', 'LD_PRELOAD': str(hook), 'SYSTEMD_TEST_EDITOR': str(editor), 'SYSTEMD_TEST_ROOT': str(root), 'SYSTEMD_TEST_LOG': str(calls)}, config_content='[input]\ninvert_scroll = false\n')
try:
with IPCClient(tmp, timeout=15) as ipc:
ipc.open_control_center()
diff --git a/tests/decorations.py b/tests/decorations.py
index 32f7251..be8eafb 100644
--- a/tests/decorations.py
+++ b/tests/decorations.py
@@ -16,7 +16,7 @@ def run():
build_client(tmp)
(tmp / "config.toml").write_text("")
env = dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WLR_BACKENDS="headless",
- WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER="pixman", REDIWM_SCALE="1",
+ WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER="gles2", REDIWM_SCALE="1",
REDIWM_CONFIG=str(tmp / "config.toml"), REDIWM_IPC_AUTOMATION="1")
env.pop("WAYLAND_DISPLAY", None)
env.pop("REDIWM_SOCKET", None)
diff --git a/tests/desktop_canvas.py b/tests/desktop_canvas.py
index 25c0f4e..24e1d03 100644
--- a/tests/desktop_canvas.py
+++ b/tests/desktop_canvas.py
@@ -14,7 +14,7 @@ def run():
# A 100 ms desktop slide settles well inside the 0.25 s waits below.
original = '# keep me\n[input]\ninvert_scroll = false\npan_speed = 1.0\n[compositor]\nxwayland = false\ndesktop_switch_ms = 100\n'
process, log = spawn_compositor(
- tmp, config_content=original, renderer=os.getenv("REDIWM_TEST_RENDERER", "pixman"),
+ tmp, config_content=original, renderer=os.getenv("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": ""})
try:
with IPCClient(tmp, timeout=20) as ipc:
diff --git a/tests/desktop_damage.py b/tests/desktop_damage.py
index 207a1e6..380de52 100644
--- a/tests/desktop_damage.py
+++ b/tests/desktop_damage.py
@@ -16,7 +16,7 @@ import time
from PIL import Image, ImageChops
-from ipc_client import IPCClient, ROOT, scene_renderer_config
+from ipc_client import IPCClient, ROOT
def run(args):
@@ -29,8 +29,8 @@ def run(args):
(desktop_dir / name).write_text("desktop damage fixture")
config = tmp / "config.toml"
def configure_scale(scale, desktop=True):
- config.write_text(scene_renderer_config(f'[compositor]\nxwayland = false\n[desktop]\nenabled = {str(desktop).lower()}\n'
- f'[[outputs]]\nname = "HEADLESS-1"\nscale = {scale}\n'))
+ config.write_text(f'[compositor]\nxwayland = false\n[desktop]\nenabled = {str(desktop).lower()}\n'
+ f'[[outputs]]\nname = "HEADLESS-1"\nscale = {scale}\n')
configure_scale(args.scale)
env = dict(os.environ, XDG_RUNTIME_DIR=directory,
@@ -286,7 +286,7 @@ if __name__ == "__main__":
parser.add_argument("--bin-dir", type=Path, default=ROOT / "zig-out/bin")
parser.add_argument("--scale", type=float, choices=(1, 1.5, 2), default=1)
parser.add_argument("--rename-only", action="store_true", help="Check the inline rename overlay and cancellation only")
- parser.add_argument("--renderer", choices=("pixman", "gles2"), default=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ parser.add_argument("--renderer", choices=("pixman", "gles2"), default=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
help="gles2 also requires in-place texture updates (set WLR_RENDER_DRM_DEVICE)")
parser.add_argument("--capture-dir", type=Path, help="Save screenshots for before/after comparison")
run(parser.parse_args())
diff --git a/tests/desktop_icons.py b/tests/desktop_icons.py
index e41f3d8..25e4f2b 100644
--- a/tests/desktop_icons.py
+++ b/tests/desktop_icons.py
@@ -22,7 +22,7 @@ def run():
tmp = Path(directory)
desktop = tmp / 'Desktop'
env = dict(os.environ, XDG_RUNTIME_DIR=directory, XDG_CONFIG_HOME=str(tmp/'config'), XDG_CACHE_HOME=str(tmp/'cache'), XDG_STATE_HOME=str(tmp/'state'),
- WLR_BACKENDS='headless', REDIWM_FILES_DEVICES='0', WLR_HEADLESS_OUTPUTS='1', WLR_RENDERER=os.getenv('REDIWM_TEST_RENDERER', 'pixman'),
+ WLR_BACKENDS='headless', REDIWM_FILES_DEVICES='0', WLR_HEADLESS_OUTPUTS='1', WLR_RENDERER=os.getenv('REDIWM_TEST_RENDERER', 'gles2'),
REDIWM_SCALE='1', REDIWM_DESKTOP_BUILTINS="0", REDIWM_DESKTOP_DIR=str(desktop))
config_path = tmp/'rediwm-config.toml'
config_path.write_text('[compositor]\ndefault_file_manager = "rediwm-fixture-files.desktop"\n')
diff --git a/tests/desktop_zoom.py b/tests/desktop_zoom.py
index 5a4cb34..1c634b4 100644
--- a/tests/desktop_zoom.py
+++ b/tests/desktop_zoom.py
@@ -14,7 +14,6 @@ import tempfile
import time
from PIL import Image
-from ipc_client import scene_renderer_config
ROOT = Path(__file__).resolve().parents[1]
@@ -44,12 +43,12 @@ def run():
with tempfile.TemporaryDirectory(prefix="rediwm-zoom-test-") as tmp:
tmp = Path(tmp)
build_client(tmp)
- env = dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WLR_BACKENDS="headless", WLR_HEADLESS_OUTPUTS=os.environ.get("REDIWM_TEST_OUTPUTS", "1"), WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"), WLR_RENDERER_ALLOW_SOFTWARE="1", REDIWM_SCALE=os.environ.get("REDIWM_TEST_SCALE", "1"), REDIWM_IPC_AUTOMATION="1")
+ env = dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WLR_BACKENDS="headless", WLR_HEADLESS_OUTPUTS=os.environ.get("REDIWM_TEST_OUTPUTS", "1"), WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"), WLR_RENDERER_ALLOW_SOFTWARE="1", REDIWM_SCALE=os.environ.get("REDIWM_TEST_SCALE", "1"), REDIWM_IPC_AUTOMATION="1")
config_path = tmp / "rediwm-config.toml"
# Protocol deltas below deliberately use the non-inverted direction.
# pan_speed = 1.0 keeps pan assertions below at raw screen-space motion
# (see the default 2x pan_speed in config/loader.zig's InputConfig).
- config_path.write_text(scene_renderer_config("[input]\ninvert_scroll = false\npan_speed = 1.0\n"))
+ config_path.write_text("[input]\ninvert_scroll = false\npan_speed = 1.0\n")
env["REDIWM_CONFIG"] = str(config_path)
env.pop("WAYLAND_DISPLAY", None)
env.pop("REDIWM_SOCKET", None)
diff --git a/tests/display_arrangement.py b/tests/display_arrangement.py
index 9f97598..d239bd1 100644
--- a/tests/display_arrangement.py
+++ b/tests/display_arrangement.py
@@ -58,7 +58,7 @@ def run_two_outputs():
with tempfile.TemporaryDirectory(prefix="rediwm-arrangement-") as directory:
tmp = Path(directory)
process, log = spawn_compositor(tmp, outputs="2", config_content=CONFIG,
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"))
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"))
try:
with IPCClient(tmp, timeout=15) as ipc:
ipc.wait_for("wallpaper_presented", timeout_ms=10000)
diff --git a/tests/dm.py b/tests/dm.py
index 0c9a8ed..2e16c6f 100644
--- a/tests/dm.py
+++ b/tests/dm.py
@@ -357,7 +357,7 @@ def test_real_greeter_connects():
home = Path(runtime) / "home"
home.mkdir()
env = {
- "WLR_BACKENDS": "headless", "WLR_HEADLESS_OUTPUTS": "1", "WLR_RENDERER": "pixman", "REDIWM_SCALE": "1",
+ "WLR_BACKENDS": "headless", "WLR_HEADLESS_OUTPUTS": "1", "WLR_RENDERER": "gles2", "REDIWM_SCALE": "1",
"XDG_RUNTIME_DIR": runtime, "HOME": str(home),
"DBUS_SYSTEM_BUS_ADDRESS": "unix:path=/nonexistent-rediwm-test-system-bus",
"DBUS_SESSION_BUS_ADDRESS": "unix:path=/nonexistent-rediwm-test-session-bus",
diff --git a/tests/edge_sampling.py b/tests/edge_sampling.py
deleted file mode 100644
index afe7753..0000000
--- a/tests/edge_sampling.py
+++ /dev/null
@@ -1,229 +0,0 @@
-#!/usr/bin/env python3
-"""Damage-aware client-edge sampling. Run after zig build.
-
-Uses the zoom_client fixture with REDIWM_TEST_EDGE=1. Never connects to the
-host desktop. Set REDIWM_TEST_RENDERER=gles2 to exercise GPU readback.
-"""
-import os
-from pathlib import Path
-import subprocess
-import tempfile
-
-from desktop_zoom import ROOT, build_client, wait_for
-from ipc_client import IPCClient
-
-
-KEY_1, KEY_2, KEY_3, KEY_4 = 2, 3, 4, 5
-KEY_7, KEY_8, KEY_9 = 7, 8, 9
-KEY_F5, KEY_F6 = 63, 64
-KEY_F8, KEY_F9 = 66, 67
-
-
-def approx_rgba(value, expected, eps=0.02):
- assert value is not None, f"expected {expected}, got null skirt"
- assert len(value) == 4, value
- for got, want in zip(value, expected):
- assert abs(got - want) <= eps, f"{value} !~ {expected}"
-
-
-def run():
- renderer = os.environ.get("REDIWM_TEST_RENDERER", "pixman")
- with tempfile.TemporaryDirectory(prefix="rediwm-edge-") as directory:
- tmp = Path(directory)
- build_client(tmp)
- (tmp / "config.toml").write_text("")
- env = dict(
- os.environ,
- XDG_RUNTIME_DIR=str(tmp),
- WLR_BACKENDS="headless",
- WLR_HEADLESS_OUTPUTS="1",
- WLR_RENDERER=renderer,
- WLR_RENDERER_ALLOW_SOFTWARE="1",
- REDIWM_SCALE="1",
- REDIWM_CONFIG=str(tmp / "config.toml"),
- REDIWM_TEST_EDGE="1",
- REDIWM_TEST_DECORATION="server",
- )
- env.pop("WAYLAND_DISPLAY", None)
- env.pop("REDIWM_SOCKET", None)
- client_log = tmp / "client.log"
- with (tmp / "compositor.log").open("w") as log:
- compositor = subprocess.Popen([str(ROOT / "zig-out/bin/rediwm")], env=env, stdout=log, stderr=log)
- client = None
- try:
- ipc_path = wait_for(lambda: next(tmp.glob("rediwm-*.sock"), None), "IPC unavailable")
- display = next(p.name for p in tmp.glob("wayland-*") if not p.name.endswith(".lock"))
- with client_log.open("w") as clog:
- client = subprocess.Popen(
- [str(tmp / "client")],
- env=dict(env, WAYLAND_DISPLAY=display),
- stdout=clog,
- stderr=clog,
- )
- with IPCClient(ipc_path, timeout=15) as ipc:
- win = wait_for(
- lambda: next((w for w in ipc.get_windows() if w.get("app_id") == "rediwm.zoom-fixture"), None),
- "fixture did not map",
- )
- wait_for(lambda: client_log.exists() and "frame 8" in client_log.read_text(), "frame callbacks not delivered")
- ipc.action("focus_window", {"id": win["id"]})
- ipc.wait_for_frame()
-
- debug = ipc.get_window_debug(win["id"])
- assert debug["decoration_mode"] == "server", debug
- approx_rgba(debug["skirt_fill"], (0.0, 0.0, 1.0, 1.0))
- assert debug["edge_sample"] == "color", debug
-
- def fire(code, token):
- start = client_log.read_text().count(token)
- ipc.key_down_up(code)
- wait_for(lambda: client_log.read_text().count(token) > start, f"client did not log {token}")
- ipc.wait_for_frame()
-
- ipc.reset_perf()
- before = ipc.get_perf()
- title_before = before["titlebar_paints"]
- footer_before = before["footer_paints"]
- attempted_before = before["edge_samples_attempted"]
- skipped_before = before["edge_samples_skipped"]
-
- fire(KEY_1, "edge above")
- after_above = ipc.get_perf()
- assert after_above["edge_samples_attempted"] == attempted_before, after_above
- assert after_above["edge_samples_skipped"] > skipped_before, after_above
- assert after_above["titlebar_paints"] == title_before, after_above
- assert after_above["footer_paints"] == footer_before, after_above
- debug = ipc.get_window_debug(win["id"])
- approx_rgba(debug["skirt_fill"], (0.0, 0.0, 1.0, 1.0))
-
- fire(KEY_3, "edge none")
- after_none = ipc.get_perf()
- assert after_none["edge_samples_attempted"] == attempted_before, after_none
- debug = ipc.get_window_debug(win["id"])
- approx_rgba(debug["skirt_fill"], (0.0, 0.0, 1.0, 1.0))
-
- fire(KEY_4, "edge rotate")
- after_rotate = ipc.get_perf()
- assert after_rotate["edge_samples_attempted"] == attempted_before, after_rotate
- debug = ipc.get_window_debug(win["id"])
- approx_rgba(debug["skirt_fill"], (0.0, 0.0, 1.0, 1.0))
-
- fire(KEY_2, "edge row")
- after_row = ipc.get_perf()
- assert after_row["edge_samples_attempted"] > attempted_before, after_row
- assert after_row["edge_samples_succeeded"] >= 1, after_row
- assert after_row["titlebar_paints"] == title_before, after_row
- assert after_row["footer_paints"] > footer_before, after_row
- debug = ipc.get_window_debug(win["id"])
- approx_rgba(debug["skirt_fill"], (0.0, 1.0, 0.0, 1.0))
-
- ipc.reset_perf()
- ipc.action("move_window_to", {"id": win["id"], "x": win["x"] + 40, "y": win["y"] + 20})
- ipc.wait_for_frame()
- moved = ipc.get_perf()
- assert moved["edge_samples_attempted"] == 0, moved
- debug = ipc.get_window_debug(win["id"])
- approx_rgba(debug["skirt_fill"], (0.0, 1.0, 0.0, 1.0))
-
- ipc.reset_perf()
- ipc.action("move_cursor", {"x": debug["chrome_box"]["x"] + 80, "y": debug["chrome_box"]["y"] + 10})
- ipc.wait_for_frame()
- hovered = ipc.get_perf()
- assert hovered["edge_samples_attempted"] == 0, hovered
-
- ipc.reset_perf()
- fire(KEY_8, "edge transform")
- rotated = ipc.get_window_debug(win["id"])
- assert rotated["edge_sample"] == "fallback", rotated
- assert rotated["skirt_fill"] is None, rotated
- assert rotated["buffer_transform"] != "normal", rotated
- fire(KEY_8, "edge transform")
- restored = ipc.get_window_debug(win["id"])
- assert restored["edge_sample"] == "color", restored
- approx_rgba(restored["skirt_fill"], (0.0, 1.0, 0.0, 1.0))
-
- ipc.reset_perf()
- fire(KEY_7, "edge scale")
- scaled = ipc.get_perf()
- assert scaled["edge_samples_attempted"] >= 1, scaled
- debug = ipc.get_window_debug(win["id"])
- assert debug["edge_sample"] == "color", debug
- fire(KEY_7, "edge scale")
-
- ipc.reset_perf()
- fire(KEY_9, "edge geometry")
- geo = ipc.get_perf()
- assert geo["edge_samples_attempted"] >= 1, geo
- fire(KEY_9, "edge geometry")
-
- ipc.key_down_up(KEY_F8)
- wait_for(
- lambda: next((w for w in ipc.get_windows() if w["id"] == win["id"] and w.get("is_maximized") and w["width"] > 1000), None),
- "maximize failed",
- )
- ipc.wait_for_frame()
- ipc.key_down_up(KEY_F9)
- wait_for(
- lambda: next((w for w in ipc.get_windows() if w["id"] == win["id"] and not w.get("is_maximized")), None),
- "restore failed",
- )
- ipc.wait_for_frame()
- debug = ipc.get_window_debug(win["id"])
- assert debug["edge_sample"] == "color", debug
-
- ipc.key_down_up(KEY_F5)
- wait_for(
- lambda: ipc.get_window_debug(win["id"])["decoration_mode"] == "client",
- "CSD switch failed",
- )
- csd = ipc.get_window_debug(win["id"])
- assert csd["decoration_mode"] == "client", csd
- ipc.key_down_up(KEY_F6)
- wait_for(
- lambda: ipc.get_window_debug(win["id"])["decoration_mode"] == "server",
- "SSD switch failed",
- )
- ssd = ipc.get_window_debug(win["id"])
- assert ssd["decoration_mode"] == "server", ssd
- assert ssd["edge_sample"] == "color", ssd
-
- ipc.action("close_window", {"id": win["id"]})
- wait_for(lambda: not ipc.get_windows(), "client did not close")
- ipc.reset_perf()
- with client_log.open("a") as clog:
- client2 = subprocess.Popen(
- [str(tmp / "client")],
- env=dict(env, WAYLAND_DISPLAY=display),
- stdout=clog,
- stderr=clog,
- )
- try:
- remapped = wait_for(
- lambda: next((w for w in ipc.get_windows() if w.get("app_id") == "rediwm.zoom-fixture"), None),
- "second map failed",
- )
- ipc.wait_for_frame()
- debug = ipc.get_window_debug(remapped["id"])
- assert debug["edge_sample"] == "color", debug
- approx_rgba(debug["skirt_fill"], (0.0, 0.0, 1.0, 1.0))
- mapped = ipc.get_perf()
- assert mapped["edge_samples_attempted"] >= 1, mapped
- finally:
- if client2.poll() is None:
- client2.terminate()
- client2.wait(timeout=3)
-
- print(f"PASS: edge sampling ({renderer})")
- except Exception:
- for path in tmp.glob("*.log"):
- print(path.name, path.read_text()[-4000:])
- raise
- finally:
- for process in (client, compositor):
- if process is not None and process.poll() is None:
- process.terminate()
- process.wait(timeout=3)
-
-
-if __name__ == "__main__":
- run()
diff --git a/tests/editor.py b/tests/editor.py
index 5f74d01..4c925a4 100644
--- a/tests/editor.py
+++ b/tests/editor.py
@@ -28,7 +28,7 @@ def run():
XDG_CONFIG_HOME=str(tmp / "config"), XDG_DATA_HOME=str(tmp / "data"),
XDG_CACHE_HOME=str(tmp / "cache"), XDG_STATE_HOME=str(tmp / "state"),
REDIWM_CONFIG=str(config), WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0", WLR_HEADLESS_OUTPUTS="1",
- WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
REDIWM_SCALE=os.environ.get("REDIWM_TEST_SCALE", "1"), DBUS_SESSION_BUS_ADDRESS="")
env.pop("WAYLAND_DISPLAY", None)
env.pop("REDIWM_SOCKET", None)
diff --git a/tests/editor_visuals.py b/tests/editor_visuals.py
index 1da6c3b..9196389 100644
--- a/tests/editor_visuals.py
+++ b/tests/editor_visuals.py
@@ -20,7 +20,7 @@ def run():
XDG_CONFIG_HOME=str(tmp / 'config'), XDG_DATA_HOME=str(tmp / 'data'),
XDG_STATE_HOME=str(tmp / 'state'), XDG_CACHE_HOME=str(tmp / 'cache'),
REDIWM_CONFIG=str(config), WLR_BACKENDS='headless', REDIWM_FILES_DEVICES='0', WLR_HEADLESS_OUTPUTS='1',
- WLR_RENDERER=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'),
+ WLR_RENDERER=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'),
REDIWM_SCALE=os.environ.get('REDIWM_TEST_SCALE', '1'), DBUS_SESSION_BUS_ADDRESS='')
env.pop('WAYLAND_DISPLAY', None)
env.pop('REDIWM_SOCKET', None)
diff --git a/tests/files_associations.py b/tests/files_associations.py
index d3e2ee0..4ab72d7 100644
--- a/tests/files_associations.py
+++ b/tests/files_associations.py
@@ -68,7 +68,7 @@ def run():
XDG_CONFIG_HOME=str(config), XDG_CONFIG_DIRS=str(config), XDG_STATE_HOME=str(tmp / "state"),
XDG_CURRENT_DESKTOP="RediWM", BROWSER="/bin/false", REDIWM_ICON_THEME="hicolor",
XDG_RUNTIME_DIR=str(tmp), REDIWM_CONFIG=str(tmp / "rediwm-config.toml"),
- WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0", WLR_RENDERER="pixman", WLR_HEADLESS_OUTPUTS="1", REDIWM_SCALE="1",
+ WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0", WLR_RENDERER="gles2", WLR_HEADLESS_OUTPUTS="1", REDIWM_SCALE="1",
DBUS_SYSTEM_BUS_ADDRESS="unix:path=/nonexistent-rediwm-test-system-bus",
DBUS_SESSION_BUS_ADDRESS="unix:path=/nonexistent-rediwm-associations")
for key in ("WAYLAND_DISPLAY", "DISPLAY", "XAUTHORITY", "REDIWM_SOCKET", "WAYLAND_DEBUG"):
diff --git a/tests/files_browser.py b/tests/files_browser.py
index 74b2aa7..a87daf5 100755
--- a/tests/files_browser.py
+++ b/tests/files_browser.py
@@ -71,7 +71,7 @@ fi
WLR_BACKENDS='headless', REDIWM_FILES_DEVICES='0',
REDIWM_IPC_AUTOMATION='1',
WLR_HEADLESS_OUTPUTS='1',
- WLR_RENDERER='pixman',
+ WLR_RENDERER='gles2',
REDIWM_SCALE='1',
PATH=str(helpers) + ':' + str(ROOT / 'zig-out/bin') + ':' + os.environ.get('PATH', ''),
)
diff --git a/tests/files_controls.py b/tests/files_controls.py
index 4682441..b9ad315 100644
--- a/tests/files_controls.py
+++ b/tests/files_controls.py
@@ -82,7 +82,7 @@ def run():
env = dict(os.environ, HOME=str(home), XDG_RUNTIME_DIR=directory,
XDG_DATA_HOME=str(tmp / "data"), XDG_CONFIG_HOME=str(config_home),
REDIWM_CONFIG=str(config), WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0",
- WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
REDIWM_SCALE="1", XDG_STATE_HOME=str(tmp / "state"), PATH=str(helpers) + ":" + os.environ["PATH"],
REDIWM_IPC_AUTOMATION="1")
env.pop("WAYLAND_DISPLAY", None)
diff --git a/tests/files_decoration.py b/tests/files_decoration.py
index 694ba3c..02c7fbb 100644
--- a/tests/files_decoration.py
+++ b/tests/files_decoration.py
@@ -46,7 +46,7 @@ def run():
XDG_STATE_HOME=str(tmp / "state"),
WLR_BACKENDS='headless', REDIWM_FILES_DEVICES='0',
WLR_HEADLESS_OUTPUTS='1',
- WLR_RENDERER='pixman',
+ WLR_RENDERER='gles2',
REDIWM_SCALE='1',
PATH=os.environ.get('PATH', ''),
)
diff --git a/tests/files_drag.py b/tests/files_drag.py
index d26f36a..77bfac8 100644
--- a/tests/files_drag.py
+++ b/tests/files_drag.py
@@ -25,7 +25,7 @@ def run(browser=False, select=False, list_view=False):
for name in names:
(home / name).write_text("drag upload payload")
comp, log = spawn_compositor(tmp, config_content="[compositor]\nxwayland = false\n",
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"HOME": str(home)})
peers = []
try:
@@ -177,7 +177,7 @@ def run_pin():
(home / "note.txt").write_text("pin me")
state = tmp / "state/rediwm/files-places"
comp, log = spawn_compositor(tmp, config_content="[compositor]\nxwayland = false\n",
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"HOME": str(home)})
files = None
try:
diff --git a/tests/files_drag_dodge.py b/tests/files_drag_dodge.py
index 0355dcf..f5a7b29 100644
--- a/tests/files_drag_dodge.py
+++ b/tests/files_drag_dodge.py
@@ -39,7 +39,7 @@ def run(scenario):
if scenario == "off":
config += "dodge_file_drags = false\n"
comp, log = spawn_compositor(tmp, config_content=config,
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"HOME": str(home)})
peers = []
try:
diff --git a/tests/files_folder_size.py b/tests/files_folder_size.py
index a74c4df..31ef2a4 100644
--- a/tests/files_folder_size.py
+++ b/tests/files_folder_size.py
@@ -43,7 +43,7 @@ def run():
config.write_text("")
env = dict(os.environ, HOME=str(home), XDG_RUNTIME_DIR=directory,
REDIWM_CONFIG=str(config), WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0",
- WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER="pixman",
+ WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER="gles2",
REDIWM_SCALE="1", XDG_STATE_HOME=str(tmp / "state"),
REDIWM_IPC_AUTOMATION="1")
env.pop("WAYLAND_DISPLAY", None)
diff --git a/tests/files_thumbnails.py b/tests/files_thumbnails.py
index f206b19..1e44911 100644
--- a/tests/files_thumbnails.py
+++ b/tests/files_thumbnails.py
@@ -128,7 +128,7 @@ def run():
env = dict(os.environ, HOME=str(home), XDG_RUNTIME_DIR=directory,
XDG_DATA_HOME=str(tmp / "data"), XDG_CACHE_HOME=str(cache),
REDIWM_CONFIG=str(config), WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0",
- WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
REDIWM_SCALE="1", XDG_STATE_HOME=str(tmp / "state"),
REDIWM_IPC_AUTOMATION="1")
env.pop("WAYLAND_DISPLAY", None)
diff --git a/tests/focus_zoom.py b/tests/focus_zoom.py
index 2e4e000..2f49d4f 100644
--- a/tests/focus_zoom.py
+++ b/tests/focus_zoom.py
@@ -23,7 +23,7 @@ def run():
base = '[input]\ninvert_scroll = false\n[keybinds]\n"alt+tab" = "focus_next"\n"super+5" = "set_depth 4"\n'
process, log = spawn_compositor(
tmp, scale=os.environ.get("REDIWM_TEST_SCALE", "1"),
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
config_content=base, env_extra={"DBUS_SESSION_BUS_ADDRESS": ""})
clients = []
handles = []
diff --git a/tests/glass_hold.py b/tests/glass_hold.py
index 7dfc430..abdde9b 100644
--- a/tests/glass_hold.py
+++ b/tests/glass_hold.py
@@ -15,7 +15,7 @@ import time
from PIL import Image, ImageChops
from desktop_zoom import ROOT, build_client, wait_for
-from ipc_client import IPCClient, spawn_compositor, stop_process, scene_renderer_config
+from ipc_client import IPCClient, spawn_compositor, stop_process
SCALE = 1.5
TITLEBAR_HEIGHT = 55 # chrome.titlebar_height
@@ -25,7 +25,7 @@ START, GRAB, DROP = (100, 60), (300, 80), (700, 330)
def session(tmp, window_bg, drag, holds=False):
"""Drag from START to DROP, or place the window where a drag ended."""
config = tmp / "config.toml"
- config.write_text(scene_renderer_config(f'[theme]\nwindow_bg = "{window_bg}"\n' if window_bg else ""))
+ config.write_text(f'[theme]\nwindow_bg = "{window_bg}"\n' if window_bg else "")
runtime = Path(tempfile.mkdtemp(prefix="runtime-", dir=tmp))
env = dict(os.environ, XDG_RUNTIME_DIR=str(runtime), XDG_CONFIG_HOME=str(runtime / "config"),
XDG_CACHE_HOME=str(runtime / "cache"), XDG_DATA_HOME=str(runtime / "data"),
diff --git a/tests/greeter.py b/tests/greeter.py
index 8a3d1de..b3e97c9 100644
--- a/tests/greeter.py
+++ b/tests/greeter.py
@@ -47,7 +47,7 @@ def run(with_dm):
XDG_RUNTIME_DIR=str(tmp),
WLR_BACKENDS="headless",
WLR_HEADLESS_OUTPUTS="2",
- WLR_RENDERER="pixman",
+ WLR_RENDERER="gles2",
REDIWM_SCALE="1",
DBUS_SYSTEM_BUS_ADDRESS="unix:path=/nonexistent-rediwm-test-system-bus",
DBUS_SESSION_BUS_ADDRESS="unix:path=/nonexistent-rediwm-test-session-bus",
diff --git a/tests/idle.py b/tests/idle.py
index 28c5ad8..5153aa1 100755
--- a/tests/idle.py
+++ b/tests/idle.py
@@ -50,7 +50,7 @@ def advance_idle_time(ipc, seconds):
def run():
scale = float(os.environ.get("REDIWM_TEST_SCALE", "1"))
- renderer = os.environ.get("REDIWM_TEST_RENDERER", "pixman")
+ renderer = os.environ.get("REDIWM_TEST_RENDERER", "gles2")
with tempfile.TemporaryDirectory(prefix="rediwm-idle-") as directory:
tmp = Path(directory)
build_client(tmp)
diff --git a/tests/images_viewer.py b/tests/images_viewer.py
index 39de764..5d6040a 100644
--- a/tests/images_viewer.py
+++ b/tests/images_viewer.py
@@ -37,7 +37,7 @@ def run(scale):
XDG_CONFIG_HOME=str(tmp / "config"), XDG_DATA_HOME=str(tmp / "data"),
XDG_CACHE_HOME=str(tmp / "cache"), XDG_STATE_HOME=str(tmp / "state"), REDIWM_CONFIG=str(config),
WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0", WLR_HEADLESS_OUTPUTS="1",
- WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
REDIWM_SCALE=str(scale), DBUS_SESSION_BUS_ADDRESS="")
env.pop("WAYLAND_DISPLAY", None)
env.pop("REDIWM_SOCKET", None)
diff --git a/tests/ipc_client.py b/tests/ipc_client.py
index 890b237..f3ac3b6 100755
--- a/tests/ipc_client.py
+++ b/tests/ipc_client.py
@@ -20,20 +20,10 @@ from typing import Any, Dict, List, Optional, Tuple, Union
ROOT = Path(__file__).resolve().parents[1]
-def scene_renderer_config(text: str) -> str:
- """Fixture-only selector: production reads the ordinary config key."""
- renderer = os.environ.get("REDIWM_TEST_SCENE_RENDERER")
- if renderer is None:
- return text
- if renderer not in ("legacy", "owned"):
- raise ValueError("REDIWM_TEST_SCENE_RENDERER must be legacy or owned")
- if re.search(r"(?m)^\s*scene_renderer\s*=", text):
- return text # explicit test configuration wins
- section = re.search(r"(?m)^\[compositor\][ \t]*(?:#.*)?$", text)
- setting = f'\nscene_renderer = "{renderer}"\n'
- if section:
- return text[:section.end()] + setting + text[section.end():]
- return text + '\n[compositor]' + setting
+# The compositor requires GLES2 (docs/plans/scene-graph.md). On a machine with
+# several GPUs EGL needs to be pointed at one render node.
+if "WLR_RENDER_DRM_DEVICE" not in os.environ and os.path.exists("/dev/dri/renderD128"):
+ os.environ["WLR_RENDER_DRM_DEVICE"] = "/dev/dri/renderD128"
# Synthetic input, screenshots and pixel reads are off unless [ipc] automation
# is set. Tests drive the compositor through them, so every compositor started
@@ -537,7 +527,7 @@ def spawn_compositor(
XDG_RUNTIME_DIR=str(tmp_dir),
WLR_BACKENDS="headless",
WLR_HEADLESS_OUTPUTS=str(outputs),
- WLR_RENDERER=renderer or os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_RENDERER=renderer or os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
REDIWM_SCALE=str(scale),
# Opening the power menu queries CanPowerOff/CanReboot/CanSuspend
# (session/power.zig's Manager.probeCapabilities()). Without this,
@@ -554,7 +544,7 @@ def spawn_compositor(
XDG_STATE_HOME=str(tmp_dir / "state"),
)
config_path = tmp_dir / "rediwm-config.toml"
- config_path.write_text(scene_renderer_config(config_content))
+ config_path.write_text(config_content)
env["REDIWM_CONFIG"] = str(config_path)
env.pop("WAYLAND_DISPLAY", None)
env.pop("REDIWM_SOCKET", None)
diff --git a/tests/kde_decorations.py b/tests/kde_decorations.py
index c690c5d..9784a8a 100644
--- a/tests/kde_decorations.py
+++ b/tests/kde_decorations.py
@@ -33,7 +33,7 @@ def run():
tmp = Path(directory)
build_client(tmp)
base_config = '[animations]\nreduced_motion = "on"\n'
- compositor, compositor_log = spawn_compositor(tmp, config_content=base_config, renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ compositor, compositor_log = spawn_compositor(tmp, config_content=base_config, renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "unix:path=/nonexistent-rediwm-test-session-bus"})
clients = []
try:
diff --git a/tests/mini_map.py b/tests/mini_map.py
index fca99e9..0906198 100644
--- a/tests/mini_map.py
+++ b/tests/mini_map.py
@@ -13,7 +13,7 @@ def run():
tmp = Path(directory)
base = '[input]\ninvert_scroll = false\n[animations]\nenabled = false\n[compositor]\nxwayland = false\n'
process, log = spawn_compositor(tmp, scale=os.getenv('REDIWM_TEST_SCALE', '1'),
- renderer=os.getenv('REDIWM_TEST_RENDERER', 'pixman'), config_content=base,
+ renderer=os.getenv('REDIWM_TEST_RENDERER', 'gles2'), config_content=base,
env_extra={'DBUS_SESSION_BUS_ADDRESS': '', 'XDG_CACHE_HOME': str(tmp/'cache'),
'XDG_CONFIG_HOME': str(tmp/'config'), 'REDIWM_DESKTOP_DIR': str(tmp/'Desktop')})
try:
diff --git a/tests/mini_map_canvas.py b/tests/mini_map_canvas.py
index e2237a6..48a4ead 100644
--- a/tests/mini_map_canvas.py
+++ b/tests/mini_map_canvas.py
@@ -17,7 +17,7 @@ def run():
build_client(tmp)
proc, log = spawn_compositor(
tmp, scale=os.getenv('REDIWM_TEST_SCALE', '1'),
- renderer=os.getenv('REDIWM_TEST_RENDERER', 'pixman'),
+ renderer=os.getenv('REDIWM_TEST_RENDERER', 'gles2'),
config_content='[compositor]\nxwayland = false\nmini_map_hide_ms = 10000\n[animations]\nenabled = false\n',
env_extra={'DBUS_SESSION_BUS_ADDRESS': '', 'XDG_CACHE_HOME': str(tmp/'cache'),
'XDG_CONFIG_HOME': str(tmp/'config'), 'REDIWM_DESKTOP_DIR': str(tmp/'Desktop')})
diff --git a/tests/mini_map_lifecycle.py b/tests/mini_map_lifecycle.py
index bdadc87..a8c2d9a 100644
--- a/tests/mini_map_lifecycle.py
+++ b/tests/mini_map_lifecycle.py
@@ -14,7 +14,7 @@ def run():
tmp = Path(directory)
base = '[compositor]\nxwayland = false\nmini_map_hide_ms = 500\n'
proc, log = spawn_compositor(tmp, outputs='2', config_content=base,
- renderer=os.getenv('REDIWM_TEST_RENDERER', 'pixman'),
+ renderer=os.getenv('REDIWM_TEST_RENDERER', 'gles2'),
env_extra={'DBUS_SESSION_BUS_ADDRESS':'', 'XDG_CACHE_HOME':str(tmp/'cache'), 'XDG_CONFIG_HOME':str(tmp/'config')})
client = None
try:
diff --git a/tests/mini_map_windows.py b/tests/mini_map_windows.py
index 6464c7f..8a49d49 100644
--- a/tests/mini_map_windows.py
+++ b/tests/mini_map_windows.py
@@ -15,7 +15,7 @@ def run():
tmp = Path(directory)
build_client(tmp)
proc, log = spawn_compositor(tmp, scale=os.getenv('REDIWM_TEST_SCALE', '1'),
- renderer=os.getenv('REDIWM_TEST_RENDERER', 'pixman'),
+ renderer=os.getenv('REDIWM_TEST_RENDERER', 'gles2'),
config_content='[compositor]\nxwayland = false\nmini_map_hide_ms = 10000\n[animations]\nenabled = false\n',
env_extra={'DBUS_SESSION_BUS_ADDRESS': '', 'XDG_CACHE_HOME': str(tmp/'cache'),
'XDG_CONFIG_HOME': str(tmp/'config'), 'REDIWM_DESKTOP_DIR': str(tmp/'Desktop')})
diff --git a/tests/motion_perf.py b/tests/motion_perf.py
index d9fa612..9b7d4d8 100644
--- a/tests/motion_perf.py
+++ b/tests/motion_perf.py
@@ -38,7 +38,7 @@ def run(args):
XDG_DATA_HOME=str(tmp / "data"), REDIWM_DESKTOP_DIR=str(desktop_dir),
REDIWM_CONFIG=str(tmp / "config.toml"), WLR_BACKENDS="headless",
WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER_ALLOW_SOFTWARE="1",
- WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
REDIWM_SCALE=os.environ.get("REDIWM_TEST_SCALE", "1"),
REDIWM_TEST_DECORATION="server", DBUS_SESSION_BUS_ADDRESS="")
env.pop("WAYLAND_DISPLAY", None)
diff --git a/tests/output_scale.py b/tests/output_scale.py
index 073bb35..cf645e1 100644
--- a/tests/output_scale.py
+++ b/tests/output_scale.py
@@ -46,7 +46,7 @@ scale = {scale}
def run_case(binary, override='auto'):
with tempfile.TemporaryDirectory(prefix='rediwm-output-scale-') as directory:
tmp = Path(directory)
- renderer = os.environ.get('REDIWM_TEST_RENDERER', 'pixman')
+ renderer = os.environ.get('REDIWM_TEST_RENDERER', 'gles2')
compositor, log = spawn_compositor(tmp, scale=override, outputs='2', config_content=config(1.5),
renderer=renderer,
env_extra={'XDG_CACHE_HOME': str(tmp / 'cache')})
diff --git a/tests/pdf_sandbox.py b/tests/pdf_sandbox.py
index 5eef3f5..2ed5500 100644
--- a/tests/pdf_sandbox.py
+++ b/tests/pdf_sandbox.py
@@ -26,7 +26,7 @@ def run():
font = subprocess.check_output(["fc-match", "-f", "%{file}", "sans"], text=True)
compositor, log = spawn_compositor(
tmp, config_content="[compositor]\nxwayland = false\n",
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "XDG_CACHE_HOME": str(tmp / "cache")})
viewer = None
try:
diff --git a/tests/pdf_viewer.py b/tests/pdf_viewer.py
index 45e2ac6..e2f0a9c 100755
--- a/tests/pdf_viewer.py
+++ b/tests/pdf_viewer.py
@@ -166,7 +166,7 @@ def run(scale: int = 1):
REDIWM_CONFIG=str(config),
WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0",
WLR_HEADLESS_OUTPUTS="1",
- WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
REDIWM_SCALE=str(scale),
DBUS_SESSION_BUS_ADDRESS="",
DBUS_SYSTEM_BUS_ADDRESS="unix:path=/nonexistent-rediwm-test-system-bus",
diff --git a/tests/perf.py b/tests/perf.py
index 5a55582..0a390d5 100644
--- a/tests/perf.py
+++ b/tests/perf.py
@@ -101,7 +101,7 @@ def summarize(label, stats):
def run(binary=None):
- renderer = os.environ.get("REDIWM_TEST_RENDERER", "pixman")
+ renderer = os.environ.get("REDIWM_TEST_RENDERER", "gles2")
backend = os.environ.get("REDIWM_TEST_BACKEND", "headless")
seconds = float(os.environ.get("REDIWM_TEST_PERF_SECONDS", "2"))
if not math.isfinite(seconds) or seconds <= 0:
diff --git a/tests/polkit_dialog.py b/tests/polkit_dialog.py
index fac2435..2a86a50 100644
--- a/tests/polkit_dialog.py
+++ b/tests/polkit_dialog.py
@@ -22,7 +22,7 @@ from xwayland import wait_for, wayland_display_name
ROOT = Path(__file__).resolve().parents[1]
-def run(scale='1', renderer='pixman'):
+def run(scale='1', renderer='gles2'):
with tempfile.TemporaryDirectory(prefix='rediwm-polkit-ui-') as directory:
tmp = Path(directory)
compile_client(tmp)
diff --git a/tests/popup_constraint.py b/tests/popup_constraint.py
index 4a082d5..f34b7e8 100644
--- a/tests/popup_constraint.py
+++ b/tests/popup_constraint.py
@@ -53,7 +53,7 @@ def run_case(name, *, zoom, window_x, pan_dx, popup_at):
config_path.write_text("[input]\ninvert_scroll = false\npan_speed = 1.0\n")
env = dict(
os.environ, XDG_RUNTIME_DIR=str(tmp), XDG_STATE_HOME=str(tmp / "state"), WLR_BACKENDS="headless", WLR_HEADLESS_OUTPUTS="1",
- WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"), WLR_RENDERER_ALLOW_SOFTWARE="1", REDIWM_SCALE="1",
+ WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"), WLR_RENDERER_ALLOW_SOFTWARE="1", REDIWM_SCALE="1",
REDIWM_IPC_AUTOMATION="1", REDIWM_CONFIG=str(config_path), REDIWM_TEST_POPUP_SLIDE="1",
)
if popup_at:
diff --git a/tests/presentation_time.py b/tests/presentation_time.py
index bf59ca2..e4f8a53 100644
--- a/tests/presentation_time.py
+++ b/tests/presentation_time.py
@@ -45,7 +45,7 @@ def run_case(binary, version, scale, full):
config_content="[compositor]\nxwayland = false\n",
env_extra={"XDG_CACHE_HOME": str(tmp / "cache"),
"WLR_RENDERER_ALLOW_SOFTWARE": "1",
- "WLR_RENDERER": os.environ.get("REDIWM_TEST_RENDERER", "pixman")})
+ "WLR_RENDERER": os.environ.get("REDIWM_TEST_RENDERER", "gles2")})
client = None
client_log = tmp / "client.log"
try:
diff --git a/tests/scene_ab.patch b/tests/scene_ab.patch
deleted file mode 100644
index c4fbbb0..0000000
--- a/tests/scene_ab.patch
+++ /dev/null
@@ -1,198 +0,0 @@
-diff --git a/src/Output.zig b/src/Output.zig
-index 1f5a431..2fdf8a7 100644
---- a/src/Output.zig
-+++ b/src/Output.zig
-@@ -1280,6 +1280,7 @@ fn runFrame(output: *Output) void {
- const mini_map_animating = output.server.world.mini_map.tick(output, now_ms);
- // GPU timestamps enclose glass capture/blur plus the scene submission.
- // Polling happens later; no glFinish or synchronous query-result reads.
-+ @import("ab.zig").advance();
- const gpu_active = if (output.server.gpu_timer) |timer| timer.begin() else false;
- const glass_started = stats.nowNs();
- const lock_animating = output.lock_view.sync(output);
-@@ -1328,6 +1329,7 @@ fn runFrame(output: *Output) void {
- }
- const commit_duration = stats.nowNs() -% started;
- stats.global_stats.scene_commit_cpu.record(commit_duration);
-+ if (should_commit) @import("ab.zig").recordCommit(commit_duration);
- if (!committed) {
- log.err("handleFrame: scene commit failed for {s}", .{output.wlr_output.name});
- stats.recordFailedCommit();
-diff --git a/src/Server.zig b/src/Server.zig
-index dd3b562..b35f248 100644
---- a/src/Server.zig
-+++ b/src/Server.zig
-@@ -458,7 +458,8 @@ pub fn init(server: *Server, scale: ?f32, icon_theme_cfg: icon_theme.Config, io:
- // measurements; every glass call already accepts a null engine.
- server.glass_engine = if (environ.getPosix("REDIWM_NO_GLASS") != null) null else glass.Engine.create(renderer, wlr_allocator, scene, server.read_fence);
- errdefer glass.Engine.destroy(server.glass_engine);
-- if (loaded.compositor.scene_renderer == .owned) {
-+ if (environ.getPosix("REDIWM_TEST_AB") != null) @import("ab.zig").enabled = true;
-+ if (loaded.compositor.scene_renderer == .owned or @import("ab.zig").enabled) {
- server.output_renderer = scene_output_mod.Renderer.create(renderer) orelse return error.RendererInitFailed;
- log.info("scene renderer: owned GLES2 output pass", .{});
- }
-@@ -1041,9 +1042,19 @@ pub fn deinit(server: *Server) void {
- /// All output builds, including capture between frames, use the selected
- /// presenter and the same swapchain/damage history. Commits stay on Output.
- pub fn buildOutputState(server: *Server, output: *wlr.SceneOutput, state: *wlr.Output.State) bool {
-- if (server.output_renderer) |renderer|
-- return renderer.buildState(server.world.projection, output, state);
-- return output.buildState(state, null);
-+ const ab = @import("ab.zig");
-+ const use_owned = if (ab.enabled) ab.cur == 1 else server.output_renderer != null;
-+ const w0 = @import("ipc/stats.zig").nowNs();
-+ const c0 = ab.threadCpuNs();
-+ const ok = if (use_owned)
-+ server.output_renderer.?.buildState(server.world.projection, output, state)
-+ else
-+ output.buildState(state, null);
-+ if (ab.enabled and ab.warm) {
-+ ab.record(.build_cpu, ab.cur, ab.threadCpuNs() -% c0);
-+ ab.record(.build_wall, ab.cur, @import("ipc/stats.zig").nowNs() -% w0);
-+ }
-+ return ok;
- }
-
- pub fn beginRenderPass(server: *Server, buffer: *wlr.Buffer, options: ?*const wlr.Renderer.BufferPassOptions) !*wlr.RenderPass {
-diff --git a/src/ab.zig b/src/ab.zig
-new file mode 100644
-index 0000000..d382bf6
---- /dev/null
-+++ b/src/ab.zig
-@@ -0,0 +1,78 @@
-+// MEASUREMENT PATCH, never part of a production build (see tests/scene_ab.py).
-+// Applied to a throwaway copy of the tree, it makes one compositor build
-+// alternate frames between the legacy and the owned output presenter in blocks
-+// of `block` frames, drops the first `warmup` frames of every block, and records
-+// per presenter: thread CPU and wall time of the build call, wall time of build
-+// plus commit, and GPU elapsed (the timer's generation word carries the tag).
-+// Both arms share the process, clocks, thermal and power state, so drift cancels.
-+// One summary of `cap` samples per presenter and metric is logged at warn level,
-+// as "AB <metric>: legacy mean .. | owned mean .. (ns, n=..)". Selected by
-+// REDIWM_TEST_AB, which only a patched build reads.
-+const std = @import("std");
-+const log = std.log.scoped(.ab);
-+
-+pub var enabled = false;
-+var frame: u64 = 0;
-+pub var cur: u1 = 0; // 1 = owned, 0 = legacy
-+pub var warm = false;
-+pub const mask: u64 = 0x0fff_ffff_ffff_ffff;
-+pub const Kind = enum { build_cpu, build_wall, commit_wall, gpu };
-+const cap = 3000;
-+var samples: [4][2][cap]u32 = undefined;
-+var counts = [_][2]usize{.{ 0, 0 }} ** 4;
-+var reported = false;
-+
-+const block = 32;
-+const warmup = 6;
-+
-+/// Call once per frame before the GPU timer begins.
-+pub fn advance() void {
-+ if (!enabled) return;
-+ frame += 1;
-+ cur = @intCast((frame / block) % 2);
-+ warm = frame % block >= warmup;
-+}
-+
-+/// Build plus commit wall time of a frame that committed.
-+pub fn recordCommit(ns: u64) void {
-+ if (enabled and warm) record(.commit_wall, cur, ns);
-+}
-+pub fn tag() u64 {
-+ if (!enabled) return 0;
-+ return (@as(u64, cur) | (@as(u64, @intFromBool(warm)) << 1)) << 60;
-+}
-+pub fn threadCpuNs() u64 {
-+ var ts: std.posix.timespec = undefined;
-+ _ = std.posix.system.clock_gettime(std.posix.CLOCK.THREAD_CPUTIME_ID, &ts);
-+ return @as(u64, @intCast(ts.sec)) * 1_000_000_000 + @as(u64, @intCast(ts.nsec));
-+}
-+pub fn record(kind: Kind, presenter: u1, ns: u64) void {
-+ const k = @intFromEnum(kind);
-+ const n = &counts[k][presenter];
-+ if (n.* >= cap) return;
-+ samples[k][presenter][n.*] = @intCast(@min(ns, std.math.maxInt(u32)));
-+ n.* += 1;
-+ maybeReport();
-+}
-+fn maybeReport() void {
-+ if (reported) return;
-+ for (counts) |c| if (c[0] < cap or c[1] < cap) return;
-+ reported = true;
-+ inline for (.{ .build_cpu, .build_wall, .commit_wall, .gpu }) |kind| {
-+ const k = @intFromEnum(@as(Kind, kind));
-+ var stat: [2][4]u64 = undefined;
-+ for (0..2) |p| {
-+ const s = samples[k][p][0..cap];
-+ std.mem.sort(u32, s, {}, std.sort.asc(u32));
-+ var sum: u64 = 0;
-+ for (s) |v| sum += v;
-+ stat[p] = .{ sum / cap, s[cap / 2], s[cap / 10], s[cap * 9 / 10] };
-+ }
-+ log.warn("AB {s}: legacy mean {d} med {d} p10 {d} p90 {d} | owned mean {d} med {d} p10 {d} p90 {d} (ns, n={d})", .{
-+ @tagName(@as(Kind, kind)),
-+ stat[0][0], stat[0][1], stat[0][2], stat[0][3],
-+ stat[1][0], stat[1][1], stat[1][2], stat[1][3],
-+ cap,
-+ });
-+ }
-+}
-diff --git a/src/gpu_timing.c b/src/gpu_timing.c
-index 22a95c7..d329c13 100644
---- a/src/gpu_timing.c
-+++ b/src/gpu_timing.c
-@@ -143,8 +143,8 @@ size_t rediwm_gpu_timer_collect(struct gpu_timer *timer, uint64_t generation,
- for (unsigned i = 0; i < SLOTS; ++i) {
- struct query_pair *pair = &timer->slots[i];
- if (!pair->pending) continue;
-- if (disjoint || pair->generation != generation || ++pair->age > 120) {
-- if (pair->generation == generation) ++*dropped;
-+ if (disjoint || (pair->generation & 0x0fffffffffffffffULL) != generation || ++pair->age > 120) {
-+ if ((pair->generation & 0x0fffffffffffffffULL) == generation) ++*dropped;
- recycle(timer, pair);
- continue;
- }
-@@ -167,7 +167,7 @@ size_t rediwm_gpu_timer_collect(struct gpu_timer *timer, uint64_t generation,
- count = 0;
- for (unsigned i = 0; i < SLOTS; ++i) {
- if (timer->slots[i].pending) {
-- if (timer->slots[i].generation == generation) ++*dropped;
-+ if ((timer->slots[i].generation & 0x0fffffffffffffffULL) == generation) ++*dropped;
- recycle(timer, &timer->slots[i]);
- }
- }
-diff --git a/src/gpu_timing.zig b/src/gpu_timing.zig
-index 9137fa3..6f431f8 100644
---- a/src/gpu_timing.zig
-+++ b/src/gpu_timing.zig
-@@ -1,5 +1,6 @@
- const wlr = @import("wlroots");
- const stats = @import("ipc/stats.zig");
-+const ab = @import("ab.zig");
- const Sample = extern struct { ns: u64, generation: u64 };
-
- pub const Timer = opaque {
-@@ -13,7 +14,7 @@ pub const Timer = opaque {
- pub const end = rediwm_gpu_timer_end;
-
- pub fn begin(self: *Timer) bool {
-- const ok = rediwm_gpu_timer_begin(self, stats.global_stats.generation);
-+ const ok = rediwm_gpu_timer_begin(self, stats.global_stats.generation | ab.tag());
- if (!ok) stats.global_stats.gpu_samples_dropped +%= 1;
- return ok;
- }
-@@ -23,8 +24,11 @@ pub const Timer = opaque {
- const n = rediwm_gpu_timer_collect(self, stats.global_stats.generation, &samples, &dropped);
- stats.global_stats.gpu_samples_dropped +%= dropped;
- for (samples[0..n]) |sample| {
-- if (sample.generation == stats.global_stats.generation)
-+ if (sample.generation & ab.mask == stats.global_stats.generation) {
- stats.global_stats.gpu_elapsed.record(sample.ns);
-+ const t = sample.generation >> 60;
-+ if (ab.enabled and t & 2 != 0) ab.record(.gpu, @intCast(t & 1), sample.ns);
-+ }
- }
- }
- };
diff --git a/tests/scene_ab.py b/tests/scene_ab.py
deleted file mode 100644
index 38154f6..0000000
--- a/tests/scene_ab.py
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/usr/bin/env python3
-"""Frame-block A/B of the legacy and owned output presenters (scene graph stage 3 gate).
-
-Session-level pairs (`scene_baseline.py --modes paired`) cannot resolve a few
-microseconds: two sessions of the same presenter differ by up to 12 %. This runs
-ONE compositor that alternates presenters every 32 frames, so both arms share the
-process, clocks, thermal and power state. It needs a measurement build, because
-the alternation is a test hook that production must not carry:
-
- git worktree add /tmp/ab HEAD # or: git archive HEAD | tar -x -C /tmp/ab
- cd /tmp/ab && git apply <repo>/tests/scene_ab.patch
- zig build -Doptimize=ReleaseSafe
- WLR_RENDER_DRM_DEVICE=/dev/dri/renderD128 python3 <repo>/tests/scene_ab.py \\
- --binary /tmp/ab/zig-out/bin/rediwm
-
-Per cell (clear repaint / repaint under glass, at each scale) it collects 3000
-samples per presenter of the build call's thread CPU time, its wall time, build
-plus commit wall time and GPU elapsed, and compares means against the tolerance
-(docs/plans/scene-graph.md, stage 3: +5 % on build CPU and GPU elapsed). Exit
-status is 1 if any cell is over. Differences under about 1.5 points are noise;
-absolute values move between runs, only the within-run difference means anything.
-Keep the machine on AC power and run nothing else: the harness refuses battery.
-"""
-import argparse
-import json
-import os
-from pathlib import Path
-import re
-import sys
-import tempfile
-import time
-
-sys.path.insert(0, str(Path(__file__).resolve().parent))
-import scene_baseline as sb
-from desktop_zoom import build_client
-
-REPORT = re.compile(r"AB (\w+): legacy mean (\d+) med (\d+) p10 (\d+) p90 (\d+) \| "
- r"owned mean (\d+) med (\d+) p10 (\d+) p90 (\d+) \(ns, n=(\d+)\)")
-GATED = ("build_cpu", "gpu")
-
-
-def parse_reports(text):
- cells = {}
- for match in REPORT.finditer(text):
- v = [int(x) for x in match.groups()[1:]]
- cells[match.group(1)] = {
- "n": v[8], "legacy": dict(mean=v[0], median=v[1], p10=v[2], p90=v[3]),
- "owned": dict(mean=v[4], median=v[5], p10=v[6], p90=v[7])}
- return cells
-
-
-def run_cell(binary, config, scenario, timeout):
- with tempfile.TemporaryDirectory(prefix="rediwm-scene-ab-") as directory:
- tmp = Path(directory)
- build_client(tmp)
- session = sb.Session(tmp, config, binary, "gles2", False, False, 4.0)
- try:
- for key in ("a", "b", "c"):
- session.start_client(key)
- session.raise_b()
- session.settle(1.0)
- glass, clear = session.spinner_rects()
- session.start_client("c", "damage", glass if scenario == "glass" else clear)
- session.raise_b()
- session.settle(1.0)
- session.ipc.reset_perf() # the GPU timer exists only after a perf request
- power = sb.power_state()
- log = tmp / "compositor.log"
- deadline = time.monotonic() + timeout
- cells = {}
- while time.monotonic() < deadline:
- time.sleep(5)
- cells = parse_reports(log.read_text(errors="replace"))
- if len(cells) == 4:
- break
- return cells, power, sb.power_state()
- finally:
- session.close()
-
-
-def main():
- parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
- parser.add_argument("--binary", type=Path, required=True, help="measurement build (tests/scene_ab.patch applied)")
- parser.add_argument("--configs", default="scale1,scale1.5,mixed")
- parser.add_argument("--scenarios", default="clear,glass", help="clear repaint, repaint under glass")
- parser.add_argument("--tolerance", type=float, default=5.0, help="allowed increase of owned over legacy, percent")
- parser.add_argument("--timeout", type=float, default=420, help="seconds to wait per cell")
- parser.add_argument("--cpus", default="auto", help="'auto' (P-cores) or 'none'")
- parser.add_argument("--allow-battery", action="store_true")
- parser.add_argument("--out", type=Path, help="write the raw statistics here")
- args = parser.parse_args()
-
- if b"REDIWM_TEST_AB" not in args.binary.read_bytes():
- parser.error(f"{args.binary} is not a measurement build: apply tests/scene_ab.patch and rebuild")
- unknown = [c for c in args.configs.split(",") if c not in sb.CONFIGS]
- if unknown:
- parser.error(f"unknown config {unknown}")
- if args.cpus == "auto" and sb.p_core_cpus():
- os.sched_setaffinity(0, sb.p_core_cpus())
- power = sb.power_state()
- if power["ac_online"] is False and not args.allow_battery:
- parser.error("AC power is not online: clocks differ on battery (use --allow-battery to measure anyway)")
- os.environ["REDIWM_TEST_AB"] = "1"
- os.environ.pop("REDIWM_TEST_SCENE_RENDERER", None)
- print(f"power: {power}", flush=True)
-
- results, failures = {}, []
- for config in args.configs.split(","):
- for scenario in args.scenarios.split(","):
- name = f"{config}/{scenario}"
- cells, before, after = run_cell(args.binary, config, scenario, args.timeout)
- if len(cells) != 4:
- failures.append(f"{name}: only {sorted(cells)} reported before the timeout")
- print(f"{name:16s} INCOMPLETE ({sorted(cells)})", flush=True)
- continue
- results[name] = {"cells": cells, "power_before": before, "power_after": after}
- row, bad = [], []
- for metric in ("build_cpu", "commit_wall", "gpu"):
- legacy, owned = cells[metric]["legacy"]["mean"], cells[metric]["owned"]["mean"]
- delta = (owned - legacy) / legacy * 100
- row.append(f"{metric} {legacy / 1e3:6.1f} -> {owned / 1e3:6.1f} us ({delta:+5.1f}%)")
- if metric in GATED and delta > args.tolerance:
- bad.append(f"{metric} {delta:+.1f}%")
- if before != after:
- row.append("POWER CHANGED")
- print(f"{name:16s} " + " ".join(row) + (" OVER: " + ", ".join(bad) if bad else " ok"), flush=True)
- failures += [f"{name}: {b} over +{args.tolerance:g}%" for b in bad]
- if args.out:
- args.out.write_text(json.dumps(results, indent=1) + "\n")
- if failures:
- print("\nFAIL:\n " + "\n ".join(failures))
- sys.exit(1)
- print(f"\nPASS: every cell within +{args.tolerance:g}% on {' and '.join(GATED)}")
-
-
-if __name__ == "__main__":
- main()
diff --git a/tests/scene_baseline.py b/tests/scene_baseline.py
index cf3ae9c..360bb2a 100644
--- a/tests/scene_baseline.py
+++ b/tests/scene_baseline.py
@@ -13,12 +13,9 @@ never calls the performance IPC, and the compositor's own frame timers
python3 tests/scene_baseline.py --out baseline.json --capture golden/
python3 tests/scene_baseline.py --binary other/rediwm --out new.json --compare golden/
python3 tests/scene_baseline.py --report new.json --against baseline.json
- python3 tests/scene_baseline.py --modes paired --configs scale1,scale1.5,mixed --out cost.json
-"paired" runs owned/legacy/legacy/owned with small repaints clear of and under
-glass. Both instruction counts and frame timers are enabled in every run; these
-figures must not be compared with the ordinary "clean" sessions. Instructions
-are normalized per committed frame. Run without concurrent builds or tests.
+`--report` still prints the "paired" (owned/legacy) results recorded in stages 3
+and 4; the legacy presenter they compared against was removed in stage 4e.
Needs a render node (pick one with WLR_RENDER_DRM_DEVICE on multi-GPU machines),
`perf` for instruction counts (optional) and Pillow. Never touches the host session.
@@ -501,52 +498,6 @@ def machine_info(args):
"date": time.strftime("%Y-%m-%d %H:%M:%S")}
-def run_cost_pairs(args):
- """Interleave presenters in the same binary, preserving the raw measurements."""
- order = ("owned", "legacy", "legacy", "owned")
- data = {"mode": "paired", "meta": machine_info(args), "order": order, "runs": []}
- previous = os.environ.get("REDIWM_TEST_SCENE_RENDERER")
- try:
- for config in args.configs.split(","):
- for presenter in order:
- os.environ["REDIWM_TEST_SCENE_RENDERER"] = presenter
- with tempfile.TemporaryDirectory(prefix="rediwm-scene-cost-") as directory:
- tmp = Path(directory)
- build_client(tmp)
- session = Session(tmp, config, args.binary, args.renderer, True, not args.no_perf, args.seconds)
- power_before = power_state()
- try:
- for key in ("a", "b", "c"):
- session.start_client(key)
- session.raise_b()
- session.settle(1)
- glass, clear = session.spinner_rects()
- for name, rect in (("clear", clear), ("glass", glass)):
- session.start_client("c", "damage", rect)
- session.raise_b()
- session.settle(1)
- print(f"[{config}/{presenter}/{name}]", flush=True)
- result = session.measure(name)
- commits = result["stats"]["output_commits"]
- assert commits > 0, "damage client stopped committing"
- if "instructions_per_s" in result:
- result["instructions_per_commit"] = result["instructions_per_s"] * result["seconds"] / commits
- data["runs"].append({"config": config, "presenter": presenter,
- "scenario": name, "result": result,
- "power_before": power_before, "power_after": power_state()})
- finally:
- session.close()
- assert power_before == power_state(), "power conditions changed; discard this session"
- if args.out:
- args.out.write_text(json.dumps(data, indent=1) + "\n")
- finally:
- if previous is None:
- os.environ.pop("REDIWM_TEST_SCENE_RENDERER", None)
- else:
- os.environ["REDIWM_TEST_SCENE_RENDERER"] = previous
- print_cost_report(data)
-
-
def print_cost_report(data):
print("\nPaired cost (instructions owned/legacy; output CPU legacy -> owned; anonymous RSS delta)")
groups = {}
@@ -640,7 +591,7 @@ def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--binary", type=Path, help="compositor to run (default zig-out/bin/rediwm)")
parser.add_argument("--configs", default=",".join(CONFIGS), help=f"comma list of {', '.join(CONFIGS)}")
- parser.add_argument("--modes", default="clean,stats", help="clean (process cost), stats (frame timers), or paired (presenter cost)")
+ parser.add_argument("--modes", default="clean,stats", help="clean (process cost) or stats (frame timers)")
parser.add_argument("--seconds", type=float, default=DEFAULT_SECONDS, help="per scenario (idle runs at least 5)")
parser.add_argument("--renderer", default=os.environ.get("REDIWM_TEST_RENDERER", "gles2"))
parser.add_argument("--cpus", default="auto", help="'auto' (P-cores), 'none' or a list like 2-9")
@@ -663,10 +614,8 @@ def main():
print_report(data, against)
return
modes = args.modes.split(",")
- if any(mode not in ("clean", "stats", "paired") for mode in modes):
- parser.error("modes must be clean, stats, or paired")
- if "paired" in modes and (modes != ["paired"] or args.capture or args.compare or args.against):
- parser.error("paired runs separately from clean/stats and golden capture/comparison")
+ if any(mode not in ("clean", "stats") for mode in modes):
+ parser.error("modes must be clean or stats")
if args.seconds <= 0:
parser.error("seconds must be positive")
if args.cpus != "none":
@@ -683,9 +632,6 @@ def main():
unknown = [c for c in args.configs.split(",") if c not in CONFIGS]
if unknown:
parser.error(f"unknown config {unknown}")
- if modes == ["paired"]:
- run_cost_pairs(args)
- return
results, shots = {}, {}
for config in args.configs.split(","):
for mode in args.modes.split(","):
diff --git a/tests/screenshot_regressions.py b/tests/screenshot_regressions.py
index 91136d6..1dc128c 100644
--- a/tests/screenshot_regressions.py
+++ b/tests/screenshot_regressions.py
@@ -17,7 +17,7 @@ def cpu_seconds(process):
def selection_work(tmp):
- renderer = os.environ.get("REDIWM_TEST_RENDERER", "pixman")
+ renderer = os.environ.get("REDIWM_TEST_RENDERER", "gles2")
process, log = spawn_compositor(tmp, scale="1.5", renderer=renderer, config_content="[compositor]\nxwayland = false\n", env_extra={"HOME": str(tmp), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
try:
with IPCClient(tmp, timeout=15) as ipc:
diff --git a/tests/screenshot_tool.py b/tests/screenshot_tool.py
index 6e6519d..5c4d297 100644
--- a/tests/screenshot_tool.py
+++ b/tests/screenshot_tool.py
@@ -33,7 +33,7 @@ def assert_pixels(actual, expected, message):
def run(scale, displays="1"):
with tempfile.TemporaryDirectory(prefix="rediwm-screenshot-") as directory:
tmp = Path(directory)
- process, log = spawn_compositor(tmp, scale=str(scale), outputs=displays, renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"), env_extra={"HOME": str(tmp), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
+ process, log = spawn_compositor(tmp, scale=str(scale), outputs=displays, renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"), env_extra={"HOME": str(tmp), "WLR_RENDERER_ALLOW_SOFTWARE": "1"})
try:
with IPCClient(socket_path=tmp, timeout=15) as ipc:
ipc.wait_for("wallpaper_presented", timeout_ms=10000)
diff --git a/tests/session_readiness.py b/tests/session_readiness.py
index 3eac50e..5eac143 100644
--- a/tests/session_readiness.py
+++ b/tests/session_readiness.py
@@ -36,7 +36,7 @@ time.sleep(60)
config.write_text('[compositor]\nxwayland = false\n' +
f'[[autostart]]\ncmd = "{command}"\n' * 2)
env = dict(os.environ, XDG_RUNTIME_DIR=directory, WLR_BACKENDS='headless',
- WLR_RENDERER='pixman', WLR_HEADLESS_OUTPUTS='1', REDIWM_CONFIG=str(config),
+ WLR_RENDERER='gles2', WLR_HEADLESS_OUTPUTS='1', REDIWM_CONFIG=str(config),
REDIWM_SESSION_FD=str(child.fileno()), REDIWM_LOGIN_SESSION='must-not-escape',
XDG_CACHE_HOME=str(tmp / 'cache'), DISPLAY=':host',
XDG_STATE_HOME=str(tmp / 'state'),
@@ -118,7 +118,7 @@ def test_restart_during_publication():
config = tmp / 'config.toml'
config.write_text('[compositor]\nxwayland = false\n')
env = dict(os.environ, XDG_RUNTIME_DIR=directory, WLR_BACKENDS='headless',
- WLR_RENDERER='pixman', WLR_HEADLESS_OUTPUTS='1', REDIWM_CONFIG=str(config),
+ WLR_RENDERER='gles2', WLR_HEADLESS_OUTPUTS='1', REDIWM_CONFIG=str(config),
REDIWM_SESSION_FD=str(child.fileno()), XDG_STATE_HOME=str(tmp / 'state'),
XDG_CACHE_HOME=str(tmp / 'cache'), PULSE_SERVER='unix:' + str(tmp / 'missing-pulse'),
DBUS_SYSTEM_BUS_ADDRESS='unix:path=/nonexistent-rediwm-system',
@@ -168,7 +168,7 @@ def test_restart_behind_lock():
config = tmp / 'config.toml'
config.write_text('[compositor]\nxwayland = false\n')
env = dict(os.environ, XDG_RUNTIME_DIR=directory, WLR_BACKENDS='headless',
- WLR_RENDERER='pixman', WLR_HEADLESS_OUTPUTS='1', REDIWM_CONFIG=str(config),
+ WLR_RENDERER='gles2', WLR_HEADLESS_OUTPUTS='1', REDIWM_CONFIG=str(config),
REDIWM_SESSION_FD=str(child.fileno()), XDG_STATE_HOME=str(tmp / 'state'),
XDG_CACHE_HOME=str(tmp / 'cache'), PULSE_SERVER='unix:' + str(tmp / 'missing-pulse'),
DBUS_SYSTEM_BUS_ADDRESS='unix:path=/nonexistent-rediwm-system',
diff --git a/tests/session_restart.py b/tests/session_restart.py
index 9cc6fde..a2e153e 100644
--- a/tests/session_restart.py
+++ b/tests/session_restart.py
@@ -24,7 +24,7 @@ def run():
config = tmp / 'config.toml'
config.write_text('[compositor]\nxwayland = false\n[autostart]\n')
env = dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WLR_BACKENDS='headless',
- WLR_HEADLESS_OUTPUTS='1', WLR_RENDERER='pixman',
+ WLR_HEADLESS_OUTPUTS='1', WLR_RENDERER='gles2',
REDIWM_CONFIG=str(config), XDG_CACHE_HOME=str(tmp / 'cache'),
REDIWM_SOCKET=str(tmp / 'rediwm-test.sock'))
env.pop('WAYLAND_DISPLAY', None)
diff --git a/tests/single_pixel.py b/tests/single_pixel.py
index 99bfb0f..ccc3a8a 100644
--- a/tests/single_pixel.py
+++ b/tests/single_pixel.py
@@ -31,7 +31,7 @@ def build_client(tmp):
def run():
scale = float(os.environ.get("REDIWM_TEST_SCALE", "1"))
- renderer = os.environ.get("REDIWM_TEST_RENDERER", "pixman")
+ renderer = os.environ.get("REDIWM_TEST_RENDERER", "gles2")
with tempfile.TemporaryDirectory(prefix="rediwm-single-pixel-") as directory:
tmp = Path(directory)
build_client(tmp)
diff --git a/tests/spawn_latency.py b/tests/spawn_latency.py
index ce5bdff..9c13fa0 100644
--- a/tests/spawn_latency.py
+++ b/tests/spawn_latency.py
@@ -217,7 +217,7 @@ def compositor_env(tmp: Path, backend: str, renderer: str, scale: str, config: s
def run_isolated(args) -> None:
backend = os.environ.get("REDIWM_TEST_BACKEND", "headless")
- renderer = os.environ.get("REDIWM_TEST_RENDERER", "pixman")
+ renderer = os.environ.get("REDIWM_TEST_RENDERER", "gles2")
scale = os.environ.get("REDIWM_TEST_SCALE", "1")
host_display = os.environ.get("WAYLAND_DISPLAY")
if backend == "wayland" and not host_display:
diff --git a/tests/startup_perf.py b/tests/startup_perf.py
index 3a4e234..f5d7050 100644
--- a/tests/startup_perf.py
+++ b/tests/startup_perf.py
@@ -116,7 +116,7 @@ def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--binary", type=Path, default=ROOT / "zig-out/bin/rediwm")
parser.add_argument("--runs", type=int, default=7)
- parser.add_argument("--renderer", choices=("pixman", "gles2"), default="pixman")
+ parser.add_argument("--renderer", choices=("pixman", "gles2"), default="gles2")
parser.add_argument("--scale", default="1")
parser.add_argument("--native-scaling", action="store_true")
parser.add_argument("--cold-cache", action="store_true")
diff --git a/tests/switcher.py b/tests/switcher.py
index c6a2578..a9c7574 100644
--- a/tests/switcher.py
+++ b/tests/switcher.py
@@ -14,7 +14,7 @@ def run(scale, modifier=56):
with tempfile.TemporaryDirectory(prefix='rediwm-switcher-') as directory:
tmp = Path(directory)
build_client(tmp)
- proc, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'), config_content=f'[compositor]\nswitcher_opacity = {os.environ.get("REDIWM_TEST_SWITCHER_OPACITY", "1.0")}\n[input]\nkey_repeat_delay = 200\nkey_repeat_rate = 5\n[keybinds]\n\"alt+tab\" = \"focus_next\"\n\"alt+shift+tab\" = \"focus_prev\"\n')
+ proc, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'), config_content=f'[compositor]\nswitcher_opacity = {os.environ.get("REDIWM_TEST_SWITCHER_OPACITY", "1.0")}\n[input]\nkey_repeat_delay = 200\nkey_repeat_rate = 5\n[keybinds]\n\"alt+tab\" = \"focus_next\"\n\"alt+shift+tab\" = \"focus_prev\"\n')
clients = []
try:
with IPCClient(tmp) as ipc:
diff --git a/tests/switcher_live.py b/tests/switcher_live.py
index dde6143..d99e995 100644
--- a/tests/switcher_live.py
+++ b/tests/switcher_live.py
@@ -14,7 +14,7 @@ def run(scale):
with tempfile.TemporaryDirectory(prefix='rediwm-switcher-live-') as directory:
tmp = Path(directory)
build_client(tmp)
- proc, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'))
+ proc, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'))
clients = []
try:
with IPCClient(tmp) as ipc:
diff --git a/tests/taskbar_peek.py b/tests/taskbar_peek.py
index fa13024..81a7f0b 100644
--- a/tests/taskbar_peek.py
+++ b/tests/taskbar_peek.py
@@ -163,7 +163,7 @@ def context_menu():
tmp = Path(directory)
build_client(tmp)
process, log = spawn_compositor(tmp, scale=float(os.environ.get("REDIWM_TEST_SCALE", "1")),
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
config_content='[compositor]\nxwayland = false\n[animations]\nenabled = false\n', env_extra={
"DBUS_SESSION_BUS_ADDRESS": "", "XDG_CACHE_HOME": str(tmp / "cache"),
"XDG_CONFIG_HOME": str(tmp / "config"), "XDG_DATA_HOME": str(tmp / "data")})
diff --git a/tests/taskbar_title_repaint.py b/tests/taskbar_title_repaint.py
index 79d0009..6af866d 100644
--- a/tests/taskbar_title_repaint.py
+++ b/tests/taskbar_title_repaint.py
@@ -29,7 +29,7 @@ def run(scale):
with tempfile.TemporaryDirectory(prefix='rediwm-title-repaint-') as directory:
tmp = Path(directory)
build_client(tmp)
- proc, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'))
+ proc, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'))
clients = []
try:
with IPCClient(tmp) as ipc:
diff --git a/tests/tray.py b/tests/tray.py
index 051a779..dca29ae 100644
--- a/tests/tray.py
+++ b/tests/tray.py
@@ -116,7 +116,7 @@ def test(scale):
events = runtime / 'events'
# Start before the watcher to verify discovery when it appears.
fixture = subprocess.Popen([sys.executable, __file__, '--service', str(events)], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
- proc, log = spawn_compositor(runtime, outputs='1', scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'),
+ proc, log = spawn_compositor(runtime, outputs='1', scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'),
env_extra={'WLR_RENDERER_ALLOW_SOFTWARE': '1', 'REDIWM_FORCE_DBUS': '1', 'PULSE_SERVER': 'unix:/nonexistent/rediwm-test-audio'})
try:
with IPCClient(runtime) as ipc:
@@ -199,7 +199,7 @@ def test(scale):
second = runtime / 'second'
second.mkdir()
other, other_log = spawn_compositor(second, outputs='1', scale=scale,
- renderer=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'),
+ renderer=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'),
env_extra={'WLR_RENDERER_ALLOW_SOFTWARE': '1', 'REDIWM_FORCE_DBUS': '1', 'PULSE_SERVER': 'unix:/nonexistent/rediwm-test-audio'})
try:
with IPCClient(second) as other_ipc:
diff --git a/tests/undo.py b/tests/undo.py
index 3164b10..76d7216 100644
--- a/tests/undo.py
+++ b/tests/undo.py
@@ -74,7 +74,7 @@ def run():
XDG_RUNTIME_DIR=str(tmp),
WLR_BACKENDS="headless",
WLR_HEADLESS_OUTPUTS=os.environ.get("REDIWM_TEST_OUTPUTS", "1"),
- WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
WLR_RENDERER_ALLOW_SOFTWARE="1",
REDIWM_SCALE=os.environ.get("REDIWM_TEST_SCALE", "1"),
REDIWM_IPC_AUTOMATION="1",
diff --git a/tests/wifi_popup.py b/tests/wifi_popup.py
index 7b25573..b57f8b6 100644
--- a/tests/wifi_popup.py
+++ b/tests/wifi_popup.py
@@ -151,7 +151,7 @@ def run(scale):
fake = start_fake()
with tempfile.TemporaryDirectory(prefix='rediwm-wifi-') as directory:
tmp = Path(directory)
- process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'), config_content='[compositor]\nxwayland = false\n', env_extra={
+ process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'), config_content='[compositor]\nxwayland = false\n', env_extra={
'DBUS_SYSTEM_BUS_ADDRESS': os.environ['DBUS_SESSION_BUS_ADDRESS'], 'DBUS_SESSION_BUS_ADDRESS': '', 'XDG_CACHE_HOME': str(tmp),
})
try:
@@ -186,7 +186,7 @@ def run(scale):
assert read_line(fake)=={'done':True}
settle()
def screenshot(name):
- target=Path('/tmp')/f'rediwm-wifi-{name}-{scale}-{os.environ.get("REDIWM_TEST_RENDERER", "pixman")}.png'
+ target=Path('/tmp')/f'rediwm-wifi-{name}-{scale}-{os.environ.get("REDIWM_TEST_RENDERER", "gles2")}.png'
target.unlink(missing_ok=True)
ipc.screenshot(str(target))
open_menu()
@@ -331,7 +331,7 @@ def settings(scale):
fake = start_fake()
with tempfile.TemporaryDirectory(prefix='rediwm-network-settings-') as directory:
tmp = Path(directory)
- process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'pixman'), config_content='[compositor]\nxwayland = false\n', env_extra={
+ process, log = spawn_compositor(tmp, scale=scale, renderer=os.environ.get('REDIWM_TEST_RENDERER', 'gles2'), config_content='[compositor]\nxwayland = false\n', env_extra={
'DBUS_SYSTEM_BUS_ADDRESS': os.environ['DBUS_SESSION_BUS_ADDRESS'], 'DBUS_SESSION_BUS_ADDRESS': '', 'XDG_CACHE_HOME': str(tmp),
'PIPEWIRE_RUNTIME_DIR': str(tmp), 'PULSE_SERVER': 'unix:/nonexistent-rediwm-test-pulse',
})
diff --git a/tests/window_corners.py b/tests/window_corners.py
index d9eb64e..22994cf 100644
--- a/tests/window_corners.py
+++ b/tests/window_corners.py
@@ -14,10 +14,8 @@ from ipc_client import IPCClient, spawn_compositor, stop_process
from ui_driver import UIDriver
-# The owned presenter clips the whole window with one shape (stage 4 of
-# docs/plans/scene-graph.md): the client's corners are transparent and the frame
-# has no skirt, its footer is the border. Select it with REDIWM_TEST_SCENE_RENDERER.
-OWNED = os.environ.get("REDIWM_TEST_SCENE_RENDERER") == "owned"
+# One shape clips the whole window (stage 4 of docs/plans/scene-graph.md): the
+# client's corners are transparent and the frame's footer is the border.
def settings_resize(scale):
@@ -34,7 +32,7 @@ def settings_resize(scale):
)
process, log = spawn_compositor(
tmp, scale=str(scale), config_content=config,
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"HOME": str(tmp), "DBUS_SESSION_BUS_ADDRESS": "",
"DBUS_SYSTEM_BUS_ADDRESS": "unix:path=/nonexistent",
"REDIWM_THEME": str(tmp / "rediwm-config.toml"), "REDIWM_NO_GLASS": "1"},
@@ -59,15 +57,13 @@ def settings_resize(scale):
image = image.convert("RGB")
x = round((box["x"] + box["width"] / 2) * scale)
join = round((box["y"] + box["height"]) * scale)
- # Below the body the frame continues it for `footer` rows, the last
- # of which is the border: a skirt of 10 on the legacy presenter, the
- # border alone (1) when a shape clips the window.
+ # Below the body the frame is the border alone: one row.
footer = frame["y"] + frame["height"] - (box["y"] + box["height"])
- assert footer == (1 if OWNED else 10), ("footer height", footer)
+ assert footer == 1, ("footer height", footer)
# The ring is max(1, round(border * scale)) device pixels at the bottom
# of the frame, so the body colour is certain only above it.
ring = max(1, round(scale))
- for y in range(join - 3, join - ring + 1 if OWNED else join + 3):
+ for y in range(join - 3, join - ring + 1):
pixel = image.getpixel((x, y))
assert pixel == (16, 18, 21), ("body/skirt seam", scale, width, height, y, pixel)
for sx, sy in ((frame["x"] + frame["width"] + 5, box["y"] + box["height"] / 2),
@@ -93,7 +89,7 @@ def workspace_focus(scale):
'[desktop]\nenabled = false\n[animations]\nenabled = false\n'
'[theme]\nwindow_bg = "#101215"\nshadow = "#00000000"\n')
process, log = spawn_compositor(tmp, scale=str(scale), config_content=config,
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "REDIWM_THEME": str(tmp / "rediwm-config.toml")})
clients = []
try:
@@ -197,144 +193,6 @@ def workspace_focus(scale):
log.close()
-def frame_screenshot(scale, presenter):
- """One opaque window on a plain wallpaper, with a shadow, under one presenter."""
- # The harness reads the presenter from the environment when it writes the config.
- previous = os.environ.get("REDIWM_TEST_SCENE_RENDERER")
- os.environ["REDIWM_TEST_SCENE_RENDERER"] = presenter
- try:
- return _frame_screenshot(scale)
- finally:
- if previous is None:
- os.environ.pop("REDIWM_TEST_SCENE_RENDERER", None)
- else:
- os.environ["REDIWM_TEST_SCENE_RENDERER"] = previous
-
-
-def _frame_screenshot(scale):
- with tempfile.TemporaryDirectory(prefix="rediwm-frame-parity-") as directory:
- tmp = Path(directory)
- build_client(tmp)
- wallpaper = tmp / "wallpaper.png"
- Image.new("RGB", (64, 64), (48, 50, 56)).save(wallpaper)
- config = (
- f'[compositor]\nxwayland = false\nwallpaper = "{wallpaper}"\n'
- '[desktop]\nenabled = false\n[animations]\nreduced_motion = "on"\n'
- '[theme]\nshadow = "#00000060"\nshadow_size = 16\nradius_lg = 10\n'
- 'window_bg = "rgba(16,18,21,0.8)"\n'
- )
- process, log = spawn_compositor(
- tmp, scale=str(scale), config_content=config,
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
- env_extra={"HOME": str(tmp), "DBUS_SESSION_BUS_ADDRESS": "", "REDIWM_NO_GLASS": "1",
- "REDIWM_THEME": str(tmp / "rediwm-config.toml")},
- )
- client = None
- try:
- with IPCClient(tmp) as ipc:
- ipc.wait_for("wallpaper_presented", timeout_ms=10000)
- display = next(p.name for p in tmp.glob("wayland-*") if not p.name.endswith(".lock"))
- live = tmp / "live"
- live.write_text("ff203040 400 260 Frame parity")
- with (tmp / "client.log").open("w") as client_log:
- client = subprocess.Popen(
- [str(tmp / "client")], stdout=client_log, stderr=client_log,
- env=dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WAYLAND_DISPLAY=display,
- REDIWM_TEST_LIVE_FILE=str(live)))
- window = wait_for(lambda: next(iter(ipc.get_windows()), None), "window did not map")
- ipc.action("set_camera", {"x": 0, "y": 0})
- ipc.action("move_window_to", {"id": window["id"], "x": 80, "y": 80})
- ipc.move_cursor(20, 20)
- time.sleep(0.4)
- ipc.wait_for_frame()
- window = ipc.get_windows()[0]
- path = tmp / "frame.png"
- ipc.screenshot(path=str(path))
- with Image.open(path) as image:
- return image.convert("RGB"), window, ipc.get_window_debug(window["id"])
- finally:
- if client is not None:
- stop_process(client)
- stop_process(process)
- log.close()
-
-
-def frame_parity(scale):
- """A shape changes the corners and the bottom band and nothing else: the
- titlebar, the side borders and the client match the legacy frame pixel for
- pixel, at every scale, and the analytic shadow matches the CPU one."""
- from PIL import ImageChops
- legacy, lwin, ldbg = frame_screenshot(scale, "legacy")
- owned, owin, odbg = frame_screenshot(scale, "owned")
- assert (lwin["x"], lwin["y"], lwin["width"]) == (owin["x"], owin["y"], owin["width"]), (lwin, owin)
- assert lwin["height"] - owin["height"] == 9, ("the frame is the radius shorter", lwin, owin)
- assert ldbg["client_box"] == odbg["client_box"], (ldbg["client_box"], odbg["client_box"])
- x, y, w, h = owin["x"], owin["y"], owin["width"], owin["height"]
- titlebar = odbg["titlebar_height"]
- arc = math.ceil(10 * scale) + 2
- def device(*box):
- return tuple(round(v * scale) for v in box)
- regions = {
- "titlebar band": (device(x, y, x + w, y + titlebar)[0] + arc, round(y * scale),
- device(x, y, x + w, y + titlebar)[2] - arc, round((y + titlebar) * scale)),
- "left titlebar edge below the arc": (round(x * scale), round(y * scale) + arc, round(x * scale) + 2, round((y + titlebar) * scale)),
- # The legacy border is a snapped rect whose width depends on where the edge falls on
- # the device grid (at 1.25 the right one is two pixels, the left one one); a shape's
- # ring is one uniform max(1, round(border * scale)). They agree on integer scales.
- "left and right side columns": (round(x * scale), round((y + titlebar) * scale),
- round((x + w) * scale) - (0 if scale == int(scale) else math.ceil(scale)),
- round((y + h) * scale) - arc),
- }
- for name, box in regions.items():
- diff = ImageChops.difference(legacy.crop(box), owned.crop(box))
- assert diff.getbbox() is None, (name, scale, box, diff.getbbox(), diff.getextrema())
- # Stage 4d: the owned pass draws the shadow from the shape, the legacy one from
- # CPU patches of the same formula; they agree to a level or two, corners too.
- # Only pixels clear of the window (one device pixel past its arc) are compared.
- # The legacy frame is 9 px taller, so its bottom shadow is compared moved up by
- # that, which lands on whole device pixels at integer scales only.
- soft, radius = 16, 10
- def outside(px, py):
- lx, ly = (px + 0.5) / scale, (py + 0.5) / scale
- qx = abs(lx - (x + w / 2)) - (w / 2 - radius)
- qy = abs(ly - (y + h / 2)) - (h / 2 - radius)
- d = math.hypot(max(qx, 0), max(qy, 0)) + min(max(qx, qy), 0) - radius
- return d * scale > 1
- shadow_regions = {
- "shadow left of the window": ((x - soft, y + 20, x, y + h - radius - 2), 0),
- "shadow above the window": ((x + 20, y - soft, x + w - 20, y), 0),
- "shadow at the top corners": ((x - soft, y - soft, x + w + soft, y + radius + 2), 0),
- }
- if scale == int(scale):
- shadow_regions["shadow below the window, corners included"] = (
- (x - soft, y + h - radius - 2, x + w + soft, y + h + soft + 8), round(9 * scale))
- # The legacy 9-slice has one known gap: its side patches take the window's edge
- # as straight down to the offset corner patch, so a few pixels under each bottom
- # arc show bare wallpaper where the shadow is at full strength. The owned shadow
- # must fill them.
- wallpaper = (48, 50, 56)
- worst, gap = 0, 0
- for name, (box, shift) in shadow_regions.items():
- x1, y1, x2, y2 = (round(v * scale) for v in box)
- for py in range(y1, y2):
- for px in range(x1, x2):
- if not outside(px, py):
- continue
- a, b = legacy.getpixel((px, py + shift)), owned.getpixel((px, py))
- level = max(abs(i - j) for i, j in zip(a, b))
- if level > 2 and a == wallpaper and sum(b) < sum(wallpaper) - 30:
- # Only ever under a bottom arc.
- lx, ly = (px + 0.5) / scale, (py + 0.5) / scale
- assert y + h - radius <= ly <= y + h and (lx <= x + radius or lx >= x + w - radius), \
- ("the shadow differs outside the legacy corner gap", scale, (px, py), a, b)
- gap += 1
- continue
- worst = max(worst, level)
- assert level <= 2, (name, scale, (px, py), a, b)
- print(f"PASS scale {scale}: titlebar, sides and client identical to the legacy frame, "
- f"the analytic shadow within {worst} levels of the CPU one ({gap} legacy gap pixels filled)")
-
-
def run(scale, background=(48, 50, 56), chrome_alpha=0.98):
with tempfile.TemporaryDirectory(prefix="rediwm-corners-") as directory:
tmp = Path(directory)
@@ -350,7 +208,7 @@ def run(scale, background=(48, 50, 56), chrome_alpha=0.98):
)
process, log = spawn_compositor(
tmp, scale=str(scale), config_content=config,
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"HOME": str(tmp), "DBUS_SESSION_BUS_ADDRESS": "",
"REDIWM_THEME": str(tmp / "rediwm-config.toml"), "REDIWM_NO_GLASS": "1"},
)
@@ -397,23 +255,22 @@ def run(scale, background=(48, 50, 56), chrome_alpha=0.98):
pixel = image.getpixel((column, row))
assert all(abs(a - b) <= 2 for a, b in zip(pixel, expected)), (
"side border fill", scale, hovered, column, row, pixel, expected)
- if OWNED:
- # One shape clips the client too: its bottom corners are
- # transparent, so the wallpaper shows there (no shadow here),
- # and a click on one reaches what is below. Interior
- # pixels next to the arc keep the client's colour.
- for cx, cy in ((x, y + h - 1), (x + w - 1, y + h - 1)):
- pixel = image.getpixel((round(cx * scale) if cx == x else round((cx + 1) * scale) - 1,
- round((cy + 1) * scale) - 1))
- assert all(abs(a - b) <= 3 for a, b in zip(pixel, background)), (
- "client corner is not transparent", scale, hovered, cx, cy, pixel)
- inward = 1 if cx == x else -1
- pixel = image.getpixel((round((cx + inward * 14) * scale), round((cy - 14) * scale)))
- assert pixel == (16, 18, 21), ("client interior near the corner", scale, pixel)
- hit = ipc.hit_test(cx + inward, cy - 1)
- assert hit["target_type"] == "none", ("click on a clipped corner stayed on the window", scale, hit)
- hit = ipc.hit_test(cx + inward * 30, cy - 30)
- assert hit["target_type"] == "window", ("client interior is not the window's", scale, hit)
+ # One shape clips the client too: its bottom corners are
+ # transparent, so the wallpaper shows there (no shadow here),
+ # and a click on one reaches what is below. Interior
+ # pixels next to the arc keep the client's colour.
+ for cx, cy in ((x, y + h - 1), (x + w - 1, y + h - 1)):
+ pixel = image.getpixel((round(cx * scale) if cx == x else round((cx + 1) * scale) - 1,
+ round((cy + 1) * scale) - 1))
+ assert all(abs(a - b) <= 3 for a, b in zip(pixel, background)), (
+ "client corner is not transparent", scale, hovered, cx, cy, pixel)
+ inward = 1 if cx == x else -1
+ pixel = image.getpixel((round((cx + inward * 14) * scale), round((cy - 14) * scale)))
+ assert pixel == (16, 18, 21), ("client interior near the corner", scale, pixel)
+ hit = ipc.hit_test(cx + inward, cy - 1)
+ assert hit["target_type"] == "none", ("click on a clipped corner stayed on the window", scale, hit)
+ hit = ipc.hit_test(cx + inward * 30, cy - 30)
+ assert hit["target_type"] == "window", ("client interior is not the window's", scale, hit)
# Straight borders and the surrounding wallpaper
# bound every colour in an antialiased corner. The old
# straight-alpha interpolation overshot this by ~40 levels.
@@ -445,8 +302,6 @@ def run(scale, background=(48, 50, 56), chrome_alpha=0.98):
if __name__ == "__main__":
for scale in (1, 1.25, 1.5, 2):
- if OWNED:
- frame_parity(scale)
workspace_focus(scale)
settings_resize(scale)
run(scale)
diff --git a/tests/window_rules.py b/tests/window_rules.py
index 6cc490d..25359ab 100644
--- a/tests/window_rules.py
+++ b/tests/window_rules.py
@@ -187,7 +187,7 @@ def run():
XDG_RUNTIME_DIR=str(tmp),
WLR_BACKENDS="headless",
WLR_HEADLESS_OUTPUTS="2",
- WLR_RENDERER="pixman",
+ WLR_RENDERER="gles2",
REDIWM_SCALE="1",
REDIWM_CONFIG=str(config_file),
)
diff --git a/tests/window_tabs.py b/tests/window_tabs.py
index 1c113a9..cc08d61 100644
--- a/tests/window_tabs.py
+++ b/tests/window_tabs.py
@@ -42,7 +42,7 @@ def run():
config = config.replace('[compositor]\n', '[compositor]\ndesktop_mode = "workspaces"\n', 1)
process, log = spawn_compositor(tmp, config_content=config,
scale=os.environ.get("REDIWM_TEST_SCALE", "1"),
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "XDG_DATA_HOME": str(tmp / "data"),
"REDIWM_NO_GLASS": "1"})
clients = []
diff --git a/tests/window_titles.py b/tests/window_titles.py
index 7376c06..9925851 100644
--- a/tests/window_titles.py
+++ b/tests/window_titles.py
@@ -19,7 +19,7 @@ def run():
tmp = Path(directory)
build_client(tmp)
compositor, log = spawn_compositor(
- tmp, renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ tmp, renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": ""})
client = None
try:
diff --git a/tests/workspaces.py b/tests/workspaces.py
index c309fae..4696a3d 100644
--- a/tests/workspaces.py
+++ b/tests/workspaces.py
@@ -31,7 +31,7 @@ snap_to_edges = false
if os.getenv("REDIWM_TEST_NEGATIVE") == "1":
canvas += '\n[[outputs]]\nname = "HEADLESS-1"\nx = 0\ny = 0\n[[outputs]]\nname = "HEADLESS-2"\nx = -1280\ny = -120\n'
process, log = spawn_compositor(tmp, outputs=str(outputs), config_content=canvas,
- renderer=os.getenv("REDIWM_TEST_RENDERER", "pixman"), scale=os.getenv("REDIWM_TEST_SCALE", "1"),
+ renderer=os.getenv("REDIWM_TEST_RENDERER", "gles2"), scale=os.getenv("REDIWM_TEST_SCALE", "1"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "REDIWM_FILES_DEVICES": "0"})
clients = []
try:
@@ -235,7 +235,7 @@ enabled = false
if outputs > 1 and os.getenv("REDIWM_TEST_NEGATIVE") == "1":
config += '\n[[outputs]]\nname = "HEADLESS-1"\nx = 0\ny = 0\n[[outputs]]\nname = "HEADLESS-2"\nx = -1280\ny = -120\n'
process, log = spawn_compositor(tmp, outputs=str(outputs), config_content=config,
- renderer=os.getenv("REDIWM_TEST_RENDERER", "pixman"), scale=os.getenv("REDIWM_TEST_SCALE", "1"),
+ renderer=os.getenv("REDIWM_TEST_RENDERER", "gles2"), scale=os.getenv("REDIWM_TEST_SCALE", "1"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "XDG_DATA_HOME": str(tmp / "data")})
clients = []
try:
@@ -615,7 +615,7 @@ window_gap = 8
"Super+Shift+Left" = "tile_left"
'''
process, log = spawn_compositor(tmp, config_content=config,
- renderer=os.getenv("REDIWM_TEST_RENDERER", "pixman"), scale=os.getenv("REDIWM_TEST_SCALE", "1"),
+ renderer=os.getenv("REDIWM_TEST_RENDERER", "gles2"), scale=os.getenv("REDIWM_TEST_SCALE", "1"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": ""})
clients = []
try:
@@ -797,7 +797,7 @@ def rollout_acceptance():
value += '[[outputs]]\nname = "HEADLESS-2"\nscale = 1.5\nx = 1600\ny = -120\n'
return value
process, log = spawn_compositor(tmp, outputs=str(outputs), config_content=config(), scale="auto",
- renderer=os.getenv("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.getenv("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "XDG_CACHE_HOME": str(tmp / "cache")})
clients = []
try:
@@ -953,7 +953,7 @@ def xwayland_routing():
if outputs > 1 and os.getenv("REDIWM_TEST_NEGATIVE") == "1":
config += '\n[[outputs]]\nname = "HEADLESS-1"\nx = 0\ny = 0\n[[outputs]]\nname = "HEADLESS-2"\nx = -1280\ny = -120\n'
process, log = spawn_compositor(tmp, outputs=str(outputs), config_content=config,
- renderer=os.getenv("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.getenv("REDIWM_TEST_RENDERER", "gles2"),
scale=os.getenv("REDIWM_TEST_SCALE", "1"), env_extra={"DBUS_SESSION_BUS_ADDRESS": ""})
children = []
try:
@@ -1059,7 +1059,7 @@ def persistence_controls():
runtime.mkdir()
content = config if phase == 1 else config.replace('desktop_mode = "canvas"', 'desktop_mode = "workspaces"')
process, log = spawn_compositor(runtime, outputs=outputs, config_content=content,
- renderer=os.getenv("REDIWM_TEST_RENDERER", "pixman"), scale=os.getenv("REDIWM_TEST_SCALE", "1"),
+ renderer=os.getenv("REDIWM_TEST_RENDERER", "gles2"), scale=os.getenv("REDIWM_TEST_SCALE", "1"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "XDG_STATE_HOME": str(state), "XDG_DATA_HOME": str(tmp / "data"), "REDIWM_FILES_DEVICES": "0"})
clients = []
try:
diff --git a/tests/xwayland.py b/tests/xwayland.py
index 168f208..6051c4b 100644
--- a/tests/xwayland.py
+++ b/tests/xwayland.py
@@ -27,14 +27,13 @@ def wait_for(check, message, timeout=15):
def start_compositor(tmp, config_text, env_overrides=None):
- from ipc_client import scene_renderer_config
- (tmp / "config.toml").write_text(scene_renderer_config(config_text))
+ (tmp / "config.toml").write_text(config_text)
env = dict(
os.environ,
XDG_RUNTIME_DIR=str(tmp),
WLR_BACKENDS="headless",
WLR_HEADLESS_OUTPUTS="1",
- WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
REDIWM_SCALE="1",
REDIWM_CONFIG=str(tmp / "config.toml"),
REDIWM_IPC_AUTOMATION="1",
diff --git a/tests/xwayland_hardening.py b/tests/xwayland_hardening.py
index f00a009..5c3a32e 100644
--- a/tests/xwayland_hardening.py
+++ b/tests/xwayland_hardening.py
@@ -15,7 +15,7 @@ def run():
build_client(tmp)
compositor, log = spawn_compositor(
tmp, config_content="[compositor]\nxwayland = true\nxwayland_scale = 1\n",
- renderer=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),
+ renderer=os.environ.get("REDIWM_TEST_RENDERER", "gles2"),
env_extra={"DBUS_SESSION_BUS_ADDRESS": "", "DISPLAY": "",
"XAUTHORITY": "", "XDG_CACHE_HOME": str(tmp / "cache")})
client = None
diff --git a/tests/zoom_osd.py b/tests/zoom_osd.py
index a4dad77..3f1f1e1 100644
--- a/tests/zoom_osd.py
+++ b/tests/zoom_osd.py
@@ -14,7 +14,7 @@ def run():
tmp = Path(directory)
scale = float(os.getenv('REDIWM_TEST_SCALE', '1'))
proc, log = spawn_compositor(tmp, scale=str(scale),
- renderer=os.getenv('REDIWM_TEST_RENDERER', 'pixman'),
+ renderer=os.getenv('REDIWM_TEST_RENDERER', 'gles2'),
config_content='''[compositor]
xwayland = false
mini_map_enabled = false