From 7878d88477e8f6e366f38c427993f5e0c10206d6 Mon Sep 17 00:00:00 2001 From: Everett Date: Wed, 18 Nov 2026 01:53:22 -0800 Subject: [PATCH] Linux 0.1.1: widgets return to the desktop layer after arrange mode After arrange mode the widget windows stayed on the overlay layer, above every window, until the shell was restarted. The service turns "on top" on while arranging and the plugin hides the widget windows meanwhile; a layer change around the time a window is hidden was not applied when it was shown again. The plugin now ignores "on top" during arrange mode, sets the layer only while the window is shown, and sets it once more after it is shown. The plugin's stand-in service now behaves like the real one here, which turns an existing check into the regression test: it fails with the old plugin and passes with this one. Also records the refresh checks on the desktop (schedule, manual, ticking date, timeline transitions) and the run of the x86_64 archive on the Omarchy 4.5 test machine through emulation. Co-Authored-By: Claude Fable 5.2 --- Linux/Cargo.lock | 12 +++--- Linux/Cargo.toml | 2 +- Linux/omarchy-plugin/WidgetWindow.qml | 21 +++++++++- Linux/omarchy-plugin/manifest.json | 2 +- Linux/omarchy-plugin/tests/check.sh | 4 +- Linux/omarchy-plugin/tests/scriptwidget | 6 ++- docs/linux/README.md | 2 +- docs/linux/TODO.md | 6 +-- docs/linux/protocol.md | 2 +- docs/linux/testing.md | 51 ++++++++++++++++++++++++- 10 files changed, 90 insertions(+), 18 deletions(-) diff --git a/Linux/Cargo.lock b/Linux/Cargo.lock index 3484a66c..c45eb069 100644 --- a/Linux/Cargo.lock +++ b/Linux/Cargo.lock @@ -6164,7 +6164,7 @@ dependencies = [ [[package]] name = "sw-cli" -version = "0.1.0" +version = "0.1.1" dependencies = [ "flate2", "getrandom 0.3.4", @@ -6179,7 +6179,7 @@ dependencies = [ [[package]] name = "sw-core" -version = "0.1.0" +version = "0.1.1" dependencies = [ "cc", "flate2", @@ -6203,7 +6203,7 @@ dependencies = [ [[package]] name = "sw-host" -version = "0.1.0" +version = "0.1.1" dependencies = [ "getrandom 0.3.4", "libc", @@ -6217,14 +6217,14 @@ dependencies = [ [[package]] name = "sw-quickjs" -version = "0.1.0" +version = "0.1.1" dependencies = [ "cc", ] [[package]] name = "sw-render" -version = "0.1.0" +version = "0.1.1" dependencies = [ "serde", "serde_json", @@ -6235,7 +6235,7 @@ dependencies = [ [[package]] name = "sw-studio" -version = "0.1.0" +version = "0.1.1" dependencies = [ "futures", "getrandom 0.3.4", diff --git a/Linux/Cargo.toml b/Linux/Cargo.toml index 52b84e20..9eb53979 100644 --- a/Linux/Cargo.toml +++ b/Linux/Cargo.toml @@ -3,7 +3,7 @@ resolver = "3" members = ["crates/sw-quickjs", "crates/sw-core", "crates/sw-render", "crates/sw-cli", "crates/sw-host", "crates/sw-studio"] [workspace.package] -version = "0.1.0" +version = "0.1.1" edition = "2024" license = "Apache-2.0" publish = false diff --git a/Linux/omarchy-plugin/WidgetWindow.qml b/Linux/omarchy-plugin/WidgetWindow.qml index c721399b..55096860 100644 --- a/Linux/omarchy-plugin/WidgetWindow.qml +++ b/Linux/omarchy-plugin/WidgetWindow.qml @@ -33,7 +33,26 @@ PanelWindow { exclusionMode: ExclusionMode.Ignore WlrLayershell.namespace: "scriptwidget" WlrLayershell.keyboardFocus: WlrKeyboardFocus.None - WlrLayershell.layer: service.peek ? WlrLayer.Overlay : WlrLayer.Bottom + // Arrange mode hides these windows and the service turns "on top" on for + // its duration. A window that was told to change layer around the time it + // was hidden came back on the wrong layer, and stayed there. So "on top" + // only counts outside arrange mode (the arrange canvas has its own layer), + // the layer is only set while the window is shown, and it is set once more + // a moment after the window is shown again. + property int shownLayer: WlrLayer.Bottom + function syncLayer() { + if (visible && !service.arrange && !service.arranging) shownLayer = service.peek ? WlrLayer.Overlay : WlrLayer.Bottom + } + WlrLayershell.layer: shownLayer + onVisibleChanged: layerSync.restart() + Component.onCompleted: syncLayer() + Connections { + target: service + // Later, so that "arrange" from the same event is already in place. + function onPeekChanged() { Qt.callLater(panel.syncLayer) } + function onArrangeChanged() { layerSync.restart() } + } + Timer { id: layerSync; interval: 350; onTriggered: panel.syncLayer() } // The input region: the tap regions and nothing else. mask: Region { regions: panel.tapRegions } diff --git a/Linux/omarchy-plugin/manifest.json b/Linux/omarchy-plugin/manifest.json index c3164221..67ef96b4 100644 --- a/Linux/omarchy-plugin/manifest.json +++ b/Linux/omarchy-plugin/manifest.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "com.atomsprout.scriptwidget", "name": "ScriptWidget", - "version": "0.1.0", + "version": "0.1.1", "author": "AtomSprout", "description": "Shows the widgets ScriptWidget draws on the desktop layer and passes clicks back to it", "license": "Apache-2.0", diff --git a/Linux/omarchy-plugin/tests/check.sh b/Linux/omarchy-plugin/tests/check.sh index 8bec9adb..90144d38 100755 --- a/Linux/omarchy-plugin/tests/check.sh +++ b/Linux/omarchy-plugin/tests/check.sh @@ -265,7 +265,9 @@ check "menu: the second row sends scriptwidget menu b resize-medium" until_true check "arrange: off again" until_true 3 is arrange false sleep 0.5 DETAIL=$(widget_layers | tr '\n' ';') -check "arrange: the widget windows are back, where they were dropped" has_layer "1 680 480 329 170" +# Level 1 is the bottom layer: the stand-in, like the service, has "on top" on +# while arranging, and a widget must not stay on the overlay layer afterwards. +check "arrange: the widget windows are back on the bottom layer, where they were dropped" until_true 3 has_layer "1 680 480 329 170" check "menu: b now has the medium size" has_layer "1 1000 600 329 170" # ------------------------------------------------- remove, and bad messages diff --git a/Linux/omarchy-plugin/tests/scriptwidget b/Linux/omarchy-plugin/tests/scriptwidget index 23b0e8db..f3cc5635 100755 --- a/Linux/omarchy-plugin/tests/scriptwidget +++ b/Linux/omarchy-plugin/tests/scriptwidget @@ -67,7 +67,7 @@ exec 3<>"$fifo" protocol=1 [ -f "$dir/protocol" ] && protocol=$(tr -cd '0-9' < "$dir/protocol") -arrange=false; peek=false +arrange=false; peek=false; peek_before=false ascreen=""; ax=80; ay=80; aw=329; ah=170; aversion=0; count=0 bscreen=""; bx=460; by=80; bw=170; bh=170; bversion=0 colors=("#e64553" "#fe640b" "#40a02b" "#1e66f5") @@ -153,7 +153,9 @@ while read -r -u 3 verb one two three four; do if $peek; then peek=false; else peek=true; fi echo "{\"event\":\"mode\",\"arrange\":$arrange,\"peek\":$peek}" ;; arrange) - if $arrange; then arrange=false; else arrange=true; fi + # As the real service does: "on top" is on while arranging, and what it + # was before comes back afterwards. + if $arrange; then arrange=false; peek=$peek_before; else arrange=true; peek_before=$peek; peek=true; fi echo "{\"event\":\"mode\",\"arrange\":$arrange,\"peek\":$peek}" ;; raw) printf '%s\n' "$one${two:+ $two}${three:+ $three}${four:+ $four}" ;; diff --git a/docs/linux/README.md b/docs/linux/README.md index 83d88946..9fbc6937 100644 --- a/docs/linux/README.md +++ b/docs/linux/README.md @@ -38,7 +38,7 @@ sh install.sh - **It installs for you only**, without root: programs in `~/.local/bin`, data in `~/.local/share/scriptwidget`, a systemd user unit `scriptwidget.service` that starts with the graphical session, a launcher entry, and on Omarchy the plugin in `~/.config/omarchy/plugins`, enabled. - **The archive is not signed.** Each release lists the SHA-256 of its files. -- **Which archive.** `aarch64` was built and tested on an Omarchy 4.5 machine. `x86_64` is built and tested without a desktop by CI on Arch Linux; nobody has seen it show widgets on a desktop. +- **Which archive.** `aarch64` was built and tested on an Omarchy 4.5 machine. `x86_64` is built on Arch Linux by CI; it was tested there without a desktop, and on the Omarchy 4.5 test machine through instruction emulation, where it showed and operated widgets. It has not been run on an x86_64 computer. - **It is built against ICU 78.** When the distribution moves to a newer ICU the programs stop starting until a new archive is published; see [TODO.md](TODO.md). - **Updating.** There is no automatic update. Run `install.sh` of the newer archive; it stops the service, replaces the programs and keeps your widgets. - **Removing it.** `sh uninstall.sh` keeps your widgets; `sh uninstall.sh --purge` deletes them too. diff --git a/docs/linux/TODO.md b/docs/linux/TODO.md index ab5ec60f..cbf9e374 100644 --- a/docs/linux/TODO.md +++ b/docs/linux/TODO.md @@ -4,8 +4,8 @@ The plan is in [plan.md](plan.md) (Chinese); what was tested is in [testing.md]( ## Known limits of the preview -- **Tested on one machine.** Everything a person can see was tested in one aarch64 Omarchy 4.5 virtual machine with a virtual GPU, one 1920×1080 display at scale 1, and a virtual pointer instead of a hand. Not tested: a real computer, a real GPU, display scales above 1, several displays, a light theme, sleep and wake, a restart of the computer with the service enabled, an input method. -- **The x86_64 archive** is built and tested without a desktop by CI on Arch Linux. Nobody has seen it show widgets. +- **Tested on one machine.** Everything a person can see was tested in one aarch64 Omarchy 4.5 virtual machine with a virtual GPU, one 1920×1080 display at scale 1, and a virtual pointer instead of a hand. Not tested: a real computer, a real GPU, display scales above 1, several displays, a light theme, sleep and wake, a restart of the computer with the service enabled (the unit is enabled, the restart was not tried), an input method. +- **The x86_64 archive** was never run on an x86_64 computer. Besides the CI run without a desktop, its programs were run through instruction emulation inside the aarch64 Omarchy 4.5 test machine, against the real desktop there (see [testing.md](testing.md)); that shows the archive is complete and works, not how it behaves on real x86_64 hardware and drivers. - **ICU.** The programs link the system's ICU 78 by its versioned name. When Arch and Omarchy move to ICU 79 they stop starting until a new archive is built. Fix: link ICU statically, or publish an AUR source package that is rebuilt on the user's machine. - **Display fonts.** The six display fonts of the other platforms (Apple ][, Larabiefont Free, Monofonto, White Rabbit, OneSlot, Unispace) are not shipped: the repository records no licence for them, and the notice inside `Unispace.ttf` forbids redistribution. Text that asks for one is drawn with Inter. The same files ship in the iPhone, Android and Windows apps; their licences need to be settled there too. - **The archive is not signed**, and its third-party notices are a hand-written summary, not a generated list of every crate licence. @@ -18,7 +18,7 @@ The plan is in [plan.md](plan.md) (Chinese); what was tested is in [testing.md]( - **Time zone changes** are not noticed until the next refresh. - **Management window:** closing it with unsaved changes does not ask (moving to another page does); no "new file" button; the components and API reference pages of the Windows app are missing; changing the refresh interval writes the setting but does not tell the running service; in the test machine the editor's blinking cursor costs a quarter of a core under software rendering. - **Plugin:** frames do not pause behind ordinary windows or on the lock screen; the bar entry starts `scriptwidget-studio` without checking that it exists; widgets are not moved when the dock appears later; the Chinese strings were not seen on screen. -- **Service:** real suspend and resume, timeline transitions end to end, and the path that drops a slow display were not exercised; `doctor` does not ask the plugin for its status. +- **Service:** real suspend and resume and the path that drops a slow display were not exercised; `doctor` does not ask the plugin for its status. - `docs/platform-support.md`, the website and Web Studio list Linux; the root README files do not yet. ## Runtime diff --git a/docs/linux/protocol.md b/docs/linux/protocol.md index 5409372f..d0635dda 100644 --- a/docs/linux/protocol.md +++ b/docs/linux/protocol.md @@ -42,7 +42,7 @@ One JSON object a line, UTF-8, each with a string member `event`. A display igno Examples, exactly as printed: ``` -{"event":"hello","protocol":1,"dark":false,"arrange":false,"peek":false,"service":"0.1.0"} +{"event":"hello","protocol":1,"dark":false,"arrange":false,"peek":false,"service":"0.1.1"} {"event":"widget","id":"5ef2d5c170089ecf","screen":"eDP-1","x":40,"y":40,"width":329,"height":170,"image":"/run/user/1000/scriptwidget/frames/5ef2d5c170089ecf-1d639a55-3.png","version":3,"regions":[{"n":0,"x":16,"y":120,"width":96,"height":34}],"family":"medium","families":["small","medium","large"]} {"event":"widget","id":"c45467fe6c9c2b4a","screen":"","x":68,"y":68,"width":170,"height":170,"image":"/run/user/1000/scriptwidget/frames/c45467fe6c9c2b4a-1d639a55-1-0.png","version":1,"regions":[],"frames":[{"image":"/run/user/1000/scriptwidget/frames/c45467fe6c9c2b4a-1d639a55-1-0.png","ms":200},{"image":"/run/user/1000/scriptwidget/frames/c45467fe6c9c2b4a-1d639a55-1-1.png","ms":300}],"family":"small","families":["small","medium","large","extraLarge"]} {"event":"remove","id":"5ef2d5c170089ecf"} diff --git a/docs/linux/testing.md b/docs/linux/testing.md index cfdaa687..a89e4330 100644 --- a/docs/linux/testing.md +++ b/docs/linux/testing.md @@ -262,7 +262,56 @@ cargo test --locked -p sw-core --test parity -- --nocapture # 只跑一致性 阶段 0 的验证工程(`Linux/spikes`)在这之后从仓库里删掉了,它们在提交 `9846e47` 及更早的历史里。 -## 没跑的(汇总) +## 2026-11-18,第二台测试虚拟机:刷新、x86_64 的包、0.1.1 + +机器同上(干净的 Omarchy 4.5.0-3,aarch64)。这一轮补上 0.1.0 发布时没有做的两件事,并因此发现和修掉了一个问题。 + +### 刷新,在桌面上 + +用的是从 0.1.0 的发布包安装的服务,四个小组件一直放在桌面上。 + +| 检查 | 结果 | +| --- | --- | +| 定时刷新(默认 15 分钟) | 服务在 00:30:11 启动,01:34:33 查看时每个小组件运行了 5 次:启动时 1 次,之后 15、30、45、60 分钟各 1 次。桌面上的世界时钟从 23:50 走到了 1:30(截图看过) | +| 画面没变时不换图 | 日历、心情、Nyan Cat 运行了 5 次,图片版本仍是 1;时钟每次都换了新版本 | +| 手动刷新(`scriptwidget refresh`) | 每个小组件的运行次数加 1 | +| 计时器样式的 ``(`component/date`) | 不重新运行脚本,每秒重画:8 秒里图片版本从 4 到 12,运行次数一直是 1;相隔 3 秒的两张桌面截图不同 | +| 时间线切换点 | 把 Day Rhythm 模板复制一份,`dailyTimes` 改成 2 分钟和 3 分钟之后(01:37、01:38)。每 15 秒看一次:01:36:51 还是第 1 次运行,01:37:07 是第 2 次,01:38:07 是第 3 次;桌面上的图在两个状态之间按时切换 | + +### x86_64 的发布包,在这台 Omarchy 4.5 上 + +这台机器是 aarch64,不能直接运行 x86_64 的程序。做法:在虚拟机里装 `qemu-user-static`,用 Docker 起一个 `linux/amd64` 的 `archlinux:latest` 容器(ICU 78.3),把用户的主目录和 `/run/user/1000` 原路径挂进去,在容器里运行从 GitHub 发布页下载的 `scriptwidget-0.1.0-linux-x86_64.tar.gz`(校验和核对过)里的程序。这样 x86_64 的服务用的是真实的数据目录和真实的 socket,显示它的是这台机器上真实的 Omarchy 外壳和插件;宿主上的 `scriptwidget` 换成一个转进容器的包装脚本,所以插件运行的 `watch`、`tap`、`move` 等命令也都是 x86_64 的。 + +| 检查 | 结果 | +| --- | --- | +| `scriptwidget doctor`(x86_64) | 通过 | +| `scriptwidget render` 画日历模板 | 通过,图不为空 | +| x86_64 的服务接管桌面 | 四个小组件显示在 Omarchy 桌面的 `bottom` 层,位置是之前保存的位置 | +| 点按钮 | 心情小组件的脚本重新运行,图变成"Low" | +| 手动刷新 | 运行次数加 1 | +| 摆放模式里拖动 | 时钟从 (740,520) 到 (1140,120),位置保存 | +| GIF | 在动 | +| `add`、`remove` | 通过 | +| x86_64 的管理窗口(容器里另装了 Wayland、xkbcommon、Vulkan 软件实现) | 10 秒内在真实的 Wayland 会话里开出窗口;我的小组件页和模板页画出来了,点侧栏能切换页面 | +| 服务被直接结束后留下的旧 socket | 之后启动的服务照常接管 | + +这个测试的局限要写清楚:程序是经过指令模拟运行的,不是在 x86_64 处理器上;它用的系统库来自 Arch Linux 的 x86_64 容器,不是一台 x86_64 的 Omarchy;容器里没有设置时区,所以时钟显示的是 UTC;速度没有参考意义(画一张大尺寸日历用了 0.5 秒)。它能说明的是:x86_64 的包里的程序是完整的,能在 Omarchy 4.5 的桌面上显示小组件并响应点击、拖动、刷新。真正的 x86_64 电脑仍然没有测过。 + +### 发现的问题:用过摆放模式后,小组件停在窗口上面 + +上面看 x86_64 的管理窗口时,四个小组件盖在窗口上。原因和架构无关,0.1.0 的两个包都有:摆放模式期间服务会把"提到最上层"打开,结束时恢复;插件在摆放模式里把小组件的窗口藏起来,而窗口在隐藏前后收到的换层没有在重新显示时生效,于是窗口回来时留在了 `overlay` 层,直到重启外壳。0.1.0 的端到端检查里拖动之后没有看层,所以漏掉了。 + +修法:插件只在摆放模式之外理会"提到最上层",只在窗口显示时设置层,并在窗口重新显示之后再设一次。 + +| 检查 | 结果 | +| --- | --- | +| 摆放模式开、关(之前没有提到最上层) | 回到 `bottom` 层 | +| 先提到最上层,再摆放模式开、关 | 仍在 `overlay` 层,状态里"提到最上层"仍是开 | +| 关掉"提到最上层",再摆放一次 | `bottom` 层 | +| 插件的检查脚本,替身程序改成和真服务一样在摆放时打开"提到最上层" | 修复后 64 项里 64 项通过;换回旧的 `WidgetWindow.qml`,"摆放结束后窗口回到 bottom 层"这一项失败(另有一项跟着失败) | + +这个修复在 0.1.1 里。 + - 真实的 Linux 电脑、x86_64、Omarchy 以外的桌面。 - 画笔和其他平台的图片逐像素对比。