RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
updates
oxydizer8faf5bad425a
diff --git a/README.md b/README.mdindex e7756ee..49459a5 100644--- a/README.md+++ b/README.md@@ -33,7 +33,7 @@ https://github.com/user-attachments/assets/60bc1190-694c-4fb7-b2bc-d90e5e9faa90## Installing```sh-curl -fsSL https://raw.githubusercontent.com/oxydizer/rediwm/HEAD/scripts/install.sh | sh # add `-s -- --dm` for rediwm-dm+curl -fsSL https://rediwm.redios.org/install.sh | sh # add `-s -- --dm` for rediwm-dm````scripts/install.sh` installs the prebuilt release for your distro (Arch,diff --git a/docs/wiki/Getting-Started.md b/docs/wiki/Getting-Started.mdindex 95cb410..6659c0c 100644--- a/docs/wiki/Getting-Started.md+++ b/docs/wiki/Getting-Started.md@@ -11,7 +11,7 @@ is also the fallback for other distros and CPUs, or if the release's librariesdon't match yours. `REDIWM_VERSION=<tag>` installs a specific release.```sh-curl -fsSL https://raw.githubusercontent.com/oxydizer/rediwm/HEAD/scripts/install.sh | sh -s -- --dm # --dm also installs rediwm-dm+curl -fsSL https://rediwm.redios.org/install.sh | sh -s -- --dm # --dm also installs rediwm-dm```Installing never replaces your login manager. SDDM, GDM and friends keepdiff --git a/scripts/install.sh b/scripts/install.shindex fae5eae..7ee4a8b 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -1,7 +1,7 @@#!/bin/sh# One-command installer for RediWM:#-# curl -fsSL https://raw.githubusercontent.com/oxydizer/rediwm/HEAD/scripts/install.sh | sh+# curl -fsSL https://rediwm.redios.org/install.sh | sh## Detects the distro and installs the prebuilt release for it: a tarball with# the compositor, the apps and the exact wlroots they were tested with, made bydiff --git a/src/Taskbar.zig b/src/Taskbar.zigindex c7dce7d..c2a74b8 100644--- a/src/Taskbar.zig+++ b/src/Taskbar.zig@@ -197,8 +197,10 @@ clock_date: [128]u8 = [_]u8{0} ** 128,clock_locale: c_time.locale_t = null,clock_minute: c_time.time_t = 0,// Layout and every tick ask for these; shaping them each time showed up in-// idle profiles. The clock's is dropped when its strings change.+// idle profiles. The clock column only ever grows while its settings stay the+// same (see `updateClockStrings`), so a ticking clock never moves its neighbours.clock_width: MeasuredWidth = .{},+clock_digit: MeasuredWidth = .{},capture_width: MeasuredWidth = .{},const MeasuredWidth = struct {@@ -458,7 +460,7 @@ fn onTick(bar: *Taskbar) c_int {if (output.calendar) |calendar| calendar.refresh();}}- bar.refreshClock();+ bar.refreshClock(false);bar.scheduleClockTick();return 0;}@@ -508,16 +510,21 @@ fn updateClockLocale(bar: *Taskbar) void {pub fn refreshClockSettings(bar: *Taskbar) void {bar.updateClockLocale();- bar.refreshClock();+ bar.refreshClock(true);bar.scheduleClockTick();}-fn refreshClock(bar: *Taskbar) void {+/// `reset_width` forgets the widest the column has been (a new format, day+/// line or locale may fit a narrower one).+fn refreshClock(bar: *Taskbar, reset_width: bool) void {const previous_width = bar.clockColumnWidth();- if (!bar.updateClockStrings()) return;+ if (reset_width) bar.clock_width.valid = false;+ const changed = bar.updateClockStrings();+ const width_changed = previous_width != bar.clockColumnWidth();+ if (!changed and !width_changed) return;bar.clock_dirty = true;var causes: u8 = paint_clock;- if (previous_width != bar.clockColumnWidth()) {+ if (width_changed) {// A wider/narrower clock moves every item to its left, including the tray.bar.tray_dirty = .{ true, true };bar.capture_dirty = true;@@ -554,7 +561,14 @@ fn updateClockStrings(bar: *Taskbar) bool {bar.clock_time = next_time;bar.clock_date = next_date;- bar.clock_width.valid = false;+ // The column is as wide as the widest text it has shown (AM against PM,+ // a longer date), never narrower, so only a real growth moves the items+ // beside it. A settings change starts it over in `refreshClockSettings`.+ const scale = bar.wlr_output.scale;+ if (bar.clock_width.get(scale)) |current| {+ const needed = bar.measureClockColumn() catch current;+ if (needed > current) _ = bar.clock_width.put(scale, needed);+ }return true;}@@ -608,17 +622,67 @@ pub fn notifyToplevelsChanged(bar: *Taskbar) void {if (bar.dirty) bar.wlr_output.scheduleFrame();}+const clock_time_size: f32 = 14;+const clock_date_size: f32 = 11;++/// One piece of the time line: a single digit in a fixed cell, or a run of+/// everything between digits (":", " PM"). `x` is its offset from the line's+/// start and `w` the width of its own text.+const ClockPiece = struct { text: []const u8, x: i32, w: i32 };+const clock_pieces_max = 16;+const ClockLine = struct { pieces: [clock_pieces_max]ClockPiece = undefined, count: usize = 0, width: i32 = 0 };++/// The widest digit's advance. Every digit of the time sits in a cell this+/// wide, so the seconds ticking over change neither the line's width nor where+/// its other glyphs are (Manrope's digits are proportional).+fn clockDigitCell(bar: *Taskbar) !i32 {+ const scale = bar.wlr_output.scale;+ if (bar.clock_digit.get(scale)) |cell| return @intFromFloat(cell);+ var widest: i32 = 0;+ for ("0123456789") |*digit| widest = @max(widest, try text.measureWidth(digit[0..1], .manrope, clock_time_size, scale));+ return @intFromFloat(bar.clock_digit.put(scale, @floatFromInt(widest)));+}++fn clockLine(bar: *Taskbar, time: []const u8) !ClockLine {+ const scale = bar.wlr_output.scale;+ const cell = try bar.clockDigitCell();+ var line: ClockLine = .{};+ var i: usize = 0;+ while (i < time.len and line.count < clock_pieces_max) {+ const digit = std.ascii.isDigit(time[i]);+ var end = i + 1;+ if (!digit) {+ while (end < time.len and !std.ascii.isDigit(time[end])) end += 1;+ }+ const piece = time[i..end];+ const w = try text.measureWidth(piece, .manrope, clock_time_size, scale);+ line.pieces[line.count] = .{ .text = piece, .x = line.width + if (digit) @divTrunc(cell - w, 2) else 0, .w = w };+ line.count += 1;+ line.width += if (digit) cell else w;+ i = end;+ }+ return line;+}++/// Logical width the clock column needs for the current strings.+fn measureClockColumn(bar: *Taskbar) !f32 {+ const scale = bar.wlr_output.scale;+ const raw = std.mem.sliceTo(&bar.clock_time, 0);+ const time = std.mem.trimStart(u8, raw, " ");+ var time_w = (try bar.clockLine(time)).width;+ // "%l" pads the hours 1-9 with a blank: keep the room of the second digit+ // so that 9:59 turning 10:00 does not resize the column.+ if (time.len < raw.len) time_w += try bar.clockDigitCell();+ const date_w = try text.measureWidth(std.mem.sliceTo(&bar.clock_date, 0), .manrope, clock_date_size, scale);+ // Fit the displayed lines so unused column space cannot widen the left gap.+ return @floatFromInt(@max(time_w, date_w) + 1);+}+fn clockColumnWidth(bar: *Taskbar) f32 {const scale = bar.wlr_output.scale;if (bar.clock_width.get(scale)) |width| return width;- const time_str = std.mem.trimStart(u8, std.mem.sliceTo(&bar.clock_time, 0), " ");- const date_str = std.mem.sliceTo(&bar.clock_date, 0);- // Fit the displayed lines so unused column space cannot widen the left gap.- const time_w = text.measureWidth(time_str, .manrope, 14, scale) catch null;- const date_w = text.measureWidth(date_str, .manrope, 11, scale) catch null;- const width: f32 = @floatFromInt(@max(time_w orelse 0, date_w orelse 0) + 1);// A failed measurement is retried next time rather than remembered.- if (time_w == null or date_w == null) return width;+ const width = bar.measureClockColumn() catch return bar.clock_width.width;return bar.clock_width.put(scale, width);}@@ -1866,15 +1930,25 @@ fn drawPartText(bar: *Taskbar, now_ms: i64, part: Part, buf: *BarBuffer, ox: i32.clock => {const time = std.mem.trimStart(u8, std.mem.sliceTo(&bar.clock_time, 0), " ");const date = std.mem.sliceTo(&bar.clock_date, 0);- const tw = text.measureWidth(time, .manrope, 14, scale) catch 0;- const dw = text.measureWidth(date, .manrope, 11, scale) catch 0;+ const dw = text.measureWidth(date, .manrope, clock_date_size, scale) catch 0;const left: i32 = @intFromFloat(@round(bar.clockX()));const width: i32 = @intFromFloat(bar.clockColumnWidth());const clock_h: i32 = if (date.len == 0) 20 else 37;const time_y = @divTrunc(bar.box.height - clock_h, 2);const date_y = time_y + 21;- drawCenteredText(buf.pixels, buf.width, buf.height, local(left + @divTrunc(width - tw - 1, 2), time_y, tw + 1, 20, ox, oy), time, Color.clock_time(), scale, .manrope, 14) catch {};- if (date.len != 0) drawCenteredText(buf.pixels, buf.width, buf.height, local(left + @divTrunc(width - dw - 1, 2), date_y, dw + 1, 16, ox, oy), date, Color.clock_date(), scale, .manrope, 11) catch {};+ if (bar.clockLine(time)) |line| {+ // Every piece shares the baseline the digits would centre on.+ const row = text.inkBaseline("0123456789", .manrope, clock_time_size, scale, local(0, time_y, 1, 20, ox, oy)) catch null;+ const start = left + @divTrunc(width - line.width - 1, 2);+ for (line.pieces[0..line.count]) |piece| {+ text.drawOpts(buf.pixels, buf.width, buf.height, piece.text, Color.clock_time(), scale, .manrope, clock_time_size, .{+ .rect = local(start + piece.x, time_y, piece.w + 1, 20, ox, oy),+ .center_ink = row == null,+ .baseline = row,+ }) catch {};+ }+ } else |_| {}+ if (date.len != 0) drawCenteredText(buf.pixels, buf.width, buf.height, local(left + @divTrunc(width - dw - 1, 2), date_y, dw + 1, 16, ox, oy), date, Color.clock_date(), scale, .manrope, clock_date_size) catch {};},.chip => |chip| {const cx: i32 = @intFromFloat(@round(chip.renderX(now_ms)));diff --git a/src/delete_dialog.zig b/src/delete_dialog.zigindex 8815211..62b48ec 100644--- a/src/delete_dialog.zig+++ b/src/delete_dialog.zig@@ -111,13 +111,13 @@ pub const State = struct {dialog.paintWindowTitle(r, layer.local(), if (self.paths.items.len > 1) "Delete items?" else if (self.folder) "Delete folder?" else "Delete file?", .trash, null);const hover = g.target(mx, my);button.paint(r, g.close, .{ .variant = .chrome, .icon = .close, .label = "Close" }, .{ .pointer = if (hover == .close) .hover else .idle });- r.drawText(16, g.header + 10, g.width - 32, 24, .{+ r.drawText(16, g.header + 16, g.width - 32, 24, .{.content = if (self.permanent) "This cannot be undone." else if (self.paths.items.len == 1) "You can restore it later from Trash." else "You can restore them later from Trash.",.font_size = shell_ui.textSize(),.color = t.fg,});- const inset_y = g.header + 40;- const inset_h = @min(64, g.toggle.y - inset_y - 12);+ const inset_y = g.header + 50;+ const inset_h = @min(80, g.toggle.y - inset_y - 16);r.fillRect(16, inset_y, g.width - 32, inset_h, .{ .color = t.app_toolbar, .radius = t.radius_md, .border_width = 1, .border_color = t.app_item_border });const icon_size = @min(32, inset_h - 12);const icon_y = inset_y + (inset_h - icon_size) / 2;@@ -126,10 +126,10 @@ pub const State = struct {} else r.drawIcon(28, icon_y, icon_size, icon_size, .{ .id = if (self.folder) .folder else .document, .color = t.fg });var buf: [256]u8 = undefined;const name = if (self.paths.items.len == 1) self.name else std.fmt.bufPrint(&buf, "{d} selected items", .{self.paths.items.len}) catch "Selected items";- r.drawText(76, inset_y + @max(0, (inset_h - 44) / 2), g.width - 108, @min(24, inset_h), .{ .content = name, .font_size = shell_ui.textSize(), .weight = 600, .color = t.fg });+ r.drawText(76, inset_y + @max(0, (inset_h - 48) / 2), g.width - 108, @min(24, inset_h), .{ .content = name, .font_size = shell_ui.textSize(), .weight = 600, .color = t.fg });var detail_buf: [128]u8 = undefined;const detail = if (self.paths.items.len > 1) "Files and folders in this selection" else if (self.folder) "Folder · includes its contents" else std.fmt.bufPrint(&detail_buf, "{s} · {d:.1} {s}", .{ if (std.ascii.eqlIgnoreCase(std.fs.path.extension(self.name), ".pdf")) "PDF document" else "File", @as(f64, @floatFromInt(@max(0, self.bytes))) / (if (self.bytes >= 1048576) @as(f64, 1048576) else if (self.bytes >= 1024) @as(f64, 1024) else 1), if (self.bytes >= 1048576) "MB" else if (self.bytes >= 1024) "KB" else "bytes" }) catch "File";- if (inset_h >= 44) r.drawText(76, inset_y + (inset_h - 44) / 2 + 24, g.width - 108, 20, .{ .content = detail, .font_size = shell_ui.textSize(), .color = t.fg });+ if (inset_h >= 48) r.drawText(76, inset_y + (inset_h - 48) / 2 + 28, g.width - 108, 20, .{ .content = detail, .font_size = shell_ui.textSize(), .color = t.fg });const focus = if (self.keyboard_focus) self.focus else null;checkbox.paint(r, g.toggle, "Delete permanently", .{ .checked = self.permanent, .focused = focus == .toggle });button.paint(r, g.cancel, .{ .size = .sm, .label = "Cancel" }, .{ .focused = focus == .cancel, .pointer = if (hover == .cancel) .hover else .idle });@@ -152,8 +152,8 @@ pub const Geometry = struct {const width = @min(480, @as(f32, @floatFromInt(w)) - 24);const header: f32 = @floatFromInt((chrome.Metrics{}).titlebarHeight());const stacked = width < 440;- const height = @min(header + @as(f32, if (stacked) 202 else 170), @as(f32, @floatFromInt(h)) - 16);- const footer = height - 44;+ const height = @min(header + @as(f32, if (stacked) 264 else 222), @as(f32, @floatFromInt(h)) - 16);+ const footer = height - 58;return .{.x = (@as(f64, @floatFromInt(w)) - width) / 2,.y = (@as(f64, @floatFromInt(h)) - height) / 2,@@ -161,9 +161,9 @@ pub const Geometry = struct {.height = height,.header = header,.close = dialog.closeBox(width),- .toggle = .{ .x = 16, .y = footer - @as(f32, if (stacked) 32 else 0), .w = if (stacked) width - 32 else 174, .h = 28 },- .cancel = .{ .x = width - 268, .y = footer, .w = 80, .h = 28 },- .confirm = .{ .x = width - 180, .y = footer, .w = 164, .h = 28 },+ .toggle = .{ .x = 16, .y = footer - @as(f32, if (stacked) 42 else 0), .w = if (stacked) width - 32 else 174, .h = 34 },+ .cancel = .{ .x = width - 268, .y = footer, .w = 80, .h = 34 },+ .confirm = .{ .x = width - 180, .y = footer, .w = 164, .h = 34 },};}diff --git a/src/files/archive.zig b/src/files/archive.zigindex 956e0bd..f047a59 100644--- a/src/files/archive.zig+++ b/src/files/archive.zig@@ -36,9 +36,9 @@ fn check(cancel: *const Cancel) !void {}/// Canonical member names never contain absolute paths, '..', or backslashes.-/// Empty names describe the archive root (a common tar './' entry).+/// Empty names describe the archive root (a common tar './' or ZIP '/' entry).pub fn normalize(mem: Allocator, raw: []const u8) ![]const u8 {- if (raw.len > 4095 or std.mem.startsWith(u8, raw, "/") or std.mem.indexOfAny(u8, raw, "\\\x00") != null) return error.UnsafeArchivePath;+ if (raw.len > 4095 or (std.mem.startsWith(u8, raw, "/") and !std.mem.eql(u8, raw, "/")) or std.mem.indexOfAny(u8, raw, "\\\x00") != null) return error.UnsafeArchivePath;var result: std.ArrayList(u8) = .empty;errdefer result.deinit(mem);var parts = std.mem.splitScalar(u8, raw, '/');@@ -160,7 +160,10 @@ pub const Index = struct {name_bytes += std.mem.span(raw).len;if (name_bytes > 32 * 1024 * 1024) return error.ArchiveTooLarge;const name = try normalize(alloc, std.mem.span(raw));- if (name.len == 0) continue;+ if (name.len == 0) {+ if (a.archive_entry_filetype(entry) != c.S_IFDIR or a.archive_entry_hardlink(entry) != null) return error.UnsupportedArchiveEntry;+ continue;+ }var parts = std.mem.splitScalar(u8, name, '/');var end: usize = 0;while (parts.next()) |part| {@@ -229,7 +232,10 @@ pub fn extract(mem: Allocator, path: []const u8, destination: []const u8, memberconst raw = a.archive_entry_pathname(entry) orelse return error.InvalidArchive;const name = try normalize(mem, std.mem.span(raw));defer mem.free(name);- if (name.len == 0) continue;+ if (name.len == 0) {+ if (a.archive_entry_filetype(entry) != c.S_IFDIR or a.archive_entry_hardlink(entry) != null) return error.UnsupportedArchiveEntry;+ continue;+ }if (member) |wanted| if (!std.mem.eql(u8, name, wanted)) continue;const kind = a.archive_entry_filetype(entry);if ((kind != c.S_IFREG and kind != c.S_IFDIR) or a.archive_entry_hardlink(entry) != null) return error.UnsupportedArchiveEntry;diff --git a/src/files/open_with.zig b/src/files/open_with.zigindex ed69779..c7c94e5 100644--- a/src/files/open_with.zig+++ b/src/files/open_with.zig@@ -15,7 +15,7 @@ const Rect = ui.Rect;pub const Action = enum { none, cancel, open };const Focus = enum { list, more, remember, cancel, open };-const row_height: f32 = 28;+const row_height: f32 = 34;pub const Geometry = struct {box: Rect,@@ -25,23 +25,30 @@ pub const Geometry = struct {cancel: Rect,open: Rect,close: Rect,+ /// Y of the rule above the "more apps" button.+ divider: f32,rows: usize,pub fn init(w: i32, h: i32, count: usize) Geometry {const width: f32 = @min(480, @as(f32, @floatFromInt(w)) - 24);const header: f32 = @floatFromInt((chrome.Metrics{}).titlebarHeight());- const height: f32 = @min(@min(400, header + 176 + @as(f32, @floatFromInt(@max(1, count))) * row_height), @as(f32, @floatFromInt(h)) - 16);- const compact = height < header + 220;- const list_y = header + @as(f32, if (compact) 30 else 52);- const rows: usize = @intFromFloat(@max(1, @floor((height - @as(f32, if (compact) 104 else 124) - list_y) / row_height)));+ const height: f32 = @min(@min(500, header + 236 + @as(f32, @floatFromInt(@max(1, count))) * row_height), @as(f32, @floatFromInt(h)) - 16);+ const compact = height < header + 290;+ const list_y = header + @as(f32, if (compact) 34 else 64);+ const rows: usize = @intFromFloat(@max(1, @floor((height - @as(f32, if (compact) 112 else 172) - list_y) / row_height)));+ const more_y = height - @as(f32, if (compact) 100 else 140);+ const small: f32 = if (compact) 26 else 30;+ const button_y = height - @as(f32, if (compact) 42 else 58);+ const button_h: f32 = if (compact) 32 else 34;return .{.box = .{ .x = (@as(f32, @floatFromInt(w)) - width) / 2, .y = (@as(f32, @floatFromInt(h)) - height) / 2, .w = width, .h = height },.list = .{ .x = 16, .y = list_y, .w = width - 32, .h = @as(f32, @floatFromInt(rows)) * row_height },- .more = .{ .x = 16, .y = height - @as(f32, if (compact) 92 else 104), .w = width - 32, .h = 24 },- .remember = .{ .x = 16, .y = height - @as(f32, if (compact) 64 else 76), .w = width - 32, .h = 24 },- .cancel = .{ .x = width - 188, .y = height - @as(f32, if (compact) 36 else 44), .w = 80, .h = 28 },- .open = .{ .x = width - 100, .y = height - @as(f32, if (compact) 36 else 44), .w = 84, .h = 28 },+ .more = .{ .x = 16, .y = more_y, .w = width - 32, .h = small },+ .remember = .{ .x = 16, .y = height - @as(f32, if (compact) 72 else 102), .w = width - 32, .h = small },+ .cancel = .{ .x = width - 188, .y = button_y, .w = 80, .h = button_h },+ .open = .{ .x = width - 100, .y = button_y, .w = 84, .h = button_h },.close = frame.closeBox(width),+ .divider = more_y - @as(f32, if (compact) 8 else 18),.rows = rows,};}@@ -193,8 +200,8 @@ pub const State = struct {frame.paintWindowTitle(r, layer.local(), "Open With", .grid, null);var buffer: [256]u8 = undefined;const subtitle = if (self.message.len > 0) self.message else if (self.apps.paths.len == 1) std.fs.path.basename(self.apps.paths[0]) else std.fmt.bufPrint(&buffer, "{d} selected files", .{self.apps.paths.len}) catch "Selected files";- if (g.list.y - @as(f32, @floatFromInt((chrome.Metrics{}).titlebarHeight())) > 30) r.drawText(16, g.list.y - 44, g.box.w - 32, 20, .{ .content = subtitle, .font_size = ui.textSize(), .color = palette.fg });- r.drawText(16, g.list.y - 22, g.box.w - 32, 20, .{ .content = if (self.all) "All Applications" else "Recommended Apps", .font_size = ui.headingSize(), .weight = 600, .color = palette.fg });+ if (g.list.y - @as(f32, @floatFromInt((chrome.Metrics{}).titlebarHeight())) > 50) r.drawText(16, g.list.y - 50, g.box.w - 32, 20, .{ .content = subtitle, .font_size = ui.textSize(), .color = palette.fg });+ r.drawText(16, g.list.y - 26, g.box.w - 32, 20, .{ .content = if (self.all) "All Applications" else "Recommended Apps", .font_size = ui.headingSize(), .weight = 600, .color = palette.fg });const hovered = self.hit(w, h, mx, my);if (self.count() == 0) r.drawText(24, g.list.y, g.list.w - 16, row_height, .{ .content = "No applications available", .font_size = ui.textSize(), .color = palette.fg });const end = @min(self.count(), self.offset + g.rows);@@ -212,14 +219,14 @@ pub const State = struct {icon = icons.get(cfg, io, name, @intFromFloat(18 * ui.scaleOf(cr)));if (icon != null) break;}- if (icon) |im| r.drawImageCover(24, y + 4, 18, 18, 0, .{ .pixels = im.pixels, .width = @intCast(im.size), .height = @intCast(im.size) }) else r.drawIcon(24, y + 4, 18, 18, .{ .id = .grid, .color = palette.fg });+ if (icon) |im| r.drawImageCover(24, y + 7, 18, 18, 0, .{ .pixels = im.pixels, .width = @intCast(im.size), .height = @intCast(im.size) }) else r.drawIcon(24, y + 7, 18, 18, .{ .id = .grid, .color = palette.fg });const label = if (entry.is_default) std.fmt.bufPrint(&buffer, "{s} (default)", .{entry.name}) catch entry.name else entry.name;r.drawText(52, y, g.list.w - 44, row_height - 2, .{ .content = label, .font_size = ui.textSize(), .color = palette.fg });}const strip = scrollbar.gutter(theme.global.scrollbar_width);if (scrollbar.Geometry.compute(.vertical, .{ .x = g.box.w - strip, .y = g.list.y, .w = strip, .h = g.list.h }, @floatFromInt(g.rows), @floatFromInt(self.count()), @floatFromInt(self.offset))) |bar|scrollbar.paint(r, scrollbar.look(bar, .{}, theme.global.scrollbar_width, palette));- r.fillRect(16, g.more.y - 12, g.box.w - 32, 1, .{ .color = theme.global.app_divider });+ r.fillRect(16, g.divider, g.box.w - 32, 1, .{ .color = theme.global.app_divider });button.paint(r, g.more, .{ .size = .sm, .variant = .ghost, .alignment = .left, .leading_icon = .plus, .label = if (self.all) "Back to recommended apps" else "Choose another app…" }, .{ .focused = self.focus == .more, .pointer = if (hovered == 4) .hover else .idle });const extension = std.fs.path.extension(self.apps.paths[0]);const remember_label = if (extension.len > 0 and self.apps.paths.len == 1)diff --git a/src/files_tests.zig b/src/files_tests.zigindex 690cb34..f688ac1 100644--- a/src/files_tests.zig+++ b/src/files_tests.zig@@ -505,12 +505,12 @@ test "deletion dialog owns targets and shares responsive hit geometry" {try std.testing.expectEqual(deletion.Action.confirm, state.key(c.XKB_KEY_Return));for ([_][2]i32{ .{ 960, 540 }, .{ 480, 300 }, .{ 360, 280 }, .{ 1280, 656 } }) |size| {const g = deletion.Geometry.init(size[0], size[1]);- try std.testing.expectEqual(deletion.Action.toggle, g.hit(g.x + 100, g.y + g.height - @as(f64, if (g.width < 440) 62 else 30)));+ try std.testing.expectEqual(deletion.Action.toggle, g.hit(g.x + 100, g.y + g.height - @as(f64, if (g.width < 440) 82 else 30)));try std.testing.expectEqual(deletion.Action.cancel, g.hit(g.x + g.width - 228, g.y + g.height - 30));try std.testing.expectEqual(deletion.Action.confirm, g.hit(g.x + g.width - 98, g.y + g.height - 30));try std.testing.expectEqual(deletion.Action.cancel, g.hit(g.x + g.width - 25, g.y + g.header / 2));- try std.testing.expectEqual(@as(f32, 28), g.cancel.h);- try std.testing.expectEqual(@as(f32, 28), g.confirm.h);+ try std.testing.expectEqual(@as(f32, 34), g.cancel.h);+ try std.testing.expectEqual(@as(f32, 34), g.confirm.h);try std.testing.expectEqual(deletion.Action.none, g.hit(0, 0));}}@@ -1164,11 +1164,12 @@ fn writeArchiveFixture(path: []const u8, names: []const [:0]const u8) !void {const entry = api.archive_entry_new() orelse return error.OutOfMemory;defer api.archive_entry_free(entry);api.archive_entry_set_pathname(entry, name);- api.archive_entry_set_filetype(entry, c.S_IFREG);+ const directory = std.mem.endsWith(u8, name, "/");+ api.archive_entry_set_filetype(entry, if (directory) c.S_IFDIR else c.S_IFREG);api.archive_entry_set_perm(entry, 0o644);- api.archive_entry_set_size(entry, 7);+ api.archive_entry_set_size(entry, if (directory) 0 else 7);try std.testing.expectEqual(@as(c_int, 0), api.archive_write_header(writer, entry));- try std.testing.expectEqual(@as(isize, 7), api.archive_write_data(writer, "payload", 7));+ if (!directory) try std.testing.expectEqual(@as(isize, 7), api.archive_write_data(writer, "payload", 7));}try std.testing.expectEqual(@as(c_int, 0), api.archive_write_close(writer));}@@ -1182,7 +1183,7 @@ test "archive index, staged extraction and member reads preserve destination boudefer ops_mod.deleteRecursive(mem, root) catch {};const source = try std.fmt.allocPrint(mem, "{s}/sample{s}", .{ root, extension });defer mem.free(source);- try writeArchiveFixture(source, &.{ "nested/item.txt", "other.txt" });+ try writeArchiveFixture(source, &.{ "/", "nested/item.txt", "other.txt" });var cancel: archive.Cancel = .init(false);var index = try archive.Index.read(mem, source, &cancel);defer index.deinit();@@ -1197,6 +1198,12 @@ test "archive index, staged extraction and member reads preserve destination bouvar content: [32]u8 = undefined;try std.testing.expectEqualStrings("payload", try readTestFile(member, &content));try std.testing.expectError(error.WriteFailed, archive.extract(mem, source, stage, "nested/item.txt", &cancel));+ const full_stage = try archive.temporary(mem, root);+ defer mem.free(full_stage);+ try archive.extract(mem, source, full_stage, null, &cancel);+ const other = try std.fmt.allocPrint(mem, "{s}/other.txt", .{full_stage});+ defer mem.free(other);+ try std.testing.expectEqualStrings("payload", try readTestFile(other, &content));cancel.store(true, .release);try std.testing.expectError(error.Cancelled, archive.extract(mem, source, stage, null, &cancel));cancel.store(false, .release);@@ -1212,7 +1219,7 @@ test "archive index, staged extraction and member reads preserve destination bouconst safe = try std.fmt.allocPrintSentinel(mem, "{s}/safe.txt", .{root}, 0);defer mem.free(safe);try std.testing.expect(c.access(safe, c.F_OK) != 0);- for ([_][]const u8{ "/absolute", "dir/../../escape", "a\\b" }) |name| {+ for ([_][]const u8{ "/absolute", "//", "dir/../../escape", "a\\b" }) |name| {try std.testing.expectError(error.UnsafeArchivePath, archive.normalize(mem, name));}diff --git a/src/ui/text.zig b/src/ui/text.zigindex 6ad51bb..18329c5 100644--- a/src/ui/text.zig+++ b/src/ui/text.zig@@ -1075,21 +1075,7 @@ pub fn drawOpts(const ink_height = metrics.ascender - metrics.descender;var baseline = snap26_6(y0 * 64 + @divTrunc((y1 - y0) * 64 - ink_height, 2) + metrics.ascender) * 64;if (options.center_ink) {- var top: i32 = std.math.maxInt(i32);- var bottom: i32 = std.math.minInt(i32);- var offset_y: c.FT_Pos = 0;- for (run.glyphs) |glyph| {- defer offset_y += glyph.y_advance;- const face = ensureLoaded(glyph.face) catch continue;- applySize(face, size) catch continue;- if (glyphBitmap(face, glyph.face, glyph.index)) |bitmap| {- if (bitmap.cols == 0 or bitmap.rows == 0) continue;- const origin_y = snap26_6(offset_y - glyph.y_offset) - bitmap.top;- top = @min(top, origin_y);- bottom = @max(bottom, origin_y + bitmap.rows);- }- }- if (top < bottom) baseline = @divFloor(y0 + y1 - top - bottom + 1, 2) * 64;+ if (inkCenteredBaseline(run, size, y0, y1)) |row| baseline = row * 64;}if (options.baseline) |row| baseline = row * 64;var pen_x = x0 * 64;@@ -1123,6 +1109,39 @@ pub fn drawOpts(}}+/// Buffer-pixel baseline row that centres the visible glyph bounds of `run`+/// between rows `y0` and `y1`; null when nothing in it has ink.+fn inkCenteredBaseline(run: Run, size: c.FT_F26Dot6, y0: i32, y1: i32) ?i32 {+ var top: i32 = std.math.maxInt(i32);+ var bottom: i32 = std.math.minInt(i32);+ var offset_y: c.FT_Pos = 0;+ for (run.glyphs) |glyph| {+ defer offset_y += glyph.y_advance;+ const face = ensureLoaded(glyph.face) catch continue;+ applySize(face, size) catch continue;+ if (glyphBitmap(face, glyph.face, glyph.index)) |bitmap| {+ if (bitmap.cols == 0 or bitmap.rows == 0) continue;+ const origin_y = snap26_6(offset_y - glyph.y_offset) - bitmap.top;+ top = @min(top, origin_y);+ bottom = @max(bottom, origin_y + bitmap.rows);+ }+ }+ if (top >= bottom) return null;+ return @divFloor(y0 + y1 - top - bottom + 1, 2);+}++/// The `DrawOptions.baseline` that `center_ink` would pick for `sample` in+/// `rect` (which must lie inside the buffer). A line drawn in pieces, such as+/// tabular digits, gives every piece this row: centring each piece on its own+/// ink would lift a colon to mid-height and let a flat "1" sit a row off a+/// round "0".+pub fn inkBaseline(sample: []const u8, font: Font, size_px: f32, scale: f32, rect: Rect) !i32 {+ const size = size26(size_px, scale);+ _ = try setSize(font, size_px, scale);+ const run = try shapedRun(font, size, sample);+ return inkCenteredBaseline(run, size, devicePixels(rect.y, scale), devicePixels(rect.y + rect.h, scale)) orelse error.NoInk;+}+fn snap26_6(value: c.FT_Pos) i32 {return @intCast(@divFloor(value + 32, 64));}diff --git a/tests/desktop_icons.py b/tests/desktop_icons.pyindex 02ca2cc..b4d52a6 100644--- a/tests/desktop_icons.py+++ b/tests/desktop_icons.py@@ -255,12 +255,12 @@ def run():preview = capture('delete-dialog')preview.save('/tmp/rediwm-desktop-delete-dialog.png')assert launcher.exists()- move(600,251); button(True)- move(660,301); button(False)+ move(600,230); button(True)+ move(660,280); button(False)moved = capture('delete-dialog-moved')- assert difference(preview.crop((450,235,650,268)),- moved.crop((510,285,710,318))).getbbox() is None, 'Desktop delete dialog did not move'- click(915,301) # Close follows the moved titlebar.+ assert difference(preview.crop((450,210,650,243)),+ moved.crop((510,260,710,293))).getbbox() is None, 'Desktop delete dialog did not move'+ click(915,278) # Close follows the moved titlebar.assert launcher.exists()key(111)key(1)diff --git a/tests/files_associations.py b/tests/files_associations.pyindex b7e4aa9..d3e2ee0 100644--- a/tests/files_associations.py+++ b/tests/files_associations.py@@ -210,7 +210,7 @@ def run():# Cancel preserves the association and launches nothing.marker.unlink()picker()- drag_title(300, 130, 70, 45)+ drag_title(300, 66, 70, 30)preview = os.environ.get("REDIWM_OPEN_WITH_PREVIEW")if preview:ipc.screenshot(path=preview)diff --git a/tests/files_controls.py b/tests/files_controls.pyindex c6d7631..0cadcef 100644--- a/tests/files_controls.py+++ b/tests/files_controls.py@@ -59,10 +59,21 @@ def run():opener = helpers / "gio"opener.write_text('#!/bin/sh\n[ "$1" = "open" ] || exit 1\nprintf "%s" "$2" > "' + str(marker) + '"\n')opener.chmod(0o755)+ applications = data / "applications"+ applications.mkdir()+ (applications / "rediwm-test-opener.desktop").write_text(+ "[Desktop Entry]\nType=Application\nName=Test Opener\n"+ f"Exec={opener} open %f\nMimeType=application/octet-stream;text/plain;\n")+ config_home = tmp / "config"+ config_home.mkdir()+ (config_home / "mimeapps.list").write_text(+ "[Default Applications]\n"+ "application/octet-stream=rediwm-test-opener.desktop;\n"+ "text/plain=rediwm-test-opener.desktop;\n")config = tmp / "config.toml"config.write_text("")env = dict(os.environ, HOME=str(home), XDG_RUNTIME_DIR=directory,- XDG_DATA_HOME=str(tmp / "data"),+ XDG_DATA_HOME=str(tmp / "data"), XDG_CONFIG_HOME=str(config_home),REDIWM_CONFIG=str(config), WLR_BACKENDS="headless", REDIWM_FILES_DEVICES="0",WLR_HEADLESS_OUTPUTS="1", WLR_RENDERER=os.environ.get("REDIWM_TEST_RENDERER", "pixman"),REDIWM_SCALE="1", XDG_STATE_HOME=str(tmp / "state"), PATH=str(helpers) + ":" + os.environ["PATH"],@@ -140,6 +151,40 @@ def run():"did not open " + name)marker.unlink()+ if "--archive-only" in sys.argv:+ archive_dir = tmp / "archive-check"+ archive_dir.mkdir()+ archive = archive_dir / "sample.zip"+ with zipfile.ZipFile(archive, "w") as z:+ z.writestr("/", "")+ z.writestr("nested/item.txt", "archive member")+ key(38, ctrl=True)+ text(str(archive_dir))+ key(28)+ title("archive-check")+ click(250, 160)+ key(57)+ title("sample.zip")+ key(102)+ key(28)+ title("nested")+ key(102)+ key(28)+ wait_for(marker.exists, "archive member did not open")+ assert Path(marker.read_text()).read_text() == "archive member"+ key(103, alt=True)+ title("sample.zip")+ key(103, alt=True)+ title("archive-check")+ click(250, 160, 273)+ key(108)+ key(108)+ key(28)+ wait_for(lambda: (archive_dir / "nested/item.txt").exists(), "Extract in place failed")+ assert (archive_dir / "nested/item.txt").read_text() == "archive member"+ print("PASS: ZIP root entry browsing, member opening and extraction")+ return+# Both common evdev side-button pairs navigate on press only.for folder in ("Archive", "Documents"):key(38, ctrl=True) # Ctrl+L@@ -543,6 +588,7 @@ def run():destination.mkdir()archive = archive_dir / "sample.zip"with zipfile.ZipFile(archive, "w") as z:+ z.writestr("/", "") # Some ZIP creators include an explicit root directory.z.writestr("nested/item.txt", "archive member")z.writestr("top.txt", "top level")key(38, ctrl=True)