Skip to content

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

RediWM dock first iteration

oxydizer564e54639de8
diff --git a/README.md b/README.md
index 11e77e2..2b57c7e 100644
--- a/README.md
+++ b/README.md
@@ -199,6 +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.
- **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 d399eb5..25ae034 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -134,7 +134,8 @@ 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`, `panel_damage.py`, `glass_hold.py` (holds and
+`keyboard_shortcuts.py`, `dock.py` (opt-in Appearance toggle, persistence, launcher/input, running windows, fullscreen and scale),
+`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`,
`launch_placeholder.py`, `appearance_*.py`, `desktop_canvas.py`,
diff --git a/src/Dock.zig b/src/Dock.zig
new file mode 100644
index 0000000..69d338c
--- /dev/null
+++ b/src/Dock.zig
@@ -0,0 +1,266 @@
+//! Optional output-local launcher. Retained rasters; no animation or polling timer.
+const std = @import("std");
+const wlr = @import("wlroots");
+const ui = @import("ui");
+const Output = @import("Output.zig");
+const Toplevel = @import("Toplevel.zig");
+const PanelBuffer = @import("panel_buffer.zig").PanelBuffer;
+const SceneData = @import("scene_data.zig").SceneData;
+const gpa = @import("main.zig").gpa;
+const Self = @This();
+const height = 68;
+const step = 56;
+const max_items = 64;
+
+output: ?*Output = null,
+tree: ?*wlr.SceneTree = null,
+node: ?*wlr.SceneBuffer = null,
+tooltip: ?*wlr.SceneBuffer = null,
+data: SceneData = undefined,
+box: wlr.Box = .{ .x = 0, .y = 0, .width = 0, .height = height },
+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),
+count: usize = 0,
+offset: usize = 0,
+windows: usize = 0,
+dispatcher: ui.input.Dispatcher = .{},
+arena: std.heap.ArenaAllocator = .init(std.heap.page_allocator),
+
+pub fn deinit(self: *Self) void {
+ self.dispatcher.reset();
+ if (self.tree) |tree| tree.node.destroy();
+ self.arena.deinit();
+ self.* = .{};
+}
+
+fn ensureNodes(self: *Self, output: *Output) !void {
+ if (self.tree != null) return;
+ const tree = try output.server.taskbar_tree.createSceneTree();
+ errdefer tree.node.destroy();
+ const node = try tree.createSceneBuffer(null);
+ const tooltip = try tree.createSceneBuffer(null);
+ node.setFilterMode(.bilinear);
+ tooltip.setFilterMode(.bilinear);
+ tooltip.point_accepts_input = ignoreInput;
+ self.output = output;
+ self.data = .{ .role = .{ .dock = self } };
+ self.data.attach(&node.node);
+ 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);
+}
+
+fn ignoreInput(_: *wlr.SceneBuffer, _: *f64, _: *f64) callconv(.c) bool {
+ return false;
+}
+
+pub fn tick(self: *Self, output: *Output) void {
+ 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;
+ }
+ self.ensureNodes(output) catch return;
+ 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
+ !(if (focused) |top| top.fullscreen and top.currentOutput() == output else false);
+ self.tree.?.node.setEnabled(visible);
+ if (self.visible != visible) {
+ self.visible = visible;
+ self.leave();
+ self.dirty = true;
+ }
+ if (!visible) return;
+ if (self.scale != output.wlr_output.scale) 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;
+ const restore_hover = self.dirty and self.dispatcher.hovered != null;
+ if (self.dirty) self.rebuild(capacity) catch return;
+ self.box.x = usable.x + @divTrunc(usable.width - self.box.width, 2);
+ self.box.y = usable.y + usable.height - height - 10;
+ self.tree.?.node.setPosition(self.box.x, self.box.y);
+ if (restore_hover) self.motion(server.input.cursor.x - @as(f64, @floatFromInt(self.box.x)), server.input.cursor.y - @as(f64, @floatFromInt(self.box.y)));
+}
+
+fn rebuild(self: *Self, capacity: usize) !void {
+ const output = self.output.?;
+ 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
+ !@import("workspaces.zig").visible(top) or (top.live_rules.skip_taskbar orelse false) or
+ (output.server.world.workspaces.active and top.currentOutput() != output)) continue;
+ try tops.append(gpa, top);
+ }
+ std.mem.sort(*Toplevel, tops.items, {}, struct {
+ fn less(_: void, a: *Toplevel, b: *Toplevel) bool {
+ return a.id < b.id;
+ }
+ }.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;
+ self.scale = output.wlr_output.scale;
+ self.dispatcher.reset();
+ _ = self.arena.reset(.retain_capacity);
+ self.tooltip.?.node.setEnabled(false);
+ 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,
+ };
+ }
+ try self.paint();
+ self.dirty = false;
+}
+
+fn topAt(self: *Self, index: usize) ?*Toplevel {
+ const id = self.ids[index];
+ if (id == 0) return null;
+ var it = self.output.?.server.world.toplevels.iterator(.forward);
+ while (it.next()) |top| if (top.id == id and top.in_world and !top.backend_gone and !top.closing) return top;
+ return null;
+}
+
+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";
+ return if (self.topAt(index)) |top| top.title() else "Application";
+}
+
+fn paint(self: *Self) !void {
+ const output = self.output.?;
+ const pal = ui.theme.shellPalette();
+ const image = try PanelBuffer.create(self.box.width, 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 bg = ui.theme.taskbar(.taskbar_bg);
+ bg[3] = @max(bg[3], 0.86);
+ 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 });
+ for (self.buttons[0..self.count], 0..) |button, index| {
+ const x = button.computed_x;
+ const top = self.topAt(index);
+ ui.widgets.button.paintBackground(&r, .{ .x = x, .y = 8, .w = 48, .h = 48 }, .{ .variant = .ghost, .radius = 12 }, .{ .pointer = button.kind.button.state, .selected = if (top) |t| @import("ipc/handlers.zig").findFocusedToplevel(output.server) == t else false });
+ 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));
+ if (lookup == .ready) {
+ const icon = lookup.ready;
+ r.drawImageCover(x + 6, 14, 36, 36, 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 });
+ }
+ if (top) |t| {
+ const focused = @import("ipc/handlers.zig").findFocusedToplevel(output.server) == t;
+ var accent = pal.accent;
+ accent[3] *= if (t.minimized) @as(f32, 0.4) else 1;
+ const width: f32 = if (focused) 22 else 10;
+ r.fillRect(x + 24 - width / 2, 58, width, 4, .{ .color = accent, .radius = 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 });
+ self.node.?.setBuffer(&image.base);
+ self.node.?.setDestSize(self.box.width, height);
+ try self.paintTooltip();
+}
+
+fn paintTooltip(self: *Self) !void {
+ const hovered = self.dispatcher.hovered orelse {
+ self.tooltip.?.node.setEnabled(false);
+ return;
+ };
+ if (hovered.kind != .button) {
+ self.tooltip.?.node.setEnabled(false);
+ return;
+ }
+ const index = hovered.kind.button.id;
+ const pal = ui.theme.shellPalette();
+ const value = self.label(index);
+ const width: i32 = @intFromFloat(@min(@as(f32, @floatFromInt(self.box.width)), @max(80, (ui.text.measureWidthF(value, .manrope, pal.font_size, 1) catch 100) + 24)));
+ const image = try PanelBuffer.create(width, 30, self.scale);
+ defer image.base.drop();
+ var r = ui.paint.Renderer.init(image.pixels, image.width, image.height, self.scale);
+ r.palette = pal;
+ var bg = pal.window_bg;
+ bg[3] = 0.98;
+ r.fillRect(0, 0, @floatFromInt(width), 30, .{ .color = bg, .radius = 8, .border_width = 1, .border_color = pal.accent });
+ 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.setEnabled(true);
+}
+
+pub fn motion(self: *Self, x: f64, y: f64) void {
+ const old = self.dispatcher.hovered;
+ self.dispatcher.pointerMotion(&self.root, @floatCast(x), @floatCast(y));
+ if (old != self.dispatcher.hovered) self.repaint();
+}
+
+pub fn leave(self: *Self) void {
+ if (self.dispatcher.hovered == null) return;
+ self.dispatcher.pointerLeave(&self.root);
+ self.repaint();
+}
+
+fn repaint(self: *Self) void {
+ if (self.node == null) return;
+ self.paint() catch {};
+ self.output.?.wlr_output.scheduleFrame();
+}
+
+pub fn press(self: *Self, x: f64, y: f64) void {
+ // Shell launchers activate on press, like the taskbar.
+ self.dispatcher.pointerButtonDown(&self.root, @floatCast(x), @floatCast(y));
+ self.dispatcher.pointerButtonUp(&self.root, @floatCast(x), @floatCast(y));
+ self.repaint();
+}
+
+pub fn scroll(self: *Self, delta: f64) void {
+ if (delta == 0 or self.windows + 4 <= self.count) return;
+ if (delta > 0) self.offset +|= 1 else self.offset -|= 1;
+ self.dirty = true;
+ self.output.?.wlr_output.scheduleFrame();
+}
+
+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| {
+ const focused = @import("ipc/handlers.zig").findFocusedToplevel(server) == top;
+ if (!top.minimized and focused and server.world.isWindowVisible(top, output)) {
+ top.minimize();
+ } else {
+ if (top.minimized) top.restore() else server.world.focus(top);
+ server.world.navigateTo(top, output);
+ }
+ }
+}
diff --git a/src/Input.zig b/src/Input.zig
index 2174f8a..47ce0f9 100644
--- a/src/Input.zig
+++ b/src/Input.zig
@@ -247,7 +247,8 @@ pub fn isDesktopZoomHeld(input: *Input) bool {
/// button). A fresh hit test rather than `hovered_taskbar`, which is only
/// refreshed by passthrough motion and would otherwise lag one event behind.
pub fn cursorOverTaskbar(input: *Input) bool {
- return scene_data.hitTest(input.server, input.cursor.x, input.cursor.y) == .taskbar;
+ const hit = scene_data.hitTest(input.server, input.cursor.x, input.cursor.y);
+ return hit == .taskbar or hit == .dock;
}
pub fn updateAccel(input: *Input, profile: AccelProfile, p1: [2]f32, p2: [2]f32, max_speed: f32) void {
@@ -1522,6 +1523,10 @@ fn passthroughMotion(input: *Input, time_msec: u32) void {
if (hit != .toast) {
input.clearToastHover();
}
+ var dock_it = input.server.outputs.iterator(.forward);
+ while (dock_it.next()) |out| {
+ if (hit != .dock or hit.dock.dock != &out.dock) out.dock.leave();
+ }
input.server.world.mini_map.hover(hit == .mini_map);
if (hit != .power_menu) {
if (input.open_power_menu) |menu| menu.pointerMotion(-1, -1);
@@ -1561,6 +1566,14 @@ fn passthroughMotion(input: *Input, time_msec: u32) void {
input.setDefaultCursor();
input.seat.pointerClearFocus();
},
+ .dock => |res| {
+ input.hovered_resize_edges = null;
+ input.clearTaskbarHover();
+ input.setHover(null, null);
+ res.dock.motion(res.sx, res.sy);
+ input.setDefaultCursor();
+ input.seat.pointerClearFocus();
+ },
.taskbar => |res| {
input.hovered_resize_edges = null;
if (input.hovered_taskbar) |previous| {
@@ -2071,6 +2084,10 @@ fn processClientButton(
res.toast.pointerButtonDown(res.sx, res.sy);
return;
},
+ .dock => |res| {
+ if (button == btn_left) res.dock.press(res.sx, res.sy);
+ return;
+ },
.taskbar => |res| {
res.bar.pointerPress(res.sx, res.sy);
return;
@@ -2361,6 +2378,10 @@ pub fn processAxis(
}
return;
},
+ .dock => |hit| {
+ hit.dock.scroll(ui_scroll.axisDeltaPx(delta, delta_discrete));
+ return;
+ },
.taskbar => |hit| {
if (orientation == .vertical_scroll) {
hit.bar.scrollVolume(hit.sx, hit.sy, ui_scroll.axisDeltaPx(delta, delta_discrete));
diff --git a/src/Output.zig b/src/Output.zig
index 2b1c123..6a26bac 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -74,6 +74,7 @@ server: *Server,
wlr_output: *wlr.Output,
wallpaper: ?*wlr.SceneBuffer = null,
taskbar: ?*Taskbar = null,
+dock: @import("Dock.zig") = .{},
osd: @import("osd.zig") = .{},
start_menu: ?*StartMenu = null,
calendar: ?*@import("calendar.zig").Calendar = null,
@@ -523,6 +524,7 @@ pub fn syncLayout(server: *Server) void {
var it = server.outputs.iterator(.forward);
while (it.next()) |output| {
if (output.idle_blanked or output.user_disabled) {
+ output.dock.deinit();
if (output.server.switcher.output == output) output.server.switcher.cancel();
output.osd.hide();
continue;
@@ -1215,6 +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 taskbar_started = stats.nowNs();
var bar_animating = false;
if (output.taskbar) |bar| bar_animating = bar.tick(now_ms);
@@ -1472,6 +1475,7 @@ fn handleDestroy(listener: *wl.Listener(*wlr.Output), _: *wlr.Output) void {
output.lock_view.tree.node.destroy();
if (output.wallpaper) |node| node.node.destroy();
+ output.dock.deinit();
if (output.taskbar) |bar| bar.destroy();
output.closeCalendar();
output.closeBattery();
diff --git a/src/Server.zig b/src/Server.zig
index 772887a..8014791 100644
--- a/src/Server.zig
+++ b/src/Server.zig
@@ -1181,6 +1181,7 @@ pub fn refreshTaskbars(server: *Server) void {
const desired_h = Taskbar.barHeight();
var it = server.outputs.iterator(.forward);
while (it.next()) |output| {
+ output.dock.dirty = true;
if (output.taskbar) |bar| {
if (bar.box.height != desired_h) {
var box: wlr.Box = undefined;
@@ -1224,6 +1225,7 @@ pub fn releaseTaskbars(server: *Server) void {
pub fn refreshTaskbarsGeometry(server: *Server) void {
var it = server.outputs.iterator(.forward);
while (it.next()) |output| {
+ output.dock.dirty = true;
if (output.taskbar) |bar| {
var box: wlr.Box = undefined;
server.output_layout.getBox(output.wlr_output, &box);
@@ -1686,6 +1688,7 @@ fn handleIconWake(fd: c_int, mask: wl.EventMask, server: *Server) c_int {
var output_it = server.outputs.iterator(.forward);
while (output_it.next()) |output| {
if (output.taskbar) |bar| bar.notifyToplevelsChanged();
+ output.dock.dirty = true;
if (output.start_menu) |sm| sm.iconsReady();
}
if (server.notifications) |mgr| mgr.iconsReady();
diff --git a/src/Shell.zig b/src/Shell.zig
index e0fc27e..7b8d628 100644
--- a/src/Shell.zig
+++ b/src/Shell.zig
@@ -74,7 +74,7 @@ fn newXdgDecoration(
const toplevel = switch (data.role) {
.toplevel => |t| t,
.chrome => |t| t,
- .wifi_popup, .battery_popup, .calendar, .taskbar, .control_center, .start_menu, .power_menu, .layer, .xwayland_unmanaged, .toast, .desktop, .mini_map => return,
+ .wifi_popup, .battery_popup, .calendar, .taskbar, .dock, .control_center, .start_menu, .power_menu, .layer, .xwayland_unmanaged, .toast, .desktop, .mini_map => return,
};
Decoration.create(decoration, toplevel) catch |err| {
log.err("newXdgDecoration: could not track decoration: {}", .{err});
diff --git a/src/config/default.zig b/src/config/default.zig
index 9e656c0..72644cf 100644
--- a/src/config/default.zig
+++ b/src/config/default.zig
@@ -117,6 +117,7 @@ pub const source =
\\# Desktop application IDs; empty keeps Files and the automatic terminal.
\\default_file_manager = ""
\\default_terminal = ""
+ \\dock_enabled = false # compact launcher alongside the taskbar
\\# 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 3eb9c80..3890ea4 100644
--- a/src/config/loader.zig
+++ b/src/config/loader.zig
@@ -124,6 +124,7 @@ pub const CompositorConfig = struct {
floating_apps: []const []const u8 = &.{},
default_file_manager: []const u8 = "",
default_terminal: []const u8 = "",
+ dock_enabled: bool = false,
taskbar_items: TaskbarItems = .{},
taskbar_position: enum { top, bottom } = .bottom,
/// App identities opted into compositor tabs. Only + launches join a group.
@@ -1035,6 +1036,7 @@ const region_rules: std.enums.EnumFieldStruct(std.meta.FieldEnum(RegionConfig),
const compositor_rules: std.enums.EnumFieldStruct(std.meta.FieldEnum(CompositorConfig), FieldRule, null) = .{
.desktop_mode = .enumeration,
.floating_apps = .json_string_list,
+ .dock_enabled = .boolean,
.taskbar_items = .taskbar_items,
.taskbar_position = .enumeration,
.icon_theme = .string,
diff --git a/src/config_runtime/apply.zig b/src/config_runtime/apply.zig
index ec7cb26..dc5137c 100644
--- a/src/config_runtime/apply.zig
+++ b/src/config_runtime/apply.zig
@@ -199,6 +199,11 @@ pub fn applyDiff(server: *Server, old: Config, new: Config) void {
if (old.compositor.taskbar_position != new.compositor.taskbar_position) server.applyTaskbarPosition();
+ if (old.compositor.dock_enabled != new.compositor.dock_enabled) {
+ server.scheduleFrames();
+ if (server.input.open_control_center) |cc| cc.refresh();
+ }
+
logKeybindDiff(old, new);
for (new.autostart) |cmd| {
diff --git a/src/control_center/sections/appearance.zig b/src/control_center/sections/appearance.zig
index 5447b93..ca1d696 100644
--- a/src/control_center/sections/appearance.zig
+++ b/src/control_center/sections/appearance.zig
@@ -101,7 +101,8 @@ pub const Section = struct {
cursor_themes: ?[]cursor_theme.Theme = null,
cursor_row_children: [2]Widget = undefined,
family_row_children: [2]Widget = undefined,
- row_storage: [25]Widget = undefined,
+ row_storage: [26]Widget = undefined,
+ dock_children: [2]Widget = undefined,
focus_zoom_children: [3]Widget = undefined,
/// Rescanned on every build, so images added meanwhile show up.
wallpapers: []const wallpapers.Entry = &.{},
@@ -728,6 +729,10 @@ pub fn build(out: *Section, cc: *panel.ControlCenter) void {
labelWidget("Icon theme"),
.{ .name = "icon_theme", .kind = .{ .select = .{ .labels = icon_labels, .selected = icon_selected, .placeholder = "Pack or system default", .owner = out, .on_change = &onIconThemePicked } }, .width = .{ .fixed = segmented_width } },
};
+ out.dock_children = .{
+ labelWidget("RediWM dock"),
+ .{ .name = "dock_enabled", .kind = .{ .toggle = .{ .on = out.cc.server.config.compositor.dock_enabled, .owner = out, .on_change = &onDockChanged } } },
+ };
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 },
@@ -752,6 +757,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 },
taskbar_section,
start_menu_section,
};
@@ -1756,3 +1762,15 @@ fn onWindowTabsChanged(owner: ?*anyopaque, index: usize, checked: bool) void {
fn section(owner: ?*anyopaque) *Section {
return @ptrCast(@alignCast(owner.?));
}
+
+fn onDockChanged(owner: ?*anyopaque, _: usize, on: bool) void {
+ const server = section(owner).cc.server;
+ setting_save.saveCompositor(main.gpa, server.io, server.config.path, "dock_enabled", on) catch |err| {
+ std.log.warn("could not save dock: {}", .{err});
+ section(owner).dock_children[1].kind.toggle.on = server.config.compositor.dock_enabled;
+ section(owner).dock_children[1].markDirty();
+ return;
+ };
+ server.config.compositor.dock_enabled = on;
+ server.scheduleFrames();
+}
diff --git a/src/ipc/handlers.zig b/src/ipc/handlers.zig
index 36d1a6a..eb83d70 100644
--- a/src/ipc/handlers.zig
+++ b/src/ipc/handlers.zig
@@ -446,6 +446,11 @@ pub fn handleRequest(
result.local_x = s.sx;
result.local_y = s.sy;
},
+ .dock => |d| {
+ result.target_type = "dock";
+ result.local_x = d.sx;
+ result.local_y = d.sy;
+ },
.taskbar => |tb| {
result.target_type = "taskbar";
result.local_x = tb.sx;
@@ -574,7 +579,7 @@ pub fn handleRequest(
.widgets = try widgets.toOwnedSlice(allocator),
} } };
}
- return .{ .err = "InvalidPanel: expected start_menu, control_center, power_menu, taskbar, or window" };
+ return .{ .err = "InvalidPanel: expected start_menu, control_center, power_menu, dock, taskbar, or window" };
},
.list_panels => {
const def_out = server.getDefaultOutput();
@@ -1940,7 +1945,13 @@ fn resolvePowerMenu(out: *Output) ?PanelRoot {
return .{ .root = &pm.root, .box = pm.panel_box };
}
+fn resolveDock(output: *Output) ?PanelRoot {
+ if (!output.dock.visible) return null;
+ return .{ .root = &output.dock.root, .box = output.dock.box };
+}
+
pub const panel_registry = [_]PanelRegistryEntry{
+ .{ .name = "dock", .resolve = resolveDock },
.{ .name = "start_menu", .resolve = resolveStartMenu },
.{ .name = "control_center", .resolve = resolveControlCenter },
.{ .name = "power_menu", .resolve = resolvePowerMenu },
diff --git a/src/scene_data.zig b/src/scene_data.zig
index 81ef527..8ff3390 100644
--- a/src/scene_data.zig
+++ b/src/scene_data.zig
@@ -24,6 +24,7 @@ pub const SceneData = struct {
chrome: *Toplevel,
/// Taskbar strip for one output.
taskbar: *Taskbar,
+ dock: *@import("Dock.zig"),
calendar: *@import("calendar.zig").Calendar,
battery_popup: *@import("battery_popup.zig").Popup,
wifi_popup: *@import("network/popup.zig").Popup,
@@ -68,6 +69,7 @@ pub const Hit = union(enum) {
chrome: Chrome,
surface: Surface,
taskbar: TaskbarHit,
+ dock: struct { dock: *@import("Dock.zig"), sx: f64, sy: f64 },
wifi_popup: struct { popup: *@import("network/popup.zig").Popup, sx: f64, sy: f64 },
battery_popup: struct { popup: *@import("battery_popup.zig").Popup, sx: f64, sy: f64 },
calendar: struct { calendar: *@import("calendar.zig").Calendar, sx: f64, sy: f64 },
@@ -185,6 +187,10 @@ pub fn hitTest(server: *@import("Server.zig"), lx: f64, ly: f64) Hit {
const local = toNodeLocal(&calendar.buffer_node.node, lx, ly);
break :blk .{ .calendar = .{ .calendar = calendar, .sx = local.x, .sy = local.y } };
},
+ .dock => |dock| blk: {
+ const local = toNodeLocal(&dock.node.?.node, lx, ly);
+ break :blk .{ .dock = .{ .dock = dock, .sx = local.x, .sy = local.y } };
+ },
.taskbar => |bar| blk: {
const local = toNodeLocal(&bar.buffer_node.node, lx, ly);
break :blk .{ .taskbar = .{ .bar = bar, .sx = local.x, .sy = local.y } };
diff --git a/tests/dock.py b/tests/dock.py
new file mode 100644
index 0000000..f297977
--- /dev/null
+++ b/tests/dock.py
@@ -0,0 +1,157 @@
+#!/usr/bin/env python3
+"""Optional dock: settings persistence, input, window lifecycle and scaling."""
+import os
+from pathlib import Path
+import subprocess
+import tempfile
+import tomllib
+
+from PIL import Image, ImageChops
+from desktop_zoom import build_client, wait_for
+from ipc_client import IPCClient, spawn_compositor, stop_process
+from ui_driver import UIDriver
+
+
+def run():
+ scale = float(os.environ.get('REDIWM_TEST_SCALE', '1'))
+ with tempfile.TemporaryDirectory(prefix='rediwm-dock-') 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]
+xwayland = false
+[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'})
+ clients = []
+ try:
+ with IPCClient(tmp) as ipc:
+ ipc.wait_for('wallpaper_presented', timeout_ms=10000)
+ ui = UIDriver(ipc)
+ def dock():
+ return ui.widgets('dock')
+ def button(name):
+ return next(w for w in dock() if w['name'] == name)
+ def center(widget):
+ b = widget['global_box']
+ return round(b['x'] + b['width'] / 2), round(b['y'] + b['height'] / 2)
+ def click(widget):
+ ipc.click_at(*center(widget))
+ ipc.wait_for_frame()
+ def shot(name):
+ path = tmp / (name + '.png')
+ ipc.screenshot(str(path))
+ with Image.open(path) as image:
+ return image.convert('RGB')
+ assert not dock(), 'dock must default off'
+ ipc.action('open_control_center')
+ ipc.wait_for_panel_settled('control_center')
+ click(ui.find('Appearance', panel='control_center'))
+ toggle = ui.scroll_into_view('dock_enabled')
+ assert toggle['on'] is False
+ click(toggle)
+ wait_for(dock, 'dock enabled')
+ assert tomllib.loads((tmp / 'rediwm-config.toml').read_text())['compositor']['dock_enabled']
+ click(ui.scroll_into_view('dock_enabled'))
+ wait_for(lambda: not dock(), 'dock disabled')
+ 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')
+ 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)
+ plain = shot('plain')
+ ipc.move_cursor(*center(button('terminal')))
+ ipc.wait_for_frame()
+ hover = shot('hover')
+ assert ImageChops.difference(plain, hover).getbbox(), 'no hover feedback'
+ if preview := os.environ.get('REDIWM_DOCK_PREVIEW'):
+ hover.save(preview)
+ click(button('applications'))
+ wait_for(lambda: ipc.get_shell_state()['start_menu'], 'dock launcher')
+ ipc.action('close_panel', {'panel': 'start_menu'})
+ ipc.wait_for_frame()
+ click(button('settings'))
+ wait_for(lambda: ipc.get_shell_state()['control_center'], 'dock settings')
+ ipc.action('close_panel', {'panel': 'control_center'})
+ ipc.wait_for_frame()
+ 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))
+ win = wait_for(lambda: next((w for w in ipc.get_windows() if w['app_id'] == 'dock.test'), None), 'test window')
+ wid = win['id']
+ name = f'window_{wid}'
+ wait_for(lambda: any(w['name'] == name for w in dock()), 'window in dock')
+ ipc.wait_for('window_geometry_settled', window_id=wid)
+ click(button(name))
+ wait_for(lambda: next(w for w in ipc.get_windows() if w['id'] == wid)['is_minimized'], 'dock minimize')
+ click(button(name))
+ wait_for(lambda: not next(w for w in ipc.get_windows() if w['id'] == wid)['is_minimized'], 'dock restore')
+ assert ipc.get_focused_window()['id'] == wid
+ fullscreen_point = center(button(name))
+ ipc.action('fullscreen_window', {'id': wid})
+ wait_for(lambda: not dock(), 'fullscreen hides dock')
+ # Fullscreen on one monitor must leave the other dock visible.
+ for bar in ipc.get_shell_state()['taskbars']:
+ b = bar['box']
+ x, y = b['x'] + b['width'] // 2, b['y'] - 40
+ if not b['x'] <= fullscreen_point[0] < b['x'] + b['width']:
+ assert ipc.hit_test(x, y)['target_type'] == 'dock'
+ ipc.action('fullscreen_window', {'id': wid})
+ wait_for(dock, 'leave fullscreen restores dock')
+ ipc.move_cursor(*center(button(name)))
+ ipc.action('close_window', {'id': wid})
+ wait_for(lambda: not any(w['name'] == name for w in dock()), 'closed hovered window removed')
+ if os.environ.get('REDIWM_DOCK_OVERFLOW'):
+ capacity = (ipc.get_outputs()[0]['logical_width'] - 40) // 56 - 4
+ for index in range(capacity + 2):
+ clients.append(subprocess.Popen([str(tmp / 'client'), '--app-id', f'dock.overflow{index}'],
+ env=dict(os.environ, XDG_RUNTIME_DIR=str(tmp), WAYLAND_DISPLAY=display),
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL))
+ wait_for(lambda: len(ipc.get_windows()) == capacity + 2, 'overflow windows')
+ ipc.wait_for_frame()
+ def shown():
+ return {w['name'] for w in dock() if (w['name'] or '').startswith('window_')}
+ first = shown()
+ assert len(first) == capacity
+ ipc.move_cursor(*center(button('terminal')))
+ ipc.scroll(0, -120)
+ ipc.wait_for_frame()
+ if shown() == first:
+ ipc.scroll(0, 120)
+ ipc.wait_for_frame()
+ assert shown() != first, 'overflow windows cannot be reached'
+ for client in clients:
+ stop_process(client)
+ wait_for(lambda: not ipc.get_windows(), 'overflow cleanup')
+ ipc.wait_for_frame()
+ assert not shown()
+ # Config reload relocates the dock above a bottom taskbar only.
+ cfg = tmp / 'rediwm-config.toml'
+ before = button('terminal')['global_box']['y']
+ cfg.write_text(cfg.read_text().replace('[compositor]', '[compositor]\ntaskbar_position = "top"'))
+ ipc.reload_config()
+ ipc.wait_for_frame()
+ assert button('terminal')['global_box']['y'] > before
+ x, y = center(button('terminal'))
+ cfg.write_text(cfg.read_text().replace('dock_enabled = true', 'dock_enabled = false'))
+ ipc.reload_config()
+ ipc.wait_for_frame()
+ assert not 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)')
+ except Exception:
+ print((tmp / 'compositor.log').read_text()[-4000:])
+ raise
+ finally:
+ for client in clients:
+ stop_process(client)
+ stop_process(process)
+ log.close()
+
+
+if __name__ == '__main__':
+ run()