Skip to content

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

fixes

oxydizer3d08bd0cf64b
diff --git a/AGENTS.md b/AGENTS.md
index a6c6ad2..2e1175e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -385,13 +385,18 @@ calling a failure a regression.
`rowKind`. Hover keys: 300+i built-in (File System is 300+`pin_base`), 600+k
device, 700+k eject, 800+j pin. `pinRowY` positions pins and the drop line;
`placeY` for File System and everything below it follows the pin count.
-* **Files is a drop target only for pinning** (`main.zig` `dragOver`/
- `dragDropped`). It accepts `text/uri-list` over PLACES and nothing elsewhere,
- and only with the *copy* action: a move-only source must be refused or
- `finish()` would let it delete the originals. After `drop` the offer leaves
- `drag_offer` (a `leave` would destroy it), is read through a nonblocking pipe
- (`drop_receiving`, poll slot 15) and gets `finish()` only after the read.
- The gap comes from `pin_drop`, set by motion and taken at the drop.
+* **Files drops** (`main.zig` `dragOver`/`dragDropped`) accept `text/uri-list`:
+ PLACES pins with *copy* only; the content area transfers to the hovered folder
+ or, on empty space, the displayed directory. Files sources advertise
+ `application/x-rediwm-file-transfer`: the receiving job owns moves and the
+ source never deletes on `dnd_finished`. Ctrl at drag start offers copy only;
+ other sources copy. After `drop` the offer leaves `drag_offer` (a `leave`
+ would destroy it) and is read through a nonblocking pipe (`drop_receiving`,
+ poll slot 15). Snapshot the destination before reading. Drops use the normal
+ conflict/progress jobs without touching cut-clipboard state; reject a folder
+ dropped into itself/descendants, including through symlinks. Pins take their
+ gap from `pin_drop`. Ctrl-click deselection waits for release so Ctrl-drag
+ preserves the selection.
* **Pins are not built-ins:** a built-in place's path is refused ("Already in
Places"), a hidden built-in can be dropped back as a pin, a missing target
stays listed dimmed, a file pin opens like a double click (a chooser browses
diff --git a/TESTING.md b/TESTING.md
index f3bcd0e..58181c5 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -176,7 +176,8 @@ also be launched with `rediwm-files --open`, `--save` or `--folder`; it returns
a JSON result on stdout.
**Desktop, Files, Images**: `desktop_icons.py`, `desktop_damage.py`,
-`files_browser.py`, `files_controls.py`, `files_decoration.py`,
+`files_browser.py` (file-path selection; with `REDIWM_FORCE_DBUS=1` on a private
+`dbus-run-session` bus, also checks `FileManager1.ShowItems`), `files_controls.py`, `files_decoration.py`,
`files_thumbnails.py` (draws real pictures and reads thumbnail pixels back: shape,
colour, EXIF rotation, the shared freedesktop cache read and write, a 240-picture
folder, the `REDIWM_FILES_THUMBNAILS=0` switch and idle wakeups; it sets a scratch
@@ -184,7 +185,8 @@ folder, the `REDIWM_FILES_THUMBNAILS=0` switch and idle wakeups; it sets a scrat
databases; needs update-mime-database, update-desktop-database and gio), `files_drag.py` (GTK 3; `--browser` tests
real Brave uploads with an isolated profile; `--select` selects by dragging
from empty space, `--list` exercises list view, and `--pin` drags folders and a
-file onto PLACES: insertion line, order, refused drops, open and remove), `files_drag_dodge.py`
+file onto PLACES: insertion line, order, refused drops, open and remove;
+`--transfer` moves/copies into folders and between Files windows in grid/list), `files_drag_dodge.py`
(Files slides aside while a file is dragged out onto a window it covers, and
back on drop or Escape; also camera zoom, the setting off and nothing to uncover;
`browser` runs the real Brave upload and is not in the default set), `images_viewer.py`, `client_cursor.py` (grim;
diff --git a/build.zig b/build.zig
index fea7d7b..b3d6d86 100644
--- a/build.zig
+++ b/build.zig
@@ -169,8 +169,8 @@ pub fn build(b: *std.Build) void {
const install_files = b.addInstallArtifact(files, .{});
// Advertises rediwm-files to the start menu's applications scanner
// (src/start_menu/applications.zig) and to any other XDG-aware
- // launcher; Icon references a theme icon name rather than a bundled
- // asset, consistent with how the rest of this project resolves icons.
+ // launcher. Its icon is installed in the hicolor fallback theme so the
+ // start menu and taskbar can resolve the desktop entry's Icon name.
const install_files_desktop_entry = b.addInstallFileWithDir(
b.path("data/rediwm-files.desktop"),
.prefix,
@@ -178,6 +178,10 @@ pub fn build(b: *std.Build) void {
);
b.getInstallStep().dependOn(&install_files.step);
b.getInstallStep().dependOn(&install_files_desktop_entry.step);
+ const install_files_icon = b.addSystemCommand(&.{ "install", "-Dm644" });
+ install_files_icon.addFileArg(b.path("icons/redi-fm-icon.png"));
+ install_files_icon.addArg(b.getInstallPath(.prefix, "share/icons/hicolor/256x256/apps/redi-fm-icon.png"));
+ b.getInstallStep().dependOn(&install_files_icon.step);
// rediwm-files links neither wlroots-server nor libinput/libpulse, so it
// can be built (and its dependencies checked) without the rest of this
// repository's toolchain. `zig build` (the default `install` step) still
@@ -776,7 +780,7 @@ fn addShellUi(b: *std.Build, module: *std.Build.Module) void {
// Bundle shell glyphs so installed binaries never depend on the checkout.
fn addShellIcons(b: *std.Build, module: *std.Build.Module) void {
- inline for (.{ "git-branch", "home", "folder", "settings", "keyboard", "edit", "mouse", "display", "music", "headphones", "wifi", "ethernet", "globe", "bluetooth", "battery", "notification-bell", "speaker", "speaker-xmark", "power-button", "clock", "lock", "logout", "restart", "eye", "eye-off", "refresh", "cut", "copy", "paste", "trash-outline", "trash", "view-grid", "view-list", "sort", "filter", "zoom-in", "zoom-out", "rotate", "crop", "undo", "save", "fit", "open", "usb-stick", "drive", "eject" }) |name| {
+ inline for (.{ "git-branch", "home", "folder", "settings", "keyboard", "edit", "mouse", "display", "music", "headphones", "wifi", "ethernet", "globe", "bluetooth", "battery", "notification-bell", "speaker", "speaker-xmark", "power-button", "clock", "lock", "logout", "restart", "eye", "eye-off", "refresh", "cut", "copy", "paste", "trash-outline", "trash", "view-grid", "view-list", "sort", "filter", "zoom-in", "zoom-out", "rotate", "crop", "undo", "save", "fit", "open", "usb-stick", "drive", "eject", "users", "squares" }) |name| {
module.addAnonymousImport("shell-icon-" ++ name, .{ .root_source_file = b.path("icons/" ++ name ++ ".svg") });
}
}
diff --git a/data/rediwm-files.desktop b/data/rediwm-files.desktop
index 6ab170a..b5c368f 100644
--- a/data/rediwm-files.desktop
+++ b/data/rediwm-files.desktop
@@ -1,11 +1,11 @@
[Desktop Entry]
Type=Application
Version=1.0
-Name=Files
+Name=RediWM Files
GenericName=File Manager
Comment=Browse, open and manage local files and folders
Exec=rediwm-files %f
-Icon=system-file-manager
+Icon=redi-fm-icon
Terminal=false
StartupWMClass=rediwm-files
Categories=System;FileTools;FileManager;Utility;
diff --git a/icons/redi-fm-icon.png b/icons/redi-fm-icon.png
new file mode 100644
index 0000000..050f6b8
Binary files /dev/null and b/icons/redi-fm-icon.png differ
diff --git a/scripts/install-session-root.sh b/scripts/install-session-root.sh
index 021f521..4c4ecd3 100755
--- a/scripts/install-session-root.sh
+++ b/scripts/install-session-root.sh
@@ -16,6 +16,7 @@ for binary in rediwm rediwm-msg rediwm-files rediwm-images rediwm-editor rediwm-
install -m755 "$release_dir/bin/$binary" "$stage/$binary"
done
install -Dm644 "$repo_dir/data/rediwm-files.desktop" /usr/local/share/applications/rediwm-files.desktop
+install -Dm644 "$release_dir/share/icons/hicolor/256x256/apps/redi-fm-icon.png" /usr/local/share/icons/hicolor/256x256/apps/redi-fm-icon.png
install -Dm644 "$repo_dir/data/rediwm-images.desktop" /usr/local/share/applications/rediwm-images.desktop
install -Dm644 "$repo_dir/data/rediwm-editor.desktop" /usr/local/share/applications/rediwm-editor.desktop
install -Dm644 "$repo_dir/data/rediwm-pdf.desktop" /usr/local/share/applications/rediwm-pdf.desktop
@@ -37,7 +38,7 @@ if [ -d "$release_dir/lib/rediwm" ]; then
fi
# Bundled Xcursor themes (aliases are symlinks); the compositor finds them
# through $ORIGIN/../share/icons, which it adds to XCURSOR_PATH.
-for theme in "$release_dir"/share/icons/*/; do
+for theme in "$release_dir"/share/icons/phinger-cursors-*/; do
name=$(basename "$theme")
rm -rf "/usr/local/share/icons/.$name-new"
install -d /usr/local/share/icons
diff --git a/src/Taskbar.zig b/src/Taskbar.zig
index 20c8ab6..6a12fe8 100644
--- a/src/Taskbar.zig
+++ b/src/Taskbar.zig
@@ -1891,7 +1891,7 @@ fn drawPartText(bar: *Taskbar, now_ms: i64, part: Part, buf: *BarBuffer, ox: i32
}
}
-// Theme-driven item sizing must reproduce the default 42/23/34px layout
+// Theme-driven item sizing must reproduce the default 38/21/31px layout
// at the defaults, then scale down as the bar shrinks or the item
// gap grows, staying at or above the floors that keep pills/tiles/targets
// legible and non-overlapping.
@@ -1900,10 +1900,10 @@ test "chip/tile/tray sizing matches default theme" {
defer ui_theme.global = saved;
ui_theme.global = .{};
- try std.testing.expectEqual(@as(i32, base_chip_size), chipSize());
- try std.testing.expectEqual(@as(i32, @intFromFloat(@round(base_tile_size))), tileSize());
- try std.testing.expectEqual(@as(i32, 9), chipPad());
- try std.testing.expectEqual(@as(i32, base_tray_hit), trayHit());
+ try std.testing.expectEqual(@as(i32, 38), chipSize());
+ try std.testing.expectEqual(@as(i32, 21), tileSize());
+ try std.testing.expectEqual(@as(i32, 8), chipPad());
+ try std.testing.expectEqual(@as(i32, 31), trayHit());
try std.testing.expectEqual(chipSize(), buttonSize());
}
@@ -1938,7 +1938,7 @@ test "start button gap and icon size are theme-driven and icon is capped to the
try std.testing.expectEqual(@as(i32, 4), startButtonGap());
try std.testing.expectEqual(@as(i32, 4), startButtonLeft());
try std.testing.expectEqual(@as(i32, 4 + buttonSize() + 4), firstChipX());
- try std.testing.expectEqual(@as(i32, base_chip_size), startIconSize());
+ try std.testing.expectEqual(@as(i32, 36), startIconSize());
ui_theme.global.start_button_gap = 24;
try std.testing.expectEqual(@as(i32, 24), startButtonLeft());
diff --git a/src/World.zig b/src/World.zig
index 056c11b..50e29a0 100644
--- a/src/World.zig
+++ b/src/World.zig
@@ -497,6 +497,7 @@ pub fn syncPresentation(world: *World) void {
Projection.syncFixed(world.projection, world.camera.zoom(), world.camera.offset_x, world.camera.offset_y, world.bounds.origin_x, world.bounds.origin_y, if (world.server.config.compositor.desktop_icons_fixed) world.server.world_desktop_tree else null);
glass.Engine.project(world.server.glass_engine, world.projection, @floatCast(world.camera.zoom()));
if (world.server.text_input) |relay| relay.updatePopups();
+ if (world.server.desktop) |desktop| desktop.syncOverlayPosition();
}
pub fn toWorld(world: *const World, x: f64, y: f64) camera_mod.Vec {
return world.camera.toWorld(world.bounds, x, y);
diff --git a/src/assets/themes/redi-blue.toml b/src/assets/themes/redi-blue.toml
index 3d4e637..1fb1216 100644
--- a/src/assets/themes/redi-blue.toml
+++ b/src/assets/themes/redi-blue.toml
@@ -71,7 +71,8 @@ caret_width = 1.5
scrollbar_width = 8
chrome_height = 32
chrome_control_gap = 4
-taskbar_size = 48
+taskbar_size = 44
+start_button_icon_size = 36
chip_gap = 4
shadow_size = 24
shadow_offset_y = 8
diff --git a/src/assets/themes/rediwm-dark.toml b/src/assets/themes/rediwm-dark.toml
index 6980967..fb11204 100644
--- a/src/assets/themes/rediwm-dark.toml
+++ b/src/assets/themes/rediwm-dark.toml
@@ -9,7 +9,8 @@ title_size = 13.5
chrome_height = 46
chrome_control_gap = 4
taskbar_title_size = 12.5
-taskbar_size = 48
+taskbar_size = 44
+start_button_icon_size = 36
chip_gap = 4
chip_width = 220
start_button_gap = 4
@@ -24,7 +25,7 @@ start_menu_max_height = 600
start_menu_radius = 14
start_menu_left_pad = 2
start_menu_bottom_pad = 6
-start_menu_icon_left_pad = 2
+start_menu_icon_left_pad = 12
start_menu_icon_bottom_pad = 6
window_bg = "rgba(7.6,9,11,0.800)"
window_fg = "rgba(245,245,245,1.000)"
diff --git a/src/assets/themes/rediwm-light.toml b/src/assets/themes/rediwm-light.toml
index 57c7ab5..495cd77 100644
--- a/src/assets/themes/rediwm-light.toml
+++ b/src/assets/themes/rediwm-light.toml
@@ -9,7 +9,8 @@ title_size = 13.5
chrome_height = 46
chrome_control_gap = 4
taskbar_title_size = 12.5
-taskbar_size = 48
+taskbar_size = 44
+start_button_icon_size = 36
chip_gap = 4
chip_width = 220
start_button_gap = 4
@@ -23,7 +24,7 @@ start_menu_max_height = 600
start_menu_radius = 14
start_menu_left_pad = 2
start_menu_bottom_pad = 6
-start_menu_icon_left_pad = 2
+start_menu_icon_left_pad = 12
start_menu_icon_bottom_pad = 6
# Window chrome
diff --git a/src/config/default.zig b/src/config/default.zig
index 2e92d01..8c3d848 100644
--- a/src/config/default.zig
+++ b/src/config/default.zig
@@ -30,15 +30,15 @@ pub const source =
\\caret_width = 1.5 # text insertion caret, not the mouse pointer
\\scrollbar_width = 8.0 # every scrollbar, 4–24 logical px
\\selection_alpha = 0.35 # highlight opacity when it follows the accent
- \\taskbar_size = 48.0 # taskbar height in pixels (36.0 to 84.0)
+ \\taskbar_size = 44.0 # taskbar height in pixels (36.0 to 84.0)
\\chip_width = 220.0 # preferred window item width, 64–400px; shrinks to fit
\\chip_gap = 4.0 # gap between taskbar window-item pills; also sets
\\ # each pill's top/bottom margin in the bar (capped)
\\start_button_gap = 4.0 # gap to the left of the start button and between start button and first pill
- \\start_button_icon_size = 42.0 # start button logo size; capped to the button itself
+ \\start_button_icon_size = 36.0 # start button logo size; capped to the button itself
\\start_menu_left_pad = 2.0 # start menu distance from left edge
\\start_menu_bottom_pad = 6.0 # start menu gap above the taskbar
- \\start_menu_icon_left_pad = 2.0 # start menu app row left inset
+ \\start_menu_icon_left_pad = 12.0 # start menu app row left/right inset
\\start_menu_icon_bottom_pad = 6.0 # start menu app row top/bottom inset
\\# More colors and styling: docs/wiki/Theme.md (all keys are optional).
\\# control_thumb = "#ffffff" # sliders and toggle thumbs
diff --git a/src/control_center/panel.zig b/src/control_center/panel.zig
index 65663e1..fcfeed3 100644
--- a/src/control_center/panel.zig
+++ b/src/control_center/panel.zig
@@ -56,7 +56,7 @@ const page_descriptions = [_][]const u8{
"Connect and manage your Bluetooth devices.", "Your language, regional formats and calendar preferences.",
"Review login accounts and automatic-login settings.", "Manage and analyze systemd services.",
};
-const page_icons = [_]layout.IconId{ .settings, .mouse, .display, .music, .wifi, .settings, .keyboard, .grid, .bluetooth, .globe, .generic, .settings };
+const page_icons = [_]layout.IconId{ .settings, .mouse, .display, .music, .wifi, .settings, .keyboard, .squares, .bluetooth, .globe, .users, .settings };
const max_devices = 16;
pub fn palette() theme.Theme {
diff --git a/src/control_center/sections/default_apps.zig b/src/control_center/sections/default_apps.zig
index a60a3ab..e4889d9 100644
--- a/src/control_center/sections/default_apps.zig
+++ b/src/control_center/sections/default_apps.zig
@@ -27,7 +27,7 @@ fn tree(s: *Section, cc: *panel.ControlCenter, a: std.mem.Allocator) !W {
inline for (.{ defaults.Kind.file_manager, defaults.Kind.terminal }, 0..) |kind, index| {
var labels: std.ArrayList([]const u8) = .empty;
var values: std.ArrayList([]const u8) = .empty;
- try labels.append(a, if (kind == .file_manager) "Files (built-in)" else "Automatic ($TERMINAL / Foot)");
+ try labels.append(a, if (kind == .file_manager) "RediWM Files (built-in)" else "Automatic ($TERMINAL / Foot)");
try values.append(a, "");
const selected = if (kind == .file_manager) cc.server.config.compositor.default_file_manager else cc.server.config.compositor.default_terminal;
var selected_index: usize = 0;
diff --git a/src/control_center/sections/region.zig b/src/control_center/sections/region.zig
index 6136846..98a0863 100644
--- a/src/control_center/sections/region.zig
+++ b/src/control_center/sections/region.zig
@@ -131,7 +131,7 @@ fn tree(s: *Section, cc: *panel.ControlCenter, a: std.mem.Allocator) !W {
text("Time & Date", 17, false),
try info(a, "Time zone", try timezone(a, cc)),
toggle,
- text("Taskbar, calendar and lock screen.", 12, true),
+ text("Taskbar, calendar, lock screen and Files.", 12, true),
text("First day of the week", 13, false),
.{ .name = "first_day_of_week", .kind = .{ .select = .{ .labels = &days, .selected = @intFromEnum(prefs.first_day_of_week), .owner = cc, .on_change = firstDayChanged } }, .width = .{ .percent = 1 } },
text("Changes the taskbar calendar.", 12, true),
diff --git a/src/delete_dialog.zig b/src/delete_dialog.zig
index 7680842..8815211 100644
--- a/src/delete_dialog.zig
+++ b/src/delete_dialog.zig
@@ -90,6 +90,14 @@ pub const State = struct {
defer c.cairo_restore(cr);
@import("ui").cairo.setSource(cr, dialog.backdropColor());
c.cairo_paint(cr);
+ self.drawWindow(ctx, w, h, mx, my, background);
+ }
+
+ /// Floating compositor prompts have no app-sized backdrop to dim.
+ pub fn drawWindow(self: *const State, ctx: anytype, w: i32, h: i32, mx: f64, my: f64, background: ?[4]f32) void {
+ const cr: *c.cairo_t = @ptrCast(ctx);
+ c.cairo_save(cr);
+ defer c.cairo_restore(cr);
const g = self.geometry(w, h);
c.cairo_translate(cr, g.x, g.y);
var layer = shell_ui.Layer.begin(cr, .{ .x = 0, .y = 0, .w = g.width, .h = g.height }) orelse return;
diff --git a/src/desktop/app.zig b/src/desktop/app.zig
index d4d943b..2938893 100644
--- a/src/desktop/app.zig
+++ b/src/desktop/app.zig
@@ -37,6 +37,8 @@ pub const Icon = struct {
pub const App = struct {
worker: *watcher.Worker,
host: Host = .none,
+ /// Embedded hosts present prompts above windows in a separate scene layer.
+ separate_overlays: bool = false,
wallpaper: ?@import("wallpaper.zig").Image = null,
/// Bumped whenever `wallpaper` changes to a different image.
wallpaper_revision: u64 = 0,
@@ -1037,6 +1039,50 @@ pub const App = struct {
c.cairo_paint_with_alpha(cr, opacity);
c.cairo_pattern_destroy(group);
}
+ if (self.dragging) {
+ const r = self.geometry.rect(self.geometry.snap(self.x, self.y));
+ rounded(cr, r.x, r.y, r.w, r.h, 8);
+ shell_cairo.setSource(cr, appearance_theme.global.desktop_drop_border);
+ c.cairo_set_line_width(cr, 1);
+ c.cairo_stroke(cr);
+ }
+ if (self.rubber) {
+ if (self.band) |band| {
+ c.cairo_set_source(cr, band);
+ c.cairo_paint(cr);
+ } else self.drawBand(cr);
+ }
+ if (!self.separate_overlays) self.paintOverlay(cr, now);
+ }
+
+ /// Prompt geometry is shared by painting, scene allocation and input.
+ pub fn promptRect(self: *App) ?grid.Rect {
+ if (self.renameGeometry()) |g| return damage_mod.expand(g.panel, 2);
+ if (self.edit == .trash) {
+ const g = self.deletion.geometry(self.geometry.w, self.geometry.h - self.geometry.bottom);
+ return .{ .x = @intFromFloat(@floor(g.x)), .y = @intFromFloat(@floor(g.y)), .w = @intFromFloat(@ceil(g.width)), .h = @intFromFloat(@ceil(g.height)) };
+ }
+ if (self.edit == .add_app or self.edit == .open_with) return .{ .x = @divTrunc(self.geometry.w - 480, 2), .y = @divTrunc(self.geometry.h - 360, 2), .w = 480, .h = 360 };
+ if (self.edit != .none) return .{ .x = @divTrunc(self.geometry.w - 420, 2), .y = @divTrunc(self.geometry.h - 120, 2), .w = 420, .h = 120 };
+ if (self.menu) return .{ .x = self.menu_x, .y = self.menu_y, .w = context_menu.width, .h = Menu.height(self.menuLabels().len, self.menu_icon != null) };
+ return null;
+ }
+
+ pub fn overlayRect(self: *App) ?grid.Rect {
+ var rect = self.promptRect();
+ if (self.notice_until > nowMs()) {
+ const notice_rect = grid.Rect{ .x = 24, .y = @max(24, self.geometry.h - self.geometry.bottom - 50), .w = @min(500, self.geometry.w - 48), .h = 36 };
+ if (rect) |r| {
+ const x = @min(r.x, notice_rect.x);
+ const y = @min(r.y, notice_rect.y);
+ rect = .{ .x = x, .y = y, .w = @max(r.x + r.w, notice_rect.x + notice_rect.w) - x, .h = @max(r.y + r.h, notice_rect.y + notice_rect.h) - y };
+ } else rect = notice_rect;
+ }
+ // Context-menu shadows extend five pixels sideways and eight below.
+ return if (rect) |r| damage_mod.expand(r, 8) else null;
+ }
+
+ pub fn paintOverlay(self: *App, cr: *c.cairo_t, now: i64) void {
if (self.renameGeometry()) |g| {
// Rasterize the complete overlay independently of the repair clip,
// just like icons: clipping Cairo arcs changes their edge coverage.
@@ -1053,19 +1099,6 @@ pub const App = struct {
c.cairo_paint(cr);
c.cairo_pattern_destroy(overlay);
}
- if (self.dragging) {
- const r = self.geometry.rect(self.geometry.snap(self.x, self.y));
- rounded(cr, r.x, r.y, r.w, r.h, 8);
- shell_cairo.setSource(cr, appearance_theme.global.desktop_drop_border);
- c.cairo_set_line_width(cr, 1);
- c.cairo_stroke(cr);
- }
- if (self.rubber) {
- if (self.band) |band| {
- c.cairo_set_source(cr, band);
- c.cairo_paint(cr);
- } else self.drawBand(cr);
- }
if (self.menu) {
const labels = self.menuLabels();
context_menu.frame(cr, .{
@@ -1105,7 +1138,10 @@ pub const App = struct {
label(cr, entry.name, px + 12, y, 456, 32, false);
}
} else if (self.edit == .trash) {
- self.deletion.draw(cr, self.geometry.w, self.geometry.h - self.geometry.bottom, self.x, self.y, null);
+ if (self.separate_overlays)
+ self.deletion.drawWindow(cr, self.geometry.w, self.geometry.h - self.geometry.bottom, self.x, self.y, null)
+ else
+ self.deletion.draw(cr, self.geometry.w, self.geometry.h - self.geometry.bottom, self.x, self.y, null);
} else if (self.edit != .none and self.edit != .rename) {
const x = @divTrunc(self.geometry.w - 420, 2);
const y = @divTrunc(self.geometry.h - 120, 2);
diff --git a/src/desktop/embedded.zig b/src/desktop/embedded.zig
index 83db6a3..abfdc90 100644
--- a/src/desktop/embedded.zig
+++ b/src/desktop/embedded.zig
@@ -40,6 +40,8 @@ pub const Desktop = struct {
worker: *Worker,
app: app_mod.App,
tree: *wlr.SceneTree,
+ overlay: *wlr.SceneBuffer,
+ overlay_rect: ?grid.Rect = null,
output: ?*Output = null,
/// Layout box and scale the canvas and tiles were built for.
box: wlr.Box = .{ .x = 0, .y = 0, .width = 0, .height = 0 },
@@ -98,11 +100,17 @@ pub const Desktop = struct {
errdefer worker.deinit();
const tree = try server.world_desktop_tree.createSceneTree();
errdefer tree.node.destroy();
+ const overlay = try server.overlay_tree.createSceneBuffer(null);
+ errdefer overlay.node.destroy();
+ overlay.node.setEnabled(false);
+ overlay.point_accepts_input = overlayAcceptsInput;
+ overlay.setFilterMode(.bilinear);
const self = try a.create(Desktop);
errdefer a.destroy(self);
- self.* = .{ .server = server, .worker = worker, .app = .{ .worker = worker }, .tree = tree };
+ self.* = .{ .server = server, .worker = worker, .app = .{ .worker = worker, .separate_overlays = true }, .tree = tree, .overlay = overlay };
self.app.host = .{ .ctx = self, .vtable = &vtable };
self.scene_data = .{ .role = .{ .desktop = self } };
+ self.scene_data.attach(&overlay.node);
server.input.seat.keyboard_state.events.focus_change.add(&self.focus_change);
errdefer self.focus_change.link.remove();
const loop = server.wl_server.getEventLoop();
@@ -121,6 +129,7 @@ pub const Desktop = struct {
// Tile buffers still locked by the scene return to the pool when
// wlroots releases them; none of them points back at this desktop.
self.tree.node.destroy();
+ self.overlay.node.destroy();
self.tiles.deinit(a);
self.secondaries.deinit(a);
self.freeCanvas();
@@ -144,6 +153,7 @@ pub const Desktop = struct {
self.output = output;
const out = output orelse {
self.tree.node.setEnabled(false);
+ self.overlay.node.setEnabled(false);
return;
};
var box: wlr.Box = undefined;
@@ -370,9 +380,64 @@ pub const Desktop = struct {
c.cairo_destroy(cr);
c.cairo_surface_flush(surface);
self.publish(&self.app.damage);
+ self.paintOverlay() catch |err| log.warn("desktop overlay: {}", .{err});
self.app.presented();
}
+ fn paintOverlay(self: *Desktop) !void {
+ const rect = self.app.overlayRect() orelse {
+ self.overlay_rect = null;
+ self.overlay.node.setEnabled(false);
+ self.overlay.setBuffer(null);
+ return;
+ };
+ const buffer = try @import("../panel_buffer.zig").PanelBuffer.create(rect.w, rect.h, self.scale);
+ defer buffer.base.drop();
+ const surface = c.cairo_image_surface_create_for_data(@ptrCast(buffer.pixels.ptr), c.CAIRO_FORMAT_ARGB32, buffer.width, buffer.height, buffer.width * 4) orelse return error.CairoFailed;
+ defer c.cairo_surface_destroy(surface);
+ if (c.cairo_surface_status(surface) != c.CAIRO_STATUS_SUCCESS) return error.CairoFailed;
+ const cr = c.cairo_create(surface) orelse return error.CairoFailed;
+ defer c.cairo_destroy(cr);
+ if (c.cairo_status(cr) != c.CAIRO_STATUS_SUCCESS) return error.CairoFailed;
+ c.cairo_scale(cr, self.scale, self.scale);
+ c.cairo_translate(cr, -@as(f64, @floatFromInt(rect.x)), -@as(f64, @floatFromInt(rect.y)));
+ self.app.paintOverlay(cr, app_mod.nowMs());
+ c.cairo_surface_flush(surface);
+ const opening = self.overlay_rect == null;
+ self.overlay_rect = rect;
+ self.overlay.setBuffer(&buffer.base);
+ if (opening) self.overlay.node.raiseToTop();
+ self.syncOverlayPosition();
+ }
+
+ /// Follow the desktop's camera transform without rerasterizing its prompt.
+ pub fn syncOverlayPosition(self: *Desktop) void {
+ const rect = self.overlay_rect orelse return;
+ if (self.output == null) return;
+ const fixed = self.server.config.compositor.desktop_icons_fixed;
+ const zoom = if (fixed) 1 else self.server.world.camera.zoom();
+ const x: f64 = @floatFromInt(self.box.x + rect.x);
+ const y: f64 = @floatFromInt(self.box.y + rect.y);
+ const origin = if (fixed) geometry.Vec2{ .x = x, .y = y } else blk: {
+ const point = self.server.world.toLayout(x, y);
+ break :blk geometry.Vec2{ .x = point.x, .y = point.y };
+ };
+ const x0: i32 = @intFromFloat(@round(origin.x));
+ const y0: i32 = @intFromFloat(@round(origin.y));
+ self.overlay.node.setPosition(x0, y0);
+ self.overlay.setDestSize(@max(1, @as(i32, @intFromFloat(@round(origin.x + @as(f64, @floatFromInt(rect.w)) * zoom))) - x0), @max(1, @as(i32, @intFromFloat(@round(origin.y + @as(f64, @floatFromInt(rect.h)) * zoom))) - y0));
+ self.overlay.node.setEnabled(true);
+ }
+
+ fn overlayAcceptsInput(node: *wlr.SceneBuffer, sx: *f64, sy: *f64) callconv(.c) bool {
+ const data = SceneData.fromNode(&node.node) orelse return false;
+ const self = data.role.desktop;
+ const rect = self.overlay_rect orelse return false;
+ const prompt = self.app.promptRect() orelse return false;
+ // Scene input coordinates use the destination size, not the raster.
+ return prompt.contains(@as(f64, @floatFromInt(rect.x)) + sx.* * @as(f64, @floatFromInt(rect.w)) / @as(f64, @floatFromInt(node.dst_width)), @as(f64, @floatFromInt(rect.y)) + sy.* * @as(f64, @floatFromInt(rect.h)) / @as(f64, @floatFromInt(node.dst_height)));
+ }
+
/// Copies each damaged tile into a fresh buffer and hands projection the
/// tile-local device damage.
fn publish(self: *Desktop, damage: *const app_mod.Damage) void {
diff --git a/src/files/app.zig b/src/files/app.zig
index 03949a6..e5d6d48 100644
--- a/src/files/app.zig
+++ b/src/files/app.zig
@@ -252,6 +252,8 @@ pub const App = struct {
/// "Scanning folder..." notice waits `scan_notice_delay_ms` from here.
loading_since: i64 = 0,
scan_notice_shown: bool = false,
+ /// A file passed at startup is selected once its parent folder is listed.
+ initial_selection: ?[]const u8 = null,
error_message: ?[]const u8 = null,
show_hidden: bool = false,
list_view: bool = false,
@@ -284,6 +286,7 @@ pub const App = struct {
pins_path: ?[]u8 = null,
/// While a drag hovers PLACES: the gap, among the pins, where a drop lands.
pin_drop: ?usize = null,
+ folder_drop: ?usize = null,
// Removable and external volumes (see volumes.zig), listed under DEVICES.
// The monitor starts once the window exists; without it the list is empty.
@@ -329,6 +332,7 @@ pub const App = struct {
drag_origin: ?struct { x: f64, y: f64 } = null,
drag_ready: bool = false,
collapse_on_release: ?usize = null,
+ deselect_on_release: ?usize = null,
selection_band: ?struct {
x: f64,
y: f64, // Content coordinates, so the anchor survives edge scrolling.
@@ -509,9 +513,9 @@ pub const App = struct {
}
const cur = self.history.current;
const name = if (self.trash_dir != null and std.mem.eql(u8, cur, self.trash_dir.?)) "Trash" else if (std.mem.eql(u8, cur, "/")) "/" else std.fs.path.basename(cur);
- _ = std.fmt.bufPrintZ(&self.title_z, "{s} — Files", .{name}) catch {
- @memcpy(self.title_z[0..5], "Files");
- self.title_z[5] = 0;
+ _ = std.fmt.bufPrintZ(&self.title_z, "{s} — RediWM Files", .{name}) catch {
+ @memcpy(self.title_z[0..12], "RediWM Files");
+ self.title_z[12] = 0;
};
self.title_changed = true;
}
@@ -868,6 +872,11 @@ pub const App = struct {
self.invalidate();
}
+ pub fn selectOnLoad(self: *App, path: []const u8) void {
+ self.initial_selection = path;
+ if (std.mem.startsWith(u8, std.fs.path.basename(path), ".")) self.toggleHidden();
+ }
+
pub fn back(self: *App) void {
self.rememberView();
if (self.history.back() catch null) |path| {
@@ -1023,6 +1032,17 @@ pub const App = struct {
self.loading = false;
self.rebuildView();
if (self.restore_view) self.restoreView();
+ if (self.initial_selection) |path| {
+ self.initial_selection = null;
+ for (self.items.items, 0..) |*item, i| {
+ if (!std.mem.eql(u8, item.path, path)) continue;
+ item.selected = true;
+ self.focused_index = i;
+ self.selection_anchor = i;
+ self.revealIndex(i);
+ break;
+ }
+ }
}
/// Repositories list as one Git column and ignore the grid, but the user's
@@ -1593,14 +1613,18 @@ pub const App = struct {
}
pub fn executePaste(self: *App, kind: ops_mod.OpKind, paths: []const []const u8) bool {
+ return self.executeTransfer(kind, paths, self.history.current, true);
+ }
+
+ pub fn executeTransfer(self: *App, kind: ops_mod.OpKind, paths: []const []const u8, directory: []const u8, clipboard: bool) bool {
if (self.history.archive_len > 0) return false;
if (paths.len == 0) return false;
const runner = self.job_runner orelse return false;
- runner.start(kind, paths, self.history.current, .ask) catch {
+ runner.start(kind, paths, directory, .ask) catch {
self.setStatusNotice("Failed to start transfer job", true);
return false;
};
- self.job_cut_revision = if (kind == .move and self.clipboard_cut) self.clipboard_revision else null;
+ self.job_cut_revision = if (clipboard and kind == .move and self.clipboard_cut) self.clipboard_revision else null;
self.job_was_running = true;
self.invalidate();
return true;
@@ -2755,7 +2779,39 @@ pub const App = struct {
return slot != null;
}
+ /// Content drops use the folder under the pointer, or the displayed folder
+ /// on empty space. Archives, dialogs, and file choosers are not targets.
+ pub fn dropDirectoryAt(self: *App, x: f64, y: f64) ?[]const u8 {
+ if (self.chooser != null or self.dialog != null or self.menu != null or self.history.archive_len > 0) return null;
+ if (self.job_state == .running or self.job_state == .waiting_conflict) return null;
+ if (x < @as(f64, @floatFromInt(self.sidebarWidth())) or x >= @as(f64, @floatFromInt(self.w - self.scrollbarGutter())) or
+ y < @as(f64, @floatFromInt(self.viewTop())) or y >= @as(f64, @floatFromInt(self.h - self.footerHeight()))) return null;
+ if (self.itemAt(x, y)) |idx| {
+ const item = self.items.items[idx];
+ if (!item.is_dir or item.missing or item.is_broken) return null;
+ return item.path;
+ }
+ return self.history.current;
+ }
+
+ pub fn highlightDrop(self: *App, x: f64, y: f64, accepted: bool) void {
+ const idx = if (accepted) self.itemAt(x, y) else null;
+ if (self.folder_drop == idx) return;
+ const per_row: usize = @intCast(self.columns());
+ for ([_]?usize{ self.folder_drop, idx }) |index| {
+ const i = index orelse continue;
+ var rect = self.itemHighlight(.{ .col = @floatFromInt(i % per_row), .row = @floatFromInt(i / per_row) });
+ rect.x -= 2;
+ rect.y -= 2;
+ rect.w += 4;
+ rect.h += 4;
+ self.addDamage(self.clipToViewport(rect));
+ }
+ self.folder_drop = idx;
+ }
+
pub fn dropLeave(self: *App) void {
+ self.highlightDrop(0, 0, false);
self.setPinDrop(null);
}
@@ -3710,6 +3766,7 @@ pub const App = struct {
self.drag_ready = self.history.archive_len == 0;
self.drag_origin = null;
self.collapse_on_release = null;
+ self.deselect_on_release = null;
self.last_click_index = null;
}
}
@@ -3754,6 +3811,7 @@ pub const App = struct {
self.drag_origin = null;
self.drag_ready = false;
self.collapse_on_release = null;
+ self.deselect_on_release = null;
}
fn bandRect(self: *App) header.Rect {
@@ -3920,6 +3978,10 @@ pub const App = struct {
for (self.items.items, 0..) |*it, i| it.selected = i == idx;
self.invalidate();
}
+ if (self.deselect_on_release) |idx| {
+ if (idx < self.items.items.len) self.items.items[idx].selected = false;
+ self.invalidate();
+ }
self.cancelDrag();
}
self.text_dragging = false;
@@ -4190,7 +4252,11 @@ pub const App = struct {
it.selected = (i >= start and i <= end);
}
} else if (self.ctrl and (self.chooser == null or self.chooser.?.multiple)) {
- self.items.items[idx].selected = !self.items.items[idx].selected;
+ if (button == 0x110 and self.chooser == null and self.items.items[idx].selected) {
+ self.deselect_on_release = idx;
+ } else {
+ self.items.items[idx].selected = !self.items.items[idx].selected;
+ }
self.selection_anchor = idx;
} else {
if (button == 0x110 and self.items.items[idx].selected) {
@@ -5070,15 +5136,15 @@ pub const App = struct {
const right: f64 = @floatFromInt(self.w);
const top: f64 = @floatFromInt(self.viewTop());
const bottom: f64 = @floatFromInt(self.h - self.footerHeight());
- const w = @min(280, right - left - 8);
+ const w = @min(340, right - left - 16);
const h: f64 = 44;
- var x = left + 16;
+ var x = left + 8;
var y = top + 8;
if (dlg.target_path) |target| for (self.items.items, 0..) |item, i| {
if (!std.mem.eql(u8, item.path, target)) continue;
const icon = self.itemIconRect(@intCast(i));
if (self.list_view) {
- x = icon.x - 6;
+ x = left + 8;
y = icon.y + icon.h / 2 - h / 2;
} else {
x = icon.x + icon.w / 2 - w / 2;
@@ -5235,6 +5301,12 @@ pub const App = struct {
c.cairo_set_line_width(cr, 1);
c.cairo_stroke(cr);
}
+ if (self.folder_drop == idx) {
+ roundedRect(cr, x, y, width, @floatFromInt(self.cardHeight()), 6);
+ setSource(cr, accent);
+ c.cairo_set_line_width(cr, 2);
+ c.cairo_stroke(cr);
+ }
var cut = false;
if (self.clipboard_cut) {
for (self.clipboard_paths.items) |path| {
@@ -5280,12 +5352,8 @@ pub const App = struct {
const ty = self.listColumn(2);
drawEllipsis(cr, itemType(item), ty.x + 4, y + baseline, ty.w - 8, shell_ui.textSize(), false);
const mt = self.listColumn(3);
- var tm: c.struct_tm = undefined;
- var seconds: c.time_t = @intCast(item.mtime);
- if (c.localtime_r(&seconds, &tm) != null) {
- const n = c.strftime(&buf, buf.len, "%Y-%m-%d %H:%M", &tm);
- drawEllipsis(cr, buf[0..n], mt.x + 4, y + baseline, mt.w - 8, shell_ui.textSize(), false);
- }
+ const timestamp = @import("settings.zig").dateTime(item.mtime, &buf);
+ drawEllipsis(cr, timestamp, mt.x + 4, y + baseline, mt.w - 8, shell_ui.textSize(), false);
const permissions = self.listColumn(4);
const mode = formatPermissions(item.mode);
drawEllipsis(cr, if (item.permissions_text.len > 0) item.permissions_text else &mode, permissions.x + 4, y + baseline, permissions.w - 8, shell_ui.textSize(), false);
@@ -6520,6 +6588,19 @@ test "file drag threshold preserves multi-selection and ordinary release collaps
app.handleButton(0x110, true);
app.handleButton(0x110, false);
try std.testing.expect(!app.items.items[1].selected);
+
+ app.ctrl = true;
+ app.last_click_index = null;
+ app.handleButton(0x110, true);
+ try std.testing.expect(app.items.items[0].selected);
+ app.handleMotion(270, 158);
+ try std.testing.expect(app.drag_ready);
+ app.handleButton(0x110, false);
+ try std.testing.expect(app.items.items[0].selected);
+ app.handleMotion(250, 158);
+ app.handleButton(0x110, true);
+ app.handleButton(0x110, false);
+ try std.testing.expect(!app.items.items[0].selected);
}
test "Files reduced motion scrolls immediately" {
diff --git a/src/files/main.zig b/src/files/main.zig
index 7329403..eb21cd9 100644
--- a/src/files/main.zig
+++ b/src/files/main.zig
@@ -18,9 +18,11 @@ const a = std.heap.c_allocator;
const Offer = struct {
proxy: *wl.DataOffer,
uri: bool = false,
+ files: bool = false,
gnome: bool = false,
text: bool = false,
utf8: bool = false,
+ action: wl.DataDeviceManager.DndAction = .{},
};
// A window with no server-side decorations must draw its own titlebar so it
@@ -64,10 +66,14 @@ pub const Client = struct {
drag_enter_serial: u32 = 0,
/// Whether the drag over the window was last told a drop here would work.
drag_accepting: bool = false,
+ drag_moving: bool = false,
+ drag_x: f64 = 0,
+ drag_y: f64 = 0,
/// A dropped offer being read, and the pin gap it was dropped on.
drop_offer: ?*Offer = null,
drop_receiving: ?transfer.Receive = null,
- drop_slot: usize = 0,
+ drop_slot: ?usize = null,
+ drop_move: bool = false,
clipboard_source: ?*ClipboardSource = null,
drag_source: ?*ClipboardSource = null,
drag_serial: u32 = 0,
@@ -609,10 +615,12 @@ pub const Client = struct {
}
fn offerEvent(_: *wl.DataOffer, event: wl.DataOffer.Event, offer: *Offer) void {
+ if (event == .action) offer.action = event.action.dnd_action;
if (event == .offer) {
if (std.mem.eql(u8, std.mem.span(event.offer.mime_type), "text/plain")) offer.text = true;
if (std.mem.eql(u8, std.mem.span(event.offer.mime_type), "text/plain;charset=utf-8")) offer.utf8 = true;
if (std.mem.eql(u8, std.mem.span(event.offer.mime_type), "text/uri-list")) offer.uri = true;
+ if (std.mem.eql(u8, std.mem.span(event.offer.mime_type), "application/x-rediwm-file-transfer")) offer.files = true;
if (std.mem.eql(u8, std.mem.span(event.offer.mime_type), "x-special/gnome-copied-files")) offer.gnome = true;
}
}
@@ -661,54 +669,68 @@ pub const Client = struct {
}
}
- /// A drag is over the window. Files takes file lists only to pin them, so
- /// it accepts them over PLACES and nowhere else.
fn dragOver(self: *Client, x: f64, y: f64, entered: bool) void {
const offer = self.drag_offer orelse return;
- const tbh: f64 = @floatFromInt(self.titlebarHeight());
- const wanted = offer.uri and self.drop_receiving == null and
- (if (y >= tbh) self.app.dropMotion(x, y - tbh) else blk: {
- self.app.dropLeave();
- break :blk false;
- });
- if (!entered and wanted == self.drag_accepting) return;
+ self.drag_x = x;
+ self.drag_y = y - @as(f64, @floatFromInt(self.titlebarHeight()));
+ const available = offer.uri and self.drop_receiving == null;
+ const pin = available and self.app.dropMotion(x, self.drag_y);
+ const folder = available and !pin and self.app.dropDirectoryAt(x, self.drag_y) != null;
+ self.app.highlightDrop(x, self.drag_y, folder);
+ const wanted = pin or folder;
+ const moving = folder and offer.files;
+ if (!entered and wanted == self.drag_accepting and moving == self.drag_moving) return;
self.drag_accepting = wanted;
+ self.drag_moving = moving;
offer.proxy.accept(self.drag_enter_serial, if (wanted) "text/uri-list" else null);
- // Only a copy: pinning must never look like permission to move or
- // delete the originals.
if (offer.proxy.getVersion() >= 3) {
- const copy: wl.DataDeviceManager.DndAction = if (wanted) .{ .copy = true } else .{};
- offer.proxy.setActions(copy, copy);
+ // Files performs filesystem moves in the receiving job, never in
+ // the source's finished callback. Other sources and pins copy.
+ offer.proxy.setActions(.{ .copy = wanted, .move = moving }, if (moving) .{ .move = true } else .{ .copy = wanted });
}
}
fn dragDropped(self: *Client) void {
const offer = self.drag_offer orelse return;
- // The offer outlives this drag: `leave` must not destroy what is read.
self.drag_offer = null;
+ defer self.app.dropLeave();
+ const accepted = self.drag_accepting;
self.drag_accepting = false;
- const slot = self.app.takePinDrop() orelse {
+ const slot = self.app.takePinDrop();
+ const directory = if (slot != null) "" else self.app.dropDirectoryAt(self.drag_x, self.drag_y) orelse {
self.discardOffer(offer);
return;
};
- self.startDropReceive(offer, slot) catch {
+ if (!accepted or (offer.proxy.getVersion() >= 3 and !offer.action.copy and !offer.action.move)) {
+ self.discardOffer(offer);
+ return;
+ }
+ self.startDropReceive(offer, slot, directory) catch {
self.app.setStatusNotice("Could not read the dropped items", true);
- self.endDrop(offer);
+ self.discardOffer(offer);
};
}
- fn startDropReceive(self: *Client, offer: *Offer, slot: usize) !void {
+ fn startDropReceive(self: *Client, offer: *Offer, slot: ?usize, target: []const u8) !void {
var fds: [2]c_int = undefined;
if (c.pipe2(&fds, c.O_CLOEXEC) != 0) return error.PipeFailed;
defer _ = c.close(fds[1]);
errdefer _ = c.close(fds[0]);
if (c.fcntl(fds[0], c.F_SETFL, @as(c_int, c.O_NONBLOCK)) < 0) return error.NonblockingFailed;
- const directory = try a.dupe(u8, "");
+ const directory = try a.dupe(u8, target);
self.drop_receiving = .{ .fd = fds[0], .text = false, .revision = 0, .directory = directory, .started = app_mod.nowMs() };
self.drop_offer = offer;
self.drop_slot = slot;
+ self.drop_move = slot == null and offer.action.move;
offer.proxy.receive("text/uri-list", fds[1]);
- // The main loop flushes this request before polling the pipe.
+ }
+
+ fn canonicalPath(path: []const u8) ![]u8 {
+ const terminated = try a.dupeZ(u8, path);
+ defer a.free(terminated);
+ var buffer: [4096]u8 = undefined;
+ const resolved = c.realpath(terminated, &buffer) orelse return error.InvalidPath;
+ return a.dupe(u8, std.mem.span(resolved));
}
fn receiveDrop(self: *Client) void {
@@ -730,7 +752,32 @@ pub const Client = struct {
return;
};
defer decoded.deinit(a);
- self.app.pinDropped(self.drop_slot, decoded.paths);
+ if (self.drop_slot) |slot| {
+ self.app.pinDropped(slot, decoded.paths);
+ } else {
+ const destination = canonicalPath(receive.directory) catch {
+ self.app.setStatusNotice("The destination folder is unavailable", true);
+ return;
+ };
+ defer a.free(destination);
+ var paths: std.ArrayList([]const u8) = .empty;
+ defer paths.deinit(a);
+ for (decoded.paths) |path| {
+ const resolved = canonicalPath(path) catch continue;
+ defer a.free(resolved);
+ if (@import("ops.zig").isDescendantOrSame(resolved, destination)) {
+ self.app.setStatusNotice("Cannot drop a folder into itself", true);
+ return;
+ }
+ const parent = std.fs.path.dirname(path) orelse continue;
+ const resolved_parent = canonicalPath(parent) catch continue;
+ defer a.free(resolved_parent);
+ if (self.drop_move and std.mem.eql(u8, resolved_parent, destination)) continue;
+ paths.append(a, path) catch return;
+ }
+ if (paths.items.len == 0) return;
+ _ = self.app.executeTransfer(if (self.drop_move) .move else .copy, paths.items, destination, false);
+ }
}
fn finishDrop(self: *Client) void {
@@ -809,8 +856,9 @@ pub const Client = struct {
clip.* = .{ .client = self, .proxy = source, .uris = uris, .gnome = gnome };
source.setListener(*ClipboardSource, clipboardEvent, clip);
source.offer("text/uri-list");
- // Uploads and copies never remove the original files.
- if (source.getVersion() >= 3) source.setActions(.{ .copy = true });
+ source.offer("application/x-rediwm-file-transfer");
+ // The receiving file manager performs moves; upload targets choose copy.
+ if (source.getVersion() >= 3) source.setActions(.{ .copy = true, .move = !self.app.ctrl });
self.drag_source = clip;
self.app.cancelWheel();
self.app.cancelDrag();
@@ -1181,7 +1229,7 @@ const Buffer = struct {
}
};
-pub fn run(init: std.process.Init, target_dir: []const u8, chooser: ?@import("chooser.zig").Options) !void {
+pub fn run(init: std.process.Init, target_dir: []const u8, selected_file: ?[]const u8, chooser: ?@import("chooser.zig").Options) !void {
_ = c.signal(c.SIGPIPE, c.SIG_IGN);
const home_dir = init.minimal.environ.getPosix("HOME") orelse "/";
@@ -1214,6 +1262,7 @@ pub fn run(init: std.process.Init, target_dir: []const u8, chooser: ?@import("ch
};
defer self.app.deinit();
if (chooser) |options| try self.app.configureChooser(options);
+ if (selected_file) |path| self.app.selectOnLoad(path);
self.app.startDevices();
defer {
self.clearDragIcon();
diff --git a/src/files/properties.zig b/src/files/properties.zig
index ff46711..7375917 100644
--- a/src/files/properties.zig
+++ b/src/files/properties.zig
@@ -262,11 +262,7 @@ fn permissionBit(index: usize) c.mode_t {
}
fn date(timestamp: ?i64, buf: []u8) []const u8 {
- var seconds: c.time_t = timestamp orelse return "Unavailable";
- var tm: c.struct_tm = undefined;
- if (c.localtime_r(&seconds, &tm) == null) return "Unavailable";
- const n = c.strftime(buf.ptr, buf.len, "%Y-%m-%d %H:%M", &tm);
- return if (n > 0) buf[0..n] else "Unavailable";
+ return @import("settings.zig").dateTime(timestamp orelse return "Unavailable", buf);
}
fn describe(a: std.mem.Allocator, path: [:0]const u8, mode: c.mode_t) ![]const u8 {
diff --git a/src/files/settings.zig b/src/files/settings.zig
index e63e17f..6516bc7 100644
--- a/src/files/settings.zig
+++ b/src/files/settings.zig
@@ -7,11 +7,13 @@ const anim = @import("ui").anim;
const anim_config = @import("config").animations;
const theme = @import("ui").theme;
const text = @import("ui").text;
+const config = @import("config").loader;
/// Owns the string tokens while a theme travels from the worker to the UI.
pub const ThemeUpdate = struct {
value: theme.Theme,
allocator: std.mem.Allocator,
+ region: config.RegionConfig = .{},
fn init(a: std.mem.Allocator, t: theme.Theme) !ThemeUpdate {
var value = t;
@@ -32,6 +34,7 @@ pub const ThemeUpdate = struct {
/// Transfers ownership to the UI thread. Never call from a worker.
pub fn apply(self: ThemeUpdate) void {
theme.global = self.value;
+ region = self.region;
text.setPreferredFamilies(self.value.font, self.value.mono_font);
if (applied_theme) |old| old.deinit();
applied_theme = self;
@@ -39,9 +42,11 @@ pub const ThemeUpdate = struct {
};
var applied_theme: ?ThemeUpdate = null;
+var region: config.RegionConfig = .{};
pub fn deinitTheme() void {
theme.global = .{};
+ region = .{};
if (applied_theme) |t| t.deinit();
applied_theme = null;
}
@@ -51,6 +56,7 @@ pub const Settings = struct {
theme_path: ?[:0]const u8 = null,
stamps: [2]?Stamp = .{ null, null },
animations: anim.Settings = .{},
+ region: config.RegionConfig = .{},
initialized: bool = false,
last_second: i64 = -1,
@@ -95,15 +101,25 @@ pub const Settings = struct {
defer arena.deinit();
var t: theme.Theme = .{};
self.animations = .{};
+ self.region = .{};
for (paths, 0..) |path, i| {
const p = path orelse continue;
const bytes = std.Io.Dir.cwd().readFileAlloc(io, p, arena.allocator(), .limited(1 << 20)) catch continue;
- if (i == 0) self.animations = parseAnimations(bytes);
+ if (i == 0) {
+ self.animations = parseAnimations(bytes);
+ var cfg = config.parse(arena.allocator(), bytes, p) catch null;
+ if (cfg) |*value| {
+ self.region = value.region;
+ value.deinit();
+ }
+ }
var next = t;
theme.overlay(arena.allocator(), &next, bytes) catch continue;
t = next;
}
- return ThemeUpdate.init(a, t) catch null;
+ var update = ThemeUpdate.init(a, t) catch return null;
+ update.region = self.region;
+ return update;
}
};
@@ -114,6 +130,26 @@ pub fn loadTheme(a: std.mem.Allocator, io: std.Io, env: std.process.Environ) voi
if (settings.poll(a, io)) |t| t.apply();
}
+/// File timestamps use the same clock preference as the shell.
+pub fn dateTime(timestamp: i64, buf: []u8) []const u8 {
+ return formatDateTime(timestamp, buf, region);
+}
+
+fn formatDateTime(timestamp: i64, buf: []u8, prefs: config.RegionConfig) []const u8 {
+ var seconds: c.time_t = @intCast(timestamp);
+ var tm: c.struct_tm = undefined;
+ if (c.localtime_r(&seconds, &tm) == null) return "Unavailable";
+ const date_len = c.strftime(buf.ptr, buf.len, "%Y-%m-%d ", &tm);
+ if (date_len == 0) return "Unavailable";
+ var time_buf: [64]u8 = undefined;
+ const time_len = c.strftime(&time_buf, time_buf.len, prefs.timeFormat(), &tm);
+ if (time_len == 0) return "Unavailable";
+ const time = std.mem.trimStart(u8, time_buf[0..time_len], " ");
+ if (date_len + time.len > buf.len) return "Unavailable";
+ @memcpy(buf[date_len..][0..time.len], time);
+ return buf[0 .. date_len + time.len];
+}
+
test "Files follows config edits, theme overrides and file removal" {
var config_path = "/tmp/rediwm-scrollbar-config-XXXXXX".*;
const config_fd = c.mkstemp(&config_path);
@@ -134,6 +170,7 @@ test "Files follows config edits, theme overrides and file removal" {
try std.testing.expectEqual(@as(f32, 12), update0.value.scrollbar_width);
try std.testing.expectEqualStrings("Noto Sans", update0.value.font);
try std.testing.expectEqualStrings("Noto Sans Mono", update0.value.mono_font);
+ try std.testing.expect(!update0.region.clock_24h);
settings.last_second = -1;
try std.testing.expect(settings.poll(a, io) == null);
try std.Io.Dir.cwd().writeFile(io, .{ .sub_path = &theme_path, .data = "[theme]\nscrollbar_width = 24\nfont = \"Liberation Sans\"\n" });
@@ -149,12 +186,29 @@ test "Files follows config edits, theme overrides and file removal" {
defer update2.deinit();
try std.testing.expectEqual(@as(f32, 12), update2.value.scrollbar_width);
try std.testing.expectEqualStrings("Noto Sans", update2.value.font);
- try std.Io.Dir.cwd().writeFile(io, .{ .sub_path = &config_path, .data = "[theme]\nscrollbar_width = 4\n" });
+ try std.Io.Dir.cwd().writeFile(io, .{ .sub_path = &config_path, .data = "[theme]\nscrollbar_width = 4\n[region]\nclock_24h = true\n" });
settings.last_second = -1;
const update3 = settings.poll(a, io).?;
defer update3.deinit();
try std.testing.expectEqual(@as(f32, 4), update3.value.scrollbar_width);
try std.testing.expectEqualStrings((theme.Theme{}).font, update3.value.font);
+ try std.testing.expect(update3.region.clock_24h);
+ // The config's preference travels with the worker update, independently
+ // of theme overrides; verify both clock formats in local time.
+ var tm: c.struct_tm = std.mem.zeroes(c.struct_tm);
+ tm.tm_year = 124;
+ tm.tm_mon = 2;
+ tm.tm_mday = 14;
+ tm.tm_min = 24;
+ tm.tm_isdst = -1;
+ var buf: [64]u8 = undefined;
+ for ([_]c_int{ 0, 12, 15 }, [_][]const u8{ "12:24 AM", "12:24 PM", "3:24 PM" }, [_][]const u8{ "00:24", "12:24", "15:24" }) |hour, time12, time24| {
+ tm.tm_hour = hour;
+ const timestamp = c.mktime(&tm);
+ try std.testing.expectEqualStrings(time12, formatDateTime(timestamp, &buf, update0.region)[11..]);
+ try std.testing.expectEqualStrings(time24, formatDateTime(timestamp, &buf, update3.region)[11..]);
+ }
+ try std.testing.expectEqualStrings("Unavailable", formatDateTime(0, buf[0..4], update3.region));
// Outstanding worker updates retain their strings across later polls.
try std.testing.expectEqualStrings("Liberation Sans", update1.value.font);
}
diff --git a/src/files/worker.zig b/src/files/worker.zig
index b905975..593ca7c 100644
--- a/src/files/worker.zig
+++ b/src/files/worker.zig
@@ -414,7 +414,10 @@ pub const Worker = struct {
list.append(mem, item) catch continue;
}
- snap.repository = git.scan(mem, self.io, self.environ, dir_path) catch null;
+ // Temporarily disable Git integration, including discovery, watches and
+ // all repository UI, regardless of the saved Git View preference.
+ const git_enabled = false;
+ snap.repository = if (git_enabled) git.scan(mem, self.io, self.environ, dir_path) catch null else null;
if (snap.repository) |repo| {
for (list.items) |*item| {
item.git_status = repo.status(item.name);
diff --git a/src/files_main.zig b/src/files_main.zig
index 8b28bc2..2df94f5 100644
--- a/src/files_main.zig
+++ b/src/files_main.zig
@@ -4,9 +4,9 @@ const c = @import("files/c.zig").api;
fn printUsage() void {
const usage =
- \\Usage: rediwm-files [DIRECTORY]
+ \\Usage: rediwm-files [DIRECTORY|FILE]
\\
- \\A lightweight, standalone file browser for Wayland.
+ \\A lightweight, standalone file browser for Wayland. A file opens its folder and is selected.
\\
\\Options:
\\ -h, --help Show this help message and exit
@@ -36,7 +36,13 @@ fn printUsage() void {
std.debug.print("{s}", .{usage});
}
-fn resolveDirectory(allocator: std.mem.Allocator, environ: std.process.Environ, target: ?[]const u8) ![]const u8 {
+const Target = struct {
+ path: []const u8,
+ directory: []const u8,
+ selected: ?[]const u8,
+};
+
+fn resolveTarget(allocator: std.mem.Allocator, environ: std.process.Environ, target: ?[]const u8, allow_file: bool) !Target {
const home = environ.getPosix("HOME") orelse "/";
var path_to_check: []const u8 = undefined;
@@ -63,11 +69,9 @@ fn resolveDirectory(allocator: std.mem.Allocator, environ: std.process.Environ,
return error.FileNotFound;
}
- if ((stat_buf.st_mode & c.S_IFMT) != c.S_IFDIR) {
- return error.NotADirectory;
- }
-
- return resolved;
+ if ((stat_buf.st_mode & c.S_IFMT) == c.S_IFDIR) return .{ .path = resolved, .directory = resolved, .selected = null };
+ if (!allow_file) return error.NotADirectory;
+ return .{ .path = resolved, .directory = std.fs.path.dirname(resolved) orelse "/", .selected = resolved };
}
pub fn main(init: std.process.Init) void {
@@ -109,12 +113,9 @@ pub fn main(init: std.process.Init) void {
}
const allocator = std.heap.c_allocator;
- const dir = resolveDirectory(allocator, init.minimal.environ, target_arg) catch |err| blk: {
- if (chooser != null) break :blk resolveDirectory(allocator, init.minimal.environ, null) catch resolveDirectory(allocator, init.minimal.environ, "/") catch std.process.exit(1);
+ const target = resolveTarget(allocator, init.minimal.environ, target_arg, chooser == null) catch |err| blk: {
+ if (chooser != null) break :blk resolveTarget(allocator, init.minimal.environ, null, false) catch resolveTarget(allocator, init.minimal.environ, "/", false) catch std.process.exit(1);
switch (err) {
- error.NotADirectory => {
- std.debug.print("rediwm-files: '{s}': Not a directory\n", .{target_arg.?});
- },
error.FileNotFound => {
std.debug.print("rediwm-files: '{s}': No such file or directory\n", .{target_arg.?});
},
@@ -124,9 +125,9 @@ pub fn main(init: std.process.Init) void {
}
std.process.exit(1);
};
- defer allocator.free(dir);
+ defer allocator.free(target.path);
- main_mod.run(init, dir, chooser) catch |err| {
+ main_mod.run(init, target.directory, if (chooser == null) target.selected else null, chooser) catch |err| {
std.log.err("rediwm-files: {}", .{err});
std.process.exit(1);
};
diff --git a/src/icon_cache.zig b/src/icon_cache.zig
index fb51390..e940298 100644
--- a/src/icon_cache.zig
+++ b/src/icon_cache.zig
@@ -282,7 +282,8 @@ fn lerpArgb(a: u32, b: u32, t: f32) u32 {
return (out[0] << 24) | (out[1] << 16) | (out[2] << 8) | out[3];
}
-// Bilinear resample of a premultiplied-ARGB buffer. Valid on premultiplied
+// Bilinear resample of a premultiplied-ARGB buffer into a square icon slot,
+// centering rectangular artwork without stretching it. Valid on premultiplied
// data (unlike some other filters) since resize is a linear operation.
fn resample(src: []const u32, src_w: i32, src_h: i32, dst_size: i32) ![]u32 {
const dst = try gpa.alloc(u32, @intCast(dst_size * dst_size));
@@ -290,10 +291,20 @@ fn resample(src: []const u32, src_w: i32, src_h: i32, dst_size: i32) ![]u32 {
const sw: f32 = @floatFromInt(src_w);
const sh: f32 = @floatFromInt(src_h);
const dwf: f32 = @floatFromInt(dst_size);
+ const longest = @max(sw, sh);
+ const image_w = dwf * sw / longest;
+ const image_h = dwf * sh / longest;
+ const left = (dwf - image_w) / 2;
+ const top = (dwf - image_h) / 2;
var dy: usize = 0;
while (dy < dw) : (dy += 1) {
- const sy = (@as(f32, @floatFromInt(dy)) + 0.5) * sh / dwf - 0.5;
+ const py = @as(f32, @floatFromInt(dy)) + 0.5;
+ if (py < top or py >= top + image_h) {
+ @memset(dst[dy * dw ..][0..dw], 0);
+ continue;
+ }
+ const sy = (py - top) * sh / image_h - 0.5;
const y0f = @floor(sy);
const fy = sy - y0f;
const y0 = clampInt(@intFromFloat(y0f), 0, src_h - 1);
@@ -301,7 +312,12 @@ fn resample(src: []const u32, src_w: i32, src_h: i32, dst_size: i32) ![]u32 {
var dx: usize = 0;
while (dx < dw) : (dx += 1) {
- const sx = (@as(f32, @floatFromInt(dx)) + 0.5) * sw / dwf - 0.5;
+ const px = @as(f32, @floatFromInt(dx)) + 0.5;
+ if (px < left or px >= left + image_w) {
+ dst[dy * dw + dx] = 0;
+ continue;
+ }
+ const sx = (px - left) * sw / image_w - 0.5;
const x0f = @floor(sx);
const fx = sx - x0f;
const x0 = clampInt(@intFromFloat(x0f), 0, src_w - 1);
@@ -318,6 +334,15 @@ fn resample(src: []const u32, src_w: i32, src_h: i32, dst_size: i32) ![]u32 {
return dst;
}
+test "rectangular PNG icons keep their proportions" {
+ const src = [_]u32{ 0xffff0000, 0xff0000ff };
+ const pixels = try resample(&src, 2, 1, 4);
+ defer gpa.free(pixels);
+ try std.testing.expectEqualSlices(u32, &.{ 0, 0, 0, 0 }, pixels[0..4]);
+ try std.testing.expectEqualSlices(u32, &.{ 0, 0, 0, 0 }, pixels[12..16]);
+ for (pixels[4..12]) |pixel| try std.testing.expectEqual(@as(u32, 0xff), pixel >> 24);
+}
+
test "decode palette PNG via cairo fallback" {
const paths = [_][*:0]const u8{
"/usr/share/icons/hicolor/32x32/apps/cups.png",
diff --git a/src/msg/main.zig b/src/msg/main.zig
index 7fe2a30..b8d5eb4 100644
--- a/src/msg/main.zig
+++ b/src/msg/main.zig
@@ -2277,6 +2277,17 @@ fn printUsage() void {
inline for (protocol.commands.specs) |s| {
if (comptime s.action_cli) |cli| printCommandHelp("action ", cli, s.description);
}
+ std.debug.print(
+ "\nOther IPC commands (via raw JSON):\n" ++
+ " rediwm-msg raw '{{\"version\":1,\"command\":\"get_theme\"}}'\n" ++
+ " rediwm-msg raw '{{\"version\":1,\"command\":\"set_dnd\",\"params\":{{\"enabled\":true}}}}'\n",
+ .{},
+ );
+ inline for (protocol.commands.specs) |s| {
+ if (comptime s.cli == null and s.action_cli == null)
+ std.debug.print(" {s} {s}\n", .{ s.wire(), s.description });
+ }
+ std.debug.print(" Use 'rediwm-msg describe' for parameter schemas.\n", .{});
}
fn printCommandHelp(prefix: []const u8, cli: protocol.commands.CliSpec, description: []const u8) void {
diff --git a/src/network/popup.zig b/src/network/popup.zig
index 6256bf2..1638305 100644
--- a/src/network/popup.zig
+++ b/src/network/popup.zig
@@ -173,18 +173,20 @@ pub const Popup = struct {
return;
}
self.sonar_node.setOpacity(opacity);
+ const sonar_scale: f32 = 48 / sonar.size;
+ const inset = (sonar.size - 48) / 2;
self.sonar_node.node.setPosition(
- self.buffer_node.node.x + @as(i32, @intFromFloat(@round(100 * self.factor))),
- self.buffer_node.node.y + @as(i32, @intFromFloat(@round(8 * self.factor))),
+ self.buffer_node.node.x + @as(i32, @intFromFloat(@round((100 + inset) * self.factor))),
+ self.buffer_node.node.y + @as(i32, @intFromFloat(@round((8 + inset) * self.factor))),
);
if (self.sonarFading() and self.sonar_step >= 0) return;
const moving = searching_now and anim.enabled() and !anim.reducedMotion();
const step = if (moving) @divTrunc(now, 32) else 0;
if (self.sonar_step == step) return;
- const side: i32 = @intFromFloat(@round(sonar.size * self.factor));
+ const side: i32 = @intFromFloat(@round(sonar.size * sonar_scale * self.factor));
const buf = PanelBuffer.createUnpooled(side, side, self.output.wlr_output.scale) catch return;
defer buf.base.drop();
- var r: paint.Renderer = .{ .pixels = buf.pixels, .width = buf.width, .height = buf.height, .scale = self.output.wlr_output.scale * self.factor };
+ var r: paint.Renderer = .{ .pixels = buf.pixels, .width = buf.width, .height = buf.height, .scale = self.output.wlr_output.scale * self.factor * sonar_scale };
const m = self.manager().?;
sonar.paint(&r, m.networks[0..m.count], if (moving) @as(f32, @floatFromInt(@mod(step, 100))) / 100 else null);
self.sonar_node.setBuffer(&buf.base);
diff --git a/src/session/file_manager_service.zig b/src/session/file_manager_service.zig
index 90e327c..e70e926 100644
--- a/src/session/file_manager_service.zig
+++ b/src/session/file_manager_service.zig
@@ -51,34 +51,36 @@ fn show(owner: ?*anyopaque, conn: *dbus.Connection, msg: wire.Message) !void {
try reader.done();
// ShowFolders names folders; the other calls name items inside one.
const items = !std.mem.eql(u8, msg.headers.member orelse "", "ShowFolders");
- var folders: std.ArrayList([]const u8) = .empty;
+ const Request = struct { folder: []const u8, item: ?[]const u8 };
+ var folders: std.ArrayList(Request) = .empty;
while (uris.offset < uris.bytes.len) {
const path = launch.fileUriPath(a, try uris.string()) catch continue;
const folder = if (items) std.fs.path.dirname(path) orelse "/" else path;
const seen = for (folders.items) |known| {
- if (std.mem.eql(u8, known, folder)) break true;
+ if (std.mem.eql(u8, known.folder, folder)) break true;
} else false;
- if (!seen and folders.items.len < max_folders) try folders.append(a, folder);
+ if (!seen and folders.items.len < max_folders) try folders.append(a, .{ .folder = folder, .item = if (items) path else null });
}
- for (folders.items) |folder| open(server, a, folder);
+ for (folders.items) |request| open(server, a, request.folder, request.item);
const empty: wire.Writer = .{ .allocator = gpa };
try conn.reply(msg, "", &empty);
}
-fn open(server: *Server, a: std.mem.Allocator, folder: []const u8) void {
+fn open(server: *Server, a: std.mem.Allocator, folder: []const u8, item: ?[]const u8) void {
const snapshot = server.start_menu_catalog.retainSnapshot();
defer snapshot.release();
const preferred = server.config.compositor.default_file_manager;
const id = if (preferred.len > 0) preferred else "rediwm-files.desktop";
+ const target = if (std.mem.eql(u8, id, "rediwm-files.desktop")) item orelse folder else folder;
if (defaults.find(snapshot.entries, id)) |entry| {
- const uri = fileUri(a, folder) catch return;
+ const uri = fileUri(a, target) catch return;
launch.launchUris(gpa, server, entry, &.{uri}) catch |err| {
log.warn("could not open {s} in {s}: {}", .{ folder, id, err });
};
return;
}
// Not installed as a desktop entry: run the built-in browser directly.
- const command = std.fmt.allocPrint(a, "rediwm-files '{s}'", .{std.mem.replaceOwned(u8, a, folder, "'", "'\\''") catch return}) catch return;
+ const command = std.fmt.allocPrint(a, "rediwm-files '{s}'", .{std.mem.replaceOwned(u8, a, item orelse folder, "'", "'\\''") catch return}) catch return;
@import("../config_runtime/actions.zig").spawnProcess(server, command);
}
diff --git a/src/start_menu/panel.zig b/src/start_menu/panel.zig
index 0ef0cc7..7805fee 100644
--- a/src/start_menu/panel.zig
+++ b/src/start_menu/panel.zig
@@ -577,7 +577,7 @@ pub const StartMenu = struct {
} },
.direction = .row,
.@"align" = .center,
- .gap = 12,
+ .gap = 16,
.padding = layout.Edges.xy(theme.global.start_menu_icon_left_pad, theme.global.start_menu_icon_bottom_pad),
.width = .{ .percent = 1 },
.height = .{ .fixed = 56 },
diff --git a/src/ui/layout.zig b/src/ui/layout.zig
index decd9aa..7769bef 100644
--- a/src/ui/layout.zig
+++ b/src/ui/layout.zig
@@ -138,6 +138,8 @@ pub const IconId = enum {
drive,
eject,
more,
+ users,
+ squares,
};
pub const ButtonState = enum { idle, hover, press, disabled };
diff --git a/src/ui/paint.zig b/src/ui/paint.zig
index fa17a1c..f42d0e9 100644
--- a/src/ui/paint.zig
+++ b/src/ui/paint.zig
@@ -677,7 +677,7 @@ fn iconDistance(id: IconId, px: f32, py: f32, cx: f32, cy: f32, half: f32, thick
const base = @min(ring_open, arrow);
break :blk if (id == .restart_shell) @min(base, sdCircle(px, py, cx, cy, half * 0.24)) else base;
},
- .git_branch, .home, .generic, .folder, .document, .terminal, .settings, .keyboard, .edit, .browser, .wifi, .ethernet, .globe, .mouse, .display, .music, .headphones, .bluetooth, .battery, .notification, .eye, .eye_off, .refresh, .cut, .copy, .paste, .trash, .trash_can, .view_grid, .view_list, .sort, .filter, .zoom_in, .zoom_out, .rotate, .crop, .undo, .save, .fit, .open, .usb_stick, .drive, .eject => sdCircle(px, py, cx, cy, half * 0.6),
+ .git_branch, .home, .generic, .folder, .document, .terminal, .settings, .keyboard, .edit, .browser, .wifi, .ethernet, .globe, .mouse, .display, .music, .headphones, .bluetooth, .battery, .notification, .eye, .eye_off, .refresh, .cut, .copy, .paste, .trash, .trash_can, .view_grid, .view_list, .sort, .filter, .zoom_in, .zoom_out, .rotate, .crop, .undo, .save, .fit, .open, .usb_stick, .drive, .eject, .users, .squares => sdCircle(px, py, cx, cy, half * 0.6),
};
}
diff --git a/src/ui/shell_icons.zig b/src/ui/shell_icons.zig
index 62ba99c..97114ed 100644
--- a/src/ui/shell_icons.zig
+++ b/src/ui/shell_icons.zig
@@ -84,6 +84,8 @@ fn source(id: IconId) ?[]const u8 {
.usb_stick => @embedFile("shell-icon-usb-stick"),
.drive => @embedFile("shell-icon-drive"),
.eject => @embedFile("shell-icon-eject"),
+ .users => @embedFile("shell-icon-users"),
+ .squares => @embedFile("shell-icon-squares"),
else => null,
};
}
diff --git a/src/ui/theme.zig b/src/ui/theme.zig
index 9234bbd..fe59ba3 100644
--- a/src/ui/theme.zig
+++ b/src/ui/theme.zig
@@ -62,7 +62,7 @@ pub const Theme = struct {
/// Unset follows the surface accent during hover/drag.
scrollbar_thumb_active: ?[4]f32 = null,
taskbar_title_size: f32 = 12.5,
- taskbar_size: f32 = 48.0,
+ taskbar_size: f32 = 44.0,
// Gap between adjacent taskbar window-item pills, logical px. Also
// drives each pill's top/bottom margin within the bar (capped — see
// Taskbar.chipVerticalMargin), so one slider spaces pills on every side
@@ -75,7 +75,7 @@ pub const Theme = struct {
// Size of the start button's icon/logo, logical px. Clamped to the
// button's own size at paint time (Taskbar.startIconSize), so it also
// shrinks if `taskbar_size` shrinks the button below this.
- start_button_icon_size: f32 = 42.0,
+ start_button_icon_size: f32 = 36.0,
button_font_size: f32 = 12.5,
bg: [4]f32 = .{ 9.0 / 255.0, 11.0 / 255.0, 24.0 / 255.0, 1 }, // #090b18
fg: [4]f32 = .{ 245.0 / 255.0, 245.0 / 255.0, 245.0 / 255.0, 1 }, // #f5f5f5
@@ -142,7 +142,7 @@ pub const Theme = struct {
start_menu_left_pad: f32 = 2.0,
start_menu_bottom_pad: f32 = 6.0,
// Inset applied to each app row (icon + label together), logical px.
- start_menu_icon_left_pad: f32 = 2.0,
+ start_menu_icon_left_pad: f32 = 12.0,
start_menu_icon_bottom_pad: f32 = 6.0,
// Additional appearance tokens. All fields are parsed and saved through
diff --git a/tests/desktop_icons.py b/tests/desktop_icons.py
index 88e5453..02ca2cc 100644
--- a/tests/desktop_icons.py
+++ b/tests/desktop_icons.py
@@ -11,12 +11,18 @@ from PIL import Image, ImageChops
ROOT = Path(__file__).resolve().parents[1]
+def difference(expected, actual):
+ diff = ImageChops.difference(expected, actual)
+ # GLES can composite unchanged background pixels one level differently
+ # after camera changes, including on an unmodified compositor.
+ return diff.point(lambda value: 0 if value <= 1 else value) if os.getenv('REDIWM_TEST_RENDERER') == 'gles2' else diff
+
def run():
with tempfile.TemporaryDirectory(prefix='rediwm-icons-') as directory:
tmp = Path(directory)
desktop = tmp / 'Desktop'
env = dict(os.environ, XDG_RUNTIME_DIR=directory, XDG_CONFIG_HOME=str(tmp/'config'), XDG_CACHE_HOME=str(tmp/'cache'), XDG_STATE_HOME=str(tmp/'state'),
- WLR_BACKENDS='headless', REDIWM_FILES_DEVICES='0', WLR_HEADLESS_OUTPUTS='1', WLR_RENDERER='pixman',
+ WLR_BACKENDS='headless', REDIWM_FILES_DEVICES='0', WLR_HEADLESS_OUTPUTS='1', WLR_RENDERER=os.getenv('REDIWM_TEST_RENDERER', 'pixman'),
REDIWM_SCALE='1', REDIWM_DESKTOP_BUILTINS="0", REDIWM_DESKTOP_DIR=str(desktop))
config_path = tmp/'rediwm-config.toml'
config_path.write_text('[compositor]\ndefault_file_manager = "rediwm-fixture-files.desktop"\n')
@@ -96,6 +102,7 @@ def run():
action('screenshot',{'path':str(path)})
return Image.open(path).convert('RGB')
background=capture('background')
+ bottom_exclusion=action('outputs')['Outputs'][0]['bottom_exclusion']
display=next(p.name for p in tmp.glob('wayland-*') if not p.name.endswith('.lock'))
# Pixel comparisons isolate icons from transient navigation overlays.
# The desktop starts and stops with its config section, like any reload.
@@ -107,7 +114,7 @@ def run():
wait_for(desktop.exists,'desktop directory not created')
time.sleep(.5)
empty=capture('empty')
- assert ImageChops.difference(background,empty).getbbox() is None, 'empty desktop is not transparent'
+ assert difference(background,empty).getbbox() is None, 'empty desktop is not transparent'
# Controlled launcher does not open or modify anything outside the temporary fixture.
launcher=desktop/'Launch.desktop'
marker=tmp/'launched'
@@ -124,17 +131,17 @@ def run():
click(600,400)
time.sleep(5.2) # the untrusted-launcher notice expires before the pixel checks
icons=capture('icons')
- assert ImageChops.difference(empty,icons).crop((1150,20,1270,145)).getbbox(), 'icon missing'
+ assert difference(empty,icons).crop((1150,20,1270,145)).getbbox(), 'icon missing'
# Default-on icons stay at the same pixels after a camera pan.
move(0,0)
action('set_camera', {'x': 300, 'y': 150})
pinned=capture('icons-pinned')
- assert ImageChops.difference(icons,pinned).crop((0,0,1280,660)).getbbox() is None, 'fixed icons moved with camera'
+ assert difference(icons,pinned).crop((0,0,1280,660)).getbbox() is None, 'fixed icons moved with camera'
for percent in (70, 100):
action('set_zoom', {'percent': percent})
time.sleep(1.4)
fixed_zoom=capture('icons-fixed-'+str(percent))
- assert ImageChops.difference(icons,fixed_zoom).crop((0,0,1280,660)).getbbox() is None, 'fixed icons scaled with camera'
+ assert difference(icons,fixed_zoom).crop((0,0,1280,660)).getbbox() is None, 'fixed icons scaled with camera'
click(1200,60);time.sleep(.05);click(1200,60)
wait_for(marker.exists,'fixed icon click after pan did not launch')
marker.unlink()
@@ -146,14 +153,14 @@ def run():
icons=capture('icons-unpinned')
# With the option off, icons share the window camera and input coordinates.
# Anchor at the origin so expected projected positions are exact.
- original_box=ImageChops.difference(empty,icons).crop((0,0,1280,660)).getbbox()
+ original_box=difference(empty,icons).crop((0,0,1280,660)).getbbox()
for percent in (85,70,55):
move(0,0)
action('set_zoom',{'percent':percent})
time.sleep(1.4) # let the shared zoom OSD fade out
zoomed=capture('icons-'+str(percent))
# Crop the taskbar: its clock may tick between captures.
- box=ImageChops.difference(empty,zoomed).crop((0,0,1280,660)).getbbox()
+ box=difference(empty,zoomed).crop((0,0,1280,660)).getbbox()
z=percent/100
assert box and all(abs(a-b*z)<=2 for a,b in zip(box,original_box)), ('icon did not scale with camera',percent,box,original_box)
click(660,33);time.sleep(.05);click(660,33)
@@ -171,7 +178,7 @@ def run():
time.sleep(1)
click(1200,60)
selected=capture('selected')
- assert ImageChops.difference(icons,selected).getbbox(), 'selection did not draw'
+ assert difference(icons,selected).getbbox(), 'selection did not draw'
click(1200,60)
time.sleep(.05)
click(1200,60)
@@ -184,13 +191,13 @@ def run():
set_desktop(False);time.sleep(.3);set_desktop(True)
time.sleep(.5)
restored=capture('restored')
- assert ImageChops.difference(empty,restored).crop((1150,140,1270,255)).getbbox(), 'position not restored'
+ assert difference(empty,restored).crop((1150,140,1270,255)).getbbox(), 'position not restored'
click(600,300,273)
menu=capture('menu')
- assert ImageChops.difference(restored,menu).crop((590,290,810,480)).getbbox(), 'empty context menu missing'
+ assert difference(restored,menu).crop((590,290,810,480)).getbbox(), 'empty context menu missing'
move(650,345)
hovered=capture('menu-hover')
- assert ImageChops.difference(menu,hovered).crop((600,300,800,540)).getbbox(), 'menu hover did not highlight a row'
+ assert difference(menu,hovered).crop((600,300,800,540)).getbbox(), 'menu hover did not highlight a row'
key(1)
click(600,300,273)
key(108) # New File, using keyboard navigation in the menu.
@@ -207,6 +214,42 @@ def run():
marker.unlink()
key(28)
wait_for(marker.exists,'keyboard focus not reacquired')
+ # Desktop prompts must paint and receive input above client windows.
+ from desktop_zoom import build_client
+ build_client(tmp)
+ cover=subprocess.Popen([str(tmp/'client')],env=dict(env,WAYLAND_DISPLAY=display),stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL)
+ processes.append(cover)
+ wait_for(lambda: any(w['app_id']=='rediwm.zoom-fixture' for w in action('windows')['Windows']), 'cover window did not map')
+ cover_id=next(w['id'] for w in action('windows')['Windows'] if w['app_id']=='rediwm.zoom-fixture')
+ action('set_window_size',{'id':cover_id,'width':800,'height':500})
+ action('move_window_to',{'id':cover_id,'x':240,'y':100})
+ time.sleep(.4)
+ click(1200,180,273)
+ covered=capture('covered-before-trash')
+ click(1100,369) # Move to Trash, in the icon's clamped context menu.
+ prompt=capture('trash-above-window')
+ assert difference(covered,prompt).crop((400,250,880,440)).getbbox(), 'Trash dialog is hidden behind the client'
+ click(650,414) # Cancel must reach the dialog, not the covered client.
+ cancelled=capture('trash-cancelled')
+ assert difference(prompt,cancelled).crop((400,250,880,440)).getbbox(), 'Cancel did not dismiss the desktop dialog'
+ assert launcher.exists(), 'Cancel removed the launcher'
+ move(0,0)
+ action('set_zoom',{'percent':70})
+ time.sleep(1.4)
+ click(840,126,273)
+ zoom_covered=capture('zoom-covered-before-trash')
+ click(770,258)
+ zoom_prompt=capture('zoom-trash-above-window')
+ assert difference(zoom_covered,zoom_prompt).crop((280,175,616,308)).getbbox(), 'Zoomed Trash dialog is hidden'
+ click(455,290)
+ zoom_cancelled=capture('zoom-trash-cancelled')
+ assert difference(zoom_prompt,zoom_cancelled).crop((280,175,616,308)).getbbox(), 'Zoomed Cancel missed the dialog'
+ move(0,0)
+ action('set_zoom',{'percent':100})
+ time.sleep(1.4)
+ cover.terminate();cover.wait(timeout=3);processes.remove(cover)
+ wait_for(lambda: not action('windows')['Windows'], 'cover window did not close')
+ click(1200,180)
# Shared deletion dialog: close and cancel preserve the selected file.
key(111)
preview = capture('delete-dialog')
@@ -215,7 +258,7 @@ def run():
move(600,251); button(True)
move(660,301); button(False)
moved = capture('delete-dialog-moved')
- assert ImageChops.difference(preview.crop((450,235,650,268)),
+ 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 launcher.exists()
@@ -230,7 +273,7 @@ def run():
wait_for(lambda: not launcher.exists(), 'Desktop permanent deletion failed')
time.sleep(.5)
removed=capture('removed')
- assert ImageChops.difference(empty,removed).crop((1150,140,1270,255)).getbbox() is None, 'removed icon remains'
+ assert difference(empty,removed).crop((1150,140,1270,255)).getbbox() is None, 'removed icon remains'
# Multi-selection uses Trash by default, including after a permanent deletion.
for name in ('Trash A.txt', 'Trash B.txt'):
(desktop/name).write_text('trash fixture')
@@ -259,14 +302,14 @@ def run():
move(1140,20);button(True);move(1255,246);time.sleep(.1);button(False)
selected_files=capture('rubber-band')
for y in (30,142):
- assert ImageChops.difference(unselected,selected_files).crop((1160,y,1180,y+10)).getbbox(), 'rubber band missed an icon'
+ assert difference(unselected,selected_files).crop((1160,y,1180,y+10)).getbbox(), 'rubber band missed an icon'
key(1)
click(1200,60)
before_rename=capture('before-rename')
key(60) # F2 selects the stem, leaving the extension intact.
editor=capture('rename-editor')
editor.save('/tmp/rediwm-desktop-rename.png')
- assert ImageChops.difference(before_rename,editor).crop((1040,94,1150,139)).getbbox(), 'rename editor clipped to icon bounds'
+ assert difference(before_rename,editor).crop((1040,94,1150,139)).getbbox(), 'rename editor clipped to icon bounds'
action('type_text',{'text':'Preview'})
click(1228,116) # Checkmark is outside the text field.
wait_for(lambda: (desktop/'Preview.txt').exists(), 'confirm button did not preserve the extension')
@@ -370,7 +413,7 @@ def run():
painted=capture('wallpaper')
pixel=painted.getpixel((1000,300))
assert all(abs(x-y)<=3 for x,y in zip(pixel,(24,48,72))), ('JPEG wallpaper missing',pixel)
- assert request({'version': 1, 'command': 'outputs'})['Outputs'][0]['bottom_exclusion']==54
+ assert request({'version': 1, 'command': 'outputs'})['Outputs'][0]['bottom_exclusion']==bottom_exclusion
request({'version': 1, 'command': 'open_appearance'})
reader.close();sock.close()
# Restart with built-ins in a scratch home. Mouse actions must map
diff --git a/tests/files_associations.py b/tests/files_associations.py
index 657ded8..a9800b0 100644
--- a/tests/files_associations.py
+++ b/tests/files_associations.py
@@ -306,7 +306,7 @@ def run():
key(108)
key(28)
key(28) # Open the selected folder; a modal would intercept this.
- wait_for(lambda: any(w['title'] == '0-folder — Files' for w in ipc.get_windows()),
+ wait_for(lambda: any(w['title'] == '0-folder — RediWM Files' for w in ipc.get_windows()),
"folder context menu unexpectedly opened an app picker")
assert client.poll() is None
print("PASS: MIME icons, Properties permissions and compact layout, Open With, default persistence, cancellation and folder exclusion")
diff --git a/tests/files_browser.py b/tests/files_browser.py
index ceda9b4..06d4a1f 100755
--- a/tests/files_browser.py
+++ b/tests/files_browser.py
@@ -57,10 +57,11 @@ fi
XDG_RUNTIME_DIR=str(tmp),
XDG_STATE_HOME=str(tmp / "state"),
WLR_BACKENDS='headless', REDIWM_FILES_DEVICES='0',
+ REDIWM_IPC_AUTOMATION='1',
WLR_HEADLESS_OUTPUTS='1',
WLR_RENDERER='pixman',
REDIWM_SCALE='1',
- PATH=str(helpers) + ':' + os.environ.get('PATH', ''),
+ PATH=str(helpers) + ':' + str(ROOT / 'zig-out/bin') + ':' + os.environ.get('PATH', ''),
)
config_path = tmp / 'rediwm-config.toml'
config_path.write_text('')
@@ -121,7 +122,7 @@ fi
return None
win = wait_for(find_window, 'rediwm-files window did not appear')
- assert win['title'] == f'{browse_dir.name} — Files', f"Unexpected title: {win['title']}"
+ assert win['title'] == f'{browse_dir.name} — RediWM Files', f"Unexpected title: {win['title']}"
print(f"Verified initial window: {win['app_id']}, title: '{win['title']}'")
# Focus the window
@@ -139,10 +140,10 @@ fi
action('key', {'keycode': 28, 'pressed': pressed})
time.sleep(0.2)
- # Wait for title to update to "subfolder — Files"
+ # Wait for title to update to "subfolder — RediWM Files"
def check_subfolder():
w = find_window()
- return w if w and w.get('title') == 'subfolder — Files' else None
+ return w if w and w.get('title') == 'subfolder — RediWM Files' else None
win = wait_for(check_subfolder, 'Did not navigate into subfolder')
print(f"Verified folder navigation: title '{win['title']}'")
@@ -156,7 +157,7 @@ fi
def check_back():
w = find_window()
- return w if w and w.get('title') == f'{browse_dir.name} — Files' else None
+ return w if w and w.get('title') == f'{browse_dir.name} — RediWM Files' else None
win = wait_for(check_back, 'Did not navigate Back')
print(f"Verified Back navigation: title '{win['title']}'")
@@ -307,6 +308,35 @@ fi
wait_for(check_closed, 'Window did not close')
print("Verified window close.")
+ # Opening a file path reveals it in its parent folder. Enter acts
+ # on that selection without a preliminary click or arrow key.
+ opened_marker.unlink()
+ start('rediwm-files', [str(browse_dir / 'sample.txt')], WAYLAND_DISPLAY=display)
+ selected_win = wait_for(find_window, 'file-path window did not appear')
+ assert selected_win['title'] == f'{browse_dir.name} — RediWM Files'
+ action('focus_window', {'id': selected_win['id']})
+ time.sleep(0.4)
+ send_key(28)
+ wait_for(opened_marker.exists, 'selected startup file did not open on Enter')
+ assert opened_marker.read_text().strip() == str(browse_dir / 'sample.txt')
+ action('close_window', {'id': selected_win['id']})
+ print('Verified file-path startup selection.')
+
+ if env.get('REDIWM_FORCE_DBUS') == '1':
+ opened_marker.unlink()
+ subprocess.run(['busctl', '--user', 'call', 'org.freedesktop.FileManager1',
+ '/org/freedesktop/FileManager1', 'org.freedesktop.FileManager1',
+ 'ShowItems', 'ass', '1', (browse_dir / 'sample.txt').as_uri(), ''],
+ env=env, check=True, capture_output=True, text=True)
+ shown_win = wait_for(find_window, 'ShowItems did not open RediWM Files')
+ action('focus_window', {'id': shown_win['id']})
+ time.sleep(0.4)
+ send_key(28)
+ wait_for(opened_marker.exists, 'ShowItems did not select the requested file')
+ assert opened_marker.read_text().strip() == str(browse_dir / 'sample.txt')
+ action('close_window', {'id': shown_win['id']})
+ print('Verified D-Bus ShowItems selection.')
+
except Exception as e:
for log_file in tmp.glob('*.log'):
print(f"=== {log_file.name} ===")
diff --git a/tests/files_controls.py b/tests/files_controls.py
index a49fb82..8c2c786 100644
--- a/tests/files_controls.py
+++ b/tests/files_controls.py
@@ -104,7 +104,7 @@ def run():
text(value)
def title(value):
- wait_for(lambda: windows() and windows()[0]["title"] == value + " — Files",
+ wait_for(lambda: windows() and windows()[0]["title"] == value + " — RediWM Files",
"navigation did not reach " + value)
def opened(name):
@@ -125,7 +125,7 @@ def run():
title(folder)
action('pointer_button', {"button": button, "pressed": False})
time.sleep(.1)
- assert windows()[0]["title"] == folder + " — Files"
+ assert windows()[0]["title"] == folder + " — RediWM Files"
# A modal editor must keep its current directory.
key(49, ctrl=True) # Ctrl+N: new folder
for pressed in (True, False):
diff --git a/tests/files_drag.py b/tests/files_drag.py
index 55ecae8..b7664b5 100644
--- a/tests/files_drag.py
+++ b/tests/files_drag.py
@@ -276,7 +276,114 @@ def run_pin():
log.close()
+def run_transfer(same_window=False, copy=False, list_view=False, folder=True):
+ with tempfile.TemporaryDirectory(prefix="rediwm-files-transfer-") as directory:
+ tmp = Path(directory)
+ home = tmp / "home"
+ home.mkdir()
+ source = home / "source"
+ source.mkdir()
+ target = source / "destination" if same_window else home / "target"
+ target.mkdir()
+ if folder and not same_window:
+ target = target / "destination"
+ target.mkdir()
+ name = "a space # 雪.txt"
+ (source / name).write_text("transfer payload")
+ if not same_window:
+ (source / "bundle").mkdir()
+ (source / "bundle" / "child.txt").write_text("nested payload")
+ comp, log = spawn_compositor(tmp, config_content="[compositor]\nxwayland = false\ndodge_file_drags = false\n",
+ env_extra={"HOME": str(home)})
+ peers = []
+ try:
+ with IPCClient(tmp).connect() as ipc:
+ display = next(p.name for p in tmp.glob("wayland-*") if not p.name.endswith(".lock"))
+ env = dict(os.environ, HOME=str(home), XDG_RUNTIME_DIR=str(tmp),
+ XDG_STATE_HOME=str(tmp / "state"), XDG_CONFIG_HOME=str(tmp / "config"),
+ REDIWM_CONFIG=str(tmp / "rediwm-config.toml"), WAYLAND_DISPLAY=display,
+ DBUS_SESSION_BUS_ADDRESS="unix:path=/nonexistent", REDIWM_FILES_DEVICES="0")
+ env.pop("DISPLAY", None)
+ def launch(path, x):
+ known = {w["id"] for w in ipc.get_windows()}
+ out = (tmp / f"files-{x}.log").open("w")
+ try:
+ peers.append(subprocess.Popen([str(ROOT / "zig-out/bin/rediwm-files"), str(path)], env=env, stdout=out, stderr=out))
+ finally:
+ out.close()
+ window = wait_for(lambda: next((w for w in ipc.get_windows() if w["id"] not in known), None), "Files did not map")
+ ipc.action('set_window_size', {"id": window["id"], "width": 600, "height": 500})
+ ipc.action('move_window_to', {"id": window["id"], "x": x, "y": 30})
+ return window
+ src = launch(source, 10)
+ dst = src if same_window else launch(target.parent if folder else target, 680)
+ ipc.action('focus_window', {"id": src["id"]})
+ time.sleep(.5)
+ box = ipc.get_window_debug(src["id"])["client_box"]
+ dest = ipc.get_window_debug(dst["id"])["client_box"]
+ def move(x, y):
+ ipc.action('move_cursor', {"x": round(x), "y": round(y)})
+ def button(pressed):
+ ipc.action('pointer_button', {"button": 272, "pressed": pressed})
+ if list_view:
+ for rect in ([box] if same_window else [box, dest]):
+ move(rect["x"] + 367, rect["y"] + 80)
+ button(True)
+ button(False)
+ time.sleep(.3)
+ # Folders sort first: the source file is second in a shared window.
+ sx = box["x"] + 250
+ sy = box["y"] + ((216 if same_window else 178) if list_view else (302 if same_window else 158))
+ tx = dest["x"] + 250
+ ty = dest["y"] + ((178 if list_view else 158) if folder else 350)
+ move(sx, sy)
+ button(True)
+ button(False)
+ time.sleep(.7)
+ if not same_window:
+ for key, pressed in ((29, True), (30, True), (30, False), (29, False)):
+ ipc.action('key', {"keycode": key, "pressed": pressed})
+ if copy:
+ ipc.action('key', {"keycode": 29, "pressed": True})
+ button(True)
+ time.sleep(.08)
+ for step in range(1, 17):
+ move(sx + (tx-sx)*step/16, sy + (ty-sy)*step/16)
+ time.sleep(.04)
+ time.sleep(.2)
+ button(False)
+ if copy:
+ ipc.action('key', {"keycode": 29, "pressed": False})
+ wait_for(lambda: (target / name).exists(), "file did not arrive at drop destination")
+ assert (target / name).read_text() == "transfer payload"
+ if copy:
+ assert (source / name).read_text() == "transfer payload"
+ else:
+ wait_for(lambda: not (source / name).exists(), "move left the source behind")
+ if not same_window:
+ wait_for(lambda: (target / "bundle" / "child.txt").exists(), "nested folder did not arrive")
+ assert (target / "bundle" / "child.txt").read_text() == "nested payload"
+ if copy:
+ assert (source / "bundle" / "child.txt").read_text() == "nested payload"
+ else:
+ wait_for(lambda: not (source / "bundle").exists(), "folder move left the source behind")
+ assert all(peer.poll() is None for peer in peers), "Files exited during transfer"
+ print(f"PASS Files {'copy' if copy else 'move'} {'within window' if same_window else 'between windows'} {'folder' if folder else 'background'} {'list' if list_view else 'grid'}")
+ finally:
+ for peer in peers:
+ stop_process(peer)
+ stop_process(comp)
+ log.close()
+
+
if __name__ == "__main__":
+ if "--transfer" in sys.argv:
+ run_transfer(same_window=True)
+ run_transfer(same_window=True, copy=True, list_view=True)
+ run_transfer(folder=False)
+ run_transfer(copy=True)
+ run_transfer(list_view=True)
+ sys.exit(0)
if "--pin" in sys.argv:
run_pin()
sys.exit(0)
diff --git a/tests/files_fixes.py b/tests/files_fixes.py
index 33e5dfe..44b285a 100644
--- a/tests/files_fixes.py
+++ b/tests/files_fixes.py
@@ -137,7 +137,7 @@ def run(scale="1"):
# Unfocused, the path bar is clickable folders; the empty space
# after them edits the path like Ctrl+L.
def title_is(value):
- return any(w["id"] == first["id"] and w["title"] == value + " — Files" for w in ipc.get_windows())
+ return any(w["id"] == first["id"] and w["title"] == value + " — RediWM Files" for w in ipc.get_windows())
click(first, 144, 27) # "Home" crumb
wait_for(lambda: title_is("Home"), "path bar folder click did not navigate")
navigate(source)
@@ -278,7 +278,7 @@ def run(scale="1"):
ipc.screenshot(path=str(preview))
# The last destination is now visible and reachable in a short sidebar.
click(first, 70, 190)
- wait_for(lambda: any(w["id"] == first["id"] and w["title"] == "Projects — Files" for w in ipc.get_windows()), "short sidebar could not reach Projects")
+ wait_for(lambda: any(w["id"] == first["id"] and w["title"] == "Projects — RediWM Files" for w in ipc.get_windows()), "short sidebar could not reach Projects")
navigate(home)
ipc.action('set_window_size', {"id": first["id"], "width": 360, "height": 240})
time.sleep(.4)
diff --git a/tests/files_folder_size.py b/tests/files_folder_size.py
index d2fc6aa..a74c4df 100644
--- a/tests/files_folder_size.py
+++ b/tests/files_folder_size.py
@@ -101,7 +101,7 @@ def run():
time.sleep(.15)
def title(value):
- wait_for(lambda: windows() and windows()[0]["title"] == value + " — Files",
+ wait_for(lambda: windows() and windows()[0]["title"] == value + " — RediWM Files",
"navigation did not reach " + value)
# 1. Test Grid View:
@@ -119,8 +119,8 @@ def run():
time.sleep(.2)
# Clicking dash must NOT select big_folder (item 1 small_folder must still be active/selected)
- # And must NOT navigate into big_folder! Title remains "Home — Files"
- assert windows()[0]["title"] == "Home — Files", "Clicking dash opened the folder!"
+ # And must NOT navigate into big_folder! Title remains "Home — RediWM Files"
+ assert windows()[0]["title"] == "Home — RediWM Files", "Clicking dash opened the folder!"
# 2. Test List View:
# Switch to list view (Header list button at x=727, y=80)
diff --git a/tests/msg.py b/tests/msg.py
index 7030ae9..f8ef582 100644
--- a/tests/msg.py
+++ b/tests/msg.py
@@ -79,6 +79,9 @@ def run(binary):
command = case["args"][1] if case["args"][0] == "action" else case["args"][0]
assert command in help_text, f"missing help for {command}"
assert "doctor" in help_text and "--save <PATH>" in help_text
+ for command in ("get_services", "set_wallpaper", "get_theme", "get_processes", "set_night_light"):
+ assert command in help_text, f"missing raw IPC help for {command}"
+ assert "Other IPC commands (via raw JSON):" in help_text
print(f"PASS: {len(cases)} CLI v1 contract cases and generated help")