Skip to content

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

icons and dock enhancements

oxydizer92ad6511b199
diff --git a/README.md b/README.md
index 2b57c7e..43b0a69 100644
--- a/README.md
+++ b/README.md
@@ -199,7 +199,7 @@ older canvas save while in workspace mode updates the saved return-to-canvas sta
- **Mouse:** Alt+drag moves windows, Alt+right-drag resizes. Super+Alt+drag (or middle-drag) pans the desktop, Super+Alt+scroll zooms it, and Alt+scroll zooms a single window.
- **Zoom on window switch:** `[compositor] focus_zoom` (also in Settings → Appearance) controls what Alt+Tab, directional focus and taskbar activation do. `"boost"` (default) shows the window at 100% until you switch away, `"keep"` only pans, and `"camera"` zooms the desktop to the window's depth.
-- **Dock:** enable **RediWM dock** in Settings → Appearance (`[compositor] dock_enabled = true`, off by default). The compact dock sits above a bottom taskbar, with Applications, Files, Terminal, running windows and Settings. Click a window to focus/restore it or minimize the focused window; scroll the dock to reach overflow windows. It hides on the focused fullscreen window’s display.
+- **Dock:** enable **RediWM dock** in Settings → Appearance (`[compositor] dock_enabled = true`, off by default). The compact dock sits above a bottom taskbar, with Applications, Files, Terminal, running windows and Settings. Appearance’s **Dock height** slider offers 48–96px (68px by default; `[compositor] dock_height`), resizing icons, spacing and click targets together. Files, Terminal and Settings share their shortcut with running windows and show a pill underneath, including configured default apps. The pill smoothly grows, shrinks and fades with focus and app state, following the animation and reduced-motion settings. Click a running icon to focus/restore its app or minimize the focused window; scroll the dock to reach overflow windows. Right-click a running icon for Close, Force Close, or Remove from dock; idle shortcuts offer Remove from dock. Removal leaves apps running and is remembered across restarts in `dock_hidden_apps` (app IDs) and `dock_hidden_shortcuts` (`applications`, `files`, `terminal`, `settings`). A removed shortcut also hides the app it represents. Remove entries from those lists to restore items. Windows without an app ID are hidden for their lifetime. It hides on the focused fullscreen window’s display.
- **Window tabs:** enable per app in Settings → Appearance (saved in `[compositor] window_tab_apps`). **+** opens a new window as a tab. The app needs a desktop entry with a launch command.
- **Lock screen:** covers every output and engages before suspend (`[compositor] lock_on_suspend`) and on `loginctl lock-session`. There's no idle lock; add `swayidle -w timeout 300 'swaylock -f'` to `[[autostart]]`.
- **Desktop icons:** a `.desktop` launcher only runs if it's installed, root-owned, executable, or an exact copy of an installed entry. Otherwise, choose **Allow Launching** from its menu.
diff --git a/TESTING.md b/TESTING.md
index 269514f..b4d15cc 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -134,7 +134,7 @@ Network settings, password/hidden forms, saved and open joins, radio, wired
details, connect/disconnect and permission errors, service restart and scrolling;
`--settings-only` runs just the settings checks), `battery_popup.py` (fake sysfs and private power-profile
service; charge states, missing details, selection and dismissal),
-`keyboard_shortcuts.py`, `dock.py` (opt-in Appearance toggle, persistence, launcher/input, running windows, fullscreen and scale),
+`keyboard_shortcuts.py`, `dock.py` (opt-in Appearance toggle, bounded height slider, live resizing and size persistence, launcher/input, shared shortcut icons and running pills, smooth pill animation/reversals and idle scheduling, preferred apps and terminal fallback, running windows, fullscreen, scale, live radius, context menu and remembered removal),
`panel_damage.py`, `glass_hold.py` (holds and
mixed-scale idle), `glass_reblur.py` (glass re-blurs for changes below it,
never for its own client), `animations.py`, `hotspots.py`, `launch_feedback.py`,
diff --git a/assets/icons/gold/blank-file.png b/assets/icons/gold/blank-file.png
new file mode 100644
index 0000000..53237db
Binary files /dev/null and b/assets/icons/gold/blank-file.png differ
diff --git a/assets/icons/gold/browser.png b/assets/icons/gold/browser.png
new file mode 100644
index 0000000..62d7eea
Binary files /dev/null and b/assets/icons/gold/browser.png differ
diff --git a/assets/icons/gold/folder.png b/assets/icons/gold/folder.png
new file mode 100644
index 0000000..69509c0
Binary files /dev/null and b/assets/icons/gold/folder.png differ
diff --git a/assets/icons/gold/home.png b/assets/icons/gold/home.png
new file mode 100644
index 0000000..4346b48
Binary files /dev/null and b/assets/icons/gold/home.png differ
diff --git a/assets/icons/gold/settings.png b/assets/icons/gold/settings.png
new file mode 100644
index 0000000..01d103a
Binary files /dev/null and b/assets/icons/gold/settings.png differ
diff --git a/assets/icons/gold/terminal.png b/assets/icons/gold/terminal.png
new file mode 100644
index 0000000..058475e
Binary files /dev/null and b/assets/icons/gold/terminal.png differ
diff --git a/assets/icons/gold/trash.png b/assets/icons/gold/trash.png
new file mode 100644
index 0000000..fc16736
Binary files /dev/null and b/assets/icons/gold/trash.png differ
diff --git a/assets/icons/gold/txt-file.png b/assets/icons/gold/txt-file.png
new file mode 100644
index 0000000..88dcd81
Binary files /dev/null and b/assets/icons/gold/txt-file.png differ
diff --git a/assets/themes/redi-mocha.toml b/assets/themes/redi-mocha.toml
new file mode 100644
index 0000000..50beb67
--- /dev/null
+++ b/assets/themes/redi-mocha.toml
@@ -0,0 +1,144 @@
+[meta]
+format = 1
+id = "redi-mocha"
+name = "Redi-Mocha"
+version = "1.0"
+description = "Catppuccin Mocha with mauve accents and the Auckland skyline."
+
+[theme]
+# Catppuccin Mocha: https://catppuccin.com/palette/#mocha
+# Base #1e1e2e, mantle #181825, crust #11111b; mauve #cba6f7.
+# Keep RediWM's default fonts and geometry.
+
+# Window chrome
+window_bg = "rgba(24,24,37,0.80)"
+window_fg = "#cdd6f4"
+window_dim = "#bac2de"
+window_border = "#45475a"
+window_border_hover = "#cba6f7"
+workspace_active_border = "#cba6f7"
+window_divider = "#313244"
+window_close_hover = "#f38ba8"
+window_close_fg = "#11111b"
+
+# App windows (Files, Images, PDF, Editor)
+text_secondary = "#bac2de"
+app_bg = "#1e1e2e"
+app_toolbar = "#181825"
+app_sidebar = "#181825"
+app_bar = "#313244"
+app_item = "#1e1e2e"
+app_item_hover = "#313244"
+app_item_border = "#45475a"
+app_item_selected = "rgba(203,166,247,0.20)"
+app_nav_selected = "rgba(203,166,247,0.20)"
+app_git_added = "#a6e3a1"
+app_divider = "#313244"
+app_icon = "#bac2de"
+scrollbar_thumb = "#6c7086"
+scrollbar_thumb_active = "#cba6f7"
+
+# Shell palette
+bg = "#11111b"
+fg = "#cdd6f4"
+dim = "#bac2de"
+faint = "#a6adc8"
+accent = "#cba6f7"
+accent_2 = "#89b4fa"
+accent_3 = "#f5c2e7"
+danger = "#f38ba8"
+on_accent = "#11111b"
+shell_accent = "#cba6f7"
+shell_on_accent = "#11111b"
+shell_border_focus = "#cba6f7"
+surface = "#313244"
+surface_hover = "#45475a"
+border = "#45475a"
+border_soft = "#313244"
+border_hover = "#585b70"
+border_focus = "#cba6f7"
+glass = "rgba(30,30,46,0.56)"
+glass_strong = "rgba(24,24,37,0.74)"
+shadow = "rgba(17,17,27,0.55)"
+
+# Taskbar and shared controls
+taskbar_bg = "rgba(24,24,37,0.96)"
+taskbar_surface = "#313244"
+taskbar_hover = "#45475a"
+taskbar_border = "#45475a"
+start_button_logo_color = "#cba6f7"
+start_button_hover = "rgba(203,166,247,0.12)"
+start_button_indicator = "#cba6f7"
+toggle_track = "#45475a"
+control_thumb = "#cdd6f4"
+slider_track = "#45475a"
+pill_bg = "#313244"
+swatch_border = "#585b70"
+swatch_border_selected = "#cba6f7"
+settings_card_bg = "#313244"
+
+# Start menu and fields; caret and text selection follow the accent.
+start_menu_bg = "rgba(30,30,46,0.98)"
+start_menu_border = "#45475a"
+start_menu_search_bg = "#11111b"
+start_menu_selected_bg = "rgba(203,166,247,0.15)"
+start_menu_selected_border = "rgba(203,166,247,0.40)"
+start_menu_selected_marker = "#cba6f7"
+field_bg = "#11111b"
+field_border = "#585b70"
+selection_alpha = 0.30
+
+# Lock screen, window switcher, calendar and overlays
+lock_bg = "#11111b"
+lock_fg = "#cdd6f4"
+lock_dim = "#a6adc8"
+lock_divider = "#45475a"
+lock_session_fg = "#bac2de"
+switcher_bg = "#181825"
+switcher_border = "#45475a"
+switcher_item_bg = "#1e1e2e"
+switcher_item_border = "#45475a"
+switcher_fg = "#cdd6f4"
+switcher_dim = "#a6adc8"
+switcher_icon_bg = "#313244"
+switcher_selected_border = "#cba6f7"
+calendar_border = "#45475a"
+osd_border = "#45475a"
+screenshot_border = "#cba6f7"
+screenshot_fg = "#cdd6f4"
+screenshot_label_bg = "rgba(24,24,37,0.95)"
+screenshot_label_border = "#45475a"
+battery_bg = "rgba(17,17,27,0.28)"
+battery_full = "#a6e3a1"
+battery_low = "#f9e2af"
+battery_critical = "#f38ba8"
+battery_shimmer = "#94e2d5"
+
+# Desktop selections and file artwork
+desktop_fg = "#cdd6f4"
+desktop_hover = "rgba(203,166,247,0.08)"
+desktop_selected = "rgba(203,166,247,0.20)"
+desktop_selection = "rgba(203,166,247,0.15)"
+desktop_selection_border = "#cba6f7"
+desktop_drop_border = "rgba(203,166,247,0.80)"
+desktop_dialog_bg = "rgba(30,30,46,0.98)"
+desktop_notice_bg = "rgba(49,50,68,0.95)"
+desktop_icon_start = "#89b4fa"
+desktop_icon_end = "#cba6f7"
+file_broken = "#f38ba8"
+file_folder_back = "#89b4fa"
+file_folder_front = "#b4befe"
+file_document = "#bac2de"
+file_document_lines = "#45475a"
+file_spinner = "#cba6f7"
+image_checker_dark = "#1e1e2e"
+image_checker_light = "#313244"
+image_crop_border = "#cdd6f4"
+image_crop_grid = "rgba(205,214,244,0.40)"
+pdf_loading = "#a6adc8"
+pdf_search_match = "rgba(249,226,175,0.40)"
+pdf_search_match_active = "rgba(250,179,135,0.65)"
+
+[assets]
+color_scheme = "dark"
+wallpaper = "wallpaper-mocha.png"
diff --git a/assets/wallpapers/wallpaper-gold.png b/assets/wallpapers/wallpaper-gold.png
new file mode 100644
index 0000000..be7969a
Binary files /dev/null and b/assets/wallpapers/wallpaper-gold.png differ
diff --git a/assets/wallpapers/wallpaper-mocha.png b/assets/wallpapers/wallpaper-mocha.png
new file mode 100644
index 0000000..3011a9a
Binary files /dev/null and b/assets/wallpapers/wallpaper-mocha.png differ
diff --git a/src/Dock.zig b/src/Dock.zig
index d5b9295..fd31baa 100644
--- a/src/Dock.zig
+++ b/src/Dock.zig
@@ -1,4 +1,4 @@
-//! Optional output-local launcher. Retained rasters; no animation or polling timer.
+//! Optional output-local launcher. Retained rasters; animation uses output frames.
const std = @import("std");
const wlr = @import("wlroots");
const ui = @import("ui");
@@ -7,24 +7,60 @@ const Toplevel = @import("Toplevel.zig");
const IconEntry = @import("icon_service.zig").Entry;
const PanelBuffer = @import("panel_buffer.zig").PanelBuffer;
const SceneData = @import("scene_data.zig").SceneData;
+const glass = @import("glass.zig");
+const apps = @import("start_menu/applications.zig");
+const default_apps = @import("config_runtime/default_apps.zig");
+const config = @import("config").loader;
+const anim = ui.anim;
const gpa = @import("main.zig").gpa;
const Self = @This();
-const height = 68;
-const step = 56;
const max_items = 64;
+pub const Shortcut = enum { applications, files, terminal, settings };
+
+/// Scale the original 68px layout in logical pixels, independently of output scale.
+const Metrics = struct {
+ height: i32,
+
+ fn size(self: Metrics, reference: f32) f32 {
+ return reference * @as(f32, @floatFromInt(self.height)) / @as(f32, @floatFromInt(config.dock_height_default));
+ }
+
+ fn length(self: Metrics, reference: f32) i32 {
+ return @max(1, @as(i32, @intFromFloat(@round(self.size(reference)))));
+ }
+
+ fn itemStep(self: Metrics) i32 {
+ return self.length(56);
+ }
+
+ fn padding(self: Metrics) i32 {
+ return self.length(12);
+ }
+};
+
+const Pill = struct {
+ shortcut: ?Shortcut = null,
+ id: u64 = 0,
+ width: anim.Anim = .{},
+ opacity: anim.Anim = .{ .property = .opacity },
+};
output: ?*Output = null,
tree: ?*wlr.SceneTree = null,
node: ?*wlr.SceneBuffer = null,
tooltip: ?*wlr.SceneBuffer = null,
+glass_effect: ?*glass.Effect = null,
data: SceneData = undefined,
-box: wlr.Box = .{ .x = 0, .y = 0, .width = 0, .height = height },
+box: wlr.Box = .{ .x = 0, .y = 0, .width = 0, .height = config.dock_height_default },
scale: f32 = 0,
dirty: bool = true,
visible: bool = false,
root: ui.layout.Widget = .{ .kind = .container },
buttons: [max_items]ui.layout.Widget = undefined,
ids: [max_items]u64 = @splat(0),
+shortcuts: [max_items]?Shortcut = @splat(null),
+pills: [max_items]Pill = @splat(.{}),
+pills_animating: bool = false,
count: usize = 0,
offset: usize = 0,
windows: usize = 0,
@@ -37,6 +73,7 @@ drawn: u64 = 0,
tip_drawn: u64 = 0,
pub fn deinit(self: *Self) void {
+ if (self.output) |output| if (output.server.input.window_menu.dock == self) output.server.input.window_menu.close();
self.dispatcher.reset();
if (self.tree) |tree| tree.node.destroy();
self.arena.deinit();
@@ -58,23 +95,26 @@ fn ensureNodes(self: *Self, output: *Output) !void {
self.tree = tree;
self.node = node;
self.tooltip = tooltip;
- if (@import("glass.zig").Engine.attach(output.server.glass_engine, node, &node.node, .taskbar)) |effect| effect.configure(16, 1);
+ self.glass_effect = glass.Engine.attach(output.server.glass_engine, node, &node.node, .taskbar);
}
fn ignoreInput(_: *wlr.SceneBuffer, _: *f64, _: *f64) callconv(.c) bool {
return false;
}
-pub fn tick(self: *Self, output: *Output) void {
+pub fn tick(self: *Self, output: *Output, now_ms: i64) bool {
const server = output.server;
if (!server.config.compositor.dock_enabled or server.greeter_mode or !output.isAvailable() or output.idle_blanked) {
if (self.tree != null) self.deinit();
- return;
+ return false;
}
- self.ensureNodes(output) catch return;
+ self.ensureNodes(output) catch return false;
const focused = @import("ipc/handlers.zig").findFocusedToplevel(server);
const usable = output.usableBox();
- const visible = server.locker == null and usable.width >= 260 and usable.height >= 140 and
+ const m: Metrics = .{ .height = @intCast(server.config.compositor.dock_height) };
+ const shortcut_count = self.shortcutCount();
+ const min_width = @max(260, @as(i32, @intCast(shortcut_count)) * m.itemStep() + m.padding() * 2 + 12);
+ const visible = server.locker == null and usable.width >= min_width and usable.height >= @max(140, m.height + 72) and
!(if (focused) |top| top.fullscreen and top.currentOutput() == output else false);
self.tree.?.node.setEnabled(visible);
if (self.visible != visible) {
@@ -82,31 +122,122 @@ pub fn tick(self: *Self, output: *Output) void {
self.leave();
self.dirty = true;
}
- if (!visible) return;
+ if (!visible) {
+ if (server.input.window_menu.dock == self) server.input.window_menu.close();
+ return false;
+ }
if (self.scale != output.wlr_output.scale) self.dirty = true;
+ if (self.box.height != m.height) self.dirty = true;
// Output geometry can change without a window or theme notification.
- const capacity: usize = @intCast(@min(max_items - 4, @max(0, @divTrunc(usable.width - 40, step) - 4)));
- const wanted = @min(capacity, self.windows) + 4;
- if (self.box.width != @as(i32, @intCast(wanted)) * step + 24) self.dirty = true;
- if (self.dirty) self.rebuild(capacity, usable) catch return;
+ const capacity: usize = @intCast(@min(max_items - shortcut_count, @max(0, @divTrunc(usable.width - m.padding() * 2 - 16, m.itemStep()) - @as(i32, @intCast(shortcut_count)))));
+ const wanted = @min(capacity, self.windows) + shortcut_count;
+ if (self.box.width != @as(i32, @intCast(wanted)) * m.itemStep() + m.padding() * 2) self.dirty = true;
+ const rebuilt = self.dirty;
+ if (rebuilt) self.rebuild(capacity, usable) catch return false;
+ self.tree.?.node.setEnabled(self.count > 0);
+ if (self.count == 0) {
+ self.pills_animating = false;
+ return false;
+ }
+ if (rebuilt or self.pills_animating) self.paint(now_ms) catch return false;
self.place(usable);
self.tree.?.node.setPosition(self.box.x, self.box.y);
+ return self.pills_animating;
+}
+
+fn hidden(items: []const []const u8, name: []const u8) bool {
+ for (items) |item| if (std.mem.eql(u8, item, name)) return true;
+ return false;
+}
+
+fn shortcutShown(self: *Self, shortcut: Shortcut) bool {
+ return !hidden(self.output.?.server.config.compositor.dock_hidden_shortcuts, @tagName(shortcut));
+}
+
+fn shortcutCount(self: *Self) usize {
+ var count: usize = 0;
+ for (std.enums.values(Shortcut)) |shortcut| if (self.shortcutShown(shortcut)) {
+ count += 1;
+ };
+ return count;
}
fn place(self: *Self, usable: wlr.Box) void {
self.box.x = usable.x + @divTrunc(usable.width - self.box.width, 2);
- self.box.y = usable.y + usable.height - height - 10;
+ self.box.y = usable.y + usable.height - self.box.height - 10;
+}
+
+fn metrics(self: *const Self) Metrics {
+ return .{ .height = self.box.height };
+}
+
+const AppMatch = struct {
+ id: []const u8 = "",
+ wm_class: ?[]const u8 = null,
+
+ fn fromEntry(entry: *const apps.AppEntry) AppMatch {
+ return .{ .id = entry.id, .wm_class = entry.startup_wm_class };
+ }
+
+ fn matches(self: AppMatch, top: *Toplevel) bool {
+ return @import("placeholder_match.zig").matchesAppId(@import("window_tabs.zig").identity(top.appId()), self.wm_class, self.id);
+ }
+};
+
+/// Resolve the same preferred applications and fallbacks as launchPreferred.
+/// Snapshot strings stay alive for this rebuild; parsed argv lives in scratch.
+fn shortcutApps(self: *Self, entries: []const apps.AppEntry, scratch: std.mem.Allocator) [4]AppMatch {
+ const server = self.output.?.server;
+ var matches: [4]AppMatch = .{ .{}, .{ .id = "rediwm-files" }, .{ .id = "foot" }, .{ .id = Toplevel.settings_app_id } };
+ if (default_apps.find(entries, server.config.compositor.default_file_manager)) |entry| matches[@intFromEnum(Shortcut.files)] = .fromEntry(entry);
+ if (default_apps.find(entries, server.config.compositor.default_terminal)) |entry| {
+ matches[@intFromEnum(Shortcut.terminal)] = .fromEntry(entry);
+ } else {
+ const parseExec = @import("start_menu/launch.zig").parseExec;
+ const argv = parseExec(scratch, server.environ.getPosix("TERMINAL") orelse "foot", null) catch return matches;
+ if (argv.len == 0) return matches;
+ const executable = std.fs.path.basename(argv[0]);
+ matches[@intFromEnum(Shortcut.terminal)] = .{ .id = executable };
+ for (entries) |*entry| {
+ if (!default_apps.matches(entry.*, .terminal)) continue;
+ const command = parseExec(scratch, entry.exec, entry) catch continue;
+ if (command.len > 0 and std.mem.eql(u8, std.fs.path.basename(command[0]), executable)) {
+ matches[@intFromEnum(Shortcut.terminal)] = .fromEntry(entry);
+ break;
+ }
+ }
+ }
+ return matches;
}
fn rebuild(self: *Self, capacity: usize, usable: wlr.Box) !void {
const output = self.output.?;
+ const previous_pills = self.pills;
+ const previous_count = self.count;
+ const snapshot = output.server.start_menu_catalog.retainSnapshot();
+ defer snapshot.release();
+ var scratch = std.heap.ArenaAllocator.init(gpa);
+ defer scratch.deinit();
+ const matches = self.shortcutApps(snapshot.entries, scratch.allocator());
+ var targets: [4]?*Toplevel = @splat(null);
+ const focused = @import("ipc/handlers.zig").findFocusedToplevel(output.server);
var tops: std.ArrayList(*Toplevel) = .empty;
defer tops.deinit(gpa);
var it = output.server.world.toplevels.iterator(.forward);
- while (it.next()) |top| {
- if (!top.in_world or top.closing or top.backend_gone or top.tab_hidden or
+ windows: while (it.next()) |top| {
+ if (!top.in_world or top.closing or top.backend_gone or top.tab_hidden or top.dock_hidden or
+ hidden(output.server.config.compositor.dock_hidden_apps, top.appId()) or
!@import("workspaces.zig").visible(top) or (top.live_rules.skip_taskbar orelse false) or
(output.server.world.workspaces.active and top.currentOutput() != output)) continue;
+ for ([_]Shortcut{ .files, .terminal, .settings }) |shortcut| {
+ if (!matches[@intFromEnum(shortcut)].matches(top)) continue;
+ const target = &targets[@intFromEnum(shortcut)];
+ // A removed shortcut also hides the app it represents. Keep the
+ // focused window, then a visible window, then the most recent one.
+ if (self.shortcutShown(shortcut) and (target.* == null or
+ (target.*.? != focused and (top == focused or (target.*.?.minimized and !top.minimized))))) target.* = top;
+ continue :windows;
+ }
try tops.append(gpa, top);
}
std.mem.sort(*Toplevel, tops.items, {}, struct {
@@ -116,23 +247,39 @@ fn rebuild(self: *Self, capacity: usize, usable: wlr.Box) !void {
}.less);
self.windows = tops.items.len;
self.offset = @min(self.offset, self.windows -| capacity);
- self.count = @min(capacity, self.windows) + 4;
- self.box.width = @as(i32, @intCast(self.count)) * step + 24;
+ const window_count = @min(capacity, self.windows);
+ self.count = window_count + self.shortcutCount();
+ self.box.height = @intCast(output.server.config.compositor.dock_height);
+ const m = self.metrics();
+ self.box.width = @as(i32, @intCast(self.count)) * m.itemStep() + m.padding() * 2;
self.scale = output.wlr_output.scale;
const hovered = self.dispatcher.hovered != null;
self.dispatcher.reset();
_ = self.arena.reset(.retain_capacity);
- self.root = .{ .kind = .container, .children = self.buttons[0..self.count], .computed_width = @floatFromInt(self.box.width), .computed_height = height };
- for (self.buttons[0..self.count], 0..) |*button, index| {
- self.ids[index] = if (index >= 3 and index < self.count - 1) tops.items[self.offset + index - 3].id else 0;
- button.* = .{
- .name = if (index == 0) "applications" else if (index == 1) "files" else if (index == 2) "terminal" else if (index == self.count - 1) "settings" else std.fmt.allocPrint(self.arena.allocator(), "window_{d}", .{self.ids[index]}) catch "window",
- .kind = .{ .button = .{ .label = self.arena.allocator().dupe(u8, self.label(index)) catch "Application", .variant = .ghost, .owner = self, .id = index, .on_click = clicked } },
- .computed_x = @as(f32, @floatFromInt(index * step)) + 12,
- .computed_y = 8,
- .computed_width = 48,
- .computed_height = 48,
- };
+ self.root = .{ .kind = .container, .children = self.buttons[0..self.count], .computed_width = @floatFromInt(self.box.width), .computed_height = @floatFromInt(self.box.height) };
+ var index: usize = 0;
+ for ([_]Shortcut{ .applications, .files, .terminal }) |shortcut| {
+ if (!self.shortcutShown(shortcut)) continue;
+ self.setButton(index, shortcut, if (targets[@intFromEnum(shortcut)]) |top| top.id else 0);
+ index += 1;
+ }
+ for (tops.items[self.offset .. self.offset + window_count]) |top| {
+ self.setButton(index, null, top.id);
+ index += 1;
+ }
+ if (self.shortcutShown(.settings)) self.setButton(index, .settings, if (targets[@intFromEnum(Shortcut.settings)]) |top| top.id else 0);
+ for (self.pills[0..self.count], 0..) |*pill, i| {
+ const shortcut = self.shortcuts[i];
+ const id = self.ids[i];
+ pill.* = .{ .shortcut = shortcut, .id = id };
+ // Widget indexes move as windows open or items are removed. A
+ // shortcut keeps its animation when its representative window changes.
+ for (previous_pills[0..previous_count]) |previous| {
+ if (previous.shortcut == shortcut and (shortcut != null or previous.id == id)) {
+ pill.* = previous;
+ break;
+ }
+ }
}
// The pointer rests on a replaced button: hover it before painting, so
// the rebuild paints once.
@@ -141,10 +288,23 @@ fn rebuild(self: *Self, capacity: usize, usable: wlr.Box) !void {
const cursor = output.server.input.cursor;
self.dispatcher.pointerMotion(&self.root, @floatCast(cursor.x - @as(f64, @floatFromInt(self.box.x))), @floatCast(cursor.y - @as(f64, @floatFromInt(self.box.y))));
}
- try self.paint();
self.dirty = false;
}
+fn setButton(self: *Self, index: usize, shortcut: ?Shortcut, id: u64) void {
+ const m = self.metrics();
+ self.ids[index] = id;
+ self.shortcuts[index] = shortcut;
+ self.buttons[index] = .{
+ .name = if (shortcut) |s| @tagName(s) else std.fmt.allocPrint(self.arena.allocator(), "window_{d}", .{id}) catch "window",
+ .kind = .{ .button = .{ .label = self.arena.allocator().dupe(u8, self.label(index)) catch "Application", .variant = .ghost, .owner = self, .id = index, .on_click = clicked } },
+ .computed_x = @floatFromInt(@as(i32, @intCast(index)) * m.itemStep() + m.padding()),
+ .computed_y = @floatFromInt(m.length(8)),
+ .computed_width = @floatFromInt(m.length(48)),
+ .computed_height = @floatFromInt(m.length(48)),
+ };
+}
+
fn topAt(self: *Self, index: usize) ?*Toplevel {
const id = self.ids[index];
if (id == 0) return null;
@@ -154,10 +314,12 @@ fn topAt(self: *Self, index: usize) ?*Toplevel {
}
fn label(self: *Self, index: usize) []const u8 {
- if (index == 0) return "Applications";
- if (index == 1) return "Files";
- if (index == 2) return "Terminal";
- if (index == self.count - 1) return "Settings";
+ if (self.shortcuts[index]) |shortcut| return switch (shortcut) {
+ .applications => "Applications",
+ .files => "Files",
+ .terminal => "Terminal",
+ .settings => "Settings",
+ };
return if (self.topAt(index)) |top| top.title() else "Application";
}
@@ -179,27 +341,49 @@ fn hashValue(hasher: *std.hash.Wyhash, value: anytype) void {
/// What one button shows.
const Look = struct {
- top: ?*Toplevel,
focused: bool,
icon: ?IconEntry,
+ pill_width: f32,
+ pill_opacity: f32,
};
-fn paint(self: *Self) !void {
+fn paint(self: *Self, now_ms: i64) !void {
const output = self.output.?;
+ const m = self.metrics();
const pal = ui.theme.shellPalette();
var bg = ui.theme.taskbar(.taskbar_bg);
bg[3] = @max(bg[3], 0.86);
const focused = @import("ipc/handlers.zig").findFocusedToplevel(output.server);
var looks: [max_items]Look = undefined;
+ self.pills_animating = false;
var hasher = std.hash.Wyhash.init(0);
- hashValue(&hasher, .{ pal, bg, self.scale, self.box.width, self.count, self.offset, self.windows });
+ hashValue(&hasher, .{ pal, bg, self.scale, self.box.width, self.box.height, self.count, self.offset, self.windows });
for (self.buttons[0..self.count], looks[0..self.count], 0..) |button, *look, index| {
const top = self.topAt(index);
- const icon_name = if (top) |t| t.appId() else if (index == 0) "builtin:redi-logo" else if (index == 1) "rediwm-files" else if (index == 2) "utilities-terminal" else "preferences-system";
- const lookup = output.server.iconLookup(icon_name, @import("geometry.zig").devicePixels(36, self.scale));
- look.* = .{ .top = top, .focused = top != null and top == focused, .icon = if (lookup == .ready) lookup.ready else null };
+ const icon_name = if (self.shortcuts[index]) |shortcut| switch (shortcut) {
+ .applications => "builtin:redi-logo",
+ .files => "rediwm-files",
+ .terminal => "utilities-terminal",
+ .settings => "preferences-system",
+ } else if (top) |t| t.appId() else "";
+ const lookup = output.server.iconLookup(icon_name, @import("geometry.zig").devicePixels(m.length(36), self.scale));
+ const active = top != null and top == focused;
+ const width: f32 = if (top == null) 0 else if (active) 22 else 10;
+ const opacity: f32 = if (top) |t| if (t.minimized) 0.4 else 1 else 0;
+ const pill = &self.pills[index];
+ if (pill.width.to != width) pill.width.retargetTo(now_ms, width, anim.curveFor(.taskbar_hover));
+ if (pill.opacity.to != opacity) pill.opacity.retargetTo(now_ms, opacity, anim.curveFor(.taskbar_hover));
+ _ = pill.width.sampleChanged(now_ms, anim.rasterPixelQuantum(self.scale) / (4 * m.size(1)));
+ _ = pill.opacity.sampleChanged(now_ms, anim.rasterAlphaQuantum());
+ self.pills_animating = self.pills_animating or !pill.width.settled(now_ms) or !pill.opacity.settled(now_ms);
+ look.* = .{
+ .focused = active,
+ .icon = if (lookup == .ready) lookup.ready else null,
+ .pill_width = @max(0, pill.width.last_quantised),
+ .pill_opacity = std.math.clamp(pill.opacity.last_quantised, 0, 1),
+ };
const icon_id: ?u64 = if (look.icon) |icon| icon.id else null;
- hashValue(&hasher, .{ button.kind.button.state, top != null, look.focused, if (top) |t| t.minimized else false, icon_id });
+ hashValue(&hasher, .{ self.shortcuts[index], button.kind.button.state, look.focused, icon_id, look.pill_width, look.pill_opacity });
}
const key = hasher.final();
if (key != self.drawn) try self.paintDock(pal, bg, looks[0..self.count]);
@@ -208,35 +392,48 @@ fn paint(self: *Self) !void {
}
fn paintDock(self: *Self, pal: ui.theme.Theme, bg: [4]f32, looks: []const Look) !void {
- const image = try PanelBuffer.create(self.box.width, height, self.scale);
+ const m = self.metrics();
+ const image = try PanelBuffer.create(self.box.width, self.box.height, self.scale);
defer image.base.drop();
var r = ui.paint.Renderer.init(image.pixels, image.width, image.height, self.scale);
r.palette = pal;
var border = pal.accent;
border[3] = 0.55;
- r.fillRect(0, 0, @floatFromInt(self.box.width), height, .{ .color = bg, .radius = 16, .border_width = 1, .border_color = border });
+ const radius = @min(ui.window_chrome.frameRadius(), @as(f32, @floatFromInt(self.box.height)) / 2);
+ glass.Effect.configure(self.glass_effect, radius, 1);
+ r.fillRect(0, 0, @floatFromInt(self.box.width), @floatFromInt(self.box.height), .{ .color = bg, .radius = radius, .border_width = 1, .border_color = border });
for (self.buttons[0..self.count], looks, 0..) |button, look, index| {
const x = button.computed_x;
- ui.widgets.button.paintBackground(&r, .{ .x = x, .y = 8, .w = 48, .h = 48 }, .{ .variant = .ghost, .radius = 12 }, .{ .pointer = button.kind.button.state, .selected = look.focused });
+ const cx = x + button.computed_width / 2;
+ const cy = button.computed_y + button.computed_height / 2;
+ ui.widgets.button.paintBackground(&r, .{ .x = x, .y = button.computed_y, .w = button.computed_width, .h = button.computed_height }, .{ .variant = .ghost, .radius = m.size(12) }, .{ .pointer = button.kind.button.state, .selected = look.focused });
if (look.icon) |icon| {
- r.drawImageCover(x + 6, 14, 36, 36, 0, .{ .pixels = icon.pixels, .width = icon.size, .height = icon.size });
+ const size: f32 = @floatFromInt(m.length(36));
+ r.drawImageCover(cx - size / 2, cy - size / 2, size, size, 0, .{ .pixels = icon.pixels, .width = icon.size, .height = icon.size });
} else {
- r.drawIcon(x + 7, 15, 34, 34, .{ .id = if (index == 0) .grid else if (index == 1) .folder else if (index == 2) .terminal else if (index == self.count - 1) .settings else .generic, .color = pal.window_fg });
+ const size: f32 = @floatFromInt(m.length(34));
+ r.drawIcon(cx - size / 2, cy - size / 2, size, size, .{ .id = if (self.shortcuts[index]) |shortcut| switch (shortcut) {
+ .applications => .grid,
+ .files => .folder,
+ .terminal => .terminal,
+ .settings => .settings,
+ } else .generic, .color = pal.window_fg });
}
- if (look.top) |t| {
+ if (look.pill_width > 0 and look.pill_opacity > 0) {
var accent = pal.accent;
- accent[3] *= if (t.minimized) @as(f32, 0.4) else 1;
- const width: f32 = if (look.focused) 22 else 10;
- r.fillRect(x + 24 - width / 2, 58, width, 4, .{ .color = accent, .radius = 2 });
+ accent[3] *= look.pill_opacity;
+ const width = m.size(look.pill_width);
+ const thickness = @max(2, m.size(4));
+ r.fillRect(cx - width / 2, @floatFromInt(m.length(58)), width, thickness, .{ .color = accent, .radius = @min(width, thickness) / 2 });
}
}
var divider = pal.window_fg;
divider[3] = 0.16;
- r.fillRect(64, 18, 1, 30, .{ .color = divider });
- if (self.offset > 0) r.drawIcon(1, 28, 10, 12, .{ .id = .chevron_left, .color = pal.accent });
- if (self.offset + self.count - 4 < self.windows) r.drawIcon(@floatFromInt(self.box.width - 11), 28, 10, 12, .{ .id = .chevron_right, .color = pal.accent });
+ if (self.count > 1 and self.shortcuts[0] == .applications) r.fillRect(@floatFromInt(m.itemStep() + m.padding() - m.length(4)), m.size(18), 1, m.size(30), .{ .color = divider });
+ if (self.offset > 0) r.drawIcon(1, m.size(28), m.size(10), m.size(12), .{ .id = .chevron_left, .color = pal.accent });
+ if (self.offset + self.count - self.shortcutCount() < self.windows) r.drawIcon(@as(f32, @floatFromInt(self.box.width)) - m.size(11), m.size(28), m.size(10), m.size(12), .{ .id = .chevron_right, .color = pal.accent });
self.node.?.setBuffer(&image.base);
- self.node.?.setDestSize(self.box.width, height);
+ self.node.?.setDestSize(self.box.width, self.box.height);
}
fn paintTooltip(self: *Self) !void {
@@ -257,7 +454,7 @@ fn paintTooltip(self: *Self) !void {
if (key == self.tip_drawn) {
// Same text: only the button under it may differ.
const width = self.tooltip.?.dst_width;
- self.tooltip.?.node.setPosition(std.math.clamp(@as(i32, @intFromFloat(hovered.computed_x + 24)) - @divTrunc(width, 2), 0, self.box.width - width), -38);
+ self.tooltip.?.node.setPosition(std.math.clamp(@as(i32, @intFromFloat(hovered.computed_x + hovered.computed_width / 2)) - @divTrunc(width, 2), 0, self.box.width - width), -38);
self.tooltip.?.node.setEnabled(true);
return;
}
@@ -272,7 +469,7 @@ fn paintTooltip(self: *Self) !void {
r.drawText(10, 0, @floatFromInt(width - 20), 30, .{ .content = value, .font_size = pal.font_size, .color = pal.window_fg });
self.tooltip.?.setBuffer(&image.base);
self.tooltip.?.setDestSize(width, 30);
- self.tooltip.?.node.setPosition(std.math.clamp(@as(i32, @intFromFloat(hovered.computed_x + 24)) - @divTrunc(width, 2), 0, self.box.width - width), -38);
+ self.tooltip.?.node.setPosition(std.math.clamp(@as(i32, @intFromFloat(hovered.computed_x + hovered.computed_width / 2)) - @divTrunc(width, 2), 0, self.box.width - width), -38);
self.tooltip.?.node.setEnabled(true);
self.tip_drawn = key;
}
@@ -291,7 +488,7 @@ pub fn leave(self: *Self) void {
fn repaint(self: *Self) void {
if (self.node == null) return;
- self.paint() catch {};
+ self.paint(anim.nowMs()) catch {};
self.output.?.wlr_output.scheduleFrame();
}
@@ -302,6 +499,51 @@ pub fn press(self: *Self, x: f64, y: f64) void {
self.repaint();
}
+pub fn contextMenu(self: *Self, x: f64, y: f64, screen_x: i32) bool {
+ self.dispatcher.pointerMotion(&self.root, @floatCast(x), @floatCast(y));
+ const button = self.dispatcher.hovered orelse return false;
+ if (button.kind != .button) return false;
+ const index = button.kind.button.id;
+ const target = self.topAt(index);
+ const shortcut = self.shortcuts[index];
+ if (target == null and shortcut == null) return false;
+ const input = &self.output.?.server.input;
+ input.window_menu.openDock(self, target, shortcut, screen_x);
+ return input.window_menu.node != null;
+}
+
+pub fn remove(self: *Self, shortcut: ?Shortcut, target: ?*Toplevel) void {
+ const server = self.output.?.server;
+ if (shortcut) |s| {
+ self.saveHidden("dock_hidden_shortcuts", @tagName(s)) catch |err| {
+ std.log.warn("could not remove dock shortcut: {}", .{err});
+ return;
+ };
+ } else if (target) |top| {
+ const id = top.appId();
+ if (id.len == 0) {
+ top.dock_hidden = true;
+ } else self.saveHidden("dock_hidden_apps", id) catch |err| {
+ std.log.warn("could not remove dock app: {}", .{err});
+ return;
+ };
+ } else return;
+ var it = server.outputs.iterator(.forward);
+ while (it.next()) |output| output.dock.invalidate();
+}
+
+fn saveHidden(self: *Self, comptime key: []const u8, name: []const u8) !void {
+ const server = self.output.?.server;
+ const old = @field(server.config.compositor, key);
+ if (hidden(old, name)) return;
+ const a = server.config.arena.allocator();
+ const items = try a.alloc([]const u8, old.len + 1);
+ @memcpy(items[0..old.len], old);
+ items[old.len] = try a.dupe(u8, name);
+ try @import("config").setting_save.saveCompositor(gpa, server.io, server.config.path, key, @as([]const []const u8, items));
+ @field(server.config.compositor, key) = items;
+}
+
/// Windows, theme or icons changed: rebuild on the output's next frame. A
/// hidden dock rebuilds when it is shown again.
pub fn invalidate(self: *Self) void {
@@ -311,19 +553,35 @@ pub fn invalidate(self: *Self) void {
pub fn scroll(self: *Self, delta: f64) void {
// A pending rebuild may add windows; it clamps the offset.
- if (delta == 0 or (!self.dirty and self.windows + 4 <= self.count)) return;
+ if (delta == 0 or (!self.dirty and self.windows + self.shortcutCount() <= self.count)) return;
if (delta > 0) self.offset +|= 1 else self.offset -|= 1;
self.invalidate();
}
+pub fn captureAnimations(self: *Self, allocator: std.mem.Allocator, list: *std.ArrayList(anim.LiveCapture), now_ms: i64) !void {
+ for (self.pills[0..self.count]) |*pill| {
+ try anim.captureIfLive(allocator, list, &pill.width, .taskbar_hover, now_ms);
+ try anim.captureIfLive(allocator, list, &pill.opacity, .taskbar_hover, now_ms);
+ }
+}
+
+pub fn appendAnimations(self: *const Self, allocator: std.mem.Allocator, list: *std.ArrayList(@import("ipc/protocol.zig").AnimationData), now_ms: i64) !void {
+ const output = self.output orelse return;
+ const inspector = @import("ipc/animations.zig");
+ for (self.pills[0..self.count], self.buttons[0..self.count]) |pill, button| {
+ const prefix = try std.fmt.allocPrint(allocator, "dock.{s}.{s}", .{ std.mem.span(output.wlr_output.name), button.name orelse "item" });
+ defer allocator.free(prefix);
+ try inspector.appendLive(allocator, list, try std.fmt.allocPrint(allocator, "{s}.pill_width", .{prefix}), pill.width, now_ms);
+ try inspector.appendLive(allocator, list, try std.fmt.allocPrint(allocator, "{s}.pill_opacity", .{prefix}), pill.opacity, now_ms);
+ }
+}
+
fn clicked(owner: ?*anyopaque, index: usize) void {
const self: *Self = @ptrCast(@alignCast(owner.?));
const output = self.output.?;
const server = output.server;
if (server.locker != null) return;
- if (index == 0) output.toggleStartMenu() else if (index == 1 or index == 2) {
- @import("config_runtime/actions.zig").executeAction(server, .{ .spawn = if (index == 1) "default-file-manager" else "default-terminal" });
- } else if (index == self.count - 1) output.toggleControlCenter() else if (self.topAt(index)) |top| {
+ if (self.topAt(index)) |top| {
const focused = @import("ipc/handlers.zig").findFocusedToplevel(server) == top;
if (!top.minimized and focused and server.world.isWindowVisible(top, output)) {
top.minimize();
@@ -331,5 +589,9 @@ fn clicked(owner: ?*anyopaque, index: usize) void {
if (top.minimized) top.restore() else server.world.focus(top);
server.world.navigateTo(top, output);
}
- }
+ } else if (self.shortcuts[index]) |shortcut| switch (shortcut) {
+ .applications => output.toggleStartMenu(),
+ .files, .terminal => @import("config_runtime/actions.zig").executeAction(server, .{ .spawn = if (shortcut == .files) "default-file-manager" else "default-terminal" }),
+ .settings => output.toggleControlCenter(),
+ };
}
diff --git a/src/Input.zig b/src/Input.zig
index 47ce0f9..b47bb60 100644
--- a/src/Input.zig
+++ b/src/Input.zig
@@ -300,7 +300,7 @@ pub fn motionReachesClient(input: *const Input) bool {
if (input.cursor_mode != .passthrough or input.grabbed_toplevel != null or input.resize_session != null) return false;
if (input.server.world.mini_map.dragging) return false;
if (input.desktop_grab or input.seat.drag != null) return false;
- if (input.window_menu.target != null) return false;
+ if (input.window_menu.node != null) return false;
if (server.tray) |tray| if (tray.menu_item != 0) return false;
return input.seat.pointer_state.focused_surface != null;
}
@@ -315,7 +315,7 @@ pub fn directInputReachesClients(input: *Input) bool {
if (input.cursor_mode != .passthrough or input.grabbed_toplevel != null or input.resize_session != null) return false;
if (input.server.world.mini_map.dragging) return false;
if (input.desktop_grab or input.seat.drag != null or input.active_buttons > 0) return false;
- if (input.window_menu.target != null) return false;
+ if (input.window_menu.node != null) return false;
if (server.tray) |tray| if (tray.menu_item != 0) return false;
if (input.open_start_menu != null or input.open_power_menu != null or input.open_wifi != null or input.open_battery != null or input.open_calendar != null) return false;
// Alt+drag moves and Super pans are pointer gestures.
@@ -1104,6 +1104,7 @@ fn beginMiddlePanAfterThreshold(session: *PanSession, x: f64, y: f64) bool {
}
pub fn detachOutput(input: *Input, output: *Output) void {
+ if (input.window_menu.output == output) input.window_menu.close();
if (input.tiling_grab != null) input.finishTilingGrab(false);
if (input.move_snap.output == output) {
input.move_snap.target = null;
@@ -1419,7 +1420,7 @@ pub fn processCursorMotion(input: *Input, time_msec: u32) void {
input.server.screenshot_selector.motion(input.cursor.x, input.cursor.y);
return;
}
- if (input.window_menu.target != null) {
+ if (input.window_menu.node != null) {
input.window_menu.motion(input.cursor.x, input.cursor.y);
input.seat.pointerClearFocus();
return;
@@ -1817,7 +1818,7 @@ pub fn processButton(
input.tray_buttons &= ~screenshot_bit;
return;
}
- if (input.window_menu.target != null) {
+ if (input.window_menu.node != null) {
if (state == .pressed) {
input.tray_buttons |= screenshot_bit;
input.window_menu.press(input.cursor.x, input.cursor.y, button);
@@ -1838,6 +1839,12 @@ pub fn processButton(
},
else => {},
}
+ } else if (picked == .dock) {
+ const hit = picked.dock;
+ if (hit.dock.contextMenu(hit.sx, hit.sy, @intFromFloat(input.cursor.x))) {
+ input.tray_buttons |= screenshot_bit;
+ return;
+ }
}
}
if (input.server.tray) |tray| {
@@ -2268,7 +2275,7 @@ pub fn processAxis(
// Flip here, before zoom/UI/client branches, so `invert_scroll` behaves
// like `natural_scroll` would if libinput's device toggle applied to
// this device: a single, uniform reversal rather than one per consumer.
- if (input.window_menu.target != null) return;
+ if (input.window_menu.node != null) return;
const invert = input.server.config.input.invert_scroll;
const delta: f64 = if (invert) -raw_delta else raw_delta;
const delta_discrete: i32 = if (invert) -raw_delta_discrete else raw_delta_discrete;
diff --git a/src/Keyboard.zig b/src/Keyboard.zig
index 55c77a6..8afe3bd 100644
--- a/src/Keyboard.zig
+++ b/src/Keyboard.zig
@@ -440,7 +440,7 @@ pub fn processKey(keyboard: *Keyboard, time_msec: u32, event_keycode: u32, state
}
}
- if (keyboard.server.input.window_menu.target != null and keyboard.server.screenshot_selector.output == null) {
+ if (keyboard.server.input.window_menu.node != null and keyboard.server.screenshot_selector.output == null) {
if (state == .pressed) {
if (event_keycode < keyboard.tray_consumed.len) keyboard.tray_consumed[event_keycode] = true;
for (xkb_state.keyGetSyms(keycode)) |sym| keyboard.server.input.window_menu.key(@intFromEnum(sym));
@@ -831,7 +831,7 @@ fn currentShellTarget(keyboard: *Keyboard) ?ShellTarget {
if (server.screenshot_selector.output != null or server.switcher.active()) return null;
if (server.tray) |tray| if (tray.menu_item != 0) return null;
const input = &server.input;
- if (input.window_menu.target != null) return null;
+ if (input.window_menu.node != null) return null;
if (input.open_wifi) |popup| return .{ .wifi = popup };
if (input.open_battery != null or input.open_calendar != null or input.open_power_menu != null) return null;
if (input.open_control_center) |cc| if (cc.hasKeyboardFocus() and input.open_start_menu == null) {
diff --git a/src/Output.zig b/src/Output.zig
index 6a26bac..132fd47 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -1217,7 +1217,7 @@ fn runFrame(output: *Output) void {
anim.observeBegin();
const switcher_animating = output.server.switcher.tick(output, now_ms);
const osd_animating = output.osd.tick(output, now_ms);
- output.dock.tick(output);
+ const dock_animating = output.dock.tick(output, now_ms);
const taskbar_started = stats.nowNs();
var bar_animating = false;
if (output.taskbar) |bar| bar_animating = bar.tick(now_ms);
@@ -1359,7 +1359,7 @@ fn runFrame(output: *Output) void {
// Keep repainting every refresh interval until the last hover/press/FLIP
// animation settles; otherwise chrome and the bar only redraw when a
// client does.
- const keep_going = mini_map_animating or switcher_animating or osd_animating or bar_animating or chrome_animating or cc_animating or sm_animating or pm_animating or taskbar_popup_animating or notif_animating or desktop_animating or lock_animating or polkit_animating;
+ const keep_going = mini_map_animating or switcher_animating or osd_animating or dock_animating or bar_animating or chrome_animating or cc_animating or sm_animating or pm_animating or taskbar_popup_animating or notif_animating or desktop_animating or lock_animating or polkit_animating;
// A pinned clock is advanced explicitly by IPC, which schedules its own
// frame. Global window/taskbar springs must not spin between those steps.
if (keep_going and !anim.clockOverridden()) {
diff --git a/src/Server.zig b/src/Server.zig
index f601d9c..3e96be2 100644
--- a/src/Server.zig
+++ b/src/Server.zig
@@ -1575,6 +1575,7 @@ fn handleCatalogWake(fd: c_int, mask: wl.EventMask, server: *Server) c_int {
if (server.input.open_control_center) |cc| cc.refresh();
var it = server.outputs.iterator(.forward);
while (it.next()) |output| {
+ output.dock.invalidate();
if (output.start_menu) |sm| sm.refreshCatalog();
}
server.startup_warmup.onCatalogReady(server);
diff --git a/src/Toplevel.zig b/src/Toplevel.zig
index 3a1d954..d4313dc 100644
--- a/src/Toplevel.zig
+++ b/src/Toplevel.zig
@@ -264,6 +264,8 @@ needs_attention: bool = false,
maximized: bool = false,
fullscreen: bool = false,
in_world: bool = false,
+/// A dock removal without an app identity lasts for this window's lifetime.
+dock_hidden: bool = false,
placed: bool = false,
placeholder_source: ?*Toplevel = null,
rules_resolved: bool = false,
diff --git a/src/World.zig b/src/World.zig
index 8bbf4ad..9e253e3 100644
--- a/src/World.zig
+++ b/src/World.zig
@@ -241,7 +241,7 @@ pub fn peekTarget(world: *World) ?*Toplevel {
while (keyboards.next()) |keyboard| {
if (keyboard.device.toKeyboard().getModifiers().logo) held = true;
}
- if (!held or input.window_menu.target != null or (world.server.locker != null or world.server.polkit_dialog != null)) {
+ if (!held or input.window_menu.node != null or (world.server.locker != null or world.server.polkit_dialog != null)) {
world.peek_window_id = null;
return null;
}
diff --git a/src/config/default.zig b/src/config/default.zig
index d65b84c..4117312 100644
--- a/src/config/default.zig
+++ b/src/config/default.zig
@@ -118,6 +118,9 @@ pub const source =
\\default_file_manager = ""
\\default_terminal = ""
\\dock_enabled = false # compact launcher alongside the taskbar
+ \\dock_height = 68 # logical px; 48-96, icons and spacing resize together
+ \\dock_hidden_apps = [] # app IDs removed from the dock's context menu
+ \\dock_hidden_shortcuts = [] # applications, files, terminal, settings
\\# Right-side taskbar items, left to right; prefix a name with - to hide it.
\\taskbar_position = "bottom" # top or bottom
\\taskbar_items = ["battery", "network", "volume", "clock"]
diff --git a/src/config/loader.zig b/src/config/loader.zig
index 65b79fa..dada739 100644
--- a/src/config/loader.zig
+++ b/src/config/loader.zig
@@ -118,6 +118,9 @@ pub const RegionConfig = struct {
pub const TaskbarItems = @import("taskbar_items.zig").Config;
pub const DesktopMode = enum { canvas, workspaces };
+pub const dock_height_min: u32 = 48;
+pub const dock_height_max: u32 = 96;
+pub const dock_height_default: u32 = 68;
pub const CompositorConfig = struct {
desktop_mode: DesktopMode = .canvas,
@@ -125,6 +128,9 @@ pub const CompositorConfig = struct {
default_file_manager: []const u8 = "",
default_terminal: []const u8 = "",
dock_enabled: bool = false,
+ dock_height: u32 = dock_height_default,
+ dock_hidden_apps: []const []const u8 = &.{},
+ dock_hidden_shortcuts: []const []const u8 = &.{},
taskbar_items: TaskbarItems = .{},
taskbar_position: enum { top, bottom } = .bottom,
/// App identities opted into compositor tabs. Only + launches join a group.
@@ -1039,6 +1045,9 @@ const compositor_rules: std.enums.EnumFieldStruct(std.meta.FieldEnum(CompositorC
.desktop_mode = .enumeration,
.floating_apps = .json_string_list,
.dock_enabled = .boolean,
+ .dock_height = .{ .uint = .{ .min = dock_height_min, .max = dock_height_max } },
+ .dock_hidden_apps = .json_string_list,
+ .dock_hidden_shortcuts = .json_string_list,
.taskbar_items = .taskbar_items,
.taskbar_position = .enumeration,
.icon_theme = .string,
@@ -1770,6 +1779,7 @@ test "config field parsing preserves ranges and derived zoom state" {
.{ "canvas_height", "1", "100000", "0", "100001" },
.{ "window_gap", "0", "512", "513", "514" },
.{ "border_radius", "0", "128", "129", "130" },
+ .{ "dock_height", "48", "96", "47", "97" },
}) |fixture| {
try applyCompositorKey(&c, a, fixture[0], fixture[1]);
try std.testing.expectEqual(@as(@TypeOf(@field(c, fixture[0])), try std.fmt.parseInt(u32, fixture[1], 10)), @field(c, fixture[0]));
diff --git a/src/config_runtime/apply.zig b/src/config_runtime/apply.zig
index dc5137c..3ff2b5f 100644
--- a/src/config_runtime/apply.zig
+++ b/src/config_runtime/apply.zig
@@ -33,6 +33,8 @@ pub fn applyDiff(server: *Server, old: Config, new: Config) void {
if (!std.mem.eql(u8, old.compositor.default_file_manager, new.compositor.default_file_manager) or
!std.mem.eql(u8, old.compositor.default_terminal, new.compositor.default_terminal))
{
+ var output_it = server.outputs.iterator(.forward);
+ while (output_it.next()) |output| output.dock.invalidate();
if (server.input.open_control_center) |cc| cc.refresh();
}
if (server.ipc) |ipc| {
@@ -204,6 +206,18 @@ pub fn applyDiff(server: *Server, old: Config, new: Config) void {
if (server.input.open_control_center) |cc| cc.refresh();
}
+ if (old.compositor.dock_height != new.compositor.dock_height or
+ !stringListsEql(old.compositor.dock_hidden_apps, new.compositor.dock_hidden_apps) or
+ !stringListsEql(old.compositor.dock_hidden_shortcuts, new.compositor.dock_hidden_shortcuts))
+ {
+ if (server.input.window_menu.dock != null) server.input.window_menu.close();
+ var output_it = server.outputs.iterator(.forward);
+ while (output_it.next()) |output| output.dock.invalidate();
+ if (old.compositor.dock_height != new.compositor.dock_height) {
+ if (server.input.open_control_center) |cc| cc.refresh();
+ }
+ }
+
logKeybindDiff(old, new);
for (new.autostart) |cmd| {
@@ -214,6 +228,12 @@ pub fn applyDiff(server: *Server, old: Config, new: Config) void {
}
}
+fn stringListsEql(a: []const []const u8, b: []const []const u8) bool {
+ if (a.len != b.len) return false;
+ for (a, b) |left, right| if (!std.mem.eql(u8, left, right)) return false;
+ return true;
+}
+
pub fn applyInputConfig(server: *Server, cfg: InputConfig) void {
// The UI engine keeps its own copy so `ui/` need not import this file;
// pushing it here means a hot reload retimes the caret with everything
diff --git a/src/control_center/sections/appearance.zig b/src/control_center/sections/appearance.zig
index 35620b8..6e827e6 100644
--- a/src/control_center/sections/appearance.zig
+++ b/src/control_center/sections/appearance.zig
@@ -88,6 +88,7 @@ const px_chrome_height = 11;
const px_chrome_control_gap = 12;
const px_menu_width = 13;
const px_menu_height = 14;
+const px_dock_height = 15;
pub const Section = struct {
cc: *panel.ControlCenter = undefined,
@@ -103,6 +104,7 @@ pub const Section = struct {
family_row_children: [2]Widget = undefined,
row_storage: [26]Widget = undefined,
dock_children: [2]Widget = undefined,
+ dock_group_children: [2]Widget = undefined,
focus_zoom_children: [3]Widget = undefined,
/// Rescanned on every build, so images added meanwhile show up.
wallpapers: []const wallpapers.Entry = &.{},
@@ -159,7 +161,7 @@ pub const Section = struct {
inactive_opacity_header_children: [2]Widget = undefined,
inactive_opacity_group_children: [2]Widget = undefined,
inactive_opacity_value_buf: [16]u8 = undefined,
- px: [15]PxControl = undefined,
+ px: [16]PxControl = undefined,
taskbar_section_children: [8]Widget = undefined,
taskbar_position_children: [2]Widget = undefined,
items_children: [3]Widget = undefined,
@@ -733,6 +735,12 @@ pub fn build(out: *Section, cc: *panel.ControlCenter) void {
labelWidget("RediWM dock"),
.{ .name = "dock_enabled", .kind = .{ .toggle = .{ .on = out.cc.server.config.compositor.dock_enabled, .owner = out, .on_change = &onDockChanged } } },
};
+ const dock_height_row = pxGroup(out, px_dock_height, "Dock height", @floatFromInt(server.config.compositor.dock_height), @floatFromInt(loader.dock_height_min), @floatFromInt(loader.dock_height_max), 2, &onDockHeightChanged);
+ out.px[px_dock_height].group_children[1].name = "dock_height";
+ out.dock_group_children = .{
+ .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_children },
+ dock_height_row,
+ };
out.row_storage = .{
.{ .kind = .container, .direction = .column, .gap = 8, .children = pack_controls },
.{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.icon_theme_row },
@@ -757,7 +765,7 @@ pub fn build(out: *Section, cc: *panel.ControlCenter) void {
inactive_opacity_row,
window_gap_row,
pxGroup(out, px_scrollbar_width, "Scrollbar width", t.scrollbar_width, 4, 24, 1, &PxHandler(px_scrollbar_width, "scrollbar_width", false).changed),
- .{ .kind = .container, .direction = .row, .justify = .space_between, .@"align" = .center, .children = &out.dock_children },
+ .{ .kind = .container, .direction = .column, .gap = 12, .children = &out.dock_group_children },
taskbar_section,
start_menu_section,
};
@@ -1774,3 +1782,24 @@ fn onDockChanged(owner: ?*anyopaque, _: usize, on: bool) void {
server.config.compositor.dock_enabled = on;
server.scheduleFrames();
}
+
+fn onDockHeightChanged(owner: ?*anyopaque, _: usize, value: f32) void {
+ const s = section(owner);
+ const server = s.cc.server;
+ const height: u32 = @intFromFloat(std.math.clamp(@round(value), @as(f32, @floatFromInt(loader.dock_height_min)), @as(f32, @floatFromInt(loader.dock_height_max))));
+ if (height == server.config.compositor.dock_height) return;
+ setting_save.saveCompositor(main.gpa, server.io, server.config.path, "dock_height", height) catch |err| {
+ std.log.warn("could not save dock height: {}", .{err});
+ s.px[px_dock_height].group_children[1].kind.slider.value = @floatFromInt(server.config.compositor.dock_height);
+ s.px[px_dock_height].group_children[1].markDirty();
+ return;
+ };
+ server.config.compositor.dock_height = height;
+ const formatted = std.fmt.bufPrint(&s.px[px_dock_height].value_buf, "{d}px", .{height}) catch "?";
+ s.px[px_dock_height].header_children[1].kind.text.content = formatted;
+ s.px[px_dock_height].header_children[1].markDirty();
+ if (server.input.window_menu.dock != null) server.input.window_menu.close();
+ var it = server.outputs.iterator(.forward);
+ while (it.next()) |output| output.dock.invalidate();
+ server.scheduleFrames();
+}
diff --git a/src/ipc/animations.zig b/src/ipc/animations.zig
index f3f29f2..09ad109 100644
--- a/src/ipc/animations.zig
+++ b/src/ipc/animations.zig
@@ -14,6 +14,7 @@ pub fn snapshot(server: *Server, allocator: std.mem.Allocator) ![]const protocol
var out_it = server.outputs.iterator(.forward);
while (out_it.next()) |output| {
+ try output.dock.appendAnimations(allocator, &list, now_ms);
if (output.taskbar) |bar| try bar.appendAnimations(allocator, &list, now_ms);
if (output.start_menu) |menu| {
try appendLive(allocator, &list, "start_menu.slide", menu.slide, now_ms);
@@ -150,6 +151,7 @@ fn captureLive(server: *Server, allocator: std.mem.Allocator, now_ms: i64) ![]an
var out_it = server.outputs.iterator(.forward);
while (out_it.next()) |output| {
+ try output.dock.captureAnimations(allocator, &list, now_ms);
if (output.taskbar) |bar| try bar.captureAnimations(allocator, &list, now_ms);
if (output.start_menu) |menu| {
try anim.captureIfLive(allocator, &list, &menu.slide, .panel_slide, now_ms);
diff --git a/src/taskbar/window_menu.zig b/src/taskbar/window_menu.zig
index 20c22f6..201486d 100644
--- a/src/taskbar/window_menu.zig
+++ b/src/taskbar/window_menu.zig
@@ -4,11 +4,15 @@ const wlr = @import("wlroots");
const Taskbar = @import("../Taskbar.zig");
const Toplevel = @import("../Toplevel.zig");
const Output = @import("../Output.zig");
+const Dock = @import("../Dock.zig");
const Buffer = @import("../panel_buffer.zig").PanelBuffer;
const ui = @import("ui");
pub const Menu = struct {
bar: ?*Taskbar = null,
+ output: ?*Output = null,
+ dock: ?*Dock = null,
+ shortcut: ?Dock.Shortcut = null,
target: ?*Toplevel = null,
node: ?*wlr.SceneBuffer = null,
box: wlr.Box = .{ .x = 0, .y = 0, .width = 0, .height = 0 },
@@ -17,31 +21,62 @@ pub const Menu = struct {
const padding = 6;
const row_height = 32;
const separator = 7;
- const height = padding * 2 + row_height * 2 + separator;
- const labels = [_][]const u8{ "Close", "Force Close" };
+ const Action = enum {
+ close,
+ force_close,
+ remove,
+
+ fn label(action: Action) []const u8 {
+ return switch (action) {
+ .close => "Close",
+ .force_close => "Force Close",
+ .remove => "Remove from dock",
+ };
+ }
+ };
+
+ fn actions(self: *const Menu) []const Action {
+ return if (self.target == null) &.{.remove} else if (self.dock != null) &.{ .close, .force_close, .remove } else &.{ .close, .force_close };
+ }
pub fn open(self: *Menu, bar: *Taskbar, target: *Toplevel, x: i32) void {
- self.close();
const output = Output.fromWlr(bar.wlr_output) orelse return;
- const input = &bar.server.input;
+ self.openOn(output, bar, null, target, null, x);
+ }
+
+ pub fn openDock(self: *Menu, dock: *Dock, target: ?*Toplevel, shortcut: ?Dock.Shortcut, x: i32) void {
+ self.openOn(dock.output orelse return, null, dock, target, shortcut, x);
+ }
+
+ fn openOn(self: *Menu, output: *Output, bar: ?*Taskbar, dock: ?*Dock, target: ?*Toplevel, shortcut: ?Dock.Shortcut, x: i32) void {
+ self.close();
+ const server = output.server;
+ const input = &server.input;
if (input.open_start_menu) |other| if (Output.fromWlr(other.wlr_output)) |out| out.closeStartMenu();
if (input.open_power_menu) |other| if (Output.fromWlr(other.wlr_output)) |out| out.closePowerMenu();
if (input.open_wifi) |other| other.output.closeWifi();
if (input.open_battery) |other| other.output.closeBattery();
if (input.open_calendar) |other| other.output.closeCalendar();
- if (bar.server.tray) |tray| tray.closeMenu();
+ if (server.tray) |tray| tray.closeMenu();
const bounds = output.usableBox();
const width = @min(216, bounds.width);
- self.node = bar.server.overlay_tree.createSceneBuffer(null) catch return;
+ self.node = server.overlay_tree.createSceneBuffer(null) catch return;
self.bar = bar;
+ self.output = output;
+ self.dock = dock;
+ self.shortcut = shortcut;
self.target = target;
+ const count: i32 = @intCast(self.actions().len);
+ const height = padding * 2 + row_height * count + separator * (count - 1);
+ const y = if (dock) |d| if (d.box.y - height - 4 >= bounds.y) d.box.y - height - 4 else d.box.y + d.box.height + 4 else output.taskbarPopupY(height, 4);
self.box = .{
.x = std.math.clamp(x, bounds.x, bounds.x + bounds.width - width),
- .y = output.taskbarPopupY(height, 4),
+ .y = std.math.clamp(y, bounds.y, @max(bounds.y, bounds.y + bounds.height - height)),
.width = width,
.height = height,
};
- bar.pointerLeave();
+ if (bar) |b| b.pointerLeave();
+ if (dock) |d| d.leave();
input.hovered_taskbar = null;
input.seat.pointerClearFocus();
input.setDefaultCursor();
@@ -62,7 +97,7 @@ pub const Menu = struct {
const lx = x - @as(f64, @floatFromInt(self.box.x));
const ly = y - @as(f64, @floatFromInt(self.box.y));
if (lx < padding or lx >= @as(f64, @floatFromInt(self.box.width - padding))) return null;
- for (0..labels.len) |i| {
+ for (0..self.actions().len) |i| {
const top: f64 = @floatFromInt(rowY(i));
if (ly >= top and ly < top + row_height) return i;
}
@@ -93,7 +128,8 @@ pub const Menu = struct {
0xff1b => self.close(), // Escape
0xff0d, 0xff8d, 0x20 => self.activate(), // Return, keypad Enter, Space
0xff52, 0xff54 => { // Up / Down skip the separator.
- self.selected = if (self.selected) |i| 1 - i else if (sym == 0xff54) 0 else 1;
+ const count = self.actions().len;
+ self.selected = if (self.selected) |i| (i + if (sym == 0xff54) @as(usize, 1) else count - 1) % count else if (sym == 0xff54) 0 else count - 1;
self.paint();
},
else => {},
@@ -102,25 +138,32 @@ pub const Menu = struct {
fn activate(self: *Menu) void {
const index = self.selected orelse return;
- const target = self.target orelse return;
+ const action = self.actions()[index];
+ const target = self.target;
+ const dock = self.dock;
+ const shortcut = self.shortcut;
// Shell windows can destroy themselves synchronously when closed.
self.close();
- if (index == 0) target.sendClose() else target.forceClose();
+ switch (action) {
+ .close => if (target) |t| t.sendClose(),
+ .force_close => if (target) |t| t.forceClose(),
+ .remove => if (dock) |d| d.remove(shortcut, target),
+ }
}
fn paint(self: *Menu) void {
- const bar = self.bar orelse return;
+ const output = self.output orelse return;
const node = self.node orelse return;
- const scale = bar.wlr_output.scale;
+ const scale = output.wlr_output.scale;
const buf = Buffer.create(self.box.width, self.box.height, scale) catch return;
defer buf.base.drop();
var renderer = ui.paint.Renderer.init(buf.pixels, buf.width, buf.height, scale);
const t = ui.theme.global;
const width: f32 = @floatFromInt(self.box.width);
- renderer.fillRect(0, 0, width, height, .{ .color = t.window_bg, .radius = 12, .border_width = 1, .border_color = t.border });
- renderer.fillRect(12, padding + row_height + 3, @max(0, width - 24), 1, .{ .color = t.border_soft });
- for (labels, 0..) |label, i| {
+ renderer.fillRect(0, 0, width, @floatFromInt(self.box.height), .{ .color = t.window_bg, .radius = 12, .border_width = 1, .border_color = t.border });
+ for (self.actions(), 0..) |action, i| {
const y: f32 = @floatFromInt(rowY(i));
+ if (i > 0) renderer.fillRect(12, y - 4, @max(0, width - 24), 1, .{ .color = t.border_soft });
const row: ui.layout.Widget = .{
.kind = .{ .row = .{ .state = if (self.selected == i) .hover else .idle } },
.computed_x = padding,
@@ -129,7 +172,7 @@ pub const Menu = struct {
.computed_height = row_height,
};
ui.paint.paint(&row, &renderer);
- renderer.drawText(18, y, @max(0, width - 36), row_height, .{ .content = label, .font_size = t.font_size, .color = if (i == 1) t.danger else t.window_fg });
+ renderer.drawText(18, y, @max(0, width - 36), row_height, .{ .content = action.label(), .font_size = t.font_size, .color = if (action == .force_close) t.danger else t.window_fg });
}
node.setBuffer(&buf.base);
node.setDestSize(self.box.width, self.box.height);
diff --git a/tests/dock.py b/tests/dock.py
index bdcdc30..1e3c186 100644
--- a/tests/dock.py
+++ b/tests/dock.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python3
"""Optional dock: settings persistence, input, window lifecycle and scaling."""
import os
+import signal
+import shutil
from pathlib import Path
import subprocess
import tempfile
@@ -17,13 +19,31 @@ def run():
with tempfile.TemporaryDirectory(prefix='rediwm-dock-') as directory:
tmp = Path(directory)
build_client(tmp)
+ applications = tmp / 'data' / 'applications'
+ applications.mkdir(parents=True)
+ for name, app_id, category in (
+ ('dock-files', 'dock.files.running', 'FileManager'),
+ ('dock-terminal', 'dock.terminal.running', 'TerminalEmulator'),
+ ):
+ (applications / f'{name}.desktop').write_text(
+ f'[Desktop Entry]\nType=Application\nName={name}\nStartupWMClass={app_id}\n'
+ f'Categories={category};\nExec={tmp / "client"} --app-id {app_id}\n')
+ fallback = tmp / 'fallback-terminal'
+ shutil.copyfile(tmp / 'client', fallback)
+ fallback.chmod(0o700)
+ (applications / 'fallback.desktop').write_text(
+ '[Desktop Entry]\nType=Application\nName=Fallback\nStartupWMClass=dock.fallback\n'
+ f'Categories=TerminalEmulator;\nExec={fallback} --app-id dock.fallback\n')
process, log = spawn_compositor(tmp, scale=scale, outputs=os.environ.get('REDIWM_TEST_OUTPUTS', '1'), config_content='''[compositor]
xwayland = false
+default_file_manager = "dock-files.desktop"
+default_terminal = "dock-terminal.desktop"
[animations]
enabled = false
''', env_extra={'DBUS_SESSION_BUS_ADDRESS': '', 'DBUS_SYSTEM_BUS_ADDRESS': 'unix:path=/nonexistent',
'XDG_CONFIG_HOME': str(tmp / 'config'), 'XDG_DATA_HOME': str(tmp / 'data'),
- 'XDG_CACHE_HOME': str(tmp / 'cache'), 'REDIWM_FILES_DEVICES': '0'})
+ 'XDG_DATA_DIRS': str(tmp / 'empty'), 'XDG_CACHE_HOME': str(tmp / 'cache'),
+ 'TERMINAL': f'"{fallback}" --app-id dock.fallback', 'REDIWM_FILES_DEVICES': '0'})
clients = []
try:
with IPCClient(tmp) as ipc:
@@ -44,6 +64,16 @@ enabled = false
ipc.screenshot(str(path))
with Image.open(path) as image:
return image.convert('RGB')
+ def pill(name, screenshot):
+ ipc.move_cursor(5, 5)
+ ipc.wait_for_frame()
+ b = button(name)['global_box']
+ root = dock()[0]['global_box']
+ x, y = b['x'] + b['width'] / 2, b['y'] + b['height'] + 1
+ return shot(screenshot).crop(tuple(round(v * scale) for v in
+ (x - 12, y, x + 12, root['y'] + root['height'] - 2)))
+ def shortcuts_only():
+ return {w['name'] for w in dock() if w['name']} == {'applications', 'files', 'terminal', 'settings'}
assert not dock(), 'dock must default off'
ipc.action('open_control_center')
ipc.wait_for_panel_settled('control_center')
@@ -58,11 +88,67 @@ enabled = false
assert not tomllib.loads((tmp / 'rediwm-config.toml').read_text())['compositor']['dock_enabled']
click(ui.scroll_into_view('dock_enabled'))
wait_for(dock, 'dock enabled again')
+ slider = ui.scroll_into_view('dock_height')
+ assert (slider['min'], slider['max'], slider['step'], slider['value']) == (48, 96, 2, 68)
+ root = dock()[0]['global_box']
+ bottom = root['y'] + root['height']
+ for height in (48, 96, 68):
+ slider = ui.scroll_into_view('dock_height')
+ area = slider['global_box']
+ fraction = (height - 48) / 48
+ for _ in range(3):
+ point = (round(area['x'] + min(area['width'] - 1, area['width'] * fraction)),
+ round(area['y'] + area['height'] / 2))
+ if ipc.hit_test(*point)['target_type'] != 'dock':
+ break
+ # A large dock can cover the bottom of the Settings
+ # window. Scroll the control farther up before clicking.
+ viewport = next(w['global_box'] for w in ui.widgets('control_center') if w['role'] == 'scroll_container')
+ ipc.move_cursor(viewport['x'] + viewport['width'] - 8, viewport['y'] + 40)
+ ipc.scroll(0, -130)
+ previous_y = area['y']
+ wait_for(lambda: ui.find('dock_height', panel='control_center')['global_box']['y'] < previous_y, 'slider scrolled above dock')
+ area = ui.scroll_into_view('dock_height')['global_box']
+ ipc.click_at(*point)
+ wait_for(lambda: dock()[0]['global_box']['height'] == height,
+ f'dock height changed live to {height}: slider={ui.find("dock_height", panel="control_center")["value"]}, dock={dock()[0]["global_box"]}')
+ assert tomllib.loads((tmp / 'rediwm-config.toml').read_text())['compositor']['dock_height'] == height
+ root = dock()[0]['global_box']
+ assert root['y'] + root['height'] == bottom, 'resize moved the dock bottom'
+ for item in (w for w in dock() if w['name']):
+ box = item['global_box']
+ assert 30 <= box['height'] <= 68 and box['width'] == box['height']
+ assert root['x'] <= box['x'] and box['x'] + box['width'] <= root['x'] + root['width']
+ assert root['y'] <= box['y'] and box['y'] + box['height'] < bottom
+ assert ipc.hit_test(*center(item))['target_type'] == 'dock'
+ if height == 96:
+ ipc.action('close_panel', {'panel': 'control_center'})
+ ipc.action('open_appearance')
+ ipc.wait_for_panel_settled('control_center')
+ assert ui.scroll_into_view('dock_height')['value'] == 96
ipc.action('close_panel', {'panel': 'control_center'})
ipc.wait_for_frame()
assert ipc.get_shell_state()['taskbars'], 'dock must coexist with taskbar'
assert ipc.hit_test(*center(button('terminal')))['target_type'] == 'dock'
ipc.move_cursor(5, 5)
+ # The dock's raster and glass mask follow the window radius,
+ # including a live reload back to a previously painted shape.
+ cfg = tmp / 'rediwm-config.toml'
+ original = cfg.read_text()
+ corners = []
+ for index, radius in enumerate((0, 24, 0)):
+ cfg.write_text(original + f'\n[theme]\nradius_lg = {radius}\n')
+ ipc.reload_config()
+ ipc.wait_for_frame()
+ box = button('applications')['global_box']
+ x, y = box['x'] - 12, box['y'] - 8
+ corners.append(shot(f'radius-{index}').crop(tuple(round(v * scale) for v in
+ (x, y, x + 8, y + 8))))
+ assert ImageChops.difference(corners[0], corners[1]).getbbox(), 'dock ignores window radius'
+ assert not ImageChops.difference(corners[0], corners[2]).getbbox(), 'dock radius did not restore'
+ cfg.write_text(original)
+ ipc.reload_config()
+ ipc.wait_for_frame()
plain = shot('plain')
ipc.move_cursor(*center(button('terminal')))
ipc.wait_for_frame()
@@ -85,10 +171,78 @@ enabled = false
wait_for(lambda: ipc.get_shell_state()['start_menu'], 'dock launcher')
ipc.action('close_panel', {'panel': 'start_menu'})
ipc.wait_for_frame()
+ settings_idle = pill('settings', 'settings-idle')
click(button('settings'))
wait_for(lambda: ipc.get_shell_state()['control_center'], 'dock settings')
- ipc.action('close_panel', {'panel': 'control_center'})
+ wait_for(shortcuts_only, 'Settings shares its shortcut')
+ assert ImageChops.difference(settings_idle, pill('settings', 'settings-running')).getbbox()
+ # A running shortcut has the same window actions as an unpinned app.
+ ipc.move_cursor(*center(button('settings')))
+ ipc.pointer_button(273, True)
+ ipc.pointer_button(273, False)
+ for code in (108, 28): # Down selects Close; Enter activates it.
+ ipc.key(code, True)
+ ipc.key(code, False)
+ wait_for(lambda: not ipc.get_shell_state()['control_center'], 'shortcut menu closes Settings')
ipc.wait_for_frame()
+ ipc.wait_for('catalog_published', timeout_ms=10000)
+ for shortcut, app_id, desktop_id, height in (
+ ('files', 'dock.files.running', 'dock-files.desktop', 48),
+ ('terminal', 'dock.terminal.running', 'dock-terminal.desktop', 96),
+ ('terminal', 'dock.fallback', None, 68),
+ ):
+ text = cfg.read_text()
+ previous_height = tomllib.loads(text)['compositor']['dock_height']
+ cfg.write_text(text.replace(f'dock_height = {previous_height}', f'dock_height = {height}'))
+ ipc.reload_config()
+ wait_for(lambda: dock()[0]['global_box']['height'] == height, 'height reload')
+ if desktop_id is None:
+ cfg.write_text(cfg.read_text().replace('default_terminal = "dock-terminal.desktop"', 'default_terminal = ""'))
+ ipc.reload_config()
+ ipc.wait_for_frame()
+ idle = pill(shortcut, f'{app_id}-idle')
+ position = button(shortcut)['global_box']
+ click(button(shortcut))
+ win = wait_for(lambda: next((w for w in ipc.get_windows() if w['app_id'] == app_id), None), 'shortcut launch')
+ wid = win['id']
+ wait_for(shortcuts_only, 'launch must not add another dock icon')
+ assert button(shortcut)['global_box'] == position, 'launch changed dock geometry'
+ running = pill(shortcut, f'{app_id}-running')
+ assert ImageChops.difference(idle, running).getbbox(), 'running pill missing'
+ click(button(shortcut))
+ wait_for(lambda: next(w for w in ipc.get_windows() if w['id'] == wid)['is_minimized'], 'shortcut minimizes its app')
+ assert len(ipc.get_windows()) == 1, 'shortcut launched another instance'
+ click(button(shortcut))
+ wait_for(lambda: not next(w for w in ipc.get_windows() if w['id'] == wid)['is_minimized'], 'shortcut restores its app')
+ assert len(ipc.get_windows()) == 1
+ assert ipc.get_focused_window()['id'] == wid
+ if desktop_id:
+ ipc.action('launch_app', {'desktop_id': desktop_id})
+ second = wait_for(lambda: next((w for w in ipc.get_windows() if w['id'] != wid), None), 'second instance')
+ wait_for(shortcuts_only, 'multiple windows share one shortcut')
+ ipc.action('close_window', {'id': second['id']})
+ wait_for(lambda: len(ipc.get_windows()) == 1, 'second window closed')
+ assert ImageChops.difference(idle, pill(shortcut, f'{app_id}-one-left')).getbbox(), 'pill disappeared with a window left'
+ if shortcut == 'files':
+ before_removal = cfg.read_text()
+ ipc.move_cursor(*center(button(shortcut)))
+ ipc.pointer_button(273, True)
+ ipc.pointer_button(273, False)
+ for code in (103, 28): # Up selects Remove from dock.
+ ipc.key(code, True)
+ ipc.key(code, False)
+ wait_for(lambda: not any(w['name'] == 'files' for w in dock()), 'running shortcut removed')
+ assert not any((w['name'] or '').startswith('window_') for w in dock()), 'removed shortcut left a duplicate'
+ assert len(ipc.get_windows()) == 1, 'removing shortcut closed the app'
+ cfg.write_text(before_removal)
+ ipc.reload_config()
+ wait_for(shortcuts_only, 'shortcut restored with its running app')
+ ipc.action('close_window', {'id': wid})
+ wait_for(lambda: not ipc.get_windows(), 'last window closed')
+ ipc.wait_for_frame()
+ restored = pill(shortcut, f'{app_id}-closed')
+ difference = ImageChops.difference(idle, restored)
+ assert max(high for low, high in difference.getextrema()) <= 1, 'pill survived the last window'
display = wait_for(lambda: next((p.name for p in tmp.glob('wayland-*') if not p.name.endswith('.lock')), None), 'display')
clients.append(subprocess.Popen([str(tmp / 'client'), '--app-id', 'dock.test', '--title', 'Dock test'],
env=dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WAYLAND_DISPLAY=display), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL))
@@ -151,8 +305,332 @@ enabled = false
ipc.reload_config()
wait_for(lambda: not dock(), 'reload disables dock')
assert ipc.hit_test(x, y)['target_type'] != 'dock', 'disabled dock intercepts input'
- print(f'PASS: dock defaults, Appearance, persistence, hover, launcher, settings, windows, fullscreen, reload ({scale}x)')
+ print(f'PASS: dock defaults, Appearance height, persistence, hover, grouped launchers, running pills, windows, fullscreen, reload ({scale}x)')
+ except Exception:
+ print((tmp / 'compositor.log').read_text()[-4000:])
+ raise
+ finally:
+ for client in clients:
+ stop_process(client)
+ stop_process(process)
+ log.close()
+
+
+def context_menu():
+ scale = float(os.environ.get('REDIWM_TEST_SCALE', '1'))
+ with tempfile.TemporaryDirectory(prefix='rediwm-dock-menu-') as directory:
+ tmp = Path(directory)
+ build_client(tmp)
+ env_extra = {'DBUS_SESSION_BUS_ADDRESS': '', 'DBUS_SYSTEM_BUS_ADDRESS': 'unix:path=/nonexistent',
+ 'XDG_CONFIG_HOME': str(tmp / 'config'), 'XDG_DATA_HOME': str(tmp / 'data'),
+ 'XDG_CACHE_HOME': str(tmp / 'cache')}
+ process, log = spawn_compositor(tmp, scale=scale,
+ outputs=os.environ.get('REDIWM_TEST_OUTPUTS', '1'),
+ config_content='# keep this comment\n[compositor]\nxwayland = false\ndock_enabled = true\ndock_height = 96\n'
+ '[animations]\nenabled = false\n', env_extra=env_extra)
+ cfg = tmp / 'rediwm-config.toml'
+ clients = []
+ try:
+ with IPCClient(tmp) as ipc:
+ ipc.wait_for('wallpaper_presented', timeout_ms=10000)
+ ui = UIDriver(ipc)
+ display = wait_for(lambda: next((p.name for p in tmp.glob('wayland-*')
+ if not p.name.endswith('.lock')), None), 'display')
+
+ def names():
+ return {w['name'] for w in ui.widgets('dock') if w['name']}
+
+ def launch(app):
+ previous = {w['id'] for w in ipc.get_windows()}
+ client = subprocess.Popen([str(tmp / 'client'), '--app-id', app],
+ env=dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WAYLAND_DISPLAY=display),
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ clients.append(client)
+ win = wait_for(lambda: next((w for w in ipc.get_windows() if w['id'] not in previous), None), 'client')
+ ipc.wait_for_frame()
+ return client, win['id']
+
+ def menu(name):
+ widget = wait_for(lambda: next((w for w in ui.widgets('dock') if w['name'] == name), None), name)
+ box = widget['global_box']
+ x = round(box['x'] + box['width'] / 2)
+ ipc.move_cursor(x, round(box['y'] + box['height'] / 2))
+ ipc.pointer_button(273, True)
+ ipc.pointer_button(273, False)
+ ipc.wait_for_frame()
+ height = 122 if name.startswith('window_') else 44
+ return x, ui.widgets('dock')[0]['global_box']['y'] - height - 4
+
+ def key(code):
+ ipc.key(code, True)
+ ipc.key(code, False)
+
+ first, wid = launch('dock.removed')
+ second, other_id = launch('dock.removed')
+ x, y = menu(f'window_{wid}')
+ ipc.click_at(x + 20, y + 41) # Separator is inert.
+ assert len(ipc.get_windows()) == 2
+ key(1) # Escape
+ menu(f'window_{wid}')
+ ipc.click_at(5, 5) # Outside dismisses without activating the dock.
+ assert len(ipc.get_windows()) == 2
+ menu(f'window_{wid}')
+ key(103) # Up selects Remove from dock.
+ key(28)
+ wait_for(lambda: not any(n.startswith('window_') for n in names()), 'app removed')
+ assert {w['id'] for w in ipc.get_windows()} == {wid, other_id}
+ assert len(ipc.get_shell_state()['taskbars'][0]['chips']) == 2
+ assert tomllib.loads(cfg.read_text())['compositor']['dock_hidden_apps'] == ['dock.removed']
+ ipc.reload_config()
+ assert not any(n.startswith('window_') for n in names())
+
+ x, y = menu('terminal')
+ ipc.click_at(x + 20, y + 22)
+ wait_for(lambda: 'terminal' not in names(), 'shortcut removed')
+ assert tomllib.loads(cfg.read_text())['compositor']['dock_hidden_shortcuts'] == ['terminal']
+ assert '# keep this comment' in cfg.read_text()
+
+ client, close_id = launch('dock.close')
+ x, y = menu(f'window_{close_id}')
+ ipc.click_at(x + 20, y + 22)
+ wait_for(lambda: all(w['id'] != close_id for w in ipc.get_windows()), 'Close')
+ assert client.wait(timeout=5) == 0
+ client, hung_id = launch('dock.hung')
+ ipc.action('minimize_window', {'id': hung_id})
+ client.send_signal(signal.SIGSTOP)
+ menu(f'window_{hung_id}')
+ key(108)
+ key(108) # Down selects Force Close, skipping the separator.
+ key(28)
+ wait_for(lambda: all(w['id'] != hung_id for w in ipc.get_windows()), 'Force Close')
+ assert client.wait(timeout=5) == -signal.SIGKILL
+
+ client, gone_id = launch('dock.gone')
+ menu(f'window_{gone_id}')
+ stop_process(client)
+ wait_for(lambda: all(w['id'] != gone_id for w in ipc.get_windows()), 'menu target gone')
+ ipc.wait_for_frame()
+ assert process.poll() is None
+
+ # An anonymous window can be hidden without hiding other anonymous windows.
+ anonymous, anon_id = launch('')
+ anonymous2, anon_id2 = launch('')
+ menu(f'window_{anon_id}')
+ key(103)
+ key(28)
+ wait_for(lambda: f'window_{anon_id}' not in names(), 'anonymous window removed')
+ assert f'window_{anon_id2}' in names()
+ assert len(ipc.get_windows()) == 4
+ stop_process(anonymous)
+ stop_process(anonymous2)
+ wait_for(lambda: len(ipc.get_windows()) == 2, 'anonymous cleanup')
+
+ # Disabling the dock dismisses even a shortcut menu with no window target.
+ menu('applications')
+ cfg.write_text(cfg.read_text().replace('dock_enabled = true', 'dock_enabled = false'))
+ ipc.reload_config()
+ wait_for(lambda: not names(), 'disabled dock')
+ key(28)
+ assert tomllib.loads(cfg.read_text())['compositor']['dock_hidden_shortcuts'] == ['terminal']
+ cfg.write_text(cfg.read_text().replace('dock_enabled = false', 'dock_enabled = true'))
+ ipc.reload_config()
+ wait_for(names, 'dock restored')
+ for shortcut in ('files', 'applications', 'settings'):
+ menu(shortcut)
+ key(103)
+ key(28)
+ wait_for(lambda: shortcut not in names(), 'shortcut removed')
+ assert not names(), 'empty dock should be hidden'
+ saved = cfg.read_text()
+
+ for client in clients:
+ stop_process(client)
+ stop_process(process)
+ log.close()
+ process, log = spawn_compositor(tmp, scale=scale, config_content=saved, env_extra=env_extra)
+ with IPCClient(tmp) as ipc:
+ ipc.wait_for('wallpaper_presented', timeout_ms=10000)
+ ui = UIDriver(ipc)
+ display = wait_for(lambda: next((p.name for p in tmp.glob('wayland-*')
+ if not p.name.endswith('.lock')), None), 'display after restart')
+ assert not names(), 'removed shortcuts returned after restart'
+ client, reopened = launch('dock.removed')
+ assert not names(), 'removed app returned after restart'
+ assert any(c['window_id'] == reopened for c in ipc.get_shell_state()['taskbars'][0]['chips'])
+ cfg.write_text(cfg.read_text().replace(
+ 'dock_hidden_shortcuts = ["terminal", "files", "applications", "settings"]',
+ 'dock_hidden_shortcuts = []').replace('[compositor]', '[compositor]\ntaskbar_position = "top"'))
+ ipc.reload_config()
+ wait_for(lambda: names() == {'applications', 'files', 'terminal', 'settings'}, 'shortcuts restored')
+ assert ui.widgets('dock')[0]['global_box']['height'] == 96, 'dock height lost after restart'
+ # A dock menu stays above the dock with a top taskbar, too.
+ x, y = menu('settings')
+ ipc.click_at(x + 20, y + 22)
+ wait_for(lambda: 'settings' not in names(), 'menu anchored to dock')
+ print(f'PASS: dock context menu, Close, Force Close, removal, dismissal, anonymous windows, persistence ({scale}x)')
+ except Exception:
+ log.flush()
+ print((tmp / 'compositor.log').read_text()[-4000:])
+ raise
+ finally:
+ for client in clients:
+ stop_process(client)
+ stop_process(process)
+ log.close()
+
+
+def pill_animation():
+ scale = float(os.environ.get('REDIWM_TEST_SCALE', '1'))
+ with tempfile.TemporaryDirectory(prefix='rediwm-dock-pill-') as directory:
+ tmp = Path(directory)
+ build_client(tmp)
+ process, log = spawn_compositor(tmp, scale=scale,
+ outputs=os.environ.get('REDIWM_TEST_OUTPUTS', '1'),
+ config_content='[compositor]\nxwayland = false\ndock_enabled = true\n'
+ '[animations]\nenabled = true\nspeed = 1.0\nreduced_motion = "off"\n',
+ env_extra={'DBUS_SESSION_BUS_ADDRESS': '', 'XDG_CONFIG_HOME': str(tmp / 'config'),
+ 'XDG_DATA_HOME': str(tmp / 'data'), 'XDG_DATA_DIRS': str(tmp / 'empty'),
+ 'XDG_CACHE_HOME': str(tmp / 'cache'), 'TERMINAL': 'foot'})
+ clients = []
+ try:
+ with IPCClient(tmp) as ipc:
+ ipc.wait_for('wallpaper_presented', timeout_ms=10000)
+ primary = ipc.get_outputs()[0]['name']
+ prefix = f'dock.{primary}.terminal.pill_'
+ display = wait_for(lambda: next((p.name for p in tmp.glob('wayland-*')
+ if not p.name.endswith('.lock')), None), 'display')
+ ui = UIDriver(ipc)
+ clock = 1000
+ ipc.action('set_anim_time', {'ms': clock})
+ ipc.wait_for_frame(output=primary)
+
+ def state(part='width'):
+ return next(a for a in ipc.action('get_animations') if a['site'] == prefix + part)
+
+ def advance(ms):
+ nonlocal clock
+ clock += ms
+ ipc.action('set_anim_time', {'ms': clock})
+ ipc.wait_for_frame(output=primary)
+
+ def launch(app):
+ previous = {w['id'] for w in ipc.get_windows()}
+ client = subprocess.Popen([str(tmp / 'client'), '--app-id', app],
+ env=dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WAYLAND_DISPLAY=display),
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ clients.append(client)
+ win = wait_for(lambda: next((w for w in ipc.get_windows() if w['id'] not in previous), None), 'client')
+ ipc.wait_for_frame(output=primary)
+ return win['id']
+
+ def pixels(name):
+ path = tmp / (name + '.png')
+ ipc.screenshot(str(path))
+ widgets = ui.widgets('dock')
+ b = next(w['global_box'] for w in widgets if w['name'] == 'terminal')
+ root = widgets[0]['global_box']
+ x, y = b['x'] + b['width'] / 2, b['y'] + b['height'] + 1
+ with Image.open(path) as image:
+ return image.convert('RGB').crop(tuple(round(v * scale) for v in
+ (x - 14, y, x + 14, root['y'] + root['height'] - 2)))
+
+ idle = pixels('idle')
+ wid = launch('foot')
+ assert state()['target'] == 22 and state()['value'] == 0
+ assert state()['curve'] == 'spring' and not state()['settled']
+ advance(60)
+ growing = state()
+ assert 0 < growing['value'] < 22
+ assert 0 < state('opacity')['value'] < 1
+ assert ImageChops.difference(idle, pixels('growing')).getbbox(), 'animated pill did not paint'
+ ipc.action('minimize_window', {'id': wid})
+ ipc.wait_for_frame(output=primary)
+ shrinking = state()
+ assert shrinking['target'] == 10
+ assert abs(shrinking['value'] - growing['value']) < 0.001
+ assert abs(shrinking['velocity'] - growing['velocity']) < 0.001
+ advance(60)
+ before = state()
+ ipc.action('restore_window', {'id': wid})
+ ipc.wait_for_frame(output=primary)
+ after = state()
+ assert after['target'] == 22 and abs(after['value'] - before['value']) < 0.001
+ assert abs(after['velocity'] - before['velocity']) < 0.001
+ advance(1000)
+ assert state()['settled'] and state()['value'] == 22
+
+ other = launch('dock.pill.other')
+ assert state()['target'] == 10 and state()['value'] == 22
+ advance(60)
+ before = state()
+ assert 10 < before['value'] < 22
+ cfg = tmp / 'rediwm-config.toml'
+ cfg.write_text(cfg.read_text().replace('[compositor]', '[compositor]\ndock_hidden_shortcuts = ["files"]'))
+ ipc.reload_config()
+ ipc.wait_for_frame(output=primary)
+ after = state()
+ assert abs(after['value'] - before['value']) < 0.001, 'dock rebuild restarted the pill'
+ assert abs(after['velocity'] - before['velocity']) < 0.001
+ cfg.write_text(cfg.read_text().replace('speed = 1.0', 'speed = 0.5'))
+ ipc.reload_config()
+ ipc.wait_for_frame(output=primary)
+ assert abs(state()['value'] - before['value']) < 0.001, 'speed reload jumped the pill'
+ advance(1000)
+ assert state()['value'] == 10 and state()['settled']
+ cfg.write_text(cfg.read_text().replace('dock_hidden_shortcuts = ["files"]\n', ''))
+ ipc.reload_config()
+ ipc.wait_for_frame(output=primary)
+ ipc.action('close_window', {'id': other})
+ wait_for(lambda: len(ipc.get_windows()) == 1, 'other closed')
+ ipc.wait_for_frame(output=primary)
+ ipc.action('close_window', {'id': wid})
+ wait_for(lambda: not ipc.get_windows(), 'terminal closed')
+ ipc.wait_for_frame(output=primary)
+ assert state()['target'] == 0 and state('opacity')['target'] == 0
+ advance(60)
+ assert 0 < state('opacity')['value'] < 1, 'pill disappeared without fading'
+ advance(1000)
+ assert state()['value'] == 0 and state('opacity')['value'] == 0
+ difference = ImageChops.difference(idle, pixels('gone'))
+ assert max(high for low, high in difference.getextrema()) <= 1, 'faded pill left pixels'
+ ipc.reset_perf()
+ for _ in range(3):
+ ipc.wait_for_frame(output=primary)
+ assert ipc.get_perf()['anim_frames_scheduled'] == 0, 'pinned animation spins'
+
+ # Turning animations off settles a transition immediately.
+ wid = launch('foot')
+ advance(60)
+ cfg.write_text(cfg.read_text().replace('\nenabled = true\n', '\nenabled = false\n'))
+ ipc.reload_config()
+ ipc.wait_for_frame(output=primary)
+ assert state()['value'] == 22 and state()['settled']
+ ipc.action('minimize_window', {'id': wid})
+ ipc.wait_for_frame(output=primary)
+ assert state()['value'] == 10 and state('opacity')['value'] == 0.4
+
+ # Reduced motion jumps width but retains the short opacity fade.
+ cfg.write_text(cfg.read_text().replace('\nenabled = false\n', '\nenabled = true\n').replace('reduced_motion = "off"', 'reduced_motion = "on"'))
+ ipc.reload_config()
+ ipc.action('restore_window', {'id': wid})
+ ipc.wait_for_frame(output=primary)
+ assert state()['value'] == 22 and state()['settled']
+ advance(1000)
+ assert state('opacity')['settled'] and state('opacity')['value'] == 1
+ ipc.action('set_anim_time', {'ms': None})
+ ipc.move_cursor(5, 5)
+ ipc.wait_for_frame(output=primary)
+ ipc.reset_perf()
+ before = ipc.get_perf()
+ for _ in range(3):
+ ipc.wait_for_frame(output=primary)
+ after = ipc.get_perf()
+ assert after['anim_frames_scheduled'] == 0, 'settled pills keep requesting frames'
+ assert (after['panel_allocated_bytes'] + after['panel_reused_bytes'] ==
+ before['panel_allocated_bytes'] + before['panel_reused_bytes']), 'settled pills keep repainting'
+ print(f'PASS: dock pill growth, focus, reversal, fading, rebuild, speed, reduced motion and idle ({scale}x)')
except Exception:
+ log.flush()
print((tmp / 'compositor.log').read_text()[-4000:])
raise
finally:
@@ -164,3 +642,5 @@ enabled = false
if __name__ == '__main__':
run()
+ context_menu()
+ pill_animation()