Skip to content

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

Add the Blackout theme pack

oxydizerf7441011132f
diff --git a/assets/themes/blackout.toml b/assets/themes/blackout.toml
new file mode 100644
index 0000000..0e2d46a
--- /dev/null
+++ b/assets/themes/blackout.toml
@@ -0,0 +1,203 @@
+[meta]
+format = 1
+id = "blackout"
+name = "Blackout"
+version = "1.0"
+description = "Near-black graphite, signal-yellow accents, cut corners and industrial striped tracks."
+
+[theme]
+font = "Manrope"
+mono_font = "JetBrains Mono"
+font_size = 13
+title_size = 13.5
+chrome_height = 42
+chrome_control_gap = 8
+chrome_control_right_pad = 2
+chrome_control_offset_y = 5
+chrome_round_buttons = false
+# 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;
+# 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_bg = "#111516"
+window_fg = "#E3E5E3"
+window_dim = "#A2A8A6"
+window_border = "#3B4242"
+window_border_hover = "#737C68"
+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).
+# 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_control_gap = 8
+window_title_plate_text_padding = 8
+window_corner_accent = "#FAEB01"
+window_corner_extent = 34
+window_corner_resize_extra = 18
+window_corner_width = 3
+# Extra inset beyond the frame ring; resize/restore durations in milliseconds.
+window_corner_inset = 0
+window_corner_end_padding = 2
+window_corner_resize_ms = 140
+window_corner_restore_ms = 180
+window_corner_resize_ease = "out_cubic"
+window_close_hover = "#FAEB01"
+window_close_fg = "#111400"
+workspace_active_border = "#FAEB01"
+
+app_bg = "#101314"
+app_fg = "#E3E5E3"
+app_toolbar = "#171B1C"
+app_sidebar = "#15191A"
+app_sidebar_fg = "#E3E5E3"
+app_bar = "#1D2223"
+app_item = "#15191A"
+app_item_hover = "#252B2B"
+app_item_border = "#303737"
+app_item_selected = "#454719"
+app_nav_selected = "#454719"
+# Keep readable pale labels in shared sidebar controls; yellow marker and
+# icons carry the accent without requiring per-app selection text overrides.
+app_sidebar_selected = "#454719"
+app_sidebar_hover = "#252B2B"
+app_sidebar_selected_marker = "#FAEB01"
+app_sidebar_item_radius = 5
+app_highlight_bevel = 7
+app_divider = "#303737"
+app_icon = "#FAEB01"
+app_menu_bg = "#171B1C"
+app_field_bg = "#0D1011"
+app_field_border = "#343C3C"
+text_secondary = "#A2A8A6"
+file_folder_back = "#A89D00"
+file_folder_front = "#FAEB01"
+file_document = "#D7DBD9"
+file_document_lines = "#515A58"
+scrollbar_thumb = "#E4D500"
+scrollbar_thumb_active = "#FFF233"
+scrollbar_track = "#1A2021"
+scrollbar_track_stripe = "#343D3E"
+# Distances along the scrollbar; slope 1 makes 45-degree diagonal bands.
+scrollbar_track_stripe_period = 10
+scrollbar_track_stripe_width = 5
+scrollbar_track_stripe_slope = 1
+scrollbar_glow = 0
+scrollbar_width = 8
+scrollbar_radius = 3
+
+bg = "#101314"
+fg = "#E3E5E3"
+dim = "#A2A8A6"
+faint = "#747E7B"
+accent = "#FAEB01"
+accent_2 = "#D3C600"
+accent_3 = "#A89D00"
+on_accent = "#111400"
+shell_accent = "#FAEB01"
+shell_on_accent = "#111400"
+danger = "#F06A51"
+surface = "#202627"
+surface_hover = "#303737"
+border = "#3B4242"
+border_soft = "#2A3030"
+border_hover = "#737C68"
+border_focus = "#FAEB01"
+border_glow = "rgba(250,235,1,0.55)"
+glass = "#15191A"
+glass_strong = "#171B1C"
+shadow = "rgba(0,0,0,0.65)"
+shadow_size = 22
+shadow_offset_y = 6
+field_bg = "#0D1011"
+field_border = "#343C3C"
+selection_alpha = 0.28
+toggle_on = "#FAEB01"
+toggle_thumb = "#E3E5E3"
+slider_track = "#343C3C"
+control_thumb = "#FAEB01"
+
+radius = 5
+radius_md = 6
+radius_lg = 12
+field_radius = 5
+settings_radius = 8
+settings_sidebar_radius = 5
+settings_card_radius = 6
+settings_card_bg = "#1D2223"
+taskbar_bg = "#111516"
+taskbar_surface = "#1D2223"
+taskbar_hover = "#303737"
+taskbar_border = "#3B4242"
+taskbar_size = 42
+# Dock: cut corners, dark tiles outlined in yellow on hover, icons drained of
+# colour until hovered.
+dock_bg = "#111516"
+dock_border = "#3B4242"
+dock_bevel = 14
+dock_item_bg = "#171B1C"
+dock_item_border = "#2A3030"
+dock_item_hover_border = "#FAEB01"
+dock_item_bevel = 7
+dock_icon_grey = 1
+# A short status bar in the top-right corner, its one exposed corner cut.
+taskbar_length = 20
+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_border = "#3B4242"
+start_menu_search_bg = "#0D1011"
+start_menu_selected_bg = "#454719"
+start_menu_selected_border = "#8F8700"
+start_menu_selected_marker = "#FAEB01"
+popup_bg = "#171B1C"
+popup_border = "#3B4242"
+popup_card_bg = "#202627"
+popup_card_fg = "#E3E5E3"
+popup_card_dim = "#A2A8A6"
+popup_card_border = "#343C3C"
+notification_bg = "#171B1C"
+notification_fg = "#E3E5E3"
+notification_dim = "#A2A8A6"
+notification_border = "#737C68"
+switcher_bg = "#111516"
+switcher_border = "#3B4242"
+switcher_item_bg = "#202627"
+switcher_item_border = "#343C3C"
+switcher_selected_border = "#FAEB01"
+switcher_fg = "#E3E5E3"
+switcher_dim = "#A2A8A6"
+switcher_icon_bg = "#303737"
+lock_bg = "#101314"
+lock_fg = "#E3E5E3"
+lock_dim = "#A2A8A6"
+lock_divider = "#3B4242"
+lock_session_fg = "#FAEB01"
+lock_wallpaper_opacity = 0.15
+power_menu_bevel = 16
+terminal_bg = "#101314"
+terminal_fg = "#E3E5E3"
+terminal_cursor = "#FAEB01"
+terminal_yellow = "#D3C600"
+terminal_bright_yellow = "#FAEB01"
+
+[layout]
+# Status items only: the start menu stays on Super, windows on Alt+Tab.
+taskbar_position = "top"
+taskbar_alignment = "right"
+taskbar_items = ["-left:start", "-left:windows", "right:capture", "right:tray", "right:battery", "~right:wifi", "~right:wired", "right:volume", "right:clock", "-right:power"]
+dock_enabled = true
+dock_position = "left"
+# Hover lights the tile; an enlarging icon would cover its outline.
+dock_hover_zoom = 1
+
+[assets]
+wallpaper = "blackout-wallpaper.png"
+color_scheme = "dark"
diff --git a/assets/themes/blackout/icons/folder-documents.svg b/assets/themes/blackout/icons/folder-documents.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/folder-documents.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/folder-download.svg b/assets/themes/blackout/icons/folder-download.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/folder-download.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/folder-music.svg b/assets/themes/blackout/icons/folder-music.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/folder-music.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/folder-pictures.svg b/assets/themes/blackout/icons/folder-pictures.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/folder-pictures.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/folder-publicshare.svg b/assets/themes/blackout/icons/folder-publicshare.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/folder-publicshare.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/folder-templates.svg b/assets/themes/blackout/icons/folder-templates.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/folder-templates.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/folder-videos.svg b/assets/themes/blackout/icons/folder-videos.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/folder-videos.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/folder.svg b/assets/themes/blackout/icons/folder.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/folder.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/rediwm-files.svg b/assets/themes/blackout/icons/rediwm-files.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/rediwm-files.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/system-file-manager.svg b/assets/themes/blackout/icons/system-file-manager.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/system-file-manager.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/user-desktop.svg b/assets/themes/blackout/icons/user-desktop.svg
new file mode 100644
index 0000000..057dee7
--- /dev/null
+++ b/assets/themes/blackout/icons/user-desktop.svg
@@ -0,0 +1,5 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+</svg>
diff --git a/assets/themes/blackout/icons/user-home.svg b/assets/themes/blackout/icons/user-home.svg
new file mode 100644
index 0000000..f555b8b
--- /dev/null
+++ b/assets/themes/blackout/icons/user-home.svg
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64">
+ <path d="M6 12h18l6 7h28v34H6z" fill="#A89D00"/>
+ <path d="M6 21h52v32H6z" fill="#FAEB01"/>
+ <path d="M8 23h48" fill="none" stroke="#FFF566" stroke-width="2"/>
+ <path d="m22 37 10-8 10 8v11h-7v-8h-6v8h-7z" fill="#111400"/>
+</svg>
diff --git a/assets/themes/blackout/wallpapers/blackout-wallpaper.png b/assets/themes/blackout/wallpapers/blackout-wallpaper.png
new file mode 100644
index 0000000..1c20774
Binary files /dev/null and b/assets/themes/blackout/wallpapers/blackout-wallpaper.png differ
diff --git a/build.zig b/build.zig
index ece0cbc..8dd3ad7 100644
--- a/build.zig
+++ b/build.zig
@@ -106,6 +106,13 @@ pub fn build(b: *std.Build) void {
ui_mod.addAnonymousImport("theme-redi-mocha", .{ .root_source_file = b.path("assets/themes/redi-mocha.toml") });
ui_mod.addAnonymousImport("theme-chamfer-blue", .{ .root_source_file = b.path("assets/themes/chamfer-blue.toml") });
ui_mod.addAnonymousImport("theme-gold", .{ .root_source_file = b.path("assets/themes/gold.toml") });
+ ui_mod.addAnonymousImport("theme-blackout", .{ .root_source_file = b.path("assets/themes/blackout.toml") });
+ b.getInstallStep().dependOn(&b.addInstallDirectory(.{
+ .source_dir = b.path("assets/themes/blackout"),
+ .install_dir = .prefix,
+ .install_subdir = "share/rediwm/themes/blackout",
+ }).step);
+ b.getInstallStep().dependOn(&b.addInstallFileWithDir(b.path("assets/themes/blackout.toml"), .prefix, "share/rediwm/themes/blackout/theme.toml").step);
b.getInstallStep().dependOn(&b.addInstallDirectory(.{
.source_dir = b.path("assets/themes/gold"),
.install_dir = .prefix,
diff --git a/docs/agent-notes/dock.md b/docs/agent-notes/dock.md
index cf0237d..621b483 100644
--- a/docs/agent-notes/dock.md
+++ b/docs/agent-notes/dock.md
@@ -72,3 +72,11 @@ taskbar, OSD and input integration. General rules remain in
when it exits; a failure cancels the drag and posts a notification. An
auto-hiding dock reveals for a file drag (`draggingFiles` in `input/motion.zig`).
Covered by `tests/dock_trash_drop.py`.
+
+* **Themed tiles** (`dock_item_bg`, `_border`, `_hover_border`, `_bevel`) replace
+ the ghost hover button with a resting tile per item, outlined while hovered,
+ pressed or the highlighted active app; `dock_bevel` cuts the dock's own
+ corners (the glass rounds deep enough to stay inside the cut). `dock_icon_grey`
+ draws icons from a desaturated copy except while lit. All of it is theme
+ state (`base_key`); lit-ness comes from the button state already in each
+ item's key.
diff --git a/docs/agent-notes/rendering.md b/docs/agent-notes/rendering.md
index 85ca521..b300131 100644
--- a/docs/agent-notes/rendering.md
+++ b/docs/agent-notes/rendering.md
@@ -49,6 +49,30 @@ chrome, capture, or retained panel painting. General rules remain in
handed the shape explicitly. The ring is one `max(1, round(border * scale))`.
Without the shaped programs (`chrome.shapes` false) windows are square, with
no ring or shadow.
+ Optional `window_corner_*` accents are four small immutable rasters owned by
+ the frame tree (`toplevel/corner_accents.zig`), following that same shape just
+ inside its ring. They decline input, inherit opacity, and memoize geometry,
+ shape, scale and theme; maximized/fullscreen/undecorated windows hide them.
+ `window_corner_resize_extra` adds length during a live resize grab. The normal
+ chrome frame tick eases that extension in/out, including split resizes; it
+ stops scheduling when settled. Begin/end wake the tick even without a client
+ commit, and pending configure acknowledgements do not prolong the feedback.
+ The grow/return durations and easing are `window_corner_resize_ms`,
+ `window_corner_restore_ms`, and `window_corner_resize_ease`; live timing edits
+ continue from the displayed length. `window_corner_inset` adds space beyond
+ the frame ring, and `window_corner_end_padding` shortens the stroke endpoints.
+ `window_title_plate*` paints an angled title label, limits text before its
+ slant and leaves grouped tabs to their existing painter. Its tokens belong
+ in `TitlebarMemo` so reload and partial title repaint agree.
+ Plate inset, bevel, height-relative slant, control gap and text padding are
+ theme tokens too; narrow frames clamp opposing cuts to prevent crossed edges.
+ With a polygon outline (`ChromeState.outline`) the plate is also cut by the
+ outline moved in by the inset (`chrome_plate.distance`, keyed in the memo),
+ so chamfers keep an even margin; a step meant to hug the plate's slant has
+ to be placed in px in `window_shape` to match the plate's width and slant.
+ `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.
* **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/src/Toplevel.zig b/src/Toplevel.zig
index 908b773..a820feb 100644
--- a/src/Toplevel.zig
+++ b/src/Toplevel.zig
@@ -151,6 +151,7 @@ sidebar_glass_effect: ?*glass.Effect = null,
titlebar_buffer: *sn.Buffer,
// Body under the border ring beside and below the client (left, right, bottom).
frame_fills: [3]*sn.Rect,
+corner_accents: @import("toplevel/corner_accents.zig").State = .{},
// The outline of a window that draws its own decorations.
border_rects: [4]*sn.Rect,
content_tree: *sn.Tree,
@@ -515,6 +516,9 @@ pub const visualChromeSize = toplevel_chrome_sync.visualChromeSize;
pub const syncShadow = toplevel_chrome_sync.syncShadow;
pub const syncResizeGrab = toplevel_chrome_sync.syncResizeGrab;
pub const applyShape = toplevel_chrome_sync.applyShape;
+pub const syncCornerAccents = @import("toplevel/corner_accents.zig").syncCornerAccents;
+pub const tickCornerAccents = @import("toplevel/corner_accents.zig").tickCornerAccents;
+pub const wakeCornerAccents = @import("toplevel/corner_accents.zig").wakeCornerAccents;
pub const syncBorders = toplevel_chrome_sync.syncBorders;
/// How far an easing frame stretches its titlebar raster before rastering anew.
diff --git a/src/chrome.zig b/src/chrome.zig
index 1d768e9..3149cdb 100644
--- a/src/chrome.zig
+++ b/src/chrome.zig
@@ -12,6 +12,7 @@ const theme = @import("ui").theme;
const text = @import("ui").text;
const log = std.log.scoped(.chrome);
+const plate = @import("chrome_plate.zig");
// App dialogs use these same decoration metrics and control hit targets.
const window_chrome = @import("ui").window_chrome;
@@ -91,6 +92,9 @@ pub const ChromeState = struct {
// right, so a polygon outline's slanted ends do not cut them (`Toplevel.controlInsets`).
inset_left: i32 = 0,
inset_right: i32 = 0,
+ // The window's polygon outline in frame coordinates, if it has one: the
+ // title plate keeps an even margin inside its cut corners and steps.
+ outline: ?@import("ui").window_shape.Resolved = null,
/// The frame's width as the controls see it: less the right inset.
pub fn controlsWidth(self: ChromeState, logical_width: i32) i32 {
@@ -135,9 +139,16 @@ pub const TitlebarMemo = struct {
title_size: f32,
chrome_height: f32 = 46,
chrome_control_gap: f32 = 4,
+ chrome_control_right_pad: f32 = 12,
+ chrome_control_offset_y: f32 = 0,
chrome_round_buttons: bool = false,
top_band: [4]f32 = @splat(0),
top_band_height: f32 = 0,
+ title_plate: [4]f32 = @splat(0),
+ title_plate_width: f32 = 0,
+ title_plate_fg: ?[4]f32 = null,
+ title_plate_geometry: [5]f32 = @splat(0),
+ title_plate_outline: u64 = 0,
inset_left: i32 = 0,
inset_right: i32 = 0,
@@ -172,9 +183,16 @@ pub const TitlebarMemo = struct {
.title_size = t.title_size,
.chrome_height = t.chrome_height,
.chrome_control_gap = t.chrome_control_gap,
+ .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,
.top_band = t.window_top_band,
.top_band_height = t.window_top_band_height,
+ .title_plate = t.window_title_plate,
+ .title_plate_width = t.window_title_plate_width,
+ .title_plate_fg = t.window_title_plate_fg,
+ .title_plate_geometry = plate.geometry(t),
+ .title_plate_outline = plate.outlineKey(state),
.inset_left = state.inset_left,
.inset_right = state.inset_right,
};
@@ -215,6 +233,9 @@ pub const TitlebarMemo = struct {
inline for (.{ "glass", "border", "border_soft", "fg", "dim", "border_hover", "surface_hover", "danger", "close_fg", "workspace_active_border" }) |field| {
if (!rgbaEql(@field(a, field), @field(b, field))) return false;
}
+ if (!std.mem.eql(f32, &a.title_plate_geometry, &b.title_plate_geometry) or a.title_plate_outline != b.title_plate_outline) return false;
+ if (!rgbaEql(a.title_plate, b.title_plate) or a.title_plate_width != b.title_plate_width or !std.meta.eql(a.title_plate_fg, b.title_plate_fg)) return false;
+ if (a.chrome_control_right_pad != b.chrome_control_right_pad or a.chrome_control_offset_y != b.chrome_control_offset_y) return false;
return a.close_hover_alpha == b.close_hover_alpha and a.title_size == b.title_size and a.chrome_height == b.chrome_height and a.chrome_control_gap == b.chrome_control_gap and a.chrome_round_buttons == b.chrome_round_buttons and
rgbaEql(a.top_band, b.top_band) and a.top_band_height == b.top_band_height and a.inset_left == b.inset_left and a.inset_right == b.inset_right;
}
@@ -385,7 +406,7 @@ pub const ChromeBuffer = struct {
fn titleRect(logical_width: i32, state: ChromeState) text.Rect {
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 = controlRectScaled(state.controlsWidth(logical_width), .minimize, state.density).x;
+ 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 };
}
@@ -440,6 +461,7 @@ pub const ChromeBuffer = struct {
const icon_left: f32 = @floatFromInt(frame.state.inset_left + m.length(title_inset));
const icon_top: f32 = @floatFromInt(@divTrunc(m.titlebarHeight() - m.iconSize(), 2));
const base = Color.chrome();
+ const title_plate = plate.polygon(frame.logical_width, frame.state);
// 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.
@@ -458,6 +480,10 @@ pub const ChromeBuffer = struct {
if (px >= control_left and px <= control_right) control_run.add(x);
if (px >= icon_left and px < icon_right) icon_run.add(x);
}
+ if (title_plate != null) {
+ icon_run.start = x0;
+ icon_run.end = @max(x0, @min(x1, @as(usize, @intFromFloat(@ceil(plate.right(title_plate.?) * scale)))));
+ }
for (0..@intCast(frame.height)) |device_y| {
const py = (@as(f32, @floatFromInt(device_y)) + 0.5) / scale;
const yi: i32 = @intFromFloat(@floor(py));
@@ -469,8 +495,8 @@ pub const ChromeBuffer = struct {
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()));
+ const icon_row = title_plate != null or (frame.state.tabs.tabs.len == 0 and frame.state.icon != null and
+ py >= icon_top and py < icon_top + @as(f32, @floatFromInt(m.iconSize())));
// The icon is left of the controls, but a narrow frame can make
// the two overlap.
var runs: [2]ColumnRun = undefined;
@@ -494,12 +520,16 @@ pub const ChromeBuffer = struct {
const px = (@as(f32, @floatFromInt(shaded)) + 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_right;
- if (!in_controls and !in_icon) {
+ if (!in_controls and !in_icon and title_plate == null) {
row[shaded] = flat_color;
continue;
}
var color = row_color;
+ if (title_plate) |polygon| {
+ const distance: f32 = @floatCast(plate.distance(polygon, frame.state, px, py));
+ color = Color.fromRgba(theme.global.window_title_plate).scaled(sdf.coverage(distance * scale)).over(color);
+ }
if (in_controls) color = controls.paint(color, px, py);
if (if (frame.state.tabs.tabs.len == 0) frame.state.icon else null) |icon| {
@@ -535,12 +565,13 @@ pub const ChromeBuffer = struct {
text_clip.x = left;
text_clip.w = right - left;
}
+ const title_color = if (title_plate != null) plate.color() else Color.text();
try text.drawOpts(
frame.pixels,
frame.width,
frame.height,
frame.state.title,
- .{ .r = Color.text().r, .g = Color.text().g, .b = Color.text().b, .a = Color.text().a },
+ .{ .r = title_color.r, .g = title_color.g, .b = title_color.b, .a = title_color.a },
scale,
frame.state.titleFont(),
theme.global.title_size * m.density,
diff --git a/src/chrome_plate.zig b/src/chrome_plate.zig
new file mode 100644
index 0000000..af6ebcc
--- /dev/null
+++ b/src/chrome_plate.zig
@@ -0,0 +1,70 @@
+//! Optional angled label behind a single window title. Tabs keep their own look.
+const std = @import("std");
+const chrome = @import("chrome.zig");
+const theme = @import("ui").theme;
+const shape = @import("ui").window_shape;
+
+/// Retained chrome must include every plate geometry input in its cache key.
+pub fn geometry(t: theme.Theme) [5]f32 {
+ return .{ t.window_title_plate_inset, t.window_title_plate_bevel, t.window_title_plate_slant, t.window_title_plate_control_gap, t.window_title_plate_text_padding };
+}
+
+pub fn width(frame_width: i32, state: chrome.ChromeState) f32 {
+ const t = theme.global;
+ if (state.tabs.tabs.len > 0 or t.window_title_plate[3] <= 0) return 0;
+ const controls = chrome.controlRectScaled(state.controlsWidth(frame_width), .minimize, state.density);
+ return @max(0, @min(t.window_title_plate_width * state.density, @as(f32, @floatFromInt(controls.x)) - t.window_title_plate_control_gap * state.density));
+}
+
+pub fn titleRight(frame_width: i32, state: chrome.ChromeState) ?i32 {
+ const p = polygon(frame_width, state) orelse return null;
+ return @intFromFloat(@floor(p.points[3][0] - theme.global.window_title_plate_text_padding * state.density));
+}
+
+pub fn polygon(frame_width: i32, state: chrome.ChromeState) ?shape.Resolved {
+ const w = width(frame_width, state);
+ if (w <= 0) return null;
+ const t = theme.global;
+ const d = state.density;
+ const h = t.chrome_height * d;
+ const inset = t.window_title_plate_inset * d;
+ // An outline's cut corner is followed by `distance`, at the same margin
+ // as the top; without one the plate keeps clear of the control insets.
+ const left = (if (state.outline != null) 0 else @as(f32, @floatFromInt(state.inset_left))) + inset;
+ if (w <= left or h <= 2 * inset) return null;
+ // Clamp opposing cuts to the available space so narrow windows and large
+ // configured bevels cannot produce crossing edges.
+ const bevel = @min(t.window_title_plate_bevel * d, @min((w - left) / 2, h - 2 * inset));
+ const slant = @min(t.window_title_plate_slant * h, w - left - bevel);
+ var result: shape.Resolved = .{ .count = 5 };
+ result.points[0..5].* = .{
+ .{ left, h - inset }, .{ left, inset + bevel }, .{ left + bevel, inset },
+ .{ w - slant, inset }, .{ w, h - inset },
+ };
+ return result;
+}
+
+/// The plate's right end, at its bottom edge.
+pub fn right(p: shape.Resolved) f32 {
+ return @floatCast(p.points[4][0]);
+}
+
+/// Signed distance to the plate (negative inside): its own polygon, cut by the
+/// window outline moved in by the inset, so a chamfer or step in the outline is
+/// followed at the same even margin as the plate's straight edges.
+pub fn distance(p: shape.Resolved, state: chrome.ChromeState, px: f32, py: f32) f64 {
+ const own = shape.sdPolygon(p, px, py);
+ const outline = state.outline orelse return own;
+ return @max(own, shape.sdPolygon(outline, px, py) + theme.global.window_title_plate_inset * state.density);
+}
+
+/// What the plate takes from the outline, for the titlebar memo: 0 without one.
+pub fn outlineKey(state: chrome.ChromeState) u64 {
+ const outline = state.outline orelse return 0;
+ if (state.tabs.tabs.len > 0 or theme.global.window_title_plate[3] <= 0) return 0;
+ return std.hash.Wyhash.hash(outline.count, std.mem.sliceAsBytes(outline.points[0..outline.count])) | 1;
+}
+
+pub fn color() @import("chrome_paint.zig").Color {
+ return @import("chrome_paint.zig").Color.fromRgba(theme.global.window_title_plate_fg orelse theme.global.window_fg);
+}
diff --git a/src/chrome_tests.zig b/src/chrome_tests.zig
index bd89f7f..2823fbd 100644
--- a/src/chrome_tests.zig
+++ b/src/chrome_tests.zig
@@ -130,6 +130,17 @@ test "chrome geometry changes invalidate retained titlebar pixels" {
const round = TitlebarMemo.capture(400, 320, null, .{});
try std.testing.expect(!before.eql(round));
try std.testing.expect(!before.reusableFor(round));
+ theme.global = saved;
+ theme.global.chrome_control_right_pad = 2;
+ try std.testing.expect(!before.reusableFor(TitlebarMemo.capture(400, 320, null, .{})));
+ theme.global = saved;
+ theme.global.chrome_control_offset_y = 5;
+ try std.testing.expect(!before.reusableFor(TitlebarMemo.capture(400, 320, 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;
+ try std.testing.expect(!before.reusableFor(TitlebarMemo.capture(400, 320, null, .{})));
+ }
}
test "chrome controls fit and stay centered at every supported height and density" {
@@ -193,6 +204,18 @@ test "ShadowMemo.eql is false when softness changes" {
}
test "cached chrome updates exactly match complete rasters across hover controls and scales" {
+ const saved = theme.global;
+ defer theme.global = saved;
+ try checkCachedChromeUpdates();
+ theme.global.window_title_plate = .{ 1, 0.9, 0, 1 };
+ theme.global.window_title_plate_width = 310;
+ theme.global.window_title_plate_fg = .{ 0, 0, 0, 1 };
+ theme.global.chrome_control_right_pad = 2;
+ theme.global.chrome_control_offset_y = 5;
+ try checkCachedChromeUpdates();
+}
+
+fn checkCachedChromeUpdates() !void {
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| {
diff --git a/src/control_center/paint.zig b/src/control_center/paint.zig
index 7245309..8499a80 100644
--- a/src/control_center/paint.zig
+++ b/src/control_center/paint.zig
@@ -62,7 +62,7 @@ pub fn tick(cc: *ControlCenter, now_ms: i64) bool {
pub fn syncNavHover(cc: *ControlCenter) void {
const cell: ?ui.hover_glide.Cell = if (ui.input.current.hovered) |widget| switch (widget.kind) {
.row => |data| if (data.owner == @as(?*anyopaque, cc) and data.on_click == pageClicked)
- .{ .col = 0, .row = @intCast(cc.navIndex(@enumFromInt(data.id)) orelse return) }
+ .{ .col = 0, .row = @intCast(cc.navIndex(@fromBackingInt(@intCast(data.id))) orelse return) }
else
null,
else => null,
@@ -116,7 +116,7 @@ pub fn paintNavHighlights(owner: ?*anyopaque, list: *const Widget, renderer: *ui
const alpha = std.math.clamp(hover.alpha, 0, 1) * apart;
if (alpha > 0) {
const box = navRowBox(list, hover.row);
- renderer.fillRect(box.x, box.y, box.w, box.h, .{
+ ui.widgets.highlight.paint(renderer, box, .{
.color = scaleAlpha(t.sidebarHover(), alpha),
.radius = t.radius,
.border_width = 1,
@@ -124,7 +124,7 @@ pub fn paintNavHighlights(owner: ?*anyopaque, list: *const Widget, renderer: *ui
});
}
const box = navRowBox(list, cc.nav_selected_row);
- renderer.fillRect(box.x, box.y, box.w, box.h, .{
+ ui.widgets.highlight.paint(renderer, box, .{
.color = t.sidebarSelected(),
.radius = t.radius,
.border_width = 1,
diff --git a/src/dock/paint.zig b/src/dock/paint.zig
index da13d06..e477147 100644
--- a/src/dock/paint.zig
+++ b/src/dock/paint.zig
@@ -214,10 +214,14 @@ pub fn paintDock(self: *Self, pal: ui.theme.Theme, bg: [4]f32, looks: []const Lo
var border = pal.accent;
border[3] = 0.55;
border = pal.dock_border orelse border;
- const radius = @min(cornerRadius(pal), @as(f32, @floatFromInt(m.height)) / 2);
- self.glass_radius = radius;
- glass.Effect.configure(self.glass_effect, radius, std.math.clamp(self.reveal.value(anim.nowMs()), 0, 1));
- r.fillRect(ox, oy, @floatFromInt(self.box.width), @floatFromInt(self.box.height), .{ .color = bg, .radius = radius, .border_width = 1, .border_color = border });
+ const half = @as(f32, @floatFromInt(m.height)) / 2;
+ const radius = @min(cornerRadius(pal), half);
+ const bevel = @min(@max(0, pal.dock_bevel), half);
+ // The blur only rounds: deep enough to stay inside a cut corner (a circle
+ // of radius r clears a cut of b when 0.586 r >= b).
+ self.glass_radius = if (bevel > 0) @min(half, bevel * 1.71) else radius;
+ glass.Effect.configure(self.glass_effect, self.glass_radius, std.math.clamp(self.reveal.value(anim.nowMs()), 0, 1));
+ r.fillRect(ox, oy, @floatFromInt(self.box.width), @floatFromInt(self.box.height), .{ .color = bg, .radius = radius, .bevel = bevel, .border_width = 1, .border_color = border });
for (looks, 0..) |look, index| {
if (dirty) |box| if (!box.overlaps(self.itemCell(m, index, width, height))) continue;
self.paintItem(&r, pal, m, index, look, ox, oy);
@@ -258,12 +262,32 @@ pub fn paintItem(self: *Self, r: *ui.paint.Renderer, pal: ui.theme.Theme, m: Met
const resting = self.iconBox(index, 1, 36);
const cx = resting.x + resting.w / 2 + ox;
const cy = resting.y + resting.h / 2 + oy;
- // An enlarging icon is the hover feedback: no rectangle behind it.
- const pointer: ui.layout.ButtonState = if (zooms) .idle else button.kind.button.state;
- ui.widgets.button.paintBackground(r, .{ .x = x, .y = y, .w = button.computed_width, .h = button.computed_height }, .{ .variant = .ghost, .radius = m.size(12) }, .{ .pointer = pointer, .selected = look.focused and self.output.?.server.config.compositor.dock_active_highlight });
+ const selected = look.focused and self.output.?.server.config.compositor.dock_active_highlight;
+ const lit = selected or button.kind.button.state == .hover or button.kind.button.state == .press;
+ if (pal.dock_item_bg) |tile| {
+ // A theme's tile: always there, outlined in the accent while lit.
+ const hover_border = pal.dock_item_hover_border orelse pal.accent;
+ r.fillRect(x, y, button.computed_width, button.computed_height, .{
+ .color = tile,
+ .radius = m.size(12),
+ .bevel = m.size(pal.dock_item_bevel),
+ .border_width = if (lit) @max(1, m.size(2)) else 1,
+ .border_color = if (lit) hover_border else pal.dock_item_border orelse pal.border_soft,
+ });
+ } else {
+ // An enlarging icon is the hover feedback: no rectangle behind it.
+ const pointer: ui.layout.ButtonState = if (zooms) .idle else button.kind.button.state;
+ ui.widgets.button.paintBackground(r, .{ .x = x, .y = y, .w = button.computed_width, .h = button.computed_height }, .{ .variant = .ghost, .radius = m.size(12) }, .{ .pointer = pointer, .selected = selected });
+ }
if (look.icon) |icon| {
const rect = self.iconBox(index, look.zoom, 36);
- r.drawImageSmooth(rect.x + ox, rect.y + oy, rect.w, rect.h, 0, .{ .pixels = icon.pixels, .width = icon.size, .height = icon.size });
+ const image: ui.paint.Image = .{ .pixels = icon.pixels, .width = icon.size, .height = icon.size };
+ const grey = if (lit) 0 else std.math.clamp(pal.dock_icon_grey, 0, 1);
+ // The launcher's logo takes the start button's tint, like the taskbar's.
+ const logo_tint = if (self.shortcuts[index] == .applications) pal.start_button_logo_color else null;
+ const drained = if (logo_tint) |tint| tinted(image, tint) else if (grey > 0) greyed(image, grey) else null;
+ defer if (drained) |pixels| gpa.free(pixels);
+ r.drawImageSmooth(rect.x + ox, rect.y + oy, rect.w, rect.h, 0, if (drained) |pixels| .{ .pixels = pixels, .width = image.width, .height = image.height } else image);
} else {
const rect = self.iconBox(index, look.zoom, 34);
r.drawIcon(rect.x + ox, rect.y + oy, rect.w, rect.h, .{ .id = if (self.shortcuts[index]) |shortcut| switch (shortcut) {
@@ -306,6 +330,43 @@ pub fn paintItem(self: *Self, r: *ui.paint.Renderer, pal: ui.theme.Theme, m: Met
}
}
+/// A copy of `image` moved `amount` of the way to its luminance (Rec. 709 on
+/// the stored premultiplied values, which keeps them premultiplied). Null, and
+/// the icon drawn in colour, if the copy cannot be made.
+fn greyed(image: ui.paint.Image, amount: f32) ?[]u32 {
+ const copy = gpa.alloc(u32, image.pixels.len) catch return null;
+ const keep: u32 = @intFromFloat(@round((1 - amount) * 256));
+ for (image.pixels, copy) |pixel, *out| {
+ const r = (pixel >> 16) & 0xff;
+ const g = (pixel >> 8) & 0xff;
+ const b = pixel & 0xff;
+ const y = (r * 54 + g * 183 + b * 19) >> 8;
+ const mix = struct {
+ fn f(c: u32, lum: u32, k: u32) u32 {
+ return (lum * (256 - k) + c * k) >> 8;
+ }
+ }.f;
+ out.* = (pixel & 0xff000000) | (mix(r, y, keep) << 16) | (mix(g, y, keep) << 8) | mix(b, y, keep);
+ }
+ return copy;
+}
+
+/// A copy of `image` in one colour, keeping each pixel's coverage, as the
+/// taskbar's start button tints the logo. Null if the copy cannot be made.
+fn tinted(image: ui.paint.Image, tint: [4]f32) ?[]u32 {
+ const copy = gpa.alloc(u32, image.pixels.len) catch return null;
+ for (image.pixels, copy) |pixel, *out| {
+ const a = @as(f32, @floatFromInt(pixel >> 24)) / 255 * tint[3];
+ const channel = struct {
+ fn f(v: f32, alpha: f32) u32 {
+ return @intFromFloat(@round(std.math.clamp(v * alpha, 0, 1) * 255));
+ }
+ }.f;
+ out.* = (channel(1, a) << 24) | (channel(tint[0], a) << 16) | (channel(tint[1], a) << 8) | channel(tint[2], a);
+ }
+ return copy;
+}
+
/// What lies between and beside the buttons: the drop gap, the divider after the
/// launcher and the scroll chevrons.
pub fn paintMarks(self: *Self, r: *ui.paint.Renderer, pal: ui.theme.Theme, m: Metrics, ox: f32, oy: f32) void {
diff --git a/src/files/app_hover_tests.zig b/src/files/app_hover_tests.zig
index 84472bd..2d2d7af 100644
--- a/src/files/app_hover_tests.zig
+++ b/src/files/app_hover_tests.zig
@@ -27,6 +27,7 @@ test "retained hover repairs match complete Cairo rasters at scale 1 and 1.5" {
app.loading = false;
try testItems(&app, 12);
for ([_]bool{ false, true }) |list| {
+ ui_theme.global.app_highlight_bevel = if (list) 7 else 0;
app.list_view = list;
for ([_]f64{ 1, 1.5 }) |scale| {
const w: i32 = @intFromFloat(@as(f64, @floatFromInt(app.w)) * scale);
@@ -364,7 +365,7 @@ test "toolbar surface owns enabled hover targets and clears disabled and departe
const refresh = header.rect(app.w, false, .refresh);
app.handleMotion(refresh.x + refresh.w / 2, refresh.y + refresh.h / 2);
- try std.testing.expectEqual(@as(u64, @intFromEnum(header.Action.refresh)), app.toolbar_surface.hovered.?.id);
+ try std.testing.expectEqual(@as(u64, @backingInt(header.Action.refresh)), app.toolbar_surface.hovered.?.id);
try std.testing.expectEqual(refresh.x, app.hoveredToolbarButton().?.x);
app.handleMotion(-1, -1);
@@ -396,7 +397,6 @@ test "toolbar proximity uses shared button geometry and damages in-button motion
try std.testing.expect(app.paint_damage.?.contains(x, y));
}
-
test "dialog surface owns generic modal button hover targets" {
var app = try testApp();
defer app.deinit();
diff --git a/src/power_menu.zig b/src/power_menu.zig
index 09ea0a3..287f5dc 100644
--- a/src/power_menu.zig
+++ b/src/power_menu.zig
@@ -34,6 +34,23 @@ const tile_height: f32 = 128;
const tile_gap: f32 = 20;
const panel_padding: f32 = 32;
const panel_radius: f32 = 16;
+
+/// The theme's straight corners: the panel's, and three quarters for the tiles
+/// and the selection outline (the same ratio as their radii). Zero is rounded.
+fn panelBevel() f32 {
+ return @max(0, theme.global.power_menu_bevel);
+}
+
+fn tileBevel() f32 {
+ return panelBevel() * 0.75;
+}
+
+/// The blur behind the panel only rounds its corners. A beveled panel leaves
+/// its corner triangles empty, so the blur rounds deep enough to stay inside the
+/// bevel (a circle of radius r clears a cut of b when 0.586 r >= b).
+fn glassRadius() f32 {
+ return @max(panel_radius, panelBevel() * 1.71);
+}
const label_size: f32 = 15;
const uptime_size: f32 = 13;
const panel_width: f32 = panel_padding * 2 + tile_width * tiles.len + tile_gap * (tiles.len - 1);
@@ -207,6 +224,7 @@ pub const PowerMenu = struct {
const base = layout.RectStyle{
.color = .{ 0, 0, 0, 0 },
.radius = 12,
+ .bevel = tileBevel(),
.border_width = 2,
.border_color = t.border_soft,
};
@@ -239,7 +257,7 @@ pub const PowerMenu = struct {
.{ .kind = .container, .direction = .row, .gap = tile_gap, .height = .{ .fixed = tile_height }, .children = &menu.cards },
};
menu.root = .{
- .kind = .{ .rect = .{ .color = t.window_bg, .radius = panel_radius, .border_width = 1, .border_color = t.border } },
+ .kind = .{ .rect = .{ .color = t.window_bg, .radius = panel_radius, .bevel = panelBevel(), .border_width = 1, .border_color = t.border } },
.direction = .column,
.@"align" = .stretch,
.gap = 20,
@@ -458,7 +476,7 @@ pub const PowerMenu = struct {
a.computed_y + (b.computed_y - a.computed_y) * fraction,
a.computed_width + (b.computed_width - a.computed_width) * fraction,
a.computed_height + (b.computed_height - a.computed_height) * fraction,
- .{ .color = .{ 0, 0, 0, 0 }, .radius = 12, .border_width = if (pressed) 3 else 2.5, .border_color = border },
+ .{ .color = .{ 0, 0, 0, 0 }, .radius = 12, .bevel = tileBevel(), .border_width = if (pressed) 3 else 2.5, .border_color = border },
);
}
@@ -513,7 +531,7 @@ pub const PowerMenu = struct {
panel_present.applySlide(menu.buffer_node, menu.panel_box, t, slide_distance);
// Glass has its own opacity: fade it with the panel so the blurred
// backdrop does not linger until the closing spring settles.
- glass.Effect.configure(menu.glass_effect, panel_radius, std.math.clamp(t, 0, 1));
+ glass.Effect.configure(menu.glass_effect, glassRadius(), std.math.clamp(t, 0, 1));
const backdrop = theme.global.power_menu_backdrop;
const scrim_alpha = backdrop[3] * std.math.clamp(t, 0, 1);
if (menu.scrim.color[3] != scrim_alpha) {
diff --git a/src/tiling_grab.zig b/src/tiling_grab.zig
index 434c438..15ca5d3 100644
--- a/src/tiling_grab.zig
+++ b/src/tiling_grab.zig
@@ -43,6 +43,7 @@ pub fn begin(input: *Input, top: *Top, edges: ?wlr.Edges, button: u32) bool {
input.tiling_grab = session;
input.grabbed_toplevel = top;
input.cursor_mode = if (edges != null) .resize else .move;
+ if (edges != null) top.wakeCornerAccents();
input.move_snap.preview.hide();
input.setHover(null, null);
input.seat.pointerClearFocus();
diff --git a/src/toplevel/appearance.zig b/src/toplevel/appearance.zig
index 7bbc0bd..bc0bc1b 100644
--- a/src/toplevel/appearance.zig
+++ b/src/toplevel/appearance.zig
@@ -197,6 +197,7 @@ pub fn tickGlow(toplevel: *Toplevel, now_ms: i64) bool {
}
pub fn tickHover(toplevel: *Toplevel, now_ms: i64) bool {
+ const corners = toplevel.tickCornerAccents(now_ms);
// Every sampler must run each frame (they track their own last value).
const border = toplevel.hover_anim.sampleChanged(now_ms, anim.rasterAlphaQuantum());
const glide = toplevel.chip_pos.sampleChanged(now_ms, anim.rasterPixelQuantum(toplevel.render_scale) / chip_slot_px);
@@ -206,7 +207,7 @@ pub fn tickHover(toplevel: *Toplevel, now_ms: i64) bool {
log.err("tickHover: could not update window decoration: {}", .{err});
};
}
- return !toplevel.hover_anim.settled(now_ms) or !toplevel.chip_pos.settled(now_ms) or !toplevel.chip_alpha.settled(now_ms);
+ return corners or !toplevel.hover_anim.settled(now_ms) or !toplevel.chip_pos.settled(now_ms) or !toplevel.chip_alpha.settled(now_ms);
}
pub fn nowMs() i64 {
diff --git a/src/toplevel/chrome_sync.zig b/src/toplevel/chrome_sync.zig
index 2aa4e79..96d3c75 100644
--- a/src/toplevel/chrome_sync.zig
+++ b/src/toplevel/chrome_sync.zig
@@ -129,6 +129,7 @@ pub fn syncChrome(toplevel: *Toplevel, rebuild_shadow: bool, now_ms: i64) !void
toplevel.last_painted_hover = 0;
toplevel.syncBorders(animated.w, animated.h);
toplevel.applyShape();
+ try toplevel.syncCornerAccents();
return;
}
@@ -172,6 +173,7 @@ pub fn syncChrome(toplevel: *Toplevel, rebuild_shadow: bool, now_ms: i64) !void
const insets = toplevel.controlInsets();
state.inset_left = insets.left;
state.inset_right = insets.right;
+ state.outline = toplevel.shapePolygon(width, height);
const title_memo = chrome.TitlebarMemo.capture(width, height, toplevel.titlePtr(), state);
const skip_titlebar = if (toplevel.last_titlebar) |prev| prev.eql(title_memo) or toplevel.stretchesTitlebar(prev, title_memo, now_ms) else false;
@@ -192,6 +194,7 @@ pub fn syncChrome(toplevel: *Toplevel, rebuild_shadow: bool, now_ms: i64) !void
toplevel.syncBorders(width, height);
toplevel.applyShape();
+ try toplevel.syncCornerAccents();
toplevel.syncResizeGrab(width, height);
if (rebuild_shadow) try toplevel.syncShadow(width, height, radius);
diff --git a/src/toplevel/configure.zig b/src/toplevel/configure.zig
index b0e5149..1184d54 100644
--- a/src/toplevel/configure.zig
+++ b/src/toplevel/configure.zig
@@ -15,6 +15,7 @@ const surface = Toplevel.surface;
const nowMs = Toplevel.nowMs;
pub fn setResizing(toplevel: *Toplevel, resizing: bool) void {
+ toplevel.wakeCornerAccents();
switch (toplevel.backend) {
.xdg => |*adapter| _ = adapter.xdg_toplevel.setResizing(resizing),
.xwayland, .placeholder, .shell => {},
@@ -137,7 +138,12 @@ pub fn controlInsets(toplevel: *const Toplevel) window_shape.Insets {
const density = toplevel.chromeDensity();
const bar: f64 = @floatFromInt(toplevel.titlebarHeight());
const band: f64 = @floatFromInt((chrome.Metrics{ .density = density }).length(34));
- return window_shape.rowInsets(polygon, @floatFromInt(toplevel.chrome_width), @max(0, (bar - band) / 2), @min(bar, (bar + band) / 2));
+ var insets = window_shape.rowInsets(polygon, @floatFromInt(toplevel.chrome_width), @max(0, (bar - band) / 2), @min(bar, (bar + band) / 2));
+ if (theme.global.chrome_control_offset_y == 0) return insets;
+ // The icon stays centred while controls may sit lower under a cut corner.
+ const control = chrome.controlRectScaled(toplevel.chrome_width, .close, density);
+ insets.right = window_shape.rowInsets(polygon, @floatFromInt(toplevel.chrome_width), @floatFromInt(control.y), @floatFromInt(control.y + control.h)).right;
+ return insets;
}
pub fn ownsSurface(toplevel: *const Toplevel, candidate: *wlr.Surface) bool {
diff --git a/src/toplevel/corner_accents.zig b/src/toplevel/corner_accents.zig
new file mode 100644
index 0000000..16a1a41
--- /dev/null
+++ b/src/toplevel/corner_accents.zig
@@ -0,0 +1,157 @@
+//! Small, immutable corner rasters above the client, clipped by the same frame
+//! outline. No full-window overlay, timers, or work on unchanged client commits.
+const std = @import("std");
+const Toplevel = @import("../Toplevel.zig");
+const sn = @import("../node.zig");
+const chrome = @import("../chrome.zig");
+const PanelBuffer = @import("../panel_buffer.zig").PanelBuffer;
+const ui = @import("ui");
+
+const Memo = struct {
+ width: i32,
+ height: i32,
+ scale: f32,
+ density: f32,
+ radius: f32,
+ shape: u64,
+ color: [4]f32,
+ extent: f32,
+ stroke: f32,
+ inset: f32,
+ end_padding: f32,
+};
+
+pub const State = struct {
+ nodes: [4]?*sn.Buffer = @splat(null),
+ memo: ?Memo = null,
+ extension: ui.anim.Anim = .{},
+};
+
+fn enabled(t: *const Toplevel) bool {
+ const palette = ui.theme.global;
+ return chrome.shapes and !t.minimized and !t.closing and t.hasServerDecorations() and !t.isMaximized() and !t.isFullscreen() and
+ palette.window_corner_accent[3] > 0 and palette.window_corner_extent > 0 and palette.window_corner_width > 0;
+}
+
+/// Start feedback even if a held pointer or an unresponsive client never
+/// changes the geometry. Release/cancel gets its first frame the same way.
+pub fn wakeCornerAccents(t: *Toplevel) void {
+ if (enabled(t) and ui.theme.global.window_corner_resize_extra > 0) t.server.scheduleFrames();
+}
+
+fn retarget(t: *Toplevel, now_ms: i64) void {
+ const input = &t.server.input;
+ // The grab, rather than pending client configure acknowledgements, owns
+ // the feedback. This also includes automatic-tile split resizing.
+ const resizing = input.cursor_mode == .resize and input.grabbed_toplevel == t;
+ const target: f32 = if (resizing) ui.theme.global.window_corner_resize_extra else 0;
+ const palette = ui.theme.global;
+ const curve: ui.anim.Curve = .{ .duration = .{
+ .ms = @intFromFloat(if (resizing) palette.window_corner_resize_ms else palette.window_corner_restore_ms),
+ .ease = std.meta.stringToEnum(ui.anim.Ease, palette.window_corner_resize_ease) orelse .out_cubic,
+ } };
+ const extension = &t.corner_accents.extension;
+ // An instant transition must stay at its endpoint if reduced motion or
+ // disabled animations are subsequently turned off.
+ if (extension.active() and extension.completesInstantly()) extension.cancel(extension.to);
+ if (extension.to == target) {
+ if (extension.settled(now_ms) or std.meta.eql(extension.curve, curve)) return;
+ // Apply timing/easing edits during a drag without restarting its length.
+ extension.continueFrom(now_ms, extension.value(now_ms), target, extension.velocity(now_ms), curve);
+ } else extension.retargetTo(now_ms, target, curve);
+ if (extension.completesInstantly()) extension.cancel(target);
+ t.server.scheduleFrames();
+}
+
+pub fn tickCornerAccents(t: *Toplevel, now_ms: i64) bool {
+ const state = &t.corner_accents;
+ if (!enabled(t)) {
+ if (state.memo != null) t.syncCornerAccents() catch {};
+ state.extension.cancel(0);
+ return false;
+ }
+ retarget(t, now_ms);
+ if (state.extension.sampleChanged(now_ms, 1 / t.chromeDensity())) {
+ t.syncCornerAccents() catch |err| std.log.scoped(.chrome).warn("corner accents: {}", .{err});
+ }
+ return !state.extension.settled(now_ms);
+}
+
+pub fn syncCornerAccents(t: *Toplevel) !void {
+ const palette = ui.theme.global;
+ const state = &t.corner_accents;
+ if (!enabled(t)) {
+ for (state.nodes) |node| if (node) |n| n.node.setEnabled(false);
+ state.memo = null;
+ state.extension.cancel(0);
+ return;
+ }
+ const now_ms = Toplevel.nowMs();
+ retarget(t, now_ms);
+ const density = t.chromeDensity();
+ const memo: Memo = .{
+ .width = t.chrome_width,
+ .height = t.chrome_height,
+ .scale = t.render_scale,
+ .density = density,
+ .radius = t.cornerRadius(),
+ .shape = t.shapeKey(),
+ .color = palette.window_corner_accent,
+ // The small raster's bounds are whole logical pixels. Memoize those
+ // same lengths so subpixel animation changes cannot reraster a held bar.
+ .extent = @ceil((palette.window_corner_extent + state.extension.value(now_ms)) * density) / density,
+ .stroke = palette.window_corner_width,
+ .inset = palette.window_corner_inset,
+ .end_padding = palette.window_corner_end_padding,
+ };
+ if (state.memo) |previous| if (std.meta.eql(previous, memo)) return;
+ const extent: i32 = @intFromFloat(@ceil(@min(memo.extent * memo.density, @as(f32, @floatFromInt(@min(memo.width, memo.height))) / 2)));
+ if (extent <= 0) return;
+ const polygon = t.shapePolygon(memo.width, memo.height);
+ for (&state.nodes, 0..) |*slot, i| {
+ const x = if (i % 2 == 0) 0 else memo.width - extent;
+ const y = if (i < 2) 0 else memo.height - extent;
+ const buffer = try PanelBuffer.createUnpooled(extent, extent, memo.scale);
+ defer buffer.base.drop();
+ paint(buffer, memo, polygon, x, y, extent);
+ if (slot.* == null) {
+ const node = try t.frame_tree.createSceneBuffer(null);
+ node.point_accepts_input = struct {
+ fn accepts(_: *sn.Buffer, _: *f64, _: *f64) callconv(.c) bool {
+ return false;
+ }
+ }.accepts;
+ node.setFilterMode(.bilinear);
+ slot.* = node;
+ }
+ const node = slot.*.?;
+ node.node.setPosition(x, y);
+ node.setDestSize(extent, extent);
+ node.setBuffer(&buffer.base);
+ node.setOpacity(t.shape_opacity);
+ node.node.setEnabled(true);
+ }
+ state.memo = memo;
+}
+
+fn paint(buffer: *PanelBuffer, memo: Memo, polygon: ?ui.window_shape.Resolved, x: i32, y: i32, extent: i32) void {
+ const color = memo.color;
+ const inset = @as(f32, @floatFromInt(chrome.frame_border)) + memo.inset * memo.density;
+ for (0..@intCast(buffer.height)) |dy| {
+ const py = (@as(f32, @floatFromInt(dy)) + 0.5) / memo.scale;
+ for (0..@intCast(buffer.width)) |dx| {
+ const px = (@as(f32, @floatFromInt(dx)) + 0.5) / memo.scale;
+ const wx = px + @as(f32, @floatFromInt(x));
+ const wy = py + @as(f32, @floatFromInt(y));
+ const distance: f32 = if (polygon) |p| @floatCast(ui.window_shape.sdPolygon(p, wx, wy)) else ui.sdf.sdRoundedBox(wx, wy, 0, 0, @floatFromInt(memo.width), @floatFromInt(memo.height), memo.radius);
+ // Leave the output pass's one-pixel 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 - memo.stroke * memo.density) * memo.scale);
+ const along_x = if (x == 0) px else @as(f32, @floatFromInt(extent)) - px;
+ const along_y = if (y == 0) py else @as(f32, @floatFromInt(extent)) - py;
+ const end = ui.sdf.coverage((@max(along_x, along_y) - @as(f32, @floatFromInt(extent)) + memo.end_padding * memo.density) * memo.scale);
+ ui.text.blendPixel(&buffer.pixels[dy * @as(usize, @intCast(buffer.width)) + dx], .{ .r = color[0], .g = color[1], .b = color[2], .a = color[3] }, coverage * end);
+ }
+ }
+}
diff --git a/src/ui/AGENTS.md b/src/ui/AGENTS.md
index 30e1ffc..984c629 100644
--- a/src/ui/AGENTS.md
+++ b/src/ui/AGENTS.md
@@ -3,8 +3,16 @@
The rules every caller follows (callback owners, one look per control, app
text and colours, secrets) are in the root `AGENTS.md` ("Shared UI").
+* **Hover/selection outlines** use `widgets/highlight.zig` in Cairo item and
+ sidebar rows and Settings navigation. `app_highlight_bevel` opts into straight
+ cut corners; zero preserves each caller's rounded radius. Keep sidebar markers
+ clipped to that outline and retained repaint damage unchanged. Any widget
+ rect can cut its corners with `RectStyle.bevel` (`fillRect` hands it to
+ `highlight.fillBeveled`; no relief or `replace`). The power menu uses it
+ through `power_menu_bevel`, rounding its glass to stay inside the cut.
+
* **The scrollbar** (`widgets/scrollbar.zig`, Files' look): a thumb (track-less
- unless `scrollbar_track_relief` cuts a groove; flat at `scrollbar_glow = 0`)
+ unless painted track tokens or `scrollbar_track_relief` enable one; flat at `scrollbar_glow = 0`)
centred in a `gutter(scrollbar_width)` strip, thin at rest, widening and
tinting to the accent on hover/drag, holding a faint tint after a scroll.
`Geometry.compute` gives the thumb for any axis and unit (pixels, or items
@@ -21,6 +29,11 @@ text and colours, secrets) are in the root `AGENTS.md` ("Shared UI").
dragging and the scroll hold brighten it. `Appearance.illumination` shares
the existing frame/deadline scheduling (no idle animation). Cairo uses the
shared raster for the lit thumb, preserving its fractional device position.
+ `scrollbar_track` and `scrollbar_track_stripe` optionally paint a stationary
+ hatched channel (both transparent by default). `scrollbar.hasTrack` also
+ controls Cairo's layer bounds: include the whole channel even without relief.
+ Stripe period, width and slope also come from the theme through `Look`;
+ period/width zero hides the stripes, and slope zero draws transverse bands.
* **Text fields with child accessories** reserve text/caret room with
`field.trailing = .accessory`. Place a shared button in the field's children
(Settings search uses a ghost clear button), so normal pointer and keyboard
diff --git a/src/ui/cairo.zig b/src/ui/cairo.zig
index 9b6e58b..c96a3e2 100644
--- a/src/ui/cairo.zig
+++ b/src/ui/cairo.zig
@@ -68,7 +68,7 @@ pub const ItemBox = struct { x: f64, y: f64, w: f64, h: f64 };
pub fn drawItemHighlight(cr_any: *anyopaque, box: ItemBox, selected: bool, fill_alpha: f32, border_alpha: f32) void {
if (box.w <= 0 or box.h <= 0 or (fill_alpha <= 0 and border_alpha <= 0)) return;
const cr: *c.cairo_t = @ptrCast(cr_any);
- roundedPath(cr, box.x, box.y, box.w, box.h, @min(6, @min(box.w, box.h) / 2));
+ @import("widgets/highlight.zig").path(cr, box.x, box.y, box.w, box.h, 6);
if (fill_alpha > 0) {
var fill = if (selected) theme.global.app_item_selected else theme.global.app_item_hover;
fill[3] *= fill_alpha;
@@ -165,7 +165,7 @@ pub fn drawProximityGlow(
layer.finish();
}
-/// Sidebar hover: a plain rounded fill at `alpha`.
+/// Sidebar hover: the theme's highlight outline filled at `alpha`.
pub fn drawSidebarHover(cr_any: *anyopaque, box: Rect, alpha: f32) void {
if (box.w <= 0 or box.h <= 0 or alpha <= 0) return;
const cr: *c.cairo_t = @ptrCast(cr_any);
@@ -218,7 +218,7 @@ pub fn drawSidebarSelected(cr_any: *anyopaque, box: Rect) void {
fn sidebarRowPath(cr: *c.cairo_t, box: Rect) void {
const radius = @min(theme.global.app_sidebar_item_radius, @min(box.w, box.h) / 2);
- roundedPath(cr, box.x, box.y, box.w, box.h, radius);
+ @import("widgets/highlight.zig").path(cr, box.x, box.y, box.w, box.h, radius);
}
fn roundedPath(cr: *c.cairo_t, x: f64, y: f64, w: f64, h: f64, radius: f64) void {
@@ -252,7 +252,7 @@ pub fn drawScrollbarAt(cr_any: *anyopaque, look: scrollbar.Look, pointer: ?Point
const track = look.track;
const thumb = look.rect;
- const needs_track_layer = look.track_relief != .flat or look.thumb_relief == .raised;
+ const needs_track_layer = scrollbar.hasTrack(look) or look.thumb_relief == .raised;
const left = if (needs_track_layer) @min(track.x, thumb.x) else thumb.x;
const top = if (needs_track_layer) @min(track.y, thumb.y) else thumb.y;
const right = if (needs_track_layer) @max(track.x + track.w, thumb.x + thumb.w) else thumb.x + thumb.w;
@@ -655,6 +655,8 @@ test "a scrollbar thumb paints its look through cairo" {
c.cairo_set_operator(cr, c.CAIRO_OPERATOR_OVER);
c.cairo_scale(cr, 1.5, 1.5);
c.cairo_translate(cr, 0.25, 0.5);
+ palette.scrollbar_track = .{ 0.1, 0.1, 0.1, 1 };
+ palette.scrollbar_track_stripe = .{ 0.25, 0.25, 0.25, 1 };
var hot = scrollbar.look(g, .{ .wide = 1, .accent = 1, .shine = 1 }, 8, palette);
drawScrollbar(cr, hot);
c.cairo_surface_flush(surface);
diff --git a/src/ui/layout.zig b/src/ui/layout.zig
index 47674e3..e4941ef 100644
--- a/src/ui/layout.zig
+++ b/src/ui/layout.zig
@@ -173,6 +173,9 @@ pub const RectStyle = struct {
/// edges still blend by coverage; useful for translucent inset panels.
replace: bool = false,
radius: f32 = 0,
+ /// Straight 45-degree corners this long instead of `radius` (and without
+ /// relief or `replace`); zero keeps them rounded.
+ bevel: f32 = 0,
border_width: f32 = 0,
border_color: [4]f32 = .{ 0, 0, 0, 0 },
relief: Relief = .flat,
diff --git a/src/ui/mod.zig b/src/ui/mod.zig
index 0d7abd1..c00a038 100644
--- a/src/ui/mod.zig
+++ b/src/ui/mod.zig
@@ -11,6 +11,7 @@ pub const interaction_surface = @import("interaction_surface.zig");
pub const trackpad_navigation = @import("trackpad_navigation.zig");
pub const widgets = struct {
+ pub const highlight = @import("widgets/highlight.zig");
pub const scrollbar = @import("widgets/scrollbar.zig");
pub const splitter = @import("widgets/splitter.zig");
pub const select = @import("widgets/select.zig");
diff --git a/src/ui/paint.zig b/src/ui/paint.zig
index ffb5db7..8ae7fce 100644
--- a/src/ui/paint.zig
+++ b/src/ui/paint.zig
@@ -197,6 +197,7 @@ pub const Renderer = struct {
/// for it and `relief_depth` is set (`relief.zig`). A raised fill's shadows
/// go under it, around its edge; an inset fill's go over it, inside.
pub fn fillRect(r: *Renderer, x: f32, y: f32, w: f32, h: f32, style: RectStyle) void {
+ if (style.bevel > 0) return @import("widgets/highlight.zig").fillBeveled(r, .{ .x = x, .y = y, .w = w, .h = h }, style, style.bevel);
if (style.relief == .flat or w <= 0 or h <= 0) return r.fillRectPlain(x, y, w, h, style);
const spec = relief.Spec.from(r.palette orelse theme.global, r.scale);
if (!spec.enabled()) return r.fillRectPlain(x, y, w, h, style);
diff --git a/src/ui/theme.zig b/src/ui/theme.zig
index cf2ff60..b229a74 100644
--- a/src/ui/theme.zig
+++ b/src/ui/theme.zig
@@ -35,6 +35,9 @@ pub const Theme = struct {
chrome_height: f32 = 46.0,
/// Space between window controls, independent of their size.
chrome_control_gap: f32 = 4.0,
+ /// Right padding in the chrome's reference units; downward shift in logical px.
+ chrome_control_right_pad: f32 = 12,
+ chrome_control_offset_y: f32 = 0,
/// Circular window controls and pill-shaped tabs, including tab controls.
chrome_round_buttons: bool = false,
/// A polygon outline for server-decorated windows instead of the rounded
@@ -44,6 +47,29 @@ pub const Theme = struct {
/// logical px tall (0 draws none), clipped by the window's shape.
window_top_band: [4]f32 = .{ 0, 0, 0, 0 },
window_top_band_height: f32 = 0,
+ /// Angled title plate, capped before the window controls. Zero width disables it.
+ window_title_plate: [4]f32 = .{ 0, 0, 0, 0 },
+ window_title_plate_width: f32 = 0,
+ window_title_plate_fg: ?[4]f32 = null,
+ window_title_plate_inset: f32 = 5,
+ window_title_plate_bevel: f32 = 7,
+ /// Right slant as a fraction of chrome_height; gaps/padding are logical px.
+ window_title_plate_slant: f32 = 0.65,
+ window_title_plate_control_gap: f32 = 8,
+ window_title_plate_text_padding: f32 = 8,
+ /// Short strokes following the actual frame outline at its four corners.
+ window_corner_accent: [4]f32 = .{ 0, 0, 0, 0 },
+ window_corner_extent: f32 = 0,
+ /// Extra length during an interactive resize (zero leaves corners static).
+ window_corner_resize_extra: f32 = 0,
+ window_corner_width: f32 = 3,
+ /// Inset beyond the frame's own border ring, and padding at stroke endpoints.
+ window_corner_inset: f32 = 0,
+ window_corner_end_padding: f32 = 2,
+ window_corner_resize_ms: f32 = 140,
+ window_corner_restore_ms: f32 = 180,
+ /// out_cubic, in_out_sine or flip_bezier; global animation preferences still apply.
+ window_corner_resize_ease: []const u8 = "out_cubic",
// Window decorations use neutral charcoal independently of shell glass.
window_bg: [4]f32 = .{ @as(f32, 7.6) / 255.0, 9.0 / 255.0, 11.0 / 255.0, 0.80 }, // 80% darkness and opacity
// Neutral foregrounds keep text and monochrome icons free of a blue tint.
@@ -82,6 +108,8 @@ pub const Theme = struct {
app_sidebar_selected_marker: ?[4]f32 = null,
/// Corners of sidebar row highlights (hover and selection).
app_sidebar_item_radius: f32 = 5,
+ /// Straight 45-degree corners on sidebar and item highlights; zero stays rounded.
+ app_highlight_bevel: f32 = 0,
app_surface_hover: ?[4]f32 = null,
app_menu_bg: ?[4]f32 = null,
app_field_bg: ?[4]f32 = null,
@@ -89,6 +117,18 @@ pub const Theme = struct {
dock_bg: ?[4]f32 = null,
dock_border: ?[4]f32 = null,
dock_radius: f32 = 0, // zero follows the window frame radius
+ /// Straight 45-degree corners on the dock instead of `dock_radius`; zero is rounded.
+ dock_bevel: f32 = 0,
+ /// A resting tile behind every dock icon (unset: none, the ghost button's
+ /// hover only), its outline, and the outline while hovered, pressed or the
+ /// highlighted active app (unset: the accent). Corners cut by `dock_item_bevel`.
+ dock_item_bg: ?[4]f32 = null,
+ dock_item_border: ?[4]f32 = null,
+ dock_item_hover_border: ?[4]f32 = null,
+ dock_item_bevel: f32 = 0,
+ /// How far dock icons are drained of colour at rest (0 keeps them, 1 is
+ /// grey); a hovered icon, or the highlighted active app, shows its colours.
+ dock_icon_grey: f32 = 0,
notification_bg: ?[4]f32 = null,
notification_fg: ?[4]f32 = null,
notification_dim: ?[4]f32 = null,
@@ -119,6 +159,14 @@ pub const Theme = struct {
scrollbar_thumb: [4]f32 = .{ 89.0 / 255.0, 98.0 / 255.0, 110.0 / 255.0, 1 }, // #59626e
/// Unset follows the surface accent during hover/drag.
scrollbar_thumb_active: ?[4]f32 = null,
+ /// Optional stationary diagonal hatching, shared by Cairo and widget bars.
+ scrollbar_track: [4]f32 = .{ 0, 0, 0, 0 },
+ scrollbar_track_stripe: [4]f32 = .{ 0, 0, 0, 0 },
+ /// Pattern distances along the bar; slope 1 is diagonal, 0 is transverse.
+ /// Zero period or width hides the stripes, retaining the track fill.
+ scrollbar_track_stripe_period: f32 = 10,
+ scrollbar_track_stripe_width: f32 = 5,
+ scrollbar_track_stripe_slope: f32 = 1,
/// Strength of the light on a hovered/dragged/scrolling thumb (1 = subtle,
/// 0 = a flat thumb: no highlight stripe, only the colour feedback).
scrollbar_glow: f32 = 1.0,
@@ -434,6 +482,9 @@ pub const Theme = struct {
start_button_radius: f32 = 6,
polkit_backdrop: [4]f32 = .{ 0, 0, 0, 0.55 },
power_menu_backdrop: [4]f32 = .{ 0, 0, 0, 0.45 },
+ /// Straight 45-degree corners on the power menu panel, logical px; its tiles
+ /// and selection outline take three quarters. Zero keeps them rounded.
+ power_menu_bevel: f32 = 0,
mini_map_bg_opacity: f32 = 0.91,
mini_map_grid_alpha: f32 = 0.065,
mini_map_border_alpha: f32 = 0.12,
diff --git a/src/ui/theme_file.zig b/src/ui/theme_file.zig
index d29c3d1..e8c2e89 100644
--- a/src/ui/theme_file.zig
+++ b/src/ui/theme_file.zig
@@ -139,6 +139,9 @@ pub fn applyKey(allocator: Allocator, t: *Theme, name_in: []const u8, value: []c
if (comptime std.mem.eql(u8, name, "window_shape") or std.mem.eql(u8, name, "taskbar_shape")) {
_ = try window_shape.parse(text);
}
+ if (comptime std.mem.eql(u8, name, "window_corner_resize_ease")) {
+ _ = std.meta.stringToEnum(@import("anim.zig").Ease, text) orelse return error.InvalidEase;
+ }
@field(t, name) = try allocator.dupe(u8, text);
return;
}
@@ -165,6 +168,9 @@ pub fn applyKey(allocator: Allocator, t: *Theme, name_in: []const u8, value: []c
if (comptime std.mem.eql(u8, name, "chrome_control_gap")) {
if (number > 24) return error.InvalidSize;
}
+ if (comptime std.mem.eql(u8, name, "window_title_plate_slant")) {
+ if (number > 1) return error.InvalidSize;
+ }
if (comptime std.mem.eql(u8, name, "taskbar_length")) {
if (number < 20 or number > 100) return error.InvalidSize;
}
diff --git a/src/ui/theme_presets.zig b/src/ui/theme_presets.zig
index f13ef33..39fa44c 100644
--- a/src/ui/theme_presets.zig
+++ b/src/ui/theme_presets.zig
@@ -15,4 +15,5 @@ pub const bundled = [_]Preset{
// Hidden from the picker until the theme is ready.
// .{ .id = "chamfer-blue", .name = "Chamfer Blue", .bytes = @embedFile("theme-chamfer-blue") },
.{ .id = "gold", .name = "Gold", .bytes = @embedFile("theme-gold") },
+ .{ .id = "blackout", .name = "Blackout", .bytes = @embedFile("theme-blackout") },
};
diff --git a/src/ui/theme_tests.zig b/src/ui/theme_tests.zig
index 51ff718..76ed4e4 100644
--- a/src/ui/theme_tests.zig
+++ b/src/ui/theme_tests.zig
@@ -285,7 +285,6 @@ test "chrome geometry validates and survives theme serialization" {
try std.testing.expect(restored.chrome_round_buttons);
}
-
test "component relief theme keys parse, inherit, and reject invalid values" {
const Relief = theme.Relief;
try std.testing.expect(theme_file.knownKey("button_relief"));
@@ -428,3 +427,27 @@ test "relief keys of the remaining widgets parse, default to flat and round-trip
try std.testing.expectEqual(Relief.flat, defaults.settings_card_relief);
try std.testing.expectEqual(Relief.flat, defaults.taskbar_chip_active_relief);
}
+
+test "decoration geometry and resize easing are validated theme data" {
+ var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer arena.deinit();
+ const a = arena.allocator();
+ var t: Theme = .{};
+ try std.testing.expectError(error.InvalidEase, applyKey(a, &t, "window_corner_resize_ease", "\"unknown\""));
+ try std.testing.expectError(error.InvalidSize, applyKey(a, &t, "window_title_plate_slant", "1.1"));
+ try applyKey(a, &t, "window_corner_resize_ease", "\"in_out_sine\"");
+ try applyKey(a, &t, "window_corner_resize_ms", "400");
+ try applyKey(a, &t, "window_corner_restore_ms", "350");
+ try applyKey(a, &t, "scrollbar_track_stripe_period", "14");
+ try applyKey(a, &t, "scrollbar_track_stripe_width", "3");
+ try applyKey(a, &t, "scrollbar_track_stripe_slope", "0.5");
+ var bytes: std.ArrayList(u8) = .empty;
+ try writeInto(a, &bytes, t);
+ const restored = try parse(a, bytes.items);
+ try std.testing.expectEqualStrings("in_out_sine", restored.window_corner_resize_ease);
+ try std.testing.expectEqual(@as(f32, 400), restored.window_corner_resize_ms);
+ try std.testing.expectEqual(@as(f32, 350), restored.window_corner_restore_ms);
+ try std.testing.expectEqual(@as(f32, 14), restored.scrollbar_track_stripe_period);
+ try std.testing.expectEqual(@as(f32, 3), restored.scrollbar_track_stripe_width);
+ try std.testing.expectEqual(@as(f32, 0.5), restored.scrollbar_track_stripe_slope);
+}
diff --git a/src/ui/widgets/highlight.zig b/src/ui/widgets/highlight.zig
new file mode 100644
index 0000000..b462d57
--- /dev/null
+++ b/src/ui/widgets/highlight.zig
@@ -0,0 +1,74 @@
+//! Shared highlight geometry for Cairo app rows and shell navigation rows.
+const std = @import("std");
+const c = @import("c_gfx");
+const theme = @import("../theme.zig");
+const paint_mod = @import("../paint.zig");
+const layout = @import("../layout.zig");
+
+pub fn path(cr: *c.cairo_t, x: f64, y: f64, w: f64, h: f64, radius: f64) void {
+ const bevel = @min(theme.global.app_highlight_bevel, @min(w, h) / 2);
+ c.cairo_new_sub_path(cr);
+ if (bevel > 0) {
+ c.cairo_move_to(cr, x + bevel, y);
+ c.cairo_line_to(cr, x + w - bevel, y);
+ c.cairo_line_to(cr, x + w, y + bevel);
+ c.cairo_line_to(cr, x + w, y + h - bevel);
+ c.cairo_line_to(cr, x + w - bevel, y + h);
+ c.cairo_line_to(cr, x + bevel, y + h);
+ c.cairo_line_to(cr, x, y + h - bevel);
+ c.cairo_line_to(cr, x, y + bevel);
+ } else {
+ const r = @min(radius, @min(w, h) / 2);
+ c.cairo_arc(cr, x + w - r, y + r, r, -std.math.pi / 2.0, 0);
+ c.cairo_arc(cr, x + w - r, y + h - r, r, 0, std.math.pi / 2.0);
+ c.cairo_arc(cr, x + r, y + h - r, r, std.math.pi / 2.0, std.math.pi);
+ c.cairo_arc(cr, x + r, y + r, r, std.math.pi, 3 * std.math.pi / 2.0);
+ }
+ c.cairo_close_path(cr);
+}
+
+pub fn paint(r: *paint_mod.Renderer, box: paint_mod.ClipRect, style: layout.RectStyle) void {
+ const bevel = (r.palette orelse theme.global).app_highlight_bevel;
+ if (bevel <= 0) {
+ r.fillRect(box.x, box.y, box.w, box.h, style);
+ return;
+ }
+ fillBeveled(r, box, style, bevel);
+}
+
+/// A box with straight 45-degree corners `bevel` long (capped at half its
+/// shorter side), filled and bordered like `Renderer.fillRect`.
+pub fn fillBeveled(r: *paint_mod.Renderer, box: paint_mod.ClipRect, style: layout.RectStyle, wanted: f32) void {
+ if (box.w <= 0 or box.h <= 0) return;
+ const bevel = @min(wanted, @min(box.w, box.h) / 2);
+ var clip = box;
+ if (r.effectiveClip()) |limit| clip = paint_mod.intersectClip(clip, limit);
+ const s = r.scale;
+ const x0: i32 = @intFromFloat(@floor(@max(0, clip.x * s)));
+ const y0: i32 = @intFromFloat(@floor(@max(0, clip.y * s)));
+ const x1: i32 = @intFromFloat(@ceil(@min(@as(f32, @floatFromInt(r.width)), (clip.x + clip.w) * s)));
+ const y1: i32 = @intFromFloat(@ceil(@min(@as(f32, @floatFromInt(r.height)), (clip.y + clip.h) * s)));
+ const half_w = box.w / 2;
+ const half_h = box.h / 2;
+ r.clean = false;
+ var py = y0;
+ while (py < y1) : (py += 1) {
+ const y = @abs((@as(f32, @floatFromInt(py)) + 0.5) / s - box.y - half_h);
+ var px = x0;
+ while (px < x1) : (px += 1) {
+ const x = @abs((@as(f32, @floatFromInt(px)) + 0.5) / s - box.x - half_w);
+ const distance = @max(@max(x - half_w, y - half_h), (x + y - half_w - half_h + bevel) / std.math.sqrt2);
+ const outer = paint_mod.sdf.coverage(distance * s);
+ const inner = paint_mod.sdf.coverage((distance + style.border_width) * s);
+ const index: usize = @intCast(py * r.width + px);
+ const fill = style.color;
+ paint_mod.blendPixel(&r.pixels[index], .{ .r = fill[0], .g = fill[1], .b = fill[2], .a = fill[3] }, outer);
+ const border = style.border_color;
+ paint_mod.blendPixel(&r.pixels[index], .{ .r = border[0], .g = border[1], .b = border[2], .a = border[3] }, @max(0, outer - inner));
+ }
+ }
+}
+
+test {
+ _ = @import("highlight_tests.zig");
+}
diff --git a/src/ui/widgets/highlight_tests.zig b/src/ui/widgets/highlight_tests.zig
new file mode 100644
index 0000000..f1fc960
--- /dev/null
+++ b/src/ui/widgets/highlight_tests.zig
@@ -0,0 +1,37 @@
+const std = @import("std");
+const c = @import("c_gfx");
+const theme = @import("../theme.zig");
+const paint = @import("../paint.zig");
+const highlight = @import("highlight.zig");
+
+test "beveled highlights cut straight corners in Cairo and shell rasters" {
+ const saved = theme.global;
+ defer theme.global = saved;
+ const surface = c.cairo_image_surface_create(c.CAIRO_FORMAT_ARGB32, 40, 24).?;
+ defer c.cairo_surface_destroy(surface);
+ const cr = c.cairo_create(surface).?;
+ defer c.cairo_destroy(cr);
+ const box: paint.ClipRect = .{ .x = 2, .y = 2, .w = 36, .h = 20 };
+ // These points are inside a rounded corner but outside a 7px bevel.
+ for ([_]f32{ 0, 7 }) |bevel| {
+ theme.global.app_highlight_bevel = bevel;
+ c.cairo_new_path(cr);
+ highlight.path(cr, box.x, box.y, box.w, box.h, 5);
+ for ([_]f64{ 4.5, 35.5 }) |x| {
+ for ([_]f64{ 4.5, 19.5 }) |y| {
+ try std.testing.expectEqual(bevel == 0, c.cairo_in_fill(cr, x, y) != 0);
+ }
+ }
+ try std.testing.expect(c.cairo_in_fill(cr, 20, 3) != 0);
+ for ([_]f32{ 1, 1.5 }) |scale| {
+ var pixels: [60 * 36]u32 = @splat(0);
+ var renderer = paint.Renderer.init(&pixels, 60, 36, scale);
+ highlight.paint(&renderer, box, .{ .color = .{ 1, 1, 0, 1 }, .radius = 5 });
+ const corner: usize = @intFromFloat(@floor(4.5 * scale));
+ const face_x: usize = @intFromFloat(20 * scale);
+ try std.testing.expectEqual(bevel == 0, pixels[corner * 60 + corner] != 0);
+ try std.testing.expect(pixels[corner * 60 + face_x] != 0);
+ try std.testing.expectEqual(@as(u32, 0), pixels[0]);
+ }
+ }
+}
diff --git a/src/ui/widgets/scrollbar.zig b/src/ui/widgets/scrollbar.zig
index a8f71f5..2db1cf0 100644
--- a/src/ui/widgets/scrollbar.zig
+++ b/src/ui/widgets/scrollbar.zig
@@ -1,8 +1,8 @@
// The shell's one scrollbar, as Files draws it: a thumb that sits centred in a
// reserved gutter, thin at rest, widening and tinting toward the accent under
-// the pointer, and holding a subtle tint while scrolling. It has no track
-// unless the theme sets `scrollbar_track_relief`, which cuts a groove for the
-// thumb; `scrollbar_glow = 0` makes the thumb itself flat. Apps
+// the pointer, and holding a subtle tint while scrolling. Tracks are opt-in:
+// `scrollbar_track_relief` cuts a groove, `scrollbar_track` paints its floor,
+// and `scrollbar_track_stripe` adds hatching. `scrollbar_glow = 0` makes the thumb flat. Apps
// keep their own scroll mechanics and ask this module for the geometry, the
// paging and drag arithmetic, the look and the feedback animation, so every
// scrollbar behaves alike: Files, Images, PDF and the editor through Cairo
@@ -149,6 +149,11 @@ pub const Look = struct {
track_radius: f32,
track_color: [4]f32,
track_relief: theme.Relief = .flat,
+ track_fill: [4]f32 = .{ 0, 0, 0, 0 },
+ track_stripe: [4]f32 = .{ 0, 0, 0, 0 },
+ stripe_period: f32 = 10,
+ stripe_width: f32 = 5,
+ stripe_slope: f32 = 1,
thumb_relief: theme.Relief = .flat,
rect: Rect,
radius: f32,
@@ -194,7 +199,7 @@ pub fn look(g: Geometry, state: Appearance, configured: f32, palette: theme.Them
}
// Nested corners: the groove's radius is the thumb's plus the margin between.
const track_radius = @min(cornerRadius(track_thickness) + 1.5, track_thickness / 2);
- return .{ .track = track_rect, .track_radius = track_radius, .track_color = track_color, .track_relief = palette.scrollbar_track_relief, .thumb_relief = palette.scrollbar_thumb_relief, .rect = rect, .radius = cornerRadius(thickness), .color = color, .axis = g.axis, .highlight = highlight, .shine = state.shine, .glow = @max(palette.scrollbar_glow, 0) };
+ return .{ .stripe_period = palette.scrollbar_track_stripe_period, .stripe_width = palette.scrollbar_track_stripe_width, .stripe_slope = palette.scrollbar_track_stripe_slope, .track_fill = palette.scrollbar_track, .track_stripe = palette.scrollbar_track_stripe, .track = track_rect, .track_radius = track_radius, .track_color = track_color, .track_relief = palette.scrollbar_track_relief, .thumb_relief = palette.scrollbar_thumb_relief, .rect = rect, .radius = cornerRadius(thickness), .color = color, .axis = g.axis, .highlight = highlight, .shine = state.shine, .glow = @max(palette.scrollbar_glow, 0) };
}
/// Whether `l`'s thumb gets the lit-edge raster. A flat thumb (`scrollbar_glow`
@@ -203,10 +208,16 @@ pub fn lit(l: Look) bool {
return l.shine > 0 and l.glow > 0;
}
-/// The groove; nothing at all while the theme leaves the track flat. It stays
+pub fn hasTrack(l: Look) bool {
+ return l.track_relief != .flat or l.track_fill[3] > 0 or (l.track_stripe[3] > 0 and l.stripe_period > 0 and l.stripe_width > 0);
+}
+
+/// The optional painted track and groove. It stays
/// inside the track's own box, so the gutter's damage covers it.
pub fn paintTrack(r: *@import("../paint.zig").Renderer, l: Look) void {
- if (l.track_relief == .flat or l.track.w <= 0 or l.track.h <= 0) return;
+ if (!hasTrack(l) or l.track.w <= 0 or l.track.h <= 0) return;
+ @import("scrollbar_track.zig").paint(r, l);
+ if (l.track_relief == .flat) return;
r.fillRect(l.track.x, l.track.y, l.track.w, l.track.h, .{
.color = l.track_color,
.radius = l.track_radius,
diff --git a/src/ui/widgets/scrollbar_track.zig b/src/ui/widgets/scrollbar_track.zig
new file mode 100644
index 0000000..50d7317
--- /dev/null
+++ b/src/ui/widgets/scrollbar_track.zig
@@ -0,0 +1,44 @@
+//! Static hatching in track-local coordinates: scrolling never animates it.
+const scrollbar = @import("scrollbar.zig");
+const paint_mod = @import("../paint.zig");
+const sdf = @import("../sdf.zig");
+
+pub fn paint(r: *paint_mod.Renderer, l: scrollbar.Look) void {
+ const box = l.track;
+ r.fillRect(box.x, box.y, box.w, box.h, .{ .color = l.track_fill, .radius = l.track_radius });
+ if (l.track_stripe[3] <= 0 or l.stripe_period <= 0 or l.stripe_width <= 0) return;
+ const period = l.stripe_period;
+ const half_width = @min(l.stripe_width, period) / 2;
+ const normal = @sqrt(1 + l.stripe_slope * l.stripe_slope);
+ const s = r.scale;
+ var left = box.x;
+ var top = box.y;
+ var right = box.x + box.w;
+ var bottom = box.y + box.h;
+ if (r.effectiveClip()) |clip| {
+ left = @max(left, clip.x);
+ top = @max(top, clip.y);
+ right = @min(right, clip.x + clip.w);
+ bottom = @min(bottom, clip.y + clip.h);
+ }
+ const x0: i32 = @intFromFloat(@floor(@max(0, left * s)));
+ const y0: i32 = @intFromFloat(@floor(@max(0, top * s)));
+ const x1: i32 = @intFromFloat(@ceil(@min(@as(f32, @floatFromInt(r.width)), right * s)));
+ const y1: i32 = @intFromFloat(@ceil(@min(@as(f32, @floatFromInt(r.height)), bottom * s)));
+ const color = l.track_stripe;
+ r.clean = false;
+ var py = y0;
+ while (py < y1) : (py += 1) {
+ const y = (@as(f32, @floatFromInt(py)) + 0.5) / s - box.y;
+ var px = x0;
+ while (px < x1) : (px += 1) {
+ const x = (@as(f32, @floatFromInt(px)) + 0.5) / s - box.x;
+ const edge = sdf.coverage(sdf.sdRoundedBox(x, y, 0, 0, box.w, box.h, l.track_radius) * s);
+ const along = if (l.axis == .vertical) y else x;
+ const across = if (l.axis == .vertical) x else y;
+ const phase = @mod(across * l.stripe_slope + along, period);
+ const stripe = sdf.coverage((@abs(phase - period / 2) - half_width) * s / normal);
+ if (edge * stripe > 0) paint_mod.blendPixel(&r.pixels[@intCast(py * r.width + px)], .{ .r = color[0], .g = color[1], .b = color[2], .a = color[3] }, edge * stripe);
+ }
+ }
+}
diff --git a/src/ui/window_chrome.zig b/src/ui/window_chrome.zig
index eb69cd7..c156e4b 100644
--- a/src/ui/window_chrome.zig
+++ b/src/ui/window_chrome.zig
@@ -19,7 +19,6 @@ pub const ControlKind = enum { minimize, maximize, close };
// Charcoal header with evenly spaced, unboxed window controls.
pub const frame_border: i32 = 1;
-const titlebar_pad_right: i32 = 12;
const btn_size: i32 = 34;
const close_size: i32 = 34;
// Preserve the original icon/control proportions when changing bar height.
@@ -81,25 +80,29 @@ 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 close_x = frame_width - frame_border - m.length(titlebar_pad_right) - m.length(close_size);
+ 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 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));
return switch (kind) {
.close => .{
.x = close_x,
- .y = @divTrunc(m.titlebarHeight() - m.length(close_size), 2),
+ .y = y,
.w = m.length(close_size),
.h = m.length(close_size),
},
.maximize => .{
.x = max_x,
- .y = @divTrunc(m.titlebarHeight() - m.length(btn_size), 2),
+ .y = y,
.w = m.length(btn_size),
.h = m.length(btn_size),
},
.minimize => .{
.x = min_x,
- .y = @divTrunc(m.titlebarHeight() - m.length(btn_size), 2),
+ .y = y,
.w = m.length(btn_size),
.h = m.length(btn_size),
},
diff --git a/tests/blackout.py b/tests/blackout.py
new file mode 100644
index 0000000..02aa9e9
--- /dev/null
+++ b/tests/blackout.py
@@ -0,0 +1,151 @@
+#!/usr/bin/env python3
+"""Blackout chrome, shared striped tracks, and live removal at both raster scales."""
+import os
+from pathlib import Path
+import subprocess
+import tempfile
+
+from PIL import Image
+from desktop_zoom import wait_for
+from ipc_client import IPCClient, spawn_compositor, stop_process
+from ui_driver import UIDriver
+
+ROOT = Path(__file__).resolve().parents[1]
+
+
+def yellow(pixel):
+ return pixel[0] > 180 and pixel[1] > 170 and pixel[2] < 60
+
+
+def run(scale):
+ with tempfile.TemporaryDirectory(prefix="rediwm-blackout-") as directory:
+ tmp = Path(directory)
+ home = tmp / "home"
+ home.mkdir()
+ for index in range(80):
+ (home / f"Folder {index:02}").mkdir()
+ env = dict(HOME=str(home), XDG_DATA_HOME=str(tmp / "data"),
+ XDG_CONFIG_HOME=str(tmp / "config"), XDG_CACHE_HOME=str(tmp / "cache"),
+ XDG_STATE_HOME=str(tmp / "state"), DBUS_SESSION_BUS_ADDRESS="",
+ DBUS_SYSTEM_BUS_ADDRESS="unix:path=/nonexistent", REDIWM_FILES_DEVICES="0")
+ env.pop("REDIWM_THEME", None)
+ env.pop("REDIWM_SOCKET", None)
+ config = ('[compositor]\nxwayland = false\nfocus_zoom = "keep"\n'
+ '[desktop]\nenabled = false\n[animations]\nenabled = false\n'
+ '[theme]\nbase = "blackout"\n')
+ process, log = spawn_compositor(tmp, scale=str(scale), config_content=config, env_extra=env)
+ files = None
+ try:
+ with IPCClient(tmp, timeout=20) as ipc:
+ assert "blackout" in {p["id"] for p in ipc.query("theme.list")["packs"]}
+ display = wait_for(lambda: next((p.name for p in tmp.glob("wayland-*")
+ if not p.name.endswith(".lock")), None), "display")
+ files = subprocess.Popen([str(ROOT / "zig-out/bin/rediwm-files"), str(home)],
+ env=dict(os.environ, **env, XDG_RUNTIME_DIR=str(tmp), WAYLAND_DISPLAY=display,
+ REDIWM_CONFIG=str(tmp / "rediwm-config.toml")),
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ win = wait_for(lambda: next((w for w in ipc.get_windows()
+ if w["app_id"] == "rediwm-files"), None), "Files")
+ wid = win["id"]
+ ipc.set_zoom(wid, 100)
+ ipc.action("set_window_size", {"id": wid, "width": 900, "height": 500})
+ wait_for(lambda: ipc.get_window_debug(wid)["client_box"]["width"] == 900, "initial resize")
+ ipc.action("move_window_to", {"id": wid, "x": 70, "y": 70})
+ ipc.focus_window(wid)
+ ipc.move_cursor(10, 10)
+ ipc.wait_for("window_geometry_settled", window_id=wid)
+
+ def capture():
+ ipc.wait_for_frame()
+ path = tmp / "shot.png"
+ path.unlink(missing_ok=True)
+ ipc.screenshot(str(path))
+ image = Image.open(path).convert("RGB")
+ image.save(f"/tmp/blackout-latest-{scale}.png")
+ return image
+
+ def crop(image, box, rect):
+ x, y, w, h = rect
+ return image.crop(tuple(round(v * scale) for v in
+ (box["x"] + x, box["y"] + y, box["x"] + x + w, box["y"] + y + h)))
+
+ def corners(image):
+ box = ipc.get_window_debug(wid)["chrome_box"]
+ return [sum(yellow(p) for p in crop(image, box, (x, y, 28, 28)).getdata())
+ for x, y in ((0, 0), (box["width"] - 28, 0),
+ (0, box["height"] - 28),
+ (box["width"] - 28, box["height"] - 28))]
+
+ def folders_ready():
+ image = capture()
+ box = ipc.get_window_debug(wid)["client_box"]
+ area = crop(image, box, (230, 110, box["width"] - 260, box["height"] - 140))
+ return image if sum(yellow(p) for p in area.getdata()) > 300 else None
+
+ shot = wait_for(folders_ready, "yellow pack folder artwork")
+ assert all(n > 20 * scale for n in corners(shot)), corners(shot)
+ body = ipc.get_window_debug(wid)["client_box"]
+ # The overflowing Files viewport must use the shared charcoal
+ # track and its lighter hatch, even below the resting thumb.
+ track = crop(shot, body, (body["width"] - 18, 100, 18, body["height"] - 130))
+ colors = dict((color, count) for count, color in track.getcolors(track.width * track.height))
+ assert colors.get((26, 32, 33), 0) > 30, colors
+ assert colors.get((52, 61, 62), 0) > 30, colors
+ debug = ipc.get_window_debug(wid)
+ 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
+ assert close["y"] + close["height"] / 2 > debug["titlebar_height"] / 2 + 3, close
+ # Keep a real rendered preview for review (never the reference image).
+ shot.save(f"/tmp/blackout-preview-{scale}.png")
+
+ from blackout_resize import check_resize
+ check_resize(ipc, wid, scale, tmp, capture, crop, yellow)
+
+ from blackout_config import check_config
+ check_config(ipc, wid, scale, tmp, capture, crop, yellow)
+
+ # 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")
+ ipc.wait_for("window_geometry_settled", window_id=wid)
+ counts = corners(capture())
+ assert all(n > 20 * scale for n in counts), (counts, ipc.get_window_debug(wid))
+ controls = {w["name"]: w for w in ipc.get_widget_tree(f"window/{wid}")["widgets"]}
+ UIDriver(ipc).click(controls["maximize"])
+ wait_for(lambda: ipc.get_window_debug(wid)["maximized"], "maximize")
+ # Switching away releases the decoration visually, including
+ # after restoring from a rectangular maximized frame.
+ ipc.action("theme.apply", {"id": "rediwm-dark"})
+ controls = {w["name"]: w for w in ipc.get_widget_tree(f"window/{wid}")["widgets"]}
+ UIDriver(ipc).click(controls["maximize"])
+ wait_for(lambda: not ipc.get_window_debug(wid)["maximized"], "restore")
+ ipc.wait_for("window_geometry_settled", window_id=wid)
+ ipc.move_cursor(10, 10)
+ assert not any(corners(capture())), "stale corner accents after theme switch"
+ ipc.action("theme.apply", {"id": "blackout"})
+ ipc.wait_for("window_geometry_settled", window_id=wid)
+ counts = corners(capture())
+ assert all(n > 20 * scale for n in counts), (counts, ipc.get_window_debug(wid))
+ controls = {w["name"]: w for w in ipc.get_widget_tree(f"window/{wid}")["widgets"]}
+ UIDriver(ipc).click(controls["minimize"])
+ wait_for(lambda: ipc.get_window_debug(wid)["minimized"], "shifted minimize target")
+ ipc.restore(wid)
+ ipc.wait_for("window_geometry_settled", window_id=wid)
+ UIDriver(ipc).click(controls["close"])
+ wait_for(lambda: not any(w["id"] == wid for w in ipc.get_windows()), "shifted close target")
+ print(f"PASS: Blackout frame, striped Files track, controls and reload (scale={scale})")
+ except Exception:
+ print((tmp / "compositor.log").read_text())
+ raise
+ finally:
+ if files:
+ stop_process(files)
+ stop_process(process)
+ log.close()
+
+
+if __name__ == "__main__":
+ os.environ.pop("REDIWM_THEME", None)
+ run(1)
+ run(1.5)
diff --git a/tests/blackout_config.py b/tests/blackout_config.py
new file mode 100644
index 0000000..a31e5f3
--- /dev/null
+++ b/tests/blackout_config.py
@@ -0,0 +1,65 @@
+"""Verify decoration rendering depends on theme data, including live overrides."""
+from pathlib import Path
+import tomllib
+
+from desktop_zoom import wait_for
+
+
+def check_config(ipc, wid, scale, tmp, capture, crop, yellow):
+ config_path = tmp / "rediwm-config.toml"
+ original = config_path.read_text()
+ # The same pack under an unrelated ID must retain all decoration features.
+ source = Path(__file__).resolve().parents[1] / "assets/themes/blackout.toml"
+ pack = tmp / "data/rediwm/themes/config-audit"
+ pack.mkdir(parents=True)
+ manifest = source.read_text().replace('id = "blackout"', 'id = "config-audit"', 1)
+ manifest = manifest.replace('name = "Blackout"', 'name = "Config audit"', 1)
+ (pack / "theme.toml").write_text(manifest)
+ try:
+ ipc.action("theme.apply", {"id": "config-audit"})
+ ipc.wait_for_frame()
+ assert tomllib.loads(config_path.read_text())["theme"]["base"] == "config-audit"
+ 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"
+ body = ipc.get_window_debug(wid)["client_box"]
+ track_box = (body["width"] - 18, 120, 18, 160)
+ old_track = crop(before, body, track_box).tobytes()
+ values = {
+ "window_title_plate_inset": 10,
+ "window_title_plate_bevel": 2,
+ "window_title_plate_slant": 0.25,
+ "window_title_plate_control_gap": 20,
+ "window_title_plate_text_padding": 12,
+ "window_corner_inset": 1,
+ "window_corner_end_padding": 8,
+ "scrollbar_track_stripe_period": 16,
+ "scrollbar_track_stripe_width": 3,
+ "scrollbar_track_stripe_slope": 0.5,
+ }
+ overrides = "\n".join(f"{key} = {value}" for key, value in values.items())
+ config_path.write_text(config_path.read_text().replace("[theme]", "[theme]\n" + overrides, 1))
+ ipc.reload_config()
+ tokens = ipc.action("get_theme")["tokens"]
+ for key, value in values.items():
+ assert abs(tokens[key] - value) < .001, (key, tokens[key], value)
+
+ def changed():
+ image = capture()
+ if yellow(image.getpixel(sample)):
+ return None
+ if crop(image, body, track_box).tobytes() == old_track:
+ return None
+ return image
+
+ after = wait_for(changed, "live plate/stripe geometry overrides")
+ def endpoint(image):
+ strip = crop(image, box, (0, box["height"] - 4, 80, 3))
+ return max((x for x in range(strip.width)
+ if any(yellow(strip.getpixel((x, y))) for y in range(strip.height))), default=0)
+ assert 5 * scale <= endpoint(before) - endpoint(after) <= 7 * scale, "corner padding ignored"
+ finally:
+ config_path.write_text(original)
+ ipc.reload_config()
+ ipc.wait_for_frame()
diff --git a/tests/blackout_resize.py b/tests/blackout_resize.py
new file mode 100644
index 0000000..91be69b
--- /dev/null
+++ b/tests/blackout_resize.py
@@ -0,0 +1,109 @@
+"""Interactive corner feedback checks, called by the Blackout visual suite."""
+import time
+
+from desktop_zoom import wait_for
+
+
+def check_resize(ipc, wid, scale, tmp, capture, crop, yellow):
+ config_path = tmp / "rediwm-config.toml"
+ original = config_path.read_text()
+ animated = original.replace('[animations]\nenabled = false',
+ '[animations]\nenabled = true\nreduced_motion = "off"')
+ now = int(time.monotonic() * 1000) + 10000
+
+ def step(ms):
+ ipc.action("set_anim_time", {"ms": now + ms})
+ ipc.wait_for_frame()
+
+ def length():
+ image = capture()
+ box = ipc.get_window_debug(wid)["chrome_box"]
+ strip = crop(image, box, (0, box["height"] - 4, 80, 3))
+ return max((x for x in range(strip.width)
+ if any(yellow(strip.getpixel((x, y))) for y in range(strip.height))), default=0)
+
+ def begin():
+ box = ipc.get_window_debug(wid)["chrome_box"]
+ x, y = box["x"] + box["width"] + 2, box["y"] + box["height"] // 2
+ ipc.move_cursor(x, y)
+ ipc.pointer_button(272, True)
+ ipc.wait_for_frame()
+ assert ipc.get_input_state()["cursor_mode"] == "resize", ipc.get_input_state()
+ return x, y
+
+ try:
+ step(0)
+ config_path.write_text(animated)
+ ipc.reload_config()
+ ipc.wait_for_frame()
+ resting = length()
+ old_width = ipc.get_window_debug(wid)["client_box"]["width"]
+ x, y = begin()
+ step(35)
+ growing = length()
+ step(160)
+ extended = length()
+ assert resting < growing < extended, (resting, growing, extended)
+ assert 16 * scale <= extended - resting <= 20 * scale, (resting, extended)
+ # The held grab lights the corners before any size change, and the
+ # length survives an actual client configure/commit during the drag.
+ ipc.move_cursor(x + 40, y)
+ wait_for(lambda: ipc.get_window_debug(wid)["client_box"]["width"] > old_width, "resize commit")
+ assert length() == extended
+ capture().save(f"/tmp/blackout-resizing-{scale}.png")
+ ipc.pointer_button(272, False)
+ ipc.wait_for_frame()
+ step(195)
+ shrinking = length()
+ step(400)
+ assert resting < shrinking < extended, (resting, shrinking, extended)
+ assert length() == resting
+
+ # Hiding a window interrupts a resize even while its button is held.
+ begin()
+ step(600)
+ assert length() == extended
+ ipc.minimize(wid)
+ assert ipc.get_input_state()["cursor_mode"] == "passthrough"
+ ipc.pointer_button(272, False)
+ step(850)
+ ipc.restore(wid)
+ step(1850)
+ ipc.move_cursor(10, 10)
+ assert length() == resting, "corner feedback stuck after an interrupted resize"
+
+ # Reduced motion keeps the feedback, but reaches both endpoints immediately.
+ config_path.write_text(animated.replace('reduced_motion = "off"', 'reduced_motion = "on"'))
+ ipc.reload_config()
+ begin()
+ assert length() == extended, "reduced-motion resize did not extend immediately"
+ ipc.pointer_button(272, False)
+ ipc.wait_for_frame()
+ assert length() == resting, "reduced-motion release did not restore immediately"
+ # Pack defaults can be overridden by config: both timing and the
+ # easing curve must change, as well as the endpoint length.
+ config_path.write_text(animated + '\nwindow_corner_resize_extra = 30\n'
+ 'window_corner_resize_ms = 400\nwindow_corner_restore_ms = 350\n'
+ 'window_corner_resize_ease = "in_out_sine"\n')
+ ipc.reload_config()
+ step(2000)
+ begin()
+ step(2100)
+ slow = length()
+ assert resting < slow < resting + 10 * scale, (resting, slow)
+ step(2450)
+ longer = length()
+ assert 28 * scale <= longer - resting <= 32 * scale, (resting, longer)
+ ipc.pointer_button(272, False)
+ ipc.wait_for_frame()
+ step(2700)
+ assert resting < length() < longer, "configured restore duration was ignored"
+ step(2850)
+ assert length() == resting
+ finally:
+ ipc.pointer_button(272, False)
+ config_path.write_text(original)
+ ipc.reload_config()
+ ipc.action("set_anim_time", {"ms": None})
+ ipc.move_cursor(10, 10)
+ ipc.wait_for_frame()
diff --git a/tests/theme_packs.py b/tests/theme_packs.py
index 9b9611b..8231fc3 100644
--- a/tests/theme_packs.py
+++ b/tests/theme_packs.py
@@ -197,7 +197,7 @@ def run():
try:
with IPCClient(tmp, timeout=30) as ipc:
before = ipc.query("theme.list")
- assert {p["id"] for p in before["packs"]} >= {"rediwm-dark", "rediwm-light", "redi-blue", "redi-mocha", "gold"}
+ assert {p["id"] for p in before["packs"]} >= {"rediwm-dark", "rediwm-light", "redi-blue", "redi-mocha", "gold", "blackout"}
mocha = next(p for p in before["packs"] if p["id"] == "redi-mocha")
assert mocha["name"] == "Redi-Mocha" and not mocha["user_installed"], mocha
ipc.action("theme.apply", {"id": "redi-mocha"})