Skip to content

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

theme updates

oxydizeref4a109b20e4
diff --git a/assets/themes/blackout.toml b/assets/themes/blackout.toml
index 0e2d46a..36e94f2 100644
--- a/assets/themes/blackout.toml
+++ b/assets/themes/blackout.toml
@@ -10,32 +10,34 @@ font = "Manrope"
mono_font = "JetBrains Mono"
font_size = 13
title_size = 13.5
-chrome_height = 42
+chrome_height = 50
chrome_control_gap = 8
chrome_control_right_pad = 2
chrome_control_offset_y = 5
chrome_round_buttons = false
+chrome_button_bevel = 7
# Raised title tab, a 45-degree step down, and four clipped corners. The step
-# is the title plate's slant moved out by the plate inset: 310 wide, 30 slant
-# (42 - 2 * 6) and inset 6 give x - y = 274 + 6 * sqrt(2). Change them together.
-# Below ~304 px wide the outline cannot fit and the window is a plain rectangle;
+# is the title plate's slant moved out by the plate inset: 310 wide, 38 slant
+# (50 - 2 * 6) and inset 6 give x - y = 266 + 6 * sqrt(2). Change them together.
+# Below ~296 px wide the outline cannot fit and the window uses rounded corners;
# maximized windows stay rectangular.
-window_shape = "0 14, 14 0, 282.5 0, 289.5 7, -14 7, -0 21, -0 -12, -12 -0, 12 -0, 0 -12"
+window_shape = "0 14, 14 0, 274.5 0, 281.5 7, -14 7, -0 21, -0 -12, -12 -0, 12 -0, 0 -12"
window_bg = "#111516"
window_fg = "#E3E5E3"
window_dim = "#A2A8A6"
window_border = "#3B4242"
window_border_hover = "#737C68"
+window_border_width = 2
window_divider = "#2A3030"
window_title_plate = "#FAEB01"
window_title_plate_width = 310
window_title_plate_fg = "#111400"
-# Plate geometry; slant is a fraction of chrome_height (30 of 42: 45 degrees).
+# Plate geometry; slant is a fraction of chrome_height (38 of 50: 45 degrees).
# With an outline the plate follows its cut corners at the inset; the bevel
# applies to rectangular (maximized) frames.
window_title_plate_inset = 6
window_title_plate_bevel = 7
-window_title_plate_slant = 0.7142857
+window_title_plate_slant = 0.76
window_title_plate_control_gap = 8
window_title_plate_text_padding = 8
window_corner_accent = "#FAEB01"
@@ -89,7 +91,7 @@ scrollbar_track_stripe_period = 10
scrollbar_track_stripe_width = 5
scrollbar_track_stripe_slope = 1
scrollbar_glow = 0
-scrollbar_width = 8
+scrollbar_width = 10
scrollbar_radius = 3
bg = "#101314"
@@ -152,6 +154,7 @@ taskbar_shape = "0 0, -0 0, -0 -0, 16 -0, 0 -16"
start_button_logo_color = "#FAEB01"
start_button_indicator = "#FAEB01"
start_menu_bg = "#15191A"
+start_menu_bevel = 16
start_menu_border = "#3B4242"
start_menu_search_bg = "#0D1011"
start_menu_selected_bg = "#454719"
diff --git a/build.zig b/build.zig
index 84399e7..9ae67d0 100644
--- a/build.zig
+++ b/build.zig
@@ -318,4 +318,6 @@ pub fn build(b: *std.Build) void {
run_cmd.addPassthruArgs();
const run_step = b.step("run", "Run the nested compositor (pass a client command after --)");
run_step.dependOn(&run_cmd.step);
+ // Last: it lists every executable registered above.
+ @import("build/install_paths.zig").writeProgramList(b);
}
diff --git a/build/install_paths.zig b/build/install_paths.zig
index a22b31b..8a934f7 100644
--- a/build/install_paths.zig
+++ b/build/install_paths.zig
@@ -62,3 +62,41 @@ pub fn configure(b: *std.Build, path: []const u8, prefix: []const u8) std.Build.
const contents = std.mem.replaceOwned(u8, b.allocator, bytes, "@BINDIR@", b.fmt("{s}/bin", .{prefix})) catch @panic("out of memory");
return b.addWriteFiles().add(std.fs.path.basename(path), contents);
}
+
+/// Writes `programs` beside `install-prefix`: every executable the install step
+/// puts in bin/, one per line. The install scripts read it instead of keeping
+/// their own lists, so a new helper cannot be left out, and a stale file
+/// lingering in an old output directory (zig build never deletes) is ignored.
+/// Call last in `build()`, after every artifact is registered.
+pub fn writeProgramList(b: *std.Build) void {
+ var names: std.ArrayList([]const u8) = .empty;
+ var seen: std.AutoHashMapUnmanaged(*std.Build.Step, void) = .empty;
+ collectPrograms(b, b.getInstallStep(), &names, &seen);
+ std.mem.sort([]const u8, names.items, {}, struct {
+ fn less(_: void, x: []const u8, y: []const u8) bool {
+ return std.mem.order(u8, x, y) == .lt;
+ }
+ }.less);
+ var text: std.ArrayList(u8) = .empty;
+ for (names.items) |name| text.print(b.allocator, "{s}\n", .{name}) catch @panic("out of memory");
+ const list = b.addWriteFiles().add("programs", text.items);
+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(list, .prefix, "programs").step);
+}
+
+fn collectPrograms(b: *std.Build, step: *std.Build.Step, names: *std.ArrayList([]const u8), seen: *std.AutoHashMapUnmanaged(*std.Build.Step, void)) void {
+ if ((seen.getOrPut(b.allocator, step) catch @panic("out of memory")).found_existing) return;
+ var program: ?[]const u8 = null;
+ if (step.cast(std.Build.Step.InstallArtifact)) |install| {
+ const in_bin = if (install.dest_dir) |dir| dir == .bin else false;
+ if (in_bin and install.artifact.kind == .exe) program = install.dest_sub_path orelse install.artifact.out_filename;
+ }
+ // Programs built by an external command (the transfers helper) install as files.
+ if (step.cast(std.Build.Step.InstallFile)) |install| {
+ if (install.dir == .bin) program = install.dest_rel_path;
+ }
+ if (program) |name| {
+ if (std.mem.indexOfScalar(u8, name, '/') != null) std.debug.panic("program {s} is installed below bin/", .{name});
+ names.append(b.allocator, name) catch @panic("out of memory");
+ }
+ for (step.dependencies.items) |dep| collectPrograms(b, dep, names, seen);
+}
diff --git a/docs/agent-notes/dock.md b/docs/agent-notes/dock.md
index 621b483..1a509fc 100644
--- a/docs/agent-notes/dock.md
+++ b/docs/agent-notes/dock.md
@@ -41,7 +41,9 @@ taskbar, OSD and input integration. General rules remain in
* **The dock reserves space only when it doesn't auto-hide.** `Output.usableBox`
is `dockAreaBox` (output less the taskbar) less `Dock.reservedStrip`, a pure
function of config and that box (`Dock.fits`), so it never flips with a lock
- or fullscreen window. The dock and the taskbar's popups/menus are placed in
+ or fullscreen window. The dock is flush with its edge of `dockAreaBox` and
+ reserves exactly its thickness, with no extra gap before windows. The dock
+ and the taskbar's popups/menus are placed in
`dockAreaBox`, never `usableBox`. A setting that changes the strip calls
`applyTaskbarPosition` (`Dock.reserves` before/after). The OSD keeps clear
of `Dock.footprint` (the resting dock, auto-hiding or not) on the bottom
diff --git a/docs/agent-notes/rendering.md b/docs/agent-notes/rendering.md
index b3fa779..a15c1d2 100644
--- a/docs/agent-notes/rendering.md
+++ b/docs/agent-notes/rendering.md
@@ -13,7 +13,9 @@ chrome, capture, or retained panel painting. General rules remain in
colour (× window opacity); the pass composites the ring over the body, so
something must be drawn under every ring pixel: the titlebar `ChromeBuffer`
(a plain band) on top and the three `frame_fills` rects beside and below the
- client. The footer is `frame_border`. `shadow_tree`, the resize-grab tree and
+ client. `chrome.frameBorder()` resolves `window_border_width` for the ring,
+ client offsets, side fills, footer and resize/layout geometry. Corner rasters
+ and titlebar memos include it for live reloads. `shadow_tree`, the resize-grab tree and
every xdg popup carry `setTreeUnclipped` (a new node that hangs outside the
window needs it too). The shadow is analytic (`setTreeShadow` on
`shadow_tree`, the CPU formula's smoothstep); its leaf `shadow_node` has no
@@ -82,10 +84,17 @@ chrome, capture, or retained panel painting. General rules remain in
outline, so `chrome_plate.mask` keeps the last one: a resize or a title
change reads it and works out no distance.
`Toplevel.shapePolygon` keeps the parsed outline and the last frame's
- polygon: every client commit asks for it several times.
+ polygon: every client commit asks for it several times. `resolveFitting`
+ rejects fixed cuts that overtake their opposite anchors on small frames,
+ before clamping can turn a raised step backwards; the clip, plate, shadow
+ and corner accents then share the rounded-rectangle fallback.
`chrome_control_right_pad` and `chrome_control_offset_y` move the shared
control rectangles, including painting and input. `controlInsets` measures
the polygon at the shifted control rows while leaving the icon centred.
+ `chrome_button_bevel` cuts the moving control highlight and is part of the
+ titlebar memo. `start_menu_bevel` uses the shared beveled widget raster for
+ both Start panels; their blur rounds inside the cut, and a beveled footer
+ draws only its separator so it cannot leave square edges outside the panel.
* **Buffer size ≠ scene size** at fractional scale (`round(len*s)` vs
`round((off+len)*s)-round(off*s)`). Chrome/panel buffers filter bilinearly:
never re-raster per device-grid phase (`ChromeBuffer.create` costs 2–8 ms).
diff --git a/docs/wiki/Home.md b/docs/wiki/Home.md
index 62d29fc..5d3bddf 100644
--- a/docs/wiki/Home.md
+++ b/docs/wiki/Home.md
@@ -32,6 +32,7 @@ no waybar/greeter/launcher/notification daemon to wire up.
| `rediwm-desktop` | desktop icons and wallpaper |
| `rediwm-share-picker` | screen sharing picker |
| `rediwm-accounts-helper` | root helper for account management, runs under `pkexec` |
+| `rediwm-keys` | unprivileged helper that reads `~/.ssh` for Settings → Keys & Certificates |
## Other docs in the repo
diff --git a/scripts/AGENTS.md b/scripts/AGENTS.md
index 4e6fe78..0b2956d 100644
--- a/scripts/AGENTS.md
+++ b/scripts/AGENTS.md
@@ -34,3 +34,8 @@
only; other CPUs build from source.
* Checksums come from the same GitHub release as the tarballs, so they catch
corruption, not a compromised release. Signing is not done yet.
+* **Programs to install come from the build's `programs` list**
+ (`build/install_paths.zig`: every exe or file the install step puts in
+ `bin/`), beside `install-prefix`. The install, deb and verify scripts read
+ it; never hand-list programs or glob `bin/` (zig build leaves retired ones
+ there). A new helper needs only its install step in `build/`.
diff --git a/scripts/install-session-root.sh b/scripts/install-session-root.sh
index 541d6da..3ec8604 100755
--- a/scripts/install-session-root.sh
+++ b/scripts/install-session-root.sh
@@ -26,7 +26,14 @@ umask 022
install -d "${bindir}"
stage=$(mktemp -d "${bindir}/.rediwm-install.XXXXXX")
trap 'rm -rf -- "$stage"' EXIT HUP INT TERM
-for binary in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-files-terminal rediwm-transfers rediwm-images rediwm-monitor rediwm-calculator rediwm-editor rediwm-pdf rediwm-player rediwm-share-picker rediwm-session rediwm-dm rediwm-accounts-helper rediwm-restart; do
+# Every program the build installed, from its own list (build/install_paths.zig),
+# never a glob of bin/: zig build leaves retired programs behind there.
+programs=$(cat "$release_dir/programs")
+for binary in $programs; do
+ case "$binary" in
+ rediwm|rediwm-*) case "$binary" in *[!a-z0-9-]*) echo "Invalid program name: $binary" >&2; exit 1 ;; esac ;;
+ *) echo "Invalid program name: $binary" >&2; exit 1 ;;
+ esac
install -m755 "$release_dir/bin/$binary" "$stage/$binary"
done
install -Dm644 "$release_dir/share/applications/rediwm-theme.desktop" "${datadir}/applications/rediwm-theme.desktop"
@@ -94,7 +101,7 @@ for pack in "$release_dir"/share/rediwm/themes/*/; do
rm -rf "${datadir}/rediwm/themes/$name"
mv -T "${datadir}/rediwm/themes/.$name-new" "${datadir}/rediwm/themes/$name"
done
-for binary in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-files-terminal rediwm-transfers rediwm-images rediwm-monitor rediwm-calculator rediwm-editor rediwm-pdf rediwm-player rediwm-share-picker rediwm-session rediwm-dm rediwm-accounts-helper rediwm-restart; do
+for binary in $programs; do
mv -fT "$stage/$binary" "${bindir}/$binary"
done
# The compositor draws the desktop itself; the old client is retired.
diff --git a/scripts/install-session.sh b/scripts/install-session.sh
index a3a1a70..3bb1479 100644
--- a/scripts/install-session.sh
+++ b/scripts/install-session.sh
@@ -62,8 +62,15 @@ if [ "${built_prefix%/}" != "${prefix%/}" ]; then
echo "Build targets $built_prefix, not $prefix. Rebuild with --prefix=$prefix (prebuilt releases cannot be relocated)." >&2
exit 1
fi
-for binary in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-images rediwm-monitor rediwm-editor rediwm-pdf rediwm-player rediwm-share-picker rediwm-dm rediwm-accounts-helper rediwm-restart; do
- test -x "$release_dir/bin/$binary"
+# The build lists the programs it installed (build/install_paths.zig); a stale
+# file left in bin/ by an older build is not on it.
+if [ ! -f "$release_dir/programs" ]; then
+ echo "$release_dir has no program list. Rebuild it with this checkout." >&2
+ exit 1
+fi
+grep -qx rediwm "$release_dir/programs" || { echo "$release_dir/programs does not list rediwm" >&2; exit 1; }
+for binary in $(cat "$release_dir/programs"); do
+ test -x "$release_dir/bin/$binary" || { echo "$release_dir/bin/$binary is missing" >&2; exit 1; }
done
as_root sh "$repo_dir/scripts/install-session-root.sh" "$repo_dir" "$release_dir" "$dm_flag"
if [ "$restart" = no ]; then
diff --git a/scripts/make-deb.sh b/scripts/make-deb.sh
index 13792c1..a24b636 100644
--- a/scripts/make-deb.sh
+++ b/scripts/make-deb.sh
@@ -13,10 +13,12 @@ rel="$repo/zig-out/release-safe"
out=${1:-$repo/zig-out}
version=$(grep -o '\.version = "[^"]*"' "$repo/build.zig.zon" | cut -d'"' -f2)
arch=$(dpkg --print-architecture)
-bins="rediwm rediwm-msg rediwm-theme rediwm-files rediwm-files-terminal rediwm-transfers rediwm-images rediwm-monitor rediwm-calculator rediwm-editor rediwm-pdf rediwm-player rediwm-share-picker rediwm-session rediwm-dm rediwm-accounts-helper rediwm-restart"
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
[ -x "$rel/bin/rediwm" ] || die "$rel is missing: build ReleaseSafe first"
+# The programs the build installed (build/install_paths.zig), not a glob of bin/.
+[ -f "$rel/programs" ] || die "$rel has no program list: rebuild it with this checkout"
+bins=$(cat "$rel/programs")
command -v dpkg-deb >/dev/null || die "dpkg-deb is required"
root=$(mktemp -d)
diff --git a/scripts/release-verify.sh b/scripts/release-verify.sh
index bf58594..17d4da6 100644
--- a/scripts/release-verify.sh
+++ b/scripts/release-verify.sh
@@ -52,7 +52,9 @@ log "Checking the installed files"
for bin in /usr/local/bin/rediwm /usr/local/bin/rediwm-*; do
readelf -d "$bin" 2>/dev/null | grep -E 'RUNPATH|RPATH' | grep -q "/work/" && die "$bin carries a build path in its RUNPATH"
done
-for bin in rediwm rediwm-msg rediwm-theme rediwm-files rediwm-files-terminal rediwm-transfers rediwm-images rediwm-monitor rediwm-calculator rediwm-editor rediwm-pdf rediwm-player rediwm-share-picker rediwm-session rediwm-dm rediwm-accounts-helper; do
+# Every program the release's build listed (build/install_paths.zig).
+programs=$(tar -xzOf "$rel/rediwm-$family-x86_64.tar.gz" rediwm/zig-out/release-safe/programs) || die "the release has no program list"
+for bin in $programs; do
[ -x "/usr/local/bin/$bin" ] || die "/usr/local/bin/$bin is missing"
ldd "/usr/local/bin/$bin" 2>&1 | grep -q 'not found' && die "$bin has unresolved libraries"
done
diff --git a/src/Dock.zig b/src/Dock.zig
index c8f3c69..3f91d15 100644
--- a/src/Dock.zig
+++ b/src/Dock.zig
@@ -26,10 +26,6 @@ pub const max_pins = 16;
/// `trash` follows `dock_show_trash`; the others `dock_hidden_shortcuts`.
pub const Shortcut = enum { applications, files, terminal, settings, trash };
pub const shortcut_count = std.enums.values(Shortcut).len;
-/// The gap between the dock and its output edge, and the one between it and the
-/// windows when it reserves its strip.
-pub const edge_margin = 5;
-pub const window_margin = 10;
/// Auto-hide: the outermost pixels of the edge that reveal the dock, how long
/// the pointer must stay (so a pass over the edge shows nothing) or stay away
/// (so a slip off the dock hides nothing), and how far the dock travels while
diff --git a/src/auto_tiling.zig b/src/auto_tiling.zig
index 9c4c84e..21eaf89 100644
--- a/src/auto_tiling.zig
+++ b/src/auto_tiling.zig
@@ -38,7 +38,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").frame_border else @as(i32, 0),
+ .vertical = top.titlebarHeight() + if (top.hasServerDecorations()) @import("chrome.zig").frameBorder() 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/chrome.zig b/src/chrome.zig
index 61f3c72..7904d59 100644
--- a/src/chrome.zig
+++ b/src/chrome.zig
@@ -16,7 +16,7 @@ const plate = @import("chrome_plate.zig");
// App dialogs use these same decoration metrics and control hit targets.
const window_chrome = @import("ui").window_chrome;
-pub const frame_border = window_chrome.frame_border;
+pub const frameBorder = window_chrome.frameBorder;
pub const Metrics = window_chrome.Metrics;
pub const frameRadius = window_chrome.frameRadius;
@@ -129,6 +129,7 @@ pub const TitlebarMemo = struct {
icon: ?icon_service.Entry,
glass: [4]f32,
border: [4]f32,
+ border_width: i32 = 1,
border_soft: [4]f32,
fg: [4]f32,
dim: [4]f32,
@@ -143,6 +144,7 @@ pub const TitlebarMemo = struct {
chrome_control_right_pad: f32 = 12,
chrome_control_offset_y: f32 = 0,
chrome_round_buttons: bool = false,
+ chrome_button_bevel: f32 = 0,
top_band: [4]f32 = @splat(0),
top_band_height: f32 = 0,
title_plate: [4]f32 = @splat(0),
@@ -172,6 +174,7 @@ pub const TitlebarMemo = struct {
.icon = state.icon,
.glass = t.window_bg,
.border = t.window_border,
+ .border_width = frameBorder(),
.border_soft = t.window_divider,
.fg = t.window_fg,
.dim = t.window_dim,
@@ -186,6 +189,7 @@ pub const TitlebarMemo = struct {
.chrome_control_right_pad = t.chrome_control_right_pad,
.chrome_control_offset_y = t.chrome_control_offset_y,
.chrome_round_buttons = t.chrome_round_buttons,
+ .chrome_button_bevel = t.chrome_button_bevel,
.top_band = t.window_top_band,
.top_band_height = t.window_top_band_height,
.title_plate = t.window_title_plate,
@@ -220,6 +224,8 @@ pub const TitlebarMemo = struct {
pub fn eql(a: TitlebarMemo, b: TitlebarMemo) bool {
if (a.font_generation != b.font_generation) return false;
if (a.width != b.width) return false;
+ if (a.border_width != b.border_width) return false;
+ if (a.chrome_button_bevel != b.chrome_button_bevel) 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;
@@ -406,7 +412,7 @@ pub const ChromeBuffer = struct {
const m: Metrics = .{ .density = state.density };
const title_left: i32 = state.inset_left + if (state.icon != null) m.length(title_inset) + m.iconSize() + m.length(title_icon_gap) else m.length(title_inset);
const controls_left = @min(controlRectScaled(state.controlsWidth(logical_width), .minimize, state.density).x, plate.titleRight(logical_width, state) orelse std.math.maxInt(i32));
- return .{ .x = title_left, .y = 0, .w = @max(0, controls_left - title_left), .h = m.titlebarHeight() - frame_border };
+ return .{ .x = title_left, .y = 0, .w = @max(0, controls_left - title_left), .h = m.titlebarHeight() - frameBorder() };
}
/// Logical width the current title can ink, measured from the title
diff --git a/src/chrome_paint.zig b/src/chrome_paint.zig
index 28eef0d..b5e384f 100644
--- a/src/chrome_paint.zig
+++ b/src/chrome_paint.zig
@@ -152,6 +152,7 @@ pub const Controls = struct {
chip_width: f32 = 0,
chip_height: f32 = 0,
chip_radius: f32 = 0,
+ chip_bevel: f32 = 0,
chip_fill: Color = undefined,
chip_alpha: f32 = 0,
min_ink: Color,
@@ -199,6 +200,7 @@ pub const Controls = struct {
controls.chip_x = mix(@floatFromInt(a_btn.x), @floatFromInt(b_btn.x), t);
controls.chip_y = mix(@floatFromInt(a_btn.y), @floatFromInt(b_btn.y), t);
controls.chip_radius = window_chrome.cornerRadius(theme.global.chrome_round_buttons, controls.chip_width, controls.chip_height, btn_radius * density);
+ controls.chip_bevel = theme.global.chrome_button_bevel * density;
controls.chip_fill = Color.lerp(Color.control_hover(), Color.close_hover(), clamp01(pos - 1));
controls.chip_alpha = clamp01(chip_alpha);
}
@@ -212,7 +214,11 @@ pub const Controls = struct {
pub fn paint(c: *const Controls, base: Color, px: f32, py: f32) Color {
var color = base;
if (c.show_chip) {
- const chip = edgeCoverage(sdRoundedBox(px, py, c.chip_x, c.chip_y, c.chip_width, c.chip_height, c.chip_radius), c.scale);
+ const distance = if (c.chip_bevel > 0)
+ sdf.sdBeveledBox(px, py, c.chip_x, c.chip_y, c.chip_width, c.chip_height, c.chip_bevel)
+ else
+ sdRoundedBox(px, py, c.chip_x, c.chip_y, c.chip_width, c.chip_height, c.chip_radius);
+ const chip = edgeCoverage(distance, c.scale);
if (chip > 0) color = c.chip_fill.scaled(chip * c.chip_alpha).over(color);
}
const g = c.glyph_scale;
diff --git a/src/chrome_tests.zig b/src/chrome_tests.zig
index cbd0a0c..c7abc0b 100644
--- a/src/chrome_tests.zig
+++ b/src/chrome_tests.zig
@@ -116,6 +116,10 @@ test "chrome geometry changes invalidate retained titlebar pixels" {
const saved = theme.global;
defer theme.global = saved;
const before = TitlebarMemo.capture(400, null, .{});
+ theme.global.window_border_width = 2;
+ try std.testing.expectEqual(@as(i32, 2), chrome_mod.frameBorder());
+ try std.testing.expect(!before.reusableFor(TitlebarMemo.capture(400, null, .{})));
+ theme.global = saved;
theme.global.chrome_control_gap += 1;
const spaced = TitlebarMemo.capture(400, null, .{});
try std.testing.expect(!before.eql(spaced));
@@ -135,6 +139,9 @@ test "chrome geometry changes invalidate retained titlebar pixels" {
theme.global = saved;
theme.global.chrome_control_offset_y = 5;
try std.testing.expect(!before.reusableFor(TitlebarMemo.capture(400, null, .{})));
+ theme.global = saved;
+ theme.global.chrome_button_bevel = 7;
+ try std.testing.expect(!before.reusableFor(TitlebarMemo.capture(400, null, .{})));
inline for (.{ "window_title_plate_inset", "window_title_plate_bevel", "window_title_plate_slant", "window_title_plate_control_gap", "window_title_plate_text_padding" }) |field| {
theme.global = saved;
@field(theme.global, field) += 0.1;
diff --git a/src/dock/items.zig b/src/dock/items.zig
index 5a13737..2803f4c 100644
--- a/src/dock/items.zig
+++ b/src/dock/items.zig
@@ -13,7 +13,6 @@ const Self = @import("../Dock.zig");
const max_pins = Self.max_pins;
const Shortcut = Self.Shortcut;
const shortcut_count = Self.shortcut_count;
-const edge_margin = Self.edge_margin;
const Metrics = Self.Metrics;
const clicked = Self.clicked;
@@ -119,15 +118,15 @@ pub fn openWindowPicker(self: *Self, index: usize) bool {
return output.server.input.window_menu.node != null;
}
-/// Where the dock rests in `area`: centred along its edge, `edge_margin` in.
+/// Where the dock rests in `area`: centred along and flush with its edge.
pub fn place(self: *Self, area: wlr.Box) void {
self.box.x = area.x + @divTrunc(area.width - self.box.width, 2);
self.box.y = area.y + @divTrunc(area.height - self.box.height, 2);
switch (self.position) {
- .top => self.box.y = area.y + edge_margin,
- .bottom => self.box.y = area.y + area.height - self.box.height - edge_margin,
- .left => self.box.x = area.x + edge_margin,
- .right => self.box.x = area.x + area.width - self.box.width - edge_margin,
+ .top => self.box.y = area.y,
+ .bottom => self.box.y = area.y + area.height - self.box.height,
+ .left => self.box.x = area.x,
+ .right => self.box.x = area.x + area.width - self.box.width,
}
}
diff --git a/src/dock/reveal.zig b/src/dock/reveal.zig
index 9929f28..8a4b66b 100644
--- a/src/dock/reveal.zig
+++ b/src/dock/reveal.zig
@@ -11,8 +11,8 @@ const anim = ui.anim;
const Self = @import("../Dock.zig");
const max_pins = Self.max_pins;
const Shortcut = Self.Shortcut;
-const edge_margin = Self.edge_margin;
-const window_margin = Self.window_margin;
+/// Pointer tolerance around a shown auto-hiding dock, independent of layout.
+const pointer_margin = 5;
const edge_band = Self.edge_band;
const reveal_delay_ms = Self.reveal_delay_ms;
const hide_delay_ms = Self.hide_delay_ms;
@@ -20,23 +20,22 @@ const slide_distance = Self.slide_distance;
const Metrics = Self.Metrics;
const shownIn = Self.shownIn;
-/// What a dock reserves along `area`'s edge for windows: its thickness and the
-/// gap on either side. Nothing when it floats over them (auto-hide), is off, or
+/// What a dock reserves along `area`'s edge for windows: exactly its thickness.
+/// Nothing when it floats over them (auto-hide), is off, or
/// does not fit and so shows nothing.
pub fn reservedStrip(server: *const Server, area: wlr.Box) i32 {
if (!reserves(&server.config.compositor)) return 0;
- const reach = footprint(server, area);
- return if (reach == 0) 0 else reach + window_margin;
+ return footprint(server, area);
}
-/// How far a resting dock reaches in from its edge of `area`: its thickness and
-/// the gap to the edge, whether it reserves that strip or auto-hides. Read from
+/// How far a resting dock reaches in from its edge of `area`: its thickness,
+/// whether it reserves that strip or auto-hides. Read from
/// the configuration alone, like `reservedStrip`, so what keeps clear of it (the
/// OSD) stays put while an auto-hiding dock comes and goes.
pub fn footprint(server: *const Server, area: wlr.Box) i32 {
const c = &server.config.compositor;
if (server.greeter_mode or !c.dock_enabled or !fits(c, area)) return 0;
- return @as(i32, @intCast(c.dock_height)) + edge_margin;
+ return @intCast(c.dock_height);
}
/// Whether the dock, as configured, keeps windows out of its strip. A change
@@ -112,7 +111,7 @@ pub fn menuOpen(self: *const Self) bool {
}
/// Whether the pointer at layout position `x`, `y` wants the dock: it is at the
-/// output edge the dock is on, or on the dock (and the gap beside it) once shown.
+/// output edge the dock is on, or on or just beside the dock once shown.
pub fn nearPointer(self: *const Self, output: *Output, x: f64, y: f64) bool {
const c = &output.server.config.compositor;
if (!c.dock_auto_hide or !self.visible) return false;
@@ -129,8 +128,8 @@ pub fn nearPointer(self: *const Self, output: *Output, x: f64, y: f64) bool {
if (at_edge) return true;
// Only a dock that is out can be pointed at: where it would be is windows.
if (!self.shown) return false;
- return (px >= self.box.x - edge_margin and px < self.box.x + self.box.width + edge_margin and
- py >= self.box.y - edge_margin and py < self.box.y + self.box.height + edge_margin) or
+ return (px >= self.box.x - pointer_margin and px < self.box.x + self.box.width + pointer_margin and
+ py >= self.box.y - pointer_margin and py < self.box.y + self.box.height + pointer_margin) or
self.buttonAt(@floatCast(x - @as(f64, @floatFromInt(self.box.x))), @floatCast(y - @as(f64, @floatFromInt(self.box.y)))) != null;
}
diff --git a/src/input/buttons.zig b/src/input/buttons.zig
index 17999fa..639bf1c 100644
--- a/src/input/buttons.zig
+++ b/src/input/buttons.zig
@@ -379,7 +379,7 @@ pub 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;
- 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| {
+ if (resize.detectResizeEdges(local.x, local.y, res.toplevel.chrome_width, res.toplevel.chrome_height, res.toplevel.titlebarHeight(), chrome.frameBorder(), chrome.frameBorder(), has_control)) |edges| {
input.startResize(res.toplevel, edges.toWlr(), device, button);
return;
}
diff --git a/src/input/motion.zig b/src/input/motion.zig
index b64b7dd..3816745 100644
--- a/src/input/motion.zig
+++ b/src/input/motion.zig
@@ -427,7 +427,7 @@ pub 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);
- if (resize.detectResizeEdges(local.x, local.y, toplevel.chrome_width, toplevel.chrome_height, toplevel.titlebarHeight(), chrome.frame_border, chrome.frame_border, has_control)) |edges| {
+ if (resize.detectResizeEdges(local.x, local.y, toplevel.chrome_width, toplevel.chrome_height, toplevel.titlebarHeight(), chrome.frameBorder(), chrome.frameBorder(), has_control)) |edges| {
input.hovered_resize_edges = edges;
input.setHover(toplevel, null);
input.setNamedCursor(edges.cursorName());
diff --git a/src/ipc/handlers_state.zig b/src/ipc/handlers_state.zig
index ea4c009..cd46f6a 100644
--- a/src/ipc/handlers_state.zig
+++ b/src/ipc/handlers_state.zig
@@ -68,10 +68,10 @@ pub fn handleStateRequest(
const geometry_box = toplevel.clientGeometry();
const decorated = toplevel.hasServerDecorations();
const radius: f32 = toplevel.cornerRadius();
- const footer = chrome.frame_border;
+ const footer = chrome.frameBorder();
const client_box: protocol.RectData = .{
- .x = toplevel.x + if (decorated) chrome.frame_border else 0,
+ .x = toplevel.x + if (decorated) chrome.frameBorder() else 0,
.y = toplevel.y + toplevel.titlebarHeight(),
.width = geometry_box.width,
.height = geometry_box.height,
@@ -108,7 +108,7 @@ pub fn handleStateRequest(
.chrome_box = chrome_box,
.titlebar_height = toplevel.titlebarHeight(),
.footer_height = if (decorated) footer else 0,
- .frame_border = if (decorated) chrome.frame_border else 0,
+ .frame_border = if (decorated) chrome.frameBorder() else 0,
.frame_radius = if (decorated) radius else 0,
.decoration_mode = if (decorated) "server" else "client",
.minimized = toplevel.minimized,
diff --git a/src/power_menu.zig b/src/power_menu.zig
index 287f5dc..7f0458d 100644
--- a/src/power_menu.zig
+++ b/src/power_menu.zig
@@ -432,7 +432,7 @@ pub const PowerMenu = struct {
const focused = menu.keyboard_focus == i;
const highlighted = focused or card.kind.row.state == .hover or card.kind.row.state == .press;
if (highlighted) target = i;
- const color = if (highlighted) theme.global.danger else theme.global.fg;
+ const color = if (highlighted) theme.shellPalette().accent else theme.global.fg;
if (card.kind.row.selected != focused or !std.meta.eql(menu.tile_pairs[i][0].kind.icon.color, color)) {
card.kind.row.selected = focused;
menu.tile_pairs[i][0].kind.icon.color = color;
@@ -468,7 +468,7 @@ pub const PowerMenu = struct {
const a = &menu.cards[menu.selected orelse index];
const b = &menu.cards[menu.selected orelse @min(index + 1, tiles.len - 1)];
const fraction = slot - @as(f32, @floatFromInt(index));
- var border = theme.global.danger;
+ var border = theme.shellPalette().accent;
border[3] *= alpha;
const pressed = if (menu.highlight_target) |id| menu.cards[id].kind.row.state == .press else false;
renderer.fillRect(
diff --git a/src/start_menu/menu_present.zig b/src/start_menu/menu_present.zig
index 7faf298..daa88f9 100644
--- a/src/start_menu/menu_present.zig
+++ b/src/start_menu/menu_present.zig
@@ -209,6 +209,8 @@ pub fn applyPresentation(menu: *StartMenu, now_ms: i64) void {
if (menu.panel_box.width <= 0 or menu.panel_box.height <= 0) return;
const t = menu.slide.value(now_ms);
panel_present.applySlide(menu.buffer_node, menu.panel_box, t, if (menu.server.config.compositor.taskbar_position == .top) -slide_distance else slide_distance);
- glass.Effect.configure(menu.glass_effect, theme.global.start_menu_radius, t);
+ // Keep the rounded blur inside a straight corner cut, as on the dock.
+ const radius = @max(theme.global.start_menu_radius, theme.global.start_menu_bevel * 1.71);
+ glass.Effect.configure(menu.glass_effect, radius, t);
if (menu.state == .opening and (menu.slide.settled(now_ms) or panel_present.slideOffset(t, slide_distance) == 0)) menu.state = .open;
}
diff --git a/src/start_menu/menu_tree.zig b/src/start_menu/menu_tree.zig
index 43c3c00..c57f7b4 100644
--- a/src/start_menu/menu_tree.zig
+++ b/src/start_menu/menu_tree.zig
@@ -364,9 +364,10 @@ pub fn buildTree(menu: *StartMenu) void {
footer_widget.* = .{
.kind = .{ .rect = .{
.color = .{ 0, 0, 0, 0 },
- .border_width = 1,
+ .border_width = if (t.start_menu_bevel > 0) 0 else 1,
.border_color = t.border_soft,
} },
+ .underlay = if (t.start_menu_bevel > 0) .{ .owner = null, .paint = paintFooterDivider } else null,
.direction = .row,
.@"align" = .center,
.justify = .space_between,
@@ -416,6 +417,7 @@ pub fn buildTree(menu: *StartMenu) void {
.kind = .{ .rect = .{
.color = t.start_menu_bg,
.radius = t.start_menu_radius,
+ .bevel = t.start_menu_bevel,
.border_width = 1,
.border_color = t.start_menu_border,
} },
@@ -437,3 +439,8 @@ pub fn buildTree(menu: *StartMenu) void {
ui.arrange.arrange(&menu.root, 0, 0, width, height);
}
}
+
+// The panel owns its beveled outer border; the footer needs only a separator.
+fn paintFooterDivider(_: ?*anyopaque, widget: *const Widget, renderer: *ui.paint.Renderer) void {
+ renderer.fillRect(widget.computed_x, widget.computed_y, widget.computed_width, 1, .{ .color = (renderer.palette orelse theme.global).border_soft });
+}
diff --git a/src/toplevel/chrome_metrics.zig b/src/toplevel/chrome_metrics.zig
index 1073f87..ce09fbe 100644
--- a/src/toplevel/chrome_metrics.zig
+++ b/src/toplevel/chrome_metrics.zig
@@ -42,7 +42,7 @@ pub fn titlebarHeight(toplevel: *const Toplevel) i32 {
}
pub fn borderWidth(toplevel: *const Toplevel) i32 {
- return if (toplevel.hasServerDecorations()) chrome.frame_border else 0;
+ return if (toplevel.hasServerDecorations()) chrome.frameBorder() else 0;
}
pub fn hasWorkspaceFocusBorder(toplevel: *const Toplevel) bool {
@@ -55,7 +55,7 @@ pub fn borderColor(toplevel: *const Toplevel) col.Premul {
pub fn footerHeight(toplevel: *const Toplevel) i32 {
if (!toplevel.hasServerDecorations()) return 0;
- return chrome.frame_border;
+ return chrome.frameBorder();
}
pub fn frameLocal(toplevel: *const Toplevel, lx: f64, ly: f64) geometry.Vec2 {
diff --git a/src/toplevel/chrome_sync.zig b/src/toplevel/chrome_sync.zig
index 74c1fc5..fbffcac 100644
--- a/src/toplevel/chrome_sync.zig
+++ b/src/toplevel/chrome_sync.zig
@@ -25,7 +25,10 @@ const nowMs = Toplevel.nowMs;
/// border/titlebar colors already do.
pub fn refreshTheme(toplevel: *Toplevel) void {
defer @import("../auto_tiling.zig").observe(toplevel);
- const height_changed = if (toplevel.last_titlebar) |memo| memo.chrome_height != theme.global.chrome_height else false;
+ const geometry_changed = if (toplevel.last_titlebar) |memo|
+ memo.chrome_height != theme.global.chrome_height or memo.border_width != chrome.frameBorder()
+ else
+ false;
switch (toplevel.backend) {
.placeholder => |*ph| col.setRect(ph.body_rect, col.Straight.fromRgba(theme.global.window_bg).premultiply()),
.shell => |*sw| if (sw.control_center) |cc| cc.requestRepaint(),
@@ -34,8 +37,8 @@ pub fn refreshTheme(toplevel: *Toplevel) void {
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.
- if (height_changed and toplevel.in_world) {
+ // Changed decoration extents must keep tiled frames inside their tile.
+ if (geometry_changed and toplevel.in_world) {
if (toplevel.tile) |tile| {
if (toplevel.currentOutput()) |out| toplevel.setTiledOn(out, tile);
}
@@ -134,8 +137,8 @@ pub fn syncChrome(toplevel: *Toplevel, rebuild_shadow: bool, now_ms: i64) !void
}
const radius: f32 = toplevel.cornerRadius();
- const natural_w = geometry_box.width + 2 * chrome.frame_border;
- const natural_h = geometry_box.height + toplevel.titlebarHeight() + chrome.frame_border;
+ const natural_w = geometry_box.width + 2 * chrome.frameBorder();
+ const natural_h = geometry_box.height + toplevel.titlebarHeight() + chrome.frameBorder();
const animated = visualChromeSize(toplevel, now_ms, natural_w, natural_h);
const width = animated.w;
const height = animated.h;
@@ -199,7 +202,7 @@ pub fn syncChrome(toplevel: *Toplevel, rebuild_shadow: bool, now_ms: i64) !void
if (rebuild_shadow) try toplevel.syncShadow(width, height, radius);
// wlr_scene_xdg_surface_create origin is the geometry top-left.
- toplevel.content_tree.node.setPosition(chrome.frame_border, toplevel.titlebarHeight());
+ toplevel.content_tree.node.setPosition(chrome.frameBorder(), toplevel.titlebarHeight());
switch (toplevel.backend) {
.placeholder => |*ph| ph.body_rect.setSize(geometry_box.width, geometry_box.height),
else => {},
@@ -343,7 +346,7 @@ pub fn applyShape(toplevel: *Toplevel) void {
.width = toplevel.chrome_width,
.height = toplevel.chrome_height,
.radii = .{ radius, radius, radius, radius },
- .border = @floatFromInt(chrome.frame_border),
+ .border = @floatFromInt(chrome.frameBorder()),
.border_color = ring.rgba,
};
if (toplevel.shapePolygon(toplevel.chrome_width, toplevel.chrome_height)) |polygon| {
@@ -372,7 +375,7 @@ pub fn syncBorders(toplevel: *Toplevel, width: i32, height: i32) void {
// 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;
+ const edge = chrome.frameBorder();
toplevel.border_rects[0].node.setPosition(-edge, -edge);
toplevel.border_rects[0].setSize(width + 2 * edge, edge);
toplevel.border_rects[1].node.setPosition(-edge, 0);
@@ -387,7 +390,7 @@ pub fn syncBorders(toplevel: *Toplevel, width: i32, height: i32) void {
// 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 edge = chrome.frame_border;
+ const edge = chrome.frameBorder();
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);
diff --git a/src/toplevel/configure.zig b/src/toplevel/configure.zig
index bb6f5c4..2ce65d8 100644
--- a/src/toplevel/configure.zig
+++ b/src/toplevel/configure.zig
@@ -124,8 +124,7 @@ pub fn shapePolygon(toplevel: *const Toplevel, width: i32, height: i32) ?window_
const cache = &shape_cache;
if (text.len > cache.text.len) {
const outline = (window_shape.parse(text) catch return null) orelse return null;
- const resolved = window_shape.resolve(outline, @floatFromInt(width), @floatFromInt(height), density);
- return if (window_shape.usable(resolved)) resolved else null;
+ return window_shape.resolveFitting(outline, @floatFromInt(width), @floatFromInt(height), density);
}
if (!cache.parsed or !std.mem.eql(u8, cache.text[0..cache.len], text)) {
cache.outline = window_shape.parse(text) catch null;
@@ -136,8 +135,7 @@ pub fn shapePolygon(toplevel: *const Toplevel, width: i32, height: i32) ?window_
}
const outline = cache.outline orelse return null;
if (cache.width != width or cache.height != height or cache.density != density) {
- const resolved = window_shape.resolve(outline, @floatFromInt(width), @floatFromInt(height), density);
- cache.resolved = if (window_shape.usable(resolved)) resolved else null;
+ cache.resolved = window_shape.resolveFitting(outline, @floatFromInt(width), @floatFromInt(height), density);
cache.width = width;
cache.height = height;
cache.density = density;
diff --git a/src/toplevel/corner_accents.zig b/src/toplevel/corner_accents.zig
index 5d747e2..6edadda 100644
--- a/src/toplevel/corner_accents.zig
+++ b/src/toplevel/corner_accents.zig
@@ -14,6 +14,7 @@ const Memo = struct {
color: [4]f32,
// Device-independent side of each corner's square, in logical px.
extent: i32,
+ border: i32,
stroke: f32,
inset: f32,
end_padding: f32,
@@ -105,6 +106,7 @@ pub fn syncCornerAccents(t: *Toplevel) !void {
.density = density,
.color = palette.window_corner_accent,
.extent = extent,
+ .border = chrome.frameBorder(),
.stroke = palette.window_corner_width,
.inset = palette.window_corner_inset,
.end_padding = palette.window_corner_end_padding,
@@ -153,7 +155,7 @@ pub fn syncCornerAccents(t: *Toplevel) !void {
/// How far from the outline the stroke's ink can lie, in logical px.
fn reach(memo: Memo) f32 {
- return @as(f32, @floatFromInt(chrome.frame_border)) + (memo.inset + memo.stroke) * memo.density + 1;
+ return @as(f32, @floatFromInt(memo.border)) + (memo.inset + memo.stroke) * memo.density + 1;
}
/// What the corner whose square starts at (`x`, `y`) shows of the outline. A
@@ -167,7 +169,7 @@ fn cornerKey(memo: Memo, polygon: ?ui.window_shape.Resolved, radius: f32, x: i32
fn paint(buffer: *PanelBuffer, memo: Memo, polygon: ?ui.window_shape.Resolved, radius: f32, x: i32, y: i32, width: i32, height: i32) void {
const color: ui.text.Color = .{ .r = memo.color[0], .g = memo.color[1], .b = memo.color[2], .a = memo.color[3] };
const extent: f32 = @floatFromInt(memo.extent);
- const inset = @as(f32, @floatFromInt(chrome.frame_border)) + memo.inset * memo.density;
+ const inset = @as(f32, @floatFromInt(memo.border)) + memo.inset * memo.density;
const stroke = memo.stroke * memo.density;
// The stroke is the band `inset` to `inset + stroke` inside the outline.
// Its ink ends half a device pixel beyond either side.
@@ -196,7 +198,7 @@ fn paint(buffer: *PanelBuffer, memo: Memo, polygon: ?ui.window_shape.Resolved, r
dx += @intFromFloat(clear);
continue;
}
- // Leave the output pass's one-pixel ring untouched. This stroke is
+ // Leave the output pass's frame ring untouched. This stroke is
// just inside it; all pixels still inherit frame opacity and clipping.
const coverage = ui.sdf.coverage((distance + inset) * memo.scale) *
ui.sdf.coverage((-distance - inset - stroke) * memo.scale);
diff --git a/src/toplevel/create.zig b/src/toplevel/create.zig
index 2e3fd2d..819383f 100644
--- a/src/toplevel/create.zig
+++ b/src/toplevel/create.zig
@@ -320,8 +320,8 @@ pub fn createPlaceholder(
toplevel.maximized = true;
if (target_out) |out| {
const usable = out.usableBox();
- const footer = chrome.frame_border;
- const mw = usable.width - 2 * chrome.frame_border;
+ const footer = chrome.frameBorder();
+ const mw = usable.width - 2 * chrome.frameBorder();
const mh = usable.height - toplevel.titlebarHeight() - footer;
toplevel.backend.placeholder.client_width = @max(1, mw);
toplevel.backend.placeholder.client_height = @max(1, mh);
@@ -331,8 +331,8 @@ pub fn createPlaceholder(
toplevel.placed = true;
}
} else if (target_out) |out| {
- const footer = chrome.frame_border;
- const natural_w = init_w + 2 * chrome.frame_border;
+ const footer = chrome.frameBorder();
+ const natural_w = init_w + 2 * chrome.frameBorder();
const natural_h = init_h + toplevel.titlebarHeight() + footer;
const geom = pickInitialPlacement(server, out, open_rules, null, natural_w, natural_h);
toplevel.setPosition(geom.x, geom.y);
diff --git a/src/toplevel/info.zig b/src/toplevel/info.zig
index ede4fff..43d3536 100644
--- a/src/toplevel/info.zig
+++ b/src/toplevel/info.zig
@@ -377,7 +377,7 @@ pub fn chromeAcceptsInput(buffer: *sn.Buffer, sx: *f64, sy: *f64) callconv(.c) b
_ = toplevel.frame_tree.node.coords(&fx, &fy);
const local = geometry.toLocal(@as(f64, @floatFromInt(ox)) + sx.*, @as(f64, @floatFromInt(oy)) + sy.*, fx, fy);
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, chrome.frame_border, has_control) != null) {
+ if (resize.detectResizeEdges(local.x, local.y, toplevel.chrome_width, toplevel.chrome_height, toplevel.titlebarHeight(), chrome.frameBorder(), chrome.frameBorder(), has_control) != null) {
return true;
}
diff --git a/src/toplevel/layout.zig b/src/toplevel/layout.zig
index 35b0fbe..f148071 100644
--- a/src/toplevel/layout.zig
+++ b/src/toplevel/layout.zig
@@ -24,7 +24,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.frame_border else 0;
+ const footer = if (toplevel.hasServerDecorations()) chrome.frameBorder() 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;
@@ -155,7 +155,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.frame_border else 0;
+ const footer = if (toplevel.hasServerDecorations()) chrome.frameBorder() 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;
@@ -186,7 +186,7 @@ pub fn setTiledOn(toplevel: *Toplevel, output: *Output, tile: tiling.Tile) void
/// a window still opening takes its first tile at once.
pub fn setAutoTile(toplevel: *Toplevel, rect: wlr.Box, animate: bool) void {
if (!toplevel.in_world or toplevel.fullscreen or toplevel.maximized) return;
- const footer = if (toplevel.hasServerDecorations()) chrome.frame_border else 0;
+ const footer = if (toplevel.hasServerDecorations()) chrome.frameBorder() else 0;
const target: RestoreGeometry = .{
.x = rect.x,
.y = rect.y,
diff --git a/src/toplevel/motion.zig b/src/toplevel/motion.zig
index 7157944..2d36c01 100644
--- a/src/toplevel/motion.zig
+++ b/src/toplevel/motion.zig
@@ -65,9 +65,9 @@ pub fn animateChromeSize(toplevel: *Toplevel, width: i32, height: i32, wait: Con
pub 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.frame_border;
+ const footer = chrome.frameBorder();
return .{
- .w = client_w + 2 * chrome.frame_border,
+ .w = client_w + 2 * chrome.frameBorder(),
.h = client_h + toplevel.titlebarHeight() + footer,
};
}
diff --git a/src/toplevel/open_close.zig b/src/toplevel/open_close.zig
index 928963d..6242961 100644
--- a/src/toplevel/open_close.zig
+++ b/src/toplevel/open_close.zig
@@ -47,9 +47,9 @@ pub fn applySizeClip(toplevel: *Toplevel) void {
return;
}
const decorated = toplevel.hasServerDecorations();
- const cw = if (decorated) @max(toplevel.chrome_width - 2 * chrome.frame_border, 0) else toplevel.chrome_width;
+ const cw = if (decorated) @max(toplevel.chrome_width - 2 * chrome.frameBorder(), 0) else toplevel.chrome_width;
const ch = if (decorated)
- @max(toplevel.chrome_height - toplevel.titlebarHeight() - chrome.frame_border, 0)
+ @max(toplevel.chrome_height - toplevel.titlebarHeight() - chrome.frameBorder(), 0)
else
toplevel.chrome_height;
const n = toplevel.surfaceScale();
diff --git a/src/toplevel/placement.zig b/src/toplevel/placement.zig
index 7f19a64..e1aba4d 100644
--- a/src/toplevel/placement.zig
+++ b/src/toplevel/placement.zig
@@ -255,7 +255,7 @@ pub fn configureInitialXdgState(toplevel: *Toplevel) void {
toplevel.maximized = true;
if (target_out) |out| {
const usable = out.usableBox();
- const footer = if (toplevel.hasServerDecorations()) chrome.frame_border else 0;
+ const footer = if (toplevel.hasServerDecorations()) chrome.frameBorder() 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));
diff --git a/src/ui/sdf.zig b/src/ui/sdf.zig
index c907c53..018df0f 100644
--- a/src/ui/sdf.zig
+++ b/src/ui/sdf.zig
@@ -50,6 +50,14 @@ pub inline fn sdRoundedBox(px: f32, py: f32, x: f32, y: f32, w: f32, h: f32, rad
return @min(@max(qx, qy), 0) + @sqrt(outside_x * outside_x + outside_y * outside_y) - r;
}
+/// Edge distance for a box with straight 45-degree cuts, as used by widget highlights.
+pub inline fn sdBeveledBox(px: f32, py: f32, x: f32, y: f32, w: f32, h: f32, bevel: f32) f32 {
+ const dx = @abs(px - x - w / 2);
+ const dy = @abs(py - y - h / 2);
+ const cut = @min(@max(0, bevel), @min(w, h) / 2);
+ return @max(@max(dx - w / 2, dy - h / 2), (dx + dy - w / 2 - h / 2 + cut) / std.math.sqrt2);
+}
+
/// Pixel coverage of a point at signed `distance` from an edge: a one-pixel
/// ramp centred on the edge.
pub inline fn coverage(distance: f32) f32 {
diff --git a/src/ui/theme.zig b/src/ui/theme.zig
index b229a74..06867e6 100644
--- a/src/ui/theme.zig
+++ b/src/ui/theme.zig
@@ -40,6 +40,8 @@ pub const Theme = struct {
chrome_control_offset_y: f32 = 0,
/// Circular window controls and pill-shaped tabs, including tab controls.
chrome_round_buttons: bool = false,
+ /// Straight 45-degree cuts on window controls, in reference units; overrides round buttons.
+ chrome_button_bevel: f32 = 0,
/// A polygon outline for server-decorated windows instead of the rounded
/// rectangle (syntax in `window_shape.zig`); empty keeps `radius_lg`.
window_shape: []const u8 = "",
@@ -77,6 +79,8 @@ pub const Theme = struct {
window_dim: [4]f32 = .{ 214.0 / 255.0, 214.0 / 255.0, 214.0 / 255.0, 1 }, // #d6d6d6
window_border: [4]f32 = .{ 1, 1, 1, 0.09 },
window_border_hover: [4]f32 = .{ 1, 1, 1, 0.13 },
+ /// Outer window frame, logical px (1–16, rounded to whole pixels).
+ window_border_width: f32 = 1,
/// Active window outline in opt-in workspace mode (#ed1b2e).
workspace_active_border: [4]f32 = .{ 237.0 / 255.0, 27.0 / 255.0, 46.0 / 255.0, 1 },
window_divider: [4]f32 = .{ 1, 1, 1, 0.045 },
@@ -327,6 +331,8 @@ pub const Theme = struct {
start_menu_width: f32 = 0,
start_menu_max_height: f32 = 0,
start_menu_radius: f32 = 14.0,
+ /// Straight 45-degree panel corners instead of start_menu_radius; zero is rounded.
+ start_menu_bevel: f32 = 0,
start_menu_bg: [4]f32 = .{ 29.0 / 255.0, 34.0 / 255.0, 41.0 / 255.0, 0.98 }, // #1d2229
start_menu_border: [4]f32 = .{ 1, 1, 1, 0.12 },
start_menu_search_bg: [4]f32 = .{ 21.0 / 255.0, 26.0 / 255.0, 31.0 / 255.0, 1 },
diff --git a/src/ui/theme_file.zig b/src/ui/theme_file.zig
index e8c2e89..3e6acb9 100644
--- a/src/ui/theme_file.zig
+++ b/src/ui/theme_file.zig
@@ -165,6 +165,9 @@ pub fn applyKey(allocator: Allocator, t: *Theme, name_in: []const u8, value: []c
if (comptime std.mem.eql(u8, name, "chrome_height")) {
if (number < 28 or number > 84) return error.InvalidSize;
}
+ if (comptime std.mem.eql(u8, name, "window_border_width")) {
+ if (number < 1 or number > 16) return error.InvalidSize;
+ }
if (comptime std.mem.eql(u8, name, "chrome_control_gap")) {
if (number > 24) return error.InvalidSize;
}
diff --git a/src/ui/theme_tests.zig b/src/ui/theme_tests.zig
index 76ed4e4..b5a9531 100644
--- a/src/ui/theme_tests.zig
+++ b/src/ui/theme_tests.zig
@@ -73,6 +73,7 @@ test "writeInto then parse round-trips every field" {
t.font_size = 14;
t.radius_md = 9;
t.radius_lg = 12;
+ t.window_border_width = 2;
t.glass = .{ 0.2, 0.4, 0.6, 0.56 };
t.taskbar_bg = .{ 0.1, 0.2, 0.3, 0.62 };
t.start_button_icon = "/tmp/custom logo.svg";
@@ -263,6 +264,10 @@ test "chrome geometry validates and survives theme serialization" {
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
defer arena.deinit();
const a = arena.allocator();
+ for ([_][]const u8{ "0", "17", "nan", "inf" }) |value| {
+ var t: Theme = .{};
+ try std.testing.expectError(error.InvalidSize, applyKey(a, &t, "window_border_width", value));
+ }
for ([_][]const u8{ "0", "27", "85", "nan", "inf" }) |value| {
var t: Theme = .{};
try std.testing.expectError(error.InvalidSize, applyKey(a, &t, "chrome_height", value));
@@ -276,11 +281,12 @@ test "chrome geometry validates and survives theme serialization" {
try std.testing.expectError(error.InvalidBoolean, applyKey(a, &t, "chrome_round_buttons", value));
}
try std.testing.expect(!(try parse(a, "[theme]\nchrome_round_buttons = false\n")).chrome_round_buttons);
- const t = try parse(a, "[theme]\nchrome_height = 28\nchrome_control_gap = 0\nchrome_round_buttons = true\n");
+ const t = try parse(a, "[theme]\nchrome_height = 28\nchrome_control_gap = 0\nchrome_round_buttons = true\nwindow_border_width = 2\n");
var buf: std.ArrayList(u8) = .empty;
try writeInto(a, &buf, t);
const restored = try parse(a, buf.items);
try std.testing.expectEqual(@as(f32, 28), restored.chrome_height);
+ try std.testing.expectEqual(@as(f32, 2), restored.window_border_width);
try std.testing.expectEqual(@as(f32, 0), restored.chrome_control_gap);
try std.testing.expect(restored.chrome_round_buttons);
}
diff --git a/src/ui/widgets/dialog.zig b/src/ui/widgets/dialog.zig
index 5dec5a1..681384a 100644
--- a/src/ui/widgets/dialog.zig
+++ b/src/ui/widgets/dialog.zig
@@ -89,7 +89,7 @@ pub fn paintTitlebar(r: *Renderer, box: Rect) void {
r.fillRect(box.x, box.y, box.w, box.h, .{
.color = .{ t.window_bg[0], t.window_bg[1], t.window_bg[2], 1 },
.radius = t.radius_lg,
- .border_width = chrome.frame_border,
+ .border_width = 1,
.border_color = t.window_border,
});
r.fillRect(box.x + 1, box.y + height - 1, box.w - 2, 1, .{ .color = t.window_divider });
diff --git a/src/ui/window_chrome.zig b/src/ui/window_chrome.zig
index c156e4b..4a56d5f 100644
--- a/src/ui/window_chrome.zig
+++ b/src/ui/window_chrome.zig
@@ -18,7 +18,9 @@ pub fn cornerRadius(round: bool, width: f32, height: f32, default_radius: f32) f
pub const ControlKind = enum { minimize, maximize, close };
// Charcoal header with evenly spaced, unboxed window controls.
-pub const frame_border: i32 = 1;
+pub fn frameBorder() i32 {
+ return @intFromFloat(@round(std.math.clamp(theme.global.window_border_width, 1, 16)));
+}
const btn_size: i32 = 34;
const close_size: i32 = 34;
// Preserve the original icon/control proportions when changing bar height.
@@ -81,12 +83,12 @@ pub fn controlRect(frame_width: i32, kind: ControlKind) Rect {
pub fn controlRectScaled(frame_width: i32, kind: ControlKind, density: f32) Rect {
const m: Metrics = .{ .density = density };
const right_pad: i32 = @intFromFloat(@round(theme.global.chrome_control_right_pad * m.contentScale()));
- const close_x = frame_width - frame_border - right_pad - m.length(close_size);
+ const close_x = frame_width - frameBorder() - right_pad - m.length(close_size);
const max_x = close_x - m.controlGap() - m.length(btn_size);
const min_x = max_x - m.controlGap() - m.length(btn_size);
const centered_y = @divTrunc(m.titlebarHeight() - m.length(btn_size), 2);
const shift_y: i32 = @intFromFloat(@round(theme.global.chrome_control_offset_y * density));
- const y = std.math.clamp(centered_y + shift_y, 0, @max(0, m.titlebarHeight() - m.length(btn_size) - frame_border));
+ const y = std.math.clamp(centered_y + shift_y, 0, @max(0, m.titlebarHeight() - m.length(btn_size) - frameBorder()));
return switch (kind) {
.close => .{
.x = close_x,
diff --git a/src/ui/window_shape.zig b/src/ui/window_shape.zig
index a18f993..2834620 100644
--- a/src/ui/window_shape.zig
+++ b/src/ui/window_shape.zig
@@ -55,8 +55,8 @@ pub fn parse(text: []const u8) Error!?Outline {
outline.count += 1;
}
if (outline.count < 3) return error.InvalidShape;
- // Checked at a nominal size: the points keep their order and sides, so a
- // sensible outline does not start crossing itself at another one.
+ // Check the theme at a nominal size. Live frames also need resolveFitting:
+ // opposite anchors can overtake each other when a window shrinks.
const nominal = resolve(outline, 800, 600, 1);
if (!simple(nominal)) return error.InvalidShape;
return outline;
@@ -81,6 +81,27 @@ pub fn resolve(outline: Outline, width: f64, height: f64, density: f64) Resolved
return out;
}
+/// Resolve a frame outline only while its fixed cuts fit. Clamping alone can
+/// turn a raised title step back towards a corner without crossing an edge,
+/// leaving a technically simple polygon with a folded-looking rim.
+pub fn resolveFitting(outline: Outline, width: f64, height: f64, density: f64) ?Resolved {
+ for (outline.points[0..outline.count], 0..) |point, i| {
+ const next = outline.points[(i + 1) % outline.count];
+ for ([2]f64{ width, height }, 0..) |length, axis| {
+ const a = point[axis];
+ const b = next[axis];
+ if (!a.percent and a.value * density > length) return null;
+ // An edge joining fixed cuts at opposite ends must not reverse.
+ // Check neighbours, not all anchors: cuts on different rows may
+ // overlap in x without interfering with each other (likewise y).
+ if (!a.percent and !b.percent and a.far != b.far and
+ (@as(f64, a.value) + b.value) * density > length) return null;
+ }
+ }
+ const resolved = resolve(outline, width, height, density);
+ return if (usable(resolved)) resolved else null;
+}
+
/// What the projection takes: at least three points, none the same as the next
/// (an edge needs a direction), no edges crossing (a window too narrow for its
/// outline folds it over itself). False falls back to the rounded rectangle.
@@ -230,84 +251,6 @@ fn cross(a: [2]f64, b: [2]f64, c: [2]f64, d: [2]f64) bool {
return ((o1 > 0) != (o2 > 0) and o1 != 0 and o2 != 0) and ((o3 > 0) != (o4 > 0) and o3 != 0 and o4 != 0);
}
-test "parse reads px, far-side and percent coordinates" {
- const outline = (try parse("0 12, 18 0, -40 0%, -0 -12")).?;
- try std.testing.expectEqual(@as(usize, 4), outline.count);
- const r = resolve(outline, 200, 100, 1);
- try std.testing.expectEqual([2]f64{ 0, 12 }, r.points[0]);
- try std.testing.expectEqual([2]f64{ 18, 0 }, r.points[1]);
- try std.testing.expectEqual([2]f64{ 160, 0 }, r.points[2]);
- try std.testing.expectEqual([2]f64{ 200, 88 }, r.points[3]);
-}
-
-test "percent keeps its fraction and px scale with density" {
- const outline = (try parse("0 0, 50% 0, 50% 10, 0 10")).?;
- const r = resolve(outline, 200, 100, 0.5);
- try std.testing.expectEqual([2]f64{ 100, 0 }, r.points[1]);
- try std.testing.expectEqual([2]f64{ 100, 5 }, r.points[2]);
-}
-
-test "an empty text is no polygon, a malformed or crossing one is refused" {
- try std.testing.expectEqual(@as(?Outline, null), try parse(" "));
- try std.testing.expectError(error.InvalidShape, parse("0 0, 10 10"));
- try std.testing.expectError(error.InvalidShape, parse("0 0, 10 x, 20 20"));
- try std.testing.expectError(error.InvalidShape, parse("0 0, 10 10 5, 20 20"));
- try std.testing.expectError(error.InvalidShape, parse("0 0, 100% 100%, 100% 0, 0 100%"));
-}
-
-test "too many points are refused" {
- const text = "0 0, 1 0, 2 0, 3 0, 4 0, 5 0, 6 0, 7 0, 8 0, 9 0, 10 0, 11 0, 12 0, 13 0, 14 0, 15 0, 16 0, 16 5";
- try std.testing.expectError(error.InvalidShape, parse(text));
-}
-
-test "the distance is negative inside, positive outside, either winding" {
- const outline = (try parse("10 0, -10 0, -0 10, -0 -10, 10 -0, 0 -10")).?;
- const r = resolve(outline, 100, 60, 1);
- try std.testing.expect(sdPolygon(r, 50, 30) < 0);
- try std.testing.expect(sdPolygon(r, 1, 1) > 0); // The cut corner.
- try std.testing.expectApproxEqAbs(@as(f64, 0), sdPolygon(r, 50, 0), 1e-9);
- var reversed = r;
- for (0..r.count) |i| reversed.points[i] = r.points[r.count - 1 - i];
- try std.testing.expectApproxEqAbs(sdPolygon(r, 5, 5), sdPolygon(reversed, 5, 5), 1e-9);
- try std.testing.expect(sdPolygon(reversed, 50, 30) < 0);
-}
-
-test "row insets follow the slants and skip a notch" {
- const outline = (try parse("0 -0, 14 0, 300 0, 312 6, -14 6, -0 -0")).?;
- const r = resolve(outline, 1000, 44, 1);
- // Rows 4 to 40: the left slant is 12.7 px in at row 4; the right end is slanted
- // from (986, 6) to (1000, 44), so 14 in at its top, and row 4 above the step is
- // the notch, which has no end to clear.
- const insets = rowInsets(r, 1000, 4, 40);
- try std.testing.expect(insets.left >= 12 and insets.left <= 14);
- try std.testing.expect(insets.right >= 12 and insets.right <= 15);
- // Rows wholly inside a rectangle need nothing.
- const box = resolve((try parse("0 0, -0 0, -0 -0, 0 -0")).?, 1000, 44, 1);
- try std.testing.expectEqual(Insets{}, rowInsets(box, 1000, 4, 40));
-}
-
-test "a corner's local key survives a resize and follows its own edges" {
- const outline = (try parse("0 14, 14 0, 282.5 0, 289.5 7, -14 7, -0 21, -0 -12, -12 -0, 12 -0, 0 -12")).?;
- const small = resolve(outline, 700, 500, 1);
- const large = resolve(outline, 913, 641, 1);
- // Each corner's 52 px square, measured from its own origin.
- try std.testing.expectEqual(localKey(small, 0, 0, 52, 52, 5), localKey(large, 0, 0, 52, 52, 5));
- try std.testing.expectEqual(localKey(small, 700 - 52, 0, 52, 52, 5), localKey(large, 913 - 52, 0, 52, 52, 5));
- try std.testing.expectEqual(localKey(small, 0, 500 - 52, 52, 52, 5), localKey(large, 0, 641 - 52, 52, 52, 5));
- try std.testing.expectEqual(localKey(small, 700 - 52, 500 - 52, 52, 52, 5), localKey(large, 913 - 52, 641 - 52, 52, 52, 5));
- // The corners differ from one another, and a narrow frame brings the step
- // of the top edge into the top right corner's square.
- try std.testing.expect(localKey(small, 0, 0, 52, 52, 5) != localKey(small, 700 - 52, 0, 52, 52, 5));
- const narrow = resolve(outline, 320, 500, 1);
- try std.testing.expect(localKey(narrow, 320 - 52, 0, 52, 52, 5) != localKey(small, 700 - 52, 0, 52, 52, 5));
- // Another density moves the cuts.
- const dense = resolve(outline, 700, 500, 1.25);
- try std.testing.expect(localKey(dense, 0, 0, 52, 52, 5) != localKey(small, 0, 0, 52, 52, 5));
-}
-
-test "a saturated run never reaches an edge" {
- try std.testing.expectEqual(@as(usize, 0), saturatedRun(0.2));
- try std.testing.expectEqual(@as(usize, 0), saturatedRun(-1.4));
- try std.testing.expectEqual(@as(usize, 1), saturatedRun(-1.6));
- try std.testing.expectEqual(@as(usize, 11), saturatedRun(12.4));
+test {
+ _ = @import("window_shape_tests.zig");
}
diff --git a/src/ui/window_shape_tests.zig b/src/ui/window_shape_tests.zig
new file mode 100644
index 0000000..bfab32a
--- /dev/null
+++ b/src/ui/window_shape_tests.zig
@@ -0,0 +1,117 @@
+const std = @import("std");
+const shape = @import("window_shape.zig");
+const Outline = shape.Outline;
+const Insets = shape.Insets;
+const parse = shape.parse;
+const resolve = shape.resolve;
+const sdPolygon = shape.sdPolygon;
+const rowInsets = shape.rowInsets;
+const localKey = shape.localKey;
+const saturatedRun = shape.saturatedRun;
+
+test "fixed title steps fall back before overtaking the opposite corner" {
+ const outline = (try parse("0 14, 14 0, 282.5 0, 289.5 7, -14 7, -0 21, -0 -12, -12 -0, 12 -0, 0 -12")).?;
+ for ([_]f64{ 0.75, 1, 1.25, 1.5 }) |density| {
+ for ([_]f64{ 210, 250, 270, 286, 300, 303, 303.5 }) |width| {
+ try std.testing.expect(shape.resolveFitting(outline, width * density, 400 * density, density) == null);
+ }
+ for ([_]f64{ 304, 320, 360, 800 }) |width| {
+ const resolved = shape.resolveFitting(outline, width * density, 400 * density, density).?;
+ try std.testing.expectEqualDeep(resolve(outline, width * density, 400 * density, density), resolved);
+ }
+ try std.testing.expect(shape.resolveFitting(outline, 800 * density, 32 * density, density) == null);
+ }
+ // The old edge-intersection check alone accepts this backwards step.
+ try std.testing.expect(shape.usable(resolve(outline, 300, 400, 1)));
+}
+
+test "fitting allows independent cuts and percentage outlines" {
+ const cuts = (try parse("0 0, 280 0, -0 30, -0 -0, -280 -0, 0 -30")).?;
+ try std.testing.expect(shape.resolveFitting(cuts, 300, 200, 1) != null);
+ try std.testing.expect(shape.resolveFitting(cuts, 279, 200, 1) == null);
+ const percent = (try parse("0 0, 100% 0, 100% 100%, 0 100%")).?;
+ try std.testing.expect(shape.resolveFitting(percent, 1, 1, 1.5) != null);
+ try std.testing.expect(shape.resolveFitting(percent, 0, 1, 1) == null);
+}
+
+test "parse reads px, far-side and percent coordinates" {
+ const outline = (try parse("0 12, 18 0, -40 0%, -0 -12")).?;
+ try std.testing.expectEqual(@as(usize, 4), outline.count);
+ const r = resolve(outline, 200, 100, 1);
+ try std.testing.expectEqual([2]f64{ 0, 12 }, r.points[0]);
+ try std.testing.expectEqual([2]f64{ 18, 0 }, r.points[1]);
+ try std.testing.expectEqual([2]f64{ 160, 0 }, r.points[2]);
+ try std.testing.expectEqual([2]f64{ 200, 88 }, r.points[3]);
+}
+
+test "percent keeps its fraction and px scale with density" {
+ const outline = (try parse("0 0, 50% 0, 50% 10, 0 10")).?;
+ const r = resolve(outline, 200, 100, 0.5);
+ try std.testing.expectEqual([2]f64{ 100, 0 }, r.points[1]);
+ try std.testing.expectEqual([2]f64{ 100, 5 }, r.points[2]);
+}
+
+test "an empty text is no polygon, a malformed or crossing one is refused" {
+ try std.testing.expectEqual(@as(?Outline, null), try parse(" "));
+ try std.testing.expectError(error.InvalidShape, parse("0 0, 10 10"));
+ try std.testing.expectError(error.InvalidShape, parse("0 0, 10 x, 20 20"));
+ try std.testing.expectError(error.InvalidShape, parse("0 0, 10 10 5, 20 20"));
+ try std.testing.expectError(error.InvalidShape, parse("0 0, 100% 100%, 100% 0, 0 100%"));
+}
+
+test "too many points are refused" {
+ const text = "0 0, 1 0, 2 0, 3 0, 4 0, 5 0, 6 0, 7 0, 8 0, 9 0, 10 0, 11 0, 12 0, 13 0, 14 0, 15 0, 16 0, 16 5";
+ try std.testing.expectError(error.InvalidShape, parse(text));
+}
+
+test "the distance is negative inside, positive outside, either winding" {
+ const outline = (try parse("10 0, -10 0, -0 10, -0 -10, 10 -0, 0 -10")).?;
+ const r = resolve(outline, 100, 60, 1);
+ try std.testing.expect(sdPolygon(r, 50, 30) < 0);
+ try std.testing.expect(sdPolygon(r, 1, 1) > 0); // The cut corner.
+ try std.testing.expectApproxEqAbs(@as(f64, 0), sdPolygon(r, 50, 0), 1e-9);
+ var reversed = r;
+ for (0..r.count) |i| reversed.points[i] = r.points[r.count - 1 - i];
+ try std.testing.expectApproxEqAbs(sdPolygon(r, 5, 5), sdPolygon(reversed, 5, 5), 1e-9);
+ try std.testing.expect(sdPolygon(reversed, 50, 30) < 0);
+}
+
+test "row insets follow the slants and skip a notch" {
+ const outline = (try parse("0 -0, 14 0, 300 0, 312 6, -14 6, -0 -0")).?;
+ const r = resolve(outline, 1000, 44, 1);
+ // Rows 4 to 40: the left slant is 12.7 px in at row 4; the right end is slanted
+ // from (986, 6) to (1000, 44), so 14 in at its top, and row 4 above the step is
+ // the notch, which has no end to clear.
+ const insets = rowInsets(r, 1000, 4, 40);
+ try std.testing.expect(insets.left >= 12 and insets.left <= 14);
+ try std.testing.expect(insets.right >= 12 and insets.right <= 15);
+ // Rows wholly inside a rectangle need nothing.
+ const box = resolve((try parse("0 0, -0 0, -0 -0, 0 -0")).?, 1000, 44, 1);
+ try std.testing.expectEqual(Insets{}, rowInsets(box, 1000, 4, 40));
+}
+
+test "a corner's local key survives a resize and follows its own edges" {
+ const outline = (try parse("0 14, 14 0, 282.5 0, 289.5 7, -14 7, -0 21, -0 -12, -12 -0, 12 -0, 0 -12")).?;
+ const small = resolve(outline, 700, 500, 1);
+ const large = resolve(outline, 913, 641, 1);
+ // Each corner's 52 px square, measured from its own origin.
+ try std.testing.expectEqual(localKey(small, 0, 0, 52, 52, 5), localKey(large, 0, 0, 52, 52, 5));
+ try std.testing.expectEqual(localKey(small, 700 - 52, 0, 52, 52, 5), localKey(large, 913 - 52, 0, 52, 52, 5));
+ try std.testing.expectEqual(localKey(small, 0, 500 - 52, 52, 52, 5), localKey(large, 0, 641 - 52, 52, 52, 5));
+ try std.testing.expectEqual(localKey(small, 700 - 52, 500 - 52, 52, 52, 5), localKey(large, 913 - 52, 641 - 52, 52, 52, 5));
+ // The corners differ from one another, and a narrow frame brings the step
+ // of the top edge into the top right corner's square.
+ try std.testing.expect(localKey(small, 0, 0, 52, 52, 5) != localKey(small, 700 - 52, 0, 52, 52, 5));
+ const narrow = resolve(outline, 320, 500, 1);
+ try std.testing.expect(localKey(narrow, 320 - 52, 0, 52, 52, 5) != localKey(small, 700 - 52, 0, 52, 52, 5));
+ // Another density moves the cuts.
+ const dense = resolve(outline, 700, 500, 1.25);
+ try std.testing.expect(localKey(dense, 0, 0, 52, 52, 5) != localKey(small, 0, 0, 52, 52, 5));
+}
+
+test "a saturated run never reaches an edge" {
+ try std.testing.expectEqual(@as(usize, 0), saturatedRun(0.2));
+ try std.testing.expectEqual(@as(usize, 0), saturatedRun(-1.4));
+ try std.testing.expectEqual(@as(usize, 1), saturatedRun(-1.6));
+ try std.testing.expectEqual(@as(usize, 11), saturatedRun(12.4));
+}
diff --git a/tests/blackout.py b/tests/blackout.py
index 02aa9e9..6a6bd34 100644
--- a/tests/blackout.py
+++ b/tests/blackout.py
@@ -92,6 +92,8 @@ def run(scale):
assert colors.get((26, 32, 33), 0) > 30, colors
assert colors.get((52, 61, 62), 0) > 30, colors
debug = ipc.get_window_debug(wid)
+ assert debug["titlebar_height"] == 50, debug
+ assert debug["frame_border"] == debug["footer_height"] == 2, debug
controls = {w["name"]: w for w in ipc.get_widget_tree(f"window/{wid}")["widgets"]}
close = controls["close"]["box"]
assert close["x"] + close["width"] > debug["chrome_box"]["width"] - 14, close
@@ -105,6 +107,16 @@ def run(scale):
from blackout_config import check_config
check_config(ipc, wid, scale, tmp, capture, crop, yellow)
+ from blackout_shapes import check_shapes
+ check_shapes(ipc, wid, scale, tmp, capture)
+
+ from blackout_resize import check_narrow
+ ipc.minimize(wid)
+ try:
+ check_narrow(ipc, scale, tmp, capture, crop)
+ finally:
+ ipc.restore(wid)
+
# Narrow widths retain working window controls and a clipped title.
ipc.action("set_window_size", {"id": wid, "width": 360, "height": 300})
wait_for(lambda: ipc.get_window_debug(wid)["client_box"]["width"] == 360, "narrow resize")
diff --git a/tests/blackout_config.py b/tests/blackout_config.py
index a31e5f3..e83ddcd 100644
--- a/tests/blackout_config.py
+++ b/tests/blackout_config.py
@@ -19,10 +19,12 @@ def check_config(ipc, wid, scale, tmp, capture, crop, yellow):
ipc.action("theme.apply", {"id": "config-audit"})
ipc.wait_for_frame()
assert tomllib.loads(config_path.read_text())["theme"]["base"] == "config-audit"
+ check_border(ipc, wid, scale, tmp, capture)
before = capture()
box = ipc.get_window_debug(wid)["chrome_box"]
sample = (round((box["x"] + 80) * scale), round((box["y"] + 8) * scale))
assert yellow(before.getpixel(sample)), "title plate depends on pack name"
+ check_power_menu(ipc, scale, capture, crop, yellow)
body = ipc.get_window_debug(wid)["client_box"]
track_box = (body["width"] - 18, 120, 18, 160)
old_track = crop(before, body, track_box).tobytes()
@@ -63,3 +65,68 @@ def check_config(ipc, wid, scale, tmp, capture, crop, yellow):
config_path.write_text(original)
ipc.reload_config()
ipc.wait_for_frame()
+
+
+def check_border(ipc, wid, scale, tmp, capture):
+ """The hover ring occupies the reserved frame width, including on reload."""
+ config_path = tmp / "rediwm-config.toml"
+ original = config_path.read_text()
+ client = ipc.get_window_debug(wid)["client_box"]
+ try:
+ for border in (2, 1, 2):
+ config_path.write_text(original + f"\nwindow_border_width = {border}\n")
+ ipc.reload_config()
+ ipc.wait_for("window_geometry_settled", window_id=wid)
+ debug = ipc.get_window_debug(wid)
+ body, frame = debug["client_box"], debug["chrome_box"]
+ assert debug["frame_border"] == debug["footer_height"] == border, debug
+ assert (body["width"], body["height"]) == (client["width"], client["height"]), debug
+ assert body["x"] == frame["x"] + border, debug
+ assert frame["width"] == body["width"] + 2 * border, debug
+ assert frame["height"] == body["height"] + debug["titlebar_height"] + border, debug
+ ipc.move_cursor(body["x"] + body["width"] // 2, body["y"] + body["height"] // 2)
+ image = capture()
+ x = round((frame["x"] + frame["width"] / 2) * scale)
+ bottom = round((frame["y"] + frame["height"]) * scale)
+ for offset in range(int(border * scale + .5)):
+ pixel = image.getpixel((x, bottom - 1 - offset))
+ assert max(abs(a - b) for a, b in zip(pixel, (115, 124, 104))) <= 3, (border, offset, pixel)
+ image.save(f"/tmp/blackout-border-{scale}.png")
+ finally:
+ config_path.write_text(original)
+ ipc.reload_config()
+ ipc.move_cursor(10, 10)
+
+
+def check_power_menu(ipc, scale, capture, crop, yellow):
+ """Hover and keyboard focus use the pack's yellow for outline and icon."""
+ ipc.move_cursor(10, 10)
+ ipc.action("open_power_menu")
+ ipc.wait_for_frame()
+ try:
+ box = ipc.get_shell_state()["power_menu"]["box"]
+ cards = [w for w in ipc.get_widget_tree("power_menu")["widgets"] if w["role"] == "row"]
+
+ def check(card):
+ image = capture()
+ x, y, w, h = (card[k] for k in ("x", "y", "width", "height"))
+ border = crop(image, box, (x + 16, y, w - 32, 4))
+ icon = crop(image, box, (x + 8, y + 8, w - 16, h - 16))
+ assert sum(yellow(p) for p in border.getdata()) > 30 * scale, "power-menu outline is not yellow"
+ assert sum(yellow(p) for p in icon.getdata()) > 20 * scale, "power-menu icon is not yellow"
+
+ # Lock and Log Out are available without a logind service. Only hover:
+ # the test never activates a session action.
+ for card in cards[:2]:
+ target = card["box"]
+ ipc.move_cursor(box["x"] + target["x"] + target["width"] // 2,
+ box["y"] + target["y"] + target["height"] // 2)
+ check(target)
+ ipc.move_cursor(10, 10)
+ ipc.key_down_up(106)
+ check(cards[0]["box"])
+ capture().save(f"/tmp/blackout-power-menu-{scale}.png")
+ finally:
+ ipc.key_down_up(1)
+ ipc.wait_for("power_menu_closed")
+ ipc.move_cursor(10, 10)
diff --git a/tests/blackout_resize.py b/tests/blackout_resize.py
index 91be69b..e3eb0c7 100644
--- a/tests/blackout_resize.py
+++ b/tests/blackout_resize.py
@@ -1,7 +1,61 @@
"""Interactive corner feedback checks, called by the Blackout visual suite."""
+import os
+import subprocess
import time
-from desktop_zoom import wait_for
+from desktop_zoom import build_client, wait_for
+from ipc_client import stop_process
+
+
+def check_narrow(ipc, scale, tmp, capture, crop):
+ """An outline that no longer fits must match the ordinary frame fallback."""
+ config_path = tmp / "rediwm-config.toml"
+ original = config_path.read_text()
+ # Files has a 360 px minimum. Use the existing resizable xdg fixture to
+ # exercise smaller frames, including the grouped titlebar in the report.
+ build_client(tmp)
+ display = next(p.name for p in tmp.glob("wayland-*") if not p.name.endswith(".lock"))
+ client = subprocess.Popen([str(tmp / "client"), "--app-id", "blackout-narrow", "--title", "Narrow"],
+ env=dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WAYLAND_DISPLAY=display,
+ REDIWM_TEST_DECORATION="server", REDIWM_TEST_RESIZE="1"),
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ try:
+ window = wait_for(lambda: next((w for w in ipc.get_windows()
+ if w["app_id"] == "blackout-narrow"), None), "narrow client")
+ wid = window["id"]
+ ipc.set_zoom(wid, 100)
+ ipc.action("move_window_to", {"id": wid, "x": 80, "y": 80})
+ ipc.focus_window(wid)
+ ipc.move_cursor(10, 10)
+ for grouped in (False, True):
+ config = original.replace('[compositor]', '[compositor]\nwindow_tab_apps = ["blackout-narrow"]', 1) if grouped else original
+ config_path.write_text(config)
+ ipc.reload_config()
+ for width in (360, 292, 291, 278, 270, 250, 210, 360):
+ ipc.action("set_window_size", {"id": wid, "width": width, "height": 300})
+ wait_for(lambda: ipc.get_window_debug(wid)["client_box"]["width"] == width,
+ f"narrow resize to {width}")
+ ipc.wait_for("window_geometry_settled", window_id=wid)
+ box = ipc.get_window_debug(wid)["chrome_box"]
+ rect = (0, 0, box["width"], ipc.get_window_debug(wid)["titlebar_height"])
+ actual = capture()
+ actual.save(f"/tmp/blackout-narrow-{width}-{scale}.png")
+ config_path.write_text(config + '\nwindow_shape = ""\n')
+ ipc.reload_config()
+ ipc.wait_for_frame()
+ fallback = capture()
+ same = crop(actual, box, rect).tobytes() == crop(fallback, box, rect).tobytes()
+ # The raised step and the right chamfer need 295.5 logical px,
+ # including the two 2 px borders around the client.
+ assert same == (box["width"] < 295.5), (grouped, width, box, same)
+ config_path.write_text(config)
+ ipc.reload_config()
+ ipc.wait_for_frame()
+ finally:
+ stop_process(client)
+ wait_for(lambda: not any(w["app_id"] == "blackout-narrow" for w in ipc.get_windows()), "narrow client closed")
+ config_path.write_text(original)
+ ipc.reload_config()
def check_resize(ipc, wid, scale, tmp, capture, crop, yellow):
diff --git a/tests/blackout_shapes.py b/tests/blackout_shapes.py
new file mode 100644
index 0000000..0cb5b3c
--- /dev/null
+++ b/tests/blackout_shapes.py
@@ -0,0 +1,68 @@
+"""Beveled chrome controls and both Start panel variants, including live reload."""
+import math
+
+
+def check_shapes(ipc, wid, scale, tmp, capture):
+ config_path = tmp / "rediwm-config.toml"
+ original = config_path.read_text()
+ assert ipc.action("get_theme")["tokens"]["scrollbar_width"] == 10
+
+ def override(name, value):
+ config_path.write_text(original + f"\n{name} = {value}\n")
+ ipc.reload_config()
+ ipc.wait_for_frame()
+
+ def pixel(image, x, y):
+ return image.getpixel((math.floor(x * scale), math.floor(y * scale)))
+
+ try:
+ for name in ("minimize", "maximize", "close"):
+ control = next(w for w in ipc.get_widget_tree(f"window/{wid}")["widgets"] if w["name"] == name)
+ box = control["global_box"]
+ ipc.move_cursor(box["x"] + box["width"] // 2, box["y"] + box["height"] // 2)
+ beveled = capture()
+ override("chrome_button_bevel", 0)
+ rounded = capture()
+ x, y = box["x"] + 1.5, box["y"] + 1.5
+ assert max(abs(a - b) for a, b in zip(pixel(beveled, x, y), (17, 21, 22))) <= 2, (name, pixel(beveled, x, y))
+ assert max(abs(a - b) for a, b in zip(pixel(beveled, x, y), pixel(rounded, x, y))) > 10, name
+ x = box["x"] + box["width"] / 2
+ assert pixel(beveled, x, y) == pixel(rounded, x, y), name
+ override("chrome_button_bevel", 7)
+ capture().save(f"/tmp/blackout-beveled-controls-{scale}.png")
+ config_path.write_text(original)
+ ipc.reload_config()
+ ipc.move_cursor(10, 10)
+
+ for launcher in (False, True):
+ closed = capture()
+ if launcher:
+ ipc.key(125, True)
+ ipc.key_down_up(57)
+ ipc.key(125, False)
+ else:
+ ipc.action("open_start_menu")
+ ipc.wait_for("menu_opened")
+ box = ipc.get_shell_state()["start_menu"]["box"]
+ points = [(box["x"] + dx, box["y"] + dy)
+ for dx in (3.5, box["width"] - 3.5)
+ for dy in (8.5, box["height"] - 8.5)]
+
+ def check_cuts(image):
+ for x, y in points:
+ assert pixel(image, x, y) == pixel(closed, x, y), (launcher, x, y, pixel(image, x, y), pixel(closed, x, y))
+ assert pixel(image, box["x"] + 11.5, box["y"] + 11.5) == (21, 25, 26)
+
+ check_cuts(capture())
+ override("start_menu_bevel", 0)
+ rounded = capture()
+ assert any(pixel(rounded, x, y) != pixel(closed, x, y) for x, y in points)
+ override("start_menu_bevel", 16)
+ check_cuts(capture())
+ capture().save(f"/tmp/blackout-beveled-menu-{launcher}-{scale}.png")
+ ipc.key_down_up(1)
+ ipc.wait_for("menu_closed")
+ finally:
+ config_path.write_text(original)
+ ipc.reload_config()
+ ipc.move_cursor(10, 10)
diff --git a/tests/dock.py b/tests/dock.py
index 4bb08a3..657d8dc 100644
--- a/tests/dock.py
+++ b/tests/dock.py
@@ -1248,10 +1248,10 @@ def positions():
width, height = output['logical_width'], output['logical_height'] - bar['height']
if vertical:
assert box['y'] == y0 + (height - box['height']) // 2, box
- assert box['x'] == (x0 + 5 if position == 'left' else x0 + width - size - 5), box
+ assert box['x'] == (x0 if position == 'left' else x0 + width - size), box
else:
assert box['x'] == x0 + (width - box['width']) // 2, box
- assert box['y'] == (y0 + 5 if position == 'top' else y0 + height - size - 5), box
+ assert box['y'] == (y0 if position == 'top' else y0 + height - size), box
buttons = [w['global_box'] for w in ui.widgets('dock') if w['name']]
along, cross = ('y', 'x') if vertical else ('x', 'y')
assert all(a[along] < b[along] and a[cross] == b[cross] for a, b in zip(buttons, buttons[1:])), buttons