mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 16:50:41 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa7fe733a6 | ||
|
|
65c04e796a | ||
|
|
3480318089 | ||
|
|
949acaac30 | ||
|
|
22fb6783a0 | ||
|
|
10166c66e0 | ||
|
|
b7f9f2aa68 | ||
|
|
6416f75b7f | ||
|
|
70cb5ad57e |
No files matched your search
@@ -24,10 +24,17 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential pkg-config \
|
||||
libx11-dev libxext-dev libxtst-dev libxfixes-dev libgtk-3-dev
|
||||
libx11-dev libxext-dev libxtst-dev libxfixes-dev libgtk-3-dev \
|
||||
libwayland-dev libwayland-bin libxkbcommon-dev
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo test --locked
|
||||
# Same as the release job: the wayland plugin is built on 22.04; libei is unavailable here, so
|
||||
# the portal plugin is skipped with a warning (release builds it on 24.04).
|
||||
- name: Release feature set
|
||||
run: |
|
||||
cargo build --locked --features wayland,portal,engine-plugins --bin uuremote-server
|
||||
test -f target/debug/libuu-wayland.so
|
||||
|
||||
test-viewer:
|
||||
runs-on: ubuntu-22.04
|
||||
@@ -56,6 +63,12 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: cargo test --locked --features wayland,portal
|
||||
# Release layout: engines as runtime-loaded plugins; uuremote-server must not link them.
|
||||
- name: Engine plugins
|
||||
run: |
|
||||
cargo build --locked --features wayland,portal,engine-plugins --bin uuremote-server
|
||||
for lib in libuu-wayland.so libuu-portal.so; do test -f "target/debug/$lib"; done
|
||||
! readelf -d target/debug/uuremote-server | grep NEEDED | grep -E 'libei|libpipewire|libwayland-client|libxkbcommon'
|
||||
- name: Native portal and EIS regression tests (ASan/UBSan)
|
||||
env:
|
||||
ASAN_OPTIONS: detect_leaks=1
|
||||
|
||||
@@ -9,7 +9,26 @@ permissions:
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
# GNOME/KDE Wayland engine: libei >= 1.1 first ships in Ubuntu 24.04, so this plugin needs
|
||||
# glibc >= 2.39. It is only loaded on portal sessions; X11 and wlroots hosts never open it.
|
||||
portal-plugin:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential pkg-config \
|
||||
libx11-dev libxext-dev libxtst-dev libxfixes-dev libglib2.0-dev libpipewire-0.3-dev libei-dev
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- run: UU_NO_GTK=1 cargo build --release --locked --features portal,engine-plugins --bin uuremote-server
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: libuu-portal
|
||||
path: target/release/libuu-portal.so
|
||||
|
||||
release:
|
||||
needs: portal-plugin
|
||||
# Built on 22.04 so the binary also runs on Ubuntu 22.04/24.04 and newer Debian (glibc >= 2.35).
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
@@ -18,17 +37,25 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y build-essential pkg-config \
|
||||
libx11-dev libxext-dev libxtst-dev libxfixes-dev libgtk-3-dev libsdl2-dev
|
||||
libx11-dev libxext-dev libxtst-dev libxfixes-dev libgtk-3-dev libsdl2-dev \
|
||||
libwayland-dev libwayland-bin libxkbcommon-dev
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- run: cargo test --release --locked
|
||||
- run: cargo build --release --locked
|
||||
# Experimental viewer; built after the host so uuremote-server keeps the default features.
|
||||
# One package for every desktop: Wayland (wlroots) and GNOME/KDE portal engines are plugins
|
||||
# opened at runtime (engine-plugins), so X11 hosts need none of their libraries.
|
||||
- run: cargo build --release --locked --features wayland,portal,engine-plugins
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: libuu-portal
|
||||
path: target/release
|
||||
# Experimental viewer; built after the host so uuremote-server keeps the release features.
|
||||
- run: cargo build --release --locked --features native-viewer,viewer-sdl --bin uuremote-viewer
|
||||
- name: Package
|
||||
run: |
|
||||
name=uu-remote-linux-${GITHUB_REF_NAME}-x86_64-linux
|
||||
mkdir -p "$name"
|
||||
cp target/release/uuremote-server target/release/uuremote-viewer LICENSE README.md README.en.md config.example.json "$name/"
|
||||
cp target/release/uuremote-server target/release/uuremote-viewer target/release/libuu-wayland.so target/release/libuu-portal.so \
|
||||
LICENSE README.md README.en.md config.example.json "$name/"
|
||||
cp -r contrib "$name/"
|
||||
tar czf "$name.tar.gz" "$name"
|
||||
sha256sum "$name.tar.gz" > "$name.tar.gz.sha256"
|
||||
|
||||
@@ -116,6 +116,8 @@ viewer does not reconnect them automatically.
|
||||
| `UU_FFMPEG_ROOT` | FFmpeg prefix (`bin/ffmpeg`, libs in `lib/x86_64-linux-gnu`) |
|
||||
| `UU_AUDIO=0`, `UU_AUDIO_SOURCE` | disable sound / choose the Pulse source (default `@DEFAULT_MONITOR@`) |
|
||||
| `UU_LOGIN_WINDOW=0` | don't auto-open the login window |
|
||||
| `UU_ENGINE_DIR` | directory holding `libuu-wayland.so` / `libuu-portal.so` (`--features engine-plugins`, used by release packages: engines are dlopen'ed only on Wayland sessions; also searched next to the binary, `../lib/uu-remote-linux`, `~/.local/lib/uu-remote-linux`, `/usr/lib/uu-remote-linux`) |
|
||||
| `UU_USE_PROXY=1` | honor HTTP/SOCKS proxy env vars; cloud API clients bypass env proxies by default |
|
||||
| `UU_REMOTE_ASSIST=0`, `UU_ASSIST_ALLOW=1`, `UU_ASSIST_UI=tty`, `UU_ASSIST_DEBUG=1` | disable assistance / allow at start / terminal UI for `assist` / include the server's short error message in assist errors |
|
||||
|
||||
Token has no expiry field; API code 1120 (HTTP 422) means invalid/expired → re-login. The config is re-read
|
||||
@@ -142,6 +144,7 @@ every 60 s.
|
||||
| `src/initialization.rs`, `src/control_protocol.rs`, `src/protocol.rs` | protobuf encoders/decoders for CONTROL |
|
||||
| `src/session_ice.rs`, `src/network_diagnostics.rs` | cloud ICE servers, address-free path diagnostics |
|
||||
| `src/desktop_backend.rs`, `src/wayland.rs`, `src/portal*.rs` | backend selection, Hyprland, GNOME/KDE portal |
|
||||
| `src/engine_plugin.rs` | `engine_ffi!`: engine C functions linked statically, or dlsym-resolved from runtime plugins with `engine-plugins` |
|
||||
| `c_engine/portal_eis.inc` | scaled GNOME input through the existing Portal session's EIS connection; all input must use EIS once connected |
|
||||
| `c_engine/x11_engine.c`, `c_engine/clipboard.c` | X11 capture/input/selection |
|
||||
| `c_engine/wayland_engine.c`, `c_engine/portal_engine.c` | Wayland and portal engines |
|
||||
|
||||
Generated
+1
-1
@@ -2741,7 +2741,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "uu-remote-linux"
|
||||
version = "0.2.10"
|
||||
version = "0.2.13"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
|
||||
+3
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "uu-remote-linux"
|
||||
version = "0.2.10"
|
||||
version = "0.2.13"
|
||||
edition = "2021"
|
||||
default-run = "uuremote-server"
|
||||
authors = ["uu-remote-linux contributors"]
|
||||
@@ -28,6 +28,8 @@ wayland = []
|
||||
# Experimental direct linear framebuffer capture; never enabled in release builds.
|
||||
kms = []
|
||||
portal = []
|
||||
# Build the wayland/portal engines as runtime-loaded libuu-wayland.so / libuu-portal.so (release packages).
|
||||
engine-plugins = []
|
||||
# In-process capture and encoding through FFmpeg 6 libraries (libavcodec/libavdevice dev packages).
|
||||
# Off by default so release binaries do not link the build machine's libav.
|
||||
inproc-av = ["dep:ffmpeg-next", "dep:x11rb"]
|
||||
|
||||
+29
-1
@@ -73,6 +73,7 @@ authorized session. Independent file/terminal tool peers do not reset input.
|
||||
| Xfce | X11 | ✅ Tested in a VM | default |
|
||||
| Cinnamon / MATE | X11 | ✅ Tested in a VM | default |
|
||||
| Hyprland | Wayland (native wlroots protocols) | 🧪 Experimental, tested in a VM (some features limited, see below) | `--features wayland` |
|
||||
| niri | Wayland (native wlroots protocols) | 🧪 Experimental; protocol support confirmed from niri sources, not yet tested on hardware (#55) | `--features wayland` |
|
||||
| GNOME / KDE Plasma | Wayland (xdg-desktop-portal) | 🧪 Experimental; validation scope and limits below | `--features wayland,portal` |
|
||||
|
||||
The GNOME Wayland Portal/EIS path has been checked for video and mouse/keyboard input on Ubuntu 26.04, GNOME 50, with one 4K screen at 200% scale; auto unlock after a cold locked connection is verified with the official Mac and iPhone 4.42.0 viewers, while other lock recovery and reconnection still need hardware acceptance testing. Apart from that path and GNOME on X11, desktop testing has primarily used virtual machines. If something goes wrong on
|
||||
@@ -119,6 +120,28 @@ mapping and hardware acceleration remain unverified. This is not zero-copy VAAPI
|
||||
|
||||
## Installation
|
||||
|
||||
### 0. Prebuilt release package (recommended, x86_64)
|
||||
|
||||
Download `uu-remote-linux-<version>-x86_64-linux.tar.gz` from [Releases](../../releases/latest), extract it, then:
|
||||
|
||||
```sh
|
||||
install -Dm755 uuremote-server ~/.local/bin/uuremote-server
|
||||
install -Dm644 libuu-wayland.so libuu-portal.so -t ~/.local/lib/uu-remote-linux/
|
||||
```
|
||||
|
||||
One package covers X11, wlroots compositors (Hyprland, Sway, niri) and GNOME/KDE Wayland: the backend is chosen from the
|
||||
running session at startup, and the matching `libuu-*.so` is loaded only on Wayland, so X11 hosts need no Wayland libraries.
|
||||
|
||||
| Session | Requirements |
|
||||
|---|---|
|
||||
| X11 | glibc >= 2.35 (Ubuntu 22.04, Debian 12 and newer) |
|
||||
| wlroots (Hyprland / Sway / niri) | the same, plus `libwayland-client` and `libxkbcommon` (present on Wayland desktops) |
|
||||
| GNOME / KDE Wayland | glibc >= 2.39 (Ubuntu 24.04, Fedora 40, Debian 13 and newer), libei >= 1.1 and PipeWire |
|
||||
|
||||
Plugins are found next to `uuremote-server`, in `../lib/uu-remote-linux/`, `~/.local/lib/uu-remote-linux/` or
|
||||
`/usr/lib/uu-remote-linux/` (`UU_ENGINE_DIR` overrides); a missing library or too old glibc is reported in the log.
|
||||
Continue with step 3 (login). Other architectures (ARM): build from source below.
|
||||
|
||||
### 1. Dependencies (Ubuntu / Debian)
|
||||
|
||||
```sh
|
||||
@@ -288,6 +311,7 @@ Common environment variables:
|
||||
| `UU_ASSIST_ALLOW=1` | Allow remote assistance at start (overrides the saved switch) |
|
||||
| `UU_LOGIN_WINDOW=0` | Do not open the login window automatically when credentials are missing |
|
||||
| `UU_PORT_MAPPING=0` | Disable port mapping (the official host's controlled-side switch) |
|
||||
| `UU_USE_PROXY=1` | Honor HTTP/SOCKS proxy environment variables; by default proxies are ignored and NetEase servers are reached directly |
|
||||
|
||||
Host settings such as "lock after remote session" and "mute host" are stored in
|
||||
`~/.config/uuremote/host_settings.json`.
|
||||
@@ -414,13 +438,17 @@ Omarchy uses Hyprland: run in its user session, select `UU_DESKTOP_BACKEND=wayla
|
||||
and retain `WAYLAND_DISPLAY` / `XDG_RUNTIME_DIR`. This requires wlr-screencopy and the
|
||||
virtual input protocols supported by Hyprland; other compositors may need `--features wayland,portal`.
|
||||
For uinput, load `uinput` (at boot: `echo uinput | sudo tee /etc/modules-load.d/uinput.conf`) and apply the uaccess rule above; seat ACLs require an active login.
|
||||
For unattended accounts, explicitly restrict `/dev/uinput` access to a dedicated group.
|
||||
For unattended accounts, explicitly restrict `/dev/uinput` access to a dedicated group, e.g. `z /dev/uinput 0660 root uinput`
|
||||
in `/etc/tmpfiles.d/uinput.conf` plus `sudo usermod -aG uinput <user>` (dedicated account only).
|
||||
This permission can inject into the whole seat, including lock/greeter screens.
|
||||
`UU_INPUT_BACKEND=uinput` requests kernel devices; verify startup actually reports uinput.
|
||||
In Hyprland / uwsm sessions `default.target` may start before the compositor exports `WAYLAND_DISPLAY`;
|
||||
tie the unit to the graphical session instead (community-verified autostart on Omarchy):
|
||||
`After=` and `PartOf=graphical-session.target`, `ConditionEnvironment=WAYLAND_DISPLAY`,
|
||||
`Environment=UU_DESKTOP_BACKEND=wayland` (no `DISPLAY`), and `WantedBy=graphical-session.target`.
|
||||
Keep the unit name `uuremote-native.service` (not a template `[email protected]`): the desktop icon and
|
||||
`uuremote-server show` always start that name (override with `UU_SERVICE_UNIT`). `niri --session` also imports
|
||||
`WAYLAND_DISPLAY` before it is ready, so the same unit applies to niri (#55).
|
||||
Optional VAAPI: `intel-media-driver` (modern Intel) or `libva-mesa-driver` (AMD), `libva-utils`
|
||||
for `vainfo`. Optional KMS: `libdrm`. Virtual Xfce: `xorg-server-xvfb xorg-xauth xorg-xdpyinfo
|
||||
xfce4-session xfce4-panel xfdesktop xfwm4 gnome-terminal`.
|
||||
|
||||
@@ -65,8 +65,11 @@ Portal 仅作用于本服务获授权的会话。文件传输、终端等独立
|
||||
| Xfce | X11 | ✅ 虚拟机测试通过 | 默认 |
|
||||
| Cinnamon / MATE | X11 | ✅ 虚拟机测试通过 | 默认 |
|
||||
| Hyprland | Wayland(wlroots 原生协议) | 🧪 实验性,虚拟机测试(部分功能受限,见下) | `--features wayland` |
|
||||
| niri | Wayland(wlroots 原生协议) | 🧪 实验性,协议支持已按 niri 源码确认,尚未实机验收(#55) | `--features wayland` |
|
||||
| GNOME / KDE Plasma | Wayland(xdg-desktop-portal) | 🧪 实验性,验证范围与限制见下 | `--features wayland,portal` |
|
||||
|
||||
最后一列是源码编译方式;Release 预编译包已包含全部后端,直接使用即可(见[安装](#0-直接用-release-预编译包推荐x86_64))。
|
||||
|
||||
GNOME Wayland 的 Portal/EIS 路径已在 Ubuntu 26.04、GNOME 50、单屏 4K/200% 缩放下验证画面和键鼠;锁屏冷连接自动解锁已用 Mac 和 iPhone 4.42.0 客户端实机验证,其余锁屏恢复及重连仍待验收。除 GNOME 的上述路径和 X11 外,其余桌面目前主要在虚拟机里测试。如果你在真机上遇到问题,欢迎[提交 issue](../../issues),
|
||||
请附上发行版、桌面环境、显卡型号和 `journalctl --user -u uuremote-native.service` 里的相关日志。
|
||||
|
||||
@@ -104,6 +107,27 @@ GNOME Portal 的控制通道不再等待授权窗口或第一帧画面:先通
|
||||
|
||||
## 安装
|
||||
|
||||
### 0. 直接用 Release 预编译包(推荐,x86_64)
|
||||
|
||||
从 [Releases](../../releases/latest) 下载 `uu-remote-linux-<版本>-x86_64-linux.tar.gz`,解压后:
|
||||
|
||||
```sh
|
||||
install -Dm755 uuremote-server ~/.local/bin/uuremote-server
|
||||
install -Dm644 libuu-wayland.so libuu-portal.so -t ~/.local/lib/uu-remote-linux/
|
||||
```
|
||||
|
||||
同一个包支持 X11、Hyprland 等 wlroots 合成器和 GNOME/KDE Wayland:程序启动时按当前会话自动选择后端,只在 Wayland 会话里
|
||||
才加载对应的 `libuu-*.so`,X11 用户不需要任何 Wayland 库。系统要求:
|
||||
|
||||
| 会话 | 要求 |
|
||||
|---|---|
|
||||
| X11 | glibc ≥ 2.35(Ubuntu 22.04、Debian 12 及更新) |
|
||||
| Hyprland / Sway / niri 等 wlroots | 同上,另需 `libwayland-client`、`libxkbcommon`(Wayland 桌面自带) |
|
||||
| GNOME / KDE Wayland | glibc ≥ 2.39(Ubuntu 24.04、Fedora 40、Debian 13 及更新),以及 libei ≥ 1.1、PipeWire |
|
||||
|
||||
插件放在 `uuremote-server` 同目录、`../lib/uu-remote-linux/`、`~/.local/lib/uu-remote-linux/` 或 `/usr/lib/uu-remote-linux/` 都能找到
|
||||
(`UU_ENGINE_DIR` 可指定)。缺库或版本太旧时日志会写明原因。之后从第 3 步「登录」继续;ARM 等其他架构请按下面源码编译。
|
||||
|
||||
### 1. 依赖(Ubuntu / Debian)
|
||||
|
||||
```sh
|
||||
@@ -258,6 +282,7 @@ systemctl --user restart uuremote-native.service
|
||||
| `UU_REMOTE_ASSIST=0` | 关闭远程协助(未登录时也不再以访客身份提供协助) |
|
||||
| `UU_ASSIST_ALLOW=1` | 启动时就允许他人远程协助(覆盖窗口里保存的开关状态) |
|
||||
| `UU_PORT_MAPPING=0` | 关闭端口映射(对应官方被控端的开关) |
|
||||
| `UU_USE_PROXY=1` | 使用环境变量里的 HTTP/SOCKS 代理;默认忽略代理、直连网易服务器 |
|
||||
|
||||
「远程结束后自动锁屏」「静音运行」等设置保存在 `~/.config/uuremote/host_settings.json`。
|
||||
|
||||
@@ -364,7 +389,8 @@ cargo build --release --features wayland
|
||||
|
||||
Omarchy 使用 Hyprland:在其用户会话中运行,设置 `UU_DESKTOP_BACKEND=wayland`,保留
|
||||
`WAYLAND_DISPLAY` 和 `XDG_RUNTIME_DIR`。其他合成器可能需要 `--features wayland,portal`。
|
||||
uinput 需加载内核模块(开机自动加载:`echo uinput | sudo tee /etc/modules-load.d/uinput.conf`)并应用上文 uaccess 规则;无人登录账号需要专用组的受限授权。
|
||||
uinput 需加载内核模块(开机自动加载:`echo uinput | sudo tee /etc/modules-load.d/uinput.conf`)并应用上文 uaccess 规则;无人登录账号需要专用组的受限授权,
|
||||
例如 `/etc/tmpfiles.d/uinput.conf` 写入 `z /dev/uinput 0660 root uinput`,再 `sudo usermod -aG uinput <用户>`(只加专用账号)。
|
||||
该权限能向整个 seat(包括锁屏/登录界面)注入输入。设置 `UU_INPUT_BACKEND=uinput` 后,
|
||||
仍须确认启动日志实际选择了 uinput。
|
||||
|
||||
@@ -385,6 +411,10 @@ Environment=UU_DESKTOP_BACKEND=wayland
|
||||
WantedBy=graphical-session.target
|
||||
```
|
||||
|
||||
单元名请保持 `uuremote-native.service`,不要写成模板单元 `[email protected]`:桌面图标和 `uuremote-server show`
|
||||
固定启动这个名字(`UU_SERVICE_UNIT` 可覆盖),systemd 不会把它解析到模板实例。niri 的 `niri --session` 同样会在就绪前导入
|
||||
`WAYLAND_DISPLAY`,上面的写法也适用(#55)。
|
||||
|
||||
VAAPI 可选包:Intel 新显卡用 `intel-media-driver`,AMD 用 `libva-mesa-driver`,`libva-utils` 提供
|
||||
`vainfo`。KMS 依赖 `libdrm`。虚拟 Xfce 依赖 `xorg-server-xvfb xorg-xauth xorg-xdpyinfo
|
||||
xfce4-session xfce4-panel xfdesktop xfwm4 gnome-terminal`。
|
||||
|
||||
@@ -50,7 +50,15 @@ fn main() {
|
||||
}
|
||||
None => println!("cargo:warning=gtk+-3.0 not found: building without the login window"),
|
||||
}
|
||||
if std::env::var_os("CARGO_FEATURE_PORTAL").is_some() {
|
||||
let plugins = std::env::var_os("CARGO_FEATURE_ENGINE_PLUGINS").is_some();
|
||||
if plugins && std::env::var_os("CARGO_FEATURE_PORTAL").is_some() {
|
||||
// Runtime-loaded libuu-portal.so; skipped (with a warning) where libei >= 1.1 is unavailable.
|
||||
for file in ["portal_engine.c", "portal_engine.h", "portal_eis.inc", "desktop_power.c"] { println!("cargo:rerun-if-changed=c_engine/{file}"); }
|
||||
match pkg_config(&["gio-2.0", "gio-unix-2.0", "libpipewire-0.3", "libei-1.0 >= 1.1"]) {
|
||||
Some((cflags, libs)) => shared_engine("libuu-portal.so", &["c_engine/portal_engine.c", "c_engine/desktop_power.c"], &[], &cflags, &libs),
|
||||
None => println!("cargo:warning=GIO/PipeWire/libei >= 1.1 not found: libuu-portal.so not built"),
|
||||
}
|
||||
} else if std::env::var_os("CARGO_FEATURE_PORTAL").is_some() {
|
||||
println!("cargo:rerun-if-changed=c_engine/portal_engine.c");
|
||||
println!("cargo:rerun-if-changed=c_engine/portal_engine.h");
|
||||
println!("cargo:rerun-if-changed=c_engine/portal_eis.inc");
|
||||
@@ -76,6 +84,7 @@ fn main() {
|
||||
let mut build = cc::Build::new();
|
||||
build.flag_if_supported("-Wno-unused-parameter"); // protocol listener signatures
|
||||
build.file("c_engine/wayland_engine.c").include(&out);
|
||||
let mut sources = vec!["c_engine/wayland_engine.c".to_owned()];
|
||||
for name in ["wlr-screencopy-unstable-v1", "wlr-virtual-pointer-unstable-v1", "virtual-keyboard-unstable-v1", "wlr-output-power-management-unstable-v1", "linux-dmabuf-unstable-v1"] {
|
||||
let xml = format!("c_engine/wayland-protocols/{name}.xml");
|
||||
println!("cargo:rerun-if-changed={xml}");
|
||||
@@ -84,13 +93,43 @@ fn main() {
|
||||
let status = std::process::Command::new("wayland-scanner").args([mode, &xml]).arg(&target).status()
|
||||
.expect("Install wayland-scanner to build the Wayland backend");
|
||||
assert!(status.success(), "wayland-scanner failed");
|
||||
if mode == "private-code" { build.file(target); }
|
||||
if mode == "private-code" { sources.push(target.to_string_lossy().into_owned()); build.file(target); }
|
||||
}
|
||||
}
|
||||
println!("cargo:rerun-if-changed=c_engine/wayland_engine.c");
|
||||
build.compile("uu_wayland_engine");
|
||||
println!("cargo:rustc-link-lib=wayland-client");
|
||||
println!("cargo:rustc-link-lib=xkbcommon");
|
||||
if plugins {
|
||||
let sources: Vec<&str> = sources.iter().map(String::as_str).collect();
|
||||
match pkg_config(&["wayland-client", "xkbcommon"]) {
|
||||
Some((cflags, libs)) => shared_engine("libuu-wayland.so", &sources, &[out.as_path()], &cflags, &libs),
|
||||
None => println!("cargo:warning=wayland-client/xkbcommon not found: libuu-wayland.so not built"),
|
||||
}
|
||||
} else {
|
||||
build.compile("uu_wayland_engine");
|
||||
println!("cargo:rustc-link-lib=wayland-client");
|
||||
println!("cargo:rustc-link-lib=xkbcommon");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `pkg-config --cflags` / `--libs` for `packages`, or None when any is missing.
|
||||
fn pkg_config(packages: &[&str]) -> Option<(String, String)> {
|
||||
let run = |kind: &str| std::process::Command::new("pkg-config").arg(kind).args(packages).output().ok()
|
||||
.filter(|o| o.status.success()).map(|o| String::from_utf8_lossy(&o.stdout).into_owned());
|
||||
run("--cflags").zip(run("--libs"))
|
||||
}
|
||||
|
||||
/// Builds an engine as a shared library for engine-plugins and places it next to the binaries
|
||||
/// (target/<profile>/), where the release workflow packages it. Not linked into uuremote-server.
|
||||
fn shared_engine(name: &str, sources: &[&str], includes: &[&std::path::Path], cflags: &str, libs: &str) {
|
||||
let out = std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
|
||||
let library = out.join(name);
|
||||
let mut command = cc::Build::new().pic(true).opt_level(2).get_compiler().to_command();
|
||||
command.args(["-shared", "-fPIC", "-Wno-unused-parameter", "-Wl,-z,defs"]).arg(format!("-Wl,-soname,{name}")).arg("-o").arg(&library);
|
||||
for include in includes { command.arg("-I").arg(include); }
|
||||
command.args(cflags.split_whitespace()).args(sources).args(libs.split_whitespace()).arg("-lpthread");
|
||||
let status = command.status().expect("C compiler for the engine plugin");
|
||||
assert!(status.success(), "building {name} failed");
|
||||
// OUT_DIR = target/<profile>/build/<package>-<hash>/out
|
||||
if let Some(profile) = out.ancestors().nth(3) { std::fs::copy(&library, profile.join(name)).expect("copy engine plugin"); }
|
||||
}
|
||||
+175
-8
@@ -58,6 +58,14 @@ static struct xkb_context *xkb;
|
||||
static struct xkb_keymap *keymap;
|
||||
static struct xkb_state *key_state;
|
||||
static unsigned char held_keys[768];
|
||||
/* Mobile input-method text (#13/#46). The protocol has no per-key remap request, but
|
||||
zwp_virtual_keyboard_v1_keymap may be re-sent at any time, so the pristine keymap text is kept
|
||||
and a spare keycode is pointed at one character's keysym at a time. Never logs the text. */
|
||||
#define UU_TEXT_SPARE 32
|
||||
static char *keymap_text;
|
||||
static size_t keymap_text_len, keymap_insert;
|
||||
static xkb_keycode_t spare_codes[UU_TEXT_SPARE];
|
||||
static unsigned spare_count;
|
||||
struct output { struct wl_output *handle; char name[128]; int transform,scale; uint32_t width,height; };
|
||||
static struct output outputs[32];
|
||||
static unsigned output_count, selected;
|
||||
@@ -116,6 +124,164 @@ static int sync_display(void) {
|
||||
if (!ready) wl_callback_destroy(cb);
|
||||
return result;
|
||||
}
|
||||
/* Hand a keymap to the virtual keyboard. The compositor dups the fd, so it is closed here. */
|
||||
static int upload_keymap(const char *text,size_t length) {
|
||||
int fd=memfd_create("uuremote-keymap",MFD_CLOEXEC);
|
||||
if(fd<0) return -1;
|
||||
if(ftruncate(fd,(off_t)length)!=0 || write(fd,text,length)!=(ssize_t)length) { close(fd); return -1; }
|
||||
zwp_virtual_keyboard_v1_keymap(keyboard,WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,fd,(uint32_t)length);
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
/* A keymap uploaded to a keyboard the seat already has is never handed to the focused client again,
|
||||
so pressing the remapped keycodes would still be translated with the keymap it has - which is how
|
||||
every message came out as the one before it. Re-attaching the keyboard is what makes the
|
||||
compositor send the keymap to the client (measured 2026-10-18 on Hyprland 0.56.2). */
|
||||
static int rekey_keyboard(void) {
|
||||
if(!keyboard_manager || !seat) return -1;
|
||||
if(keyboard) zwp_virtual_keyboard_v1_destroy(keyboard);
|
||||
keyboard=zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(keyboard_manager,seat);
|
||||
return keyboard?0:-1;
|
||||
}
|
||||
/* Offset of the '}' that closes the xkb_symbols section, so extra keys can be declared there.
|
||||
Pairing the braces is enough because the bodies are balanced; looking for the last "};" is not,
|
||||
the keymap's own brace follows, and an optional xkb_geometry section may too. */
|
||||
static size_t symbols_close(const char *text) {
|
||||
const char *section=strstr(text,"xkb_symbols");
|
||||
if(!section) return 0;
|
||||
const char *open=strchr(section,'{');
|
||||
if(!open) return 0;
|
||||
int depth=0;
|
||||
for(const char *p=open;*p;p++) {
|
||||
if(*p=='{') depth++;
|
||||
else if(*p=='}' && --depth==0) return (size_t)(p-text);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* Named keycodes the keymap gives no symbol to. Reading the compositor's own list is the only
|
||||
portable way: pressing an unmapped keycode types nothing, and uu_wl_key never matches one
|
||||
because it searches by keysym. Highest first, since uu_wl_key takes the lowest match. */
|
||||
static unsigned find_spare_codes(xkb_keycode_t *out,unsigned limit) {
|
||||
unsigned count=0;
|
||||
xkb_keycode_t min=xkb_keymap_min_keycode(keymap);
|
||||
for(xkb_keycode_t code=xkb_keymap_max_keycode(keymap);code>min && count<limit;code--) {
|
||||
if(code<8 || code>=sizeof(held_keys) || !xkb_keymap_key_get_name(keymap,code)) continue;
|
||||
int mapped=0;
|
||||
for(xkb_level_index_t level=0;level<xkb_keymap_num_levels_for_key(keymap,code,0) && !mapped;level++) {
|
||||
const xkb_keysym_t *syms;
|
||||
if(xkb_keymap_key_get_syms_by_level(keymap,code,0,level,&syms)>0) mapped=1;
|
||||
}
|
||||
if(!mapped) out[count++]=code;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
/* A keycode the session keymap already produces this symbol with, unshifted. Typing through it
|
||||
needs no upload, so no client can mistranslate it - and it is how plain latin text and spaces
|
||||
arrive without touching the keymap at all. Spares never match: the pristine keymap leaves them
|
||||
unmapped. */
|
||||
static xkb_keycode_t existing_keycode(xkb_keysym_t symbol) {
|
||||
for(xkb_keycode_t code=xkb_keymap_min_keycode(keymap);code<=xkb_keymap_max_keycode(keymap);code++) {
|
||||
if(code<8 || code>=sizeof(held_keys)) continue;
|
||||
const xkb_keysym_t *syms;
|
||||
if(xkb_keymap_key_get_syms_by_level(keymap,code,0,0,&syms)==1 && syms[0]==symbol) return code;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static void press_keycode(xkb_keycode_t code) {
|
||||
zwp_virtual_keyboard_v1_key(keyboard,timestamp(),code-8,WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
zwp_virtual_keyboard_v1_key(keyboard,timestamp(),code-8,WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||
held_keys[code]=0;
|
||||
}
|
||||
/* The replaced keyboard starts with nothing held, and a keycode held_keys still calls held would be
|
||||
skipped by uu_wl_key's next press of it. */
|
||||
static void release_held_keys_locked(void) {
|
||||
for(xkb_keycode_t code=xkb_keymap_min_keycode(keymap);code<=xkb_keymap_max_keycode(keymap);code++) {
|
||||
if(code<8 || code>=sizeof(held_keys) || !held_keys[code]) continue;
|
||||
zwp_virtual_keyboard_v1_key(keyboard,timestamp(),code-8,WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||
xkb_state_update_key(key_state,code,XKB_KEY_UP);
|
||||
}
|
||||
memset(held_keys,0,sizeof(held_keys));
|
||||
}
|
||||
/* Upload one batch: re-attach the keyboard so the client takes the keymap, point spare keycodes at
|
||||
these symbols, wait for the compositor to install it, then press them. Spares are left out of
|
||||
key_state and held_keys: pressed and released here. */
|
||||
static int flush_batch(char *buffer,size_t capacity,const char names[][64],const xkb_keycode_t *codes,unsigned count,int *typed) {
|
||||
release_held_keys_locked();
|
||||
if(rekey_keyboard()!=0) return -1;
|
||||
size_t at=keymap_insert;
|
||||
memcpy(buffer,keymap_text,at);
|
||||
for(unsigned i=0;i<count;i++) {
|
||||
int wrote=snprintf(buffer+at,capacity-at,"\tkey <%s> { [ %s ] };\n",xkb_keymap_key_get_name(keymap,codes[i]),names[i]);
|
||||
if(wrote<0 || (size_t)wrote>=capacity-at) return -1;
|
||||
at+=(size_t)wrote;
|
||||
}
|
||||
memcpy(buffer+at,keymap_text+keymap_insert,keymap_text_len-keymap_insert);
|
||||
if(upload_keymap(buffer,at+(keymap_text_len-keymap_insert))!=0) return -1;
|
||||
if(sync_display()!=0) return -1;
|
||||
for(unsigned i=0;i<count;i++) { press_keycode(codes[i]); (*typed)++; }
|
||||
return 0;
|
||||
}
|
||||
/* Type UTF-8 like xdotool type does on X11, but on Wayland: characters the session keymap already
|
||||
has go out as ordinary keycodes, the rest share the spares of one keymap upload (~70 KB, so one
|
||||
batch per upload), in text order. Never logs the text. */
|
||||
static int type_utf8_locked(const char *text) {
|
||||
size_t capacity=keymap_text_len+(size_t)UU_TEXT_SPARE*96+64;
|
||||
char *buffer=malloc(capacity);
|
||||
if(!buffer) return -1;
|
||||
char names[UU_TEXT_SPARE][64];
|
||||
xkb_keycode_t codes[UU_TEXT_SPARE];
|
||||
unsigned count=0;
|
||||
int typed=0, failed=0;
|
||||
const unsigned char *p=(const unsigned char *)text;
|
||||
while(*p && !failed) {
|
||||
unsigned cp=0; int n=0;
|
||||
if(*p<0x80) { cp=*p; n=1; }
|
||||
else if((*p&0xE0)==0xC0 && (p[1]&0xC0)==0x80) { cp=((p[0]&0x1F)<<6)|(p[1]&0x3F); n=2; }
|
||||
else if((*p&0xF0)==0xE0 && (p[1]&0xC0)==0x80 && (p[2]&0xC0)==0x80) { cp=((p[0]&0x0F)<<12)|((p[1]&0x3F)<<6)|(p[2]&0x3F); n=3; }
|
||||
else if((*p&0xF8)==0xF0 && (p[1]&0xC0)==0x80 && (p[2]&0xC0)==0x80 && (p[3]&0xC0)==0x80) { cp=((p[0]&0x07)<<18)|((p[1]&0x3F)<<12)|((p[2]&0x3F)<<6)|(p[3]&0x3F); n=4; }
|
||||
else { p++; continue; }
|
||||
p+=n;
|
||||
xkb_keysym_t sym;
|
||||
if(cp=='\n') sym=0xff0d; /* Return */
|
||||
else if(cp=='\t') sym=0xff09; /* Tab */
|
||||
else if(cp<0x20 || cp==0x7f || (cp>=0x80 && cp<0xa0)) continue; /* controls carry no text */
|
||||
else if(cp<0x100) sym=cp; /* Latin-1 keysyms equal the code point */
|
||||
else sym=(xkb_keysym_t)(0x1000000|cp); /* Unicode keysym */
|
||||
xkb_keycode_t existing=existing_keycode(sym);
|
||||
if(existing) {
|
||||
if(count && flush_batch(buffer,capacity,names,codes,count,&typed)!=0) { failed=1; break; }
|
||||
count=0;
|
||||
press_keycode(existing); typed++;
|
||||
continue;
|
||||
}
|
||||
if(count==UU_TEXT_SPARE) {
|
||||
if(flush_batch(buffer,capacity,names,codes,count,&typed)!=0) { failed=1; break; }
|
||||
count=0;
|
||||
}
|
||||
/* The name is what the keymap parser reads back; an unnamed keysym cannot be spelled. */
|
||||
if(xkb_keysym_get_name(sym,names[count],sizeof(names[count]))<=0) continue;
|
||||
codes[count]=spare_codes[count];
|
||||
count++;
|
||||
}
|
||||
if(!failed && count) failed=flush_batch(buffer,capacity,names,codes,count,&typed)!=0;
|
||||
free(buffer);
|
||||
/* Restore the pristine keymap whatever happened above, so uu_wl_key keeps its own symbol map. */
|
||||
if(upload_keymap(keymap_text,keymap_text_len)!=0) return -1;
|
||||
return failed && !typed?-1:typed;
|
||||
}
|
||||
int uu_wl_type_utf8(const char *text) {
|
||||
pthread_mutex_lock(&lock);
|
||||
int typed=-1;
|
||||
if(initialized && text && keymap_text && keymap_insert && spare_count) typed=type_utf8_locked(text);
|
||||
if(typed>=0 && wl_display_flush(display)<0) typed=-1;
|
||||
pthread_mutex_unlock(&lock); return typed;
|
||||
}
|
||||
/* Diagnostic: how many characters one keymap upload can carry, 0 when this keymap has no spare. */
|
||||
int uu_wl_text_ready(void) {
|
||||
pthread_mutex_lock(&lock);
|
||||
int ready=initialized && keymap_text && keymap_insert ? (int)spare_count : 0;
|
||||
pthread_mutex_unlock(&lock); return ready;
|
||||
}
|
||||
static void output_geometry(void*d,struct wl_output*o,int32_t x,int32_t y,int32_t w,int32_t h,int32_t sub,const char*m,const char*model,int32_t transform) { ((struct output*)d)->transform=transform; }
|
||||
static void output_mode(void*d,struct wl_output*o,uint32_t f,int32_t w,int32_t h,int32_t rate) {
|
||||
if(f&WL_OUTPUT_MODE_CURRENT) { ((struct output*)d)->width=w; ((struct output*)d)->height=h; }
|
||||
@@ -357,6 +523,7 @@ static void reset(void) {
|
||||
dmabuf=NULL; dmabuf_requested=dmabuf_disabled=dmabuf_reported=0; dmabuf_linear_formats=0;
|
||||
pending=0; output_count=0; initialized=0; memset(outputs,0,sizeof(outputs));
|
||||
memset(held_keys,0,sizeof(held_keys));
|
||||
free(keymap_text); keymap_text=NULL; keymap_text_len=keymap_insert=0; spare_count=0;
|
||||
}
|
||||
int uu_wl_init(int32_t *w,int32_t *h) {
|
||||
pthread_mutex_lock(&lock);
|
||||
@@ -390,15 +557,15 @@ int uu_wl_init(int32_t *w,int32_t *h) {
|
||||
keymap=xkb_keymap_new_from_names(xkb,&names,XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
if(!keymap) goto end;
|
||||
key_state=xkb_state_new(keymap); if(!key_state) goto end;
|
||||
char *map=xkb_keymap_get_as_string(keymap,XKB_KEYMAP_FORMAT_TEXT_V1);
|
||||
if(!map) goto end;
|
||||
size_t length=strlen(map)+1;
|
||||
int fd=memfd_create("uuremote-keymap",MFD_CLOEXEC);
|
||||
if(fd<0) { free(map); goto end; }
|
||||
if(ftruncate(fd,(off_t)length)!=0 || write(fd,map,length)!=(ssize_t)length) { free(map); close(fd); goto end; }
|
||||
free(map);
|
||||
zwp_virtual_keyboard_v1_keymap(keyboard,WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,fd,length); close(fd);
|
||||
keymap_text=xkb_keymap_get_as_string(keymap,XKB_KEYMAP_FORMAT_TEXT_V1);
|
||||
if(!keymap_text) goto end;
|
||||
keymap_text_len=strlen(keymap_text)+1;
|
||||
if(upload_keymap(keymap_text,keymap_text_len)!=0) goto end;
|
||||
if(sync_display()!=0) goto end;
|
||||
/* Text typing needs unmapped keycodes and a place to declare them. A keymap without either
|
||||
only costs that path - uu_wl_type_utf8 refuses and the caller keeps its own fallback. */
|
||||
keymap_insert=symbols_close(keymap_text);
|
||||
spare_count=find_spare_codes(spare_codes,sizeof(spare_codes)/sizeof(spare_codes[0]));
|
||||
initialized=1; *w=width; *h=height; result=0;
|
||||
end:
|
||||
if(result!=0) reset();
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
# Unofficial UU Remote Linux host in a container, for NAS boxes (Synology DSM, etc.) without a desktop.
|
||||
# Headless mode: file transfer, terminal and port mapping; no remote desktop. Uses the published release binary.
|
||||
FROM ubuntu:24.04
|
||||
ARG VERSION=v0.2.10
|
||||
ARG VERSION=v0.2.13
|
||||
LABEL org.opencontainers.image.source="https://github.com/VallierDev/uu-remote-linux" \
|
||||
org.opencontainers.image.description="Unofficial UU Remote Linux host, headless (file transfer, terminal, port mapping)" \
|
||||
org.opencontainers.image.licenses="GPL-3.0"
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
Wayland(wlroots)手机输入法上屏;登录默认直连,不走环境代理。/ Mobile IME text on wlroots Wayland; cloud API ignores ambient proxies by default.
|
||||
|
||||
### 新增 / Added
|
||||
- **wlroots Wayland 支持手机输入法 `text_input`**(#51,感谢 @hiclaw):手机端输入法提交的文字,
|
||||
在 Hyprland / Sway 等 wlroots 合成器上通过虚拟键盘的备用键码上屏。仅在 Hyprland 0.56.2 上实测;
|
||||
KWin / GNOME(门户后端)仍不支持,见 #50。
|
||||
- Mobile IME `text_input` now types through the virtual keyboard's spare keycodes on wlroots compositors.
|
||||
Tested on Hyprland 0.56.2 only; KWin/GNOME (portal backend) are not covered yet.
|
||||
|
||||
### 变更 / Changed
|
||||
- **云端接口默认忽略代理环境变量**(#52,感谢 @aresbit):本地有拦截 TLS 的 HTTP/SOCKS 代理时,登录会报
|
||||
`tls handshake eof`。现在主机和控制端访问网易服务器默认直连,忽略 `http_proxy` / `https_proxy` / `all_proxy`;
|
||||
确实需要经代理上网的环境请设置 `UU_USE_PROXY=1`。未在拦截代理环境中实机验证,CI 测试通过。
|
||||
- Cloud API clients now bypass `http_proxy` / `https_proxy` / `all_proxy` by default; set `UU_USE_PROXY=1` if your
|
||||
network requires a proxy. Not verified against an intercepting proxy; CI passes.
|
||||
|
||||
### 下载 / Download
|
||||
`uu-remote-linux-v0.2.11-x86_64-linux.tar.gz`(主机 `uuremote-server` + 控制端 `uuremote-viewer`,附带 `contrib/`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.11`。
|
||||
|
||||
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||
@@ -0,0 +1,15 @@
|
||||
修复缩放桌面尺寸为奇数时画面一直「正在传输」。/ Fix the stream never starting when the captured desktop has an odd size.
|
||||
|
||||
### 修复 / Fixed
|
||||
- **奇数尺寸桌面无法出画面**(#53,感谢 @wen0531):KDE Plasma(Wayland,门户后端)150% 缩放、两块屏上下排列时,
|
||||
逻辑桌面为 2560x2507,H.264/HEVC 编码器要求偶数宽高,全部启动失败,客户端一直停在「正在传输画面」。
|
||||
现在原生分辨率采集遇到奇数宽高时,在右/下补齐 1 像素黑边再编码;偶数尺寸、「其他分辨率」缩放不受影响。
|
||||
贡献者已在 KDE Plasma 6.7 / Wayland / NVENC + 官方安卓客户端上实测。进程内编码(`inproc-av`)路径未覆盖。
|
||||
- When the native capture size is odd (e.g. scaled stacked monitors), the encoder input is padded by one black
|
||||
row/column so every H.264/HEVC encoder can open. Verified by the contributor on KDE Plasma 6.7 (Wayland, NVENC).
|
||||
The optional `inproc-av` path is not covered.
|
||||
|
||||
### 下载 / Download
|
||||
`uu-remote-linux-v0.2.12-x86_64-linux.tar.gz`(主机 `uuremote-server` + 控制端 `uuremote-viewer`,附带 `contrib/`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.12`。
|
||||
|
||||
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||
@@ -0,0 +1,25 @@
|
||||
一个包支持所有桌面:Wayland 和 GNOME/KDE 不再需要源码编译。/ One package for every desktop: no source build needed for Wayland or GNOME/KDE.
|
||||
|
||||
### 新增 / Added
|
||||
- **预编译包内置 Wayland 与 GNOME/KDE 支持**(#43、#54):Release 包新增 `libuu-wayland.so`(Hyprland / Sway / niri 等 wlroots)
|
||||
和 `libuu-portal.so`(GNOME / KDE Wayland)。程序按当前会话自动选择后端,只在 Wayland 会话里加载对应插件,X11 用户不需要任何
|
||||
Wayland 库。安装:
|
||||
```sh
|
||||
install -Dm755 uuremote-server ~/.local/bin/uuremote-server
|
||||
install -Dm644 libuu-wayland.so libuu-portal.so -t ~/.local/lib/uu-remote-linux/
|
||||
```
|
||||
系统要求:X11 与 wlroots 为 glibc ≥ 2.35;GNOME/KDE 插件为 glibc ≥ 2.39(Ubuntu 24.04、Fedora 40、Debian 13 及更新)及 libei ≥ 1.1。
|
||||
缺库或版本过旧时日志会写明原因。**验证范围**:插件加载、回退与报错在 Hyprland 虚拟机(ARM)实测,wlroots 采集正常;
|
||||
预编译的 GNOME/KDE 插件尚未在真机上完成画面/键鼠验收(引擎代码本身未改动)。Wayland 仍为实验性。
|
||||
- The release now ships `libuu-wayland.so` and `libuu-portal.so`, loaded at runtime only on Wayland sessions; X11 hosts need no
|
||||
Wayland libraries. The portal plugin requires glibc >= 2.39 and libei >= 1.1. Plugin loading was tested on a Hyprland VM;
|
||||
the prebuilt GNOME/KDE plugin has not yet been accepted on real hardware.
|
||||
|
||||
### 改进 / Improved
|
||||
- 在 GNOME/KDE Wayland 上缺少 portal 支持时,不再反复报看不懂的 `portal unavailable (code 2)`,而是直接说明原因和解决办法(#43)。
|
||||
- README:支持表加入 niri(实验性,协议已按源码确认、未实机验收);systemd 单元名须为 `uuremote-native.service`;uinput 无人值守授权示例(#55)。
|
||||
|
||||
### 下载 / Download
|
||||
`uu-remote-linux-v0.2.13-x86_64-linux.tar.gz`(`uuremote-server`、`uuremote-viewer`、`libuu-wayland.so`、`libuu-portal.so`、`contrib/`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.13`。
|
||||
|
||||
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||
+22
-1
@@ -121,9 +121,24 @@ fn redact_urls(text: &str) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
/// Cloud API clients ignore ambient HTTP/SOCKS proxy settings by default: a local
|
||||
/// proxy that intercepts TLS breaks login and signaling. `UU_USE_PROXY=1` opts back
|
||||
/// into reqwest's standard proxy environment handling.
|
||||
pub fn http_client_builder() -> reqwest::ClientBuilder {
|
||||
let builder = reqwest::Client::builder();
|
||||
if std::env::var("UU_USE_PROXY").ok().as_deref().is_some_and(proxy_requested) {
|
||||
builder
|
||||
} else {
|
||||
builder.no_proxy()
|
||||
}
|
||||
}
|
||||
fn proxy_requested(value: &str) -> bool {
|
||||
matches!(value.trim().to_ascii_lowercase().as_str(), "1" | "true" | "yes" | "on")
|
||||
}
|
||||
|
||||
impl UUAuthClient {
|
||||
pub fn new(creds: Credentials) -> Self {
|
||||
let http = reqwest::Client::builder()
|
||||
let http = http_client_builder()
|
||||
.timeout(std::time::Duration::from_secs(12))
|
||||
.build()
|
||||
.unwrap();
|
||||
@@ -346,4 +361,10 @@ mod guest_tests {
|
||||
let text = super::redact_urls("proxy http://user:[email protected]:3128 failed for (https://api.example/p?token=abc)");
|
||||
assert_eq!(text, "proxy http://proxy.example:3128 failed for (https://api.example/p)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn proxy_opt_in_accepts_only_explicit_truthy_values() {
|
||||
for value in ["1", "true", "TRUE", " yes ", "On"] { assert!(super::proxy_requested(value)); }
|
||||
for value in ["", "0", "false", "no", "off", "2"] { assert!(!super::proxy_requested(value)); }
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
mod native {
|
||||
use std::{ffi::c_void, ptr::NonNull};
|
||||
|
||||
extern "C" {
|
||||
crate::engine_ffi! { crate::engine_plugin::Engine::Portal;
|
||||
fn uu_desktop_power_wake() -> i32;
|
||||
fn uu_desktop_idle_inhibitor_acquire(error: *mut i32) -> *mut c_void;
|
||||
fn uu_desktop_idle_inhibitor_release(inhibitor: *mut c_void);
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
//! Optional desktop engines loaded at runtime (`--features engine-plugins`).
|
||||
//!
|
||||
//! The Wayland (wlroots) and GNOME/KDE portal engines link libwayland/libxkbcommon and
|
||||
//! GIO/PipeWire/libei. Linking them into `uuremote-server` would stop it from starting on X11 hosts
|
||||
//! without those libraries, and libei is missing on older distributions. With engine-plugins they
|
||||
//! are built as `libuu-wayland.so` / `libuu-portal.so`, shipped next to the binary, and opened with
|
||||
//! dlopen only when the session needs them, so one release package serves every backend.
|
||||
//! Without the feature the engines are linked statically as before and nothing here is used.
|
||||
#![cfg_attr(not(feature = "engine-plugins"), allow(dead_code))]
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Engine { Wayland, Portal }
|
||||
|
||||
impl Engine {
|
||||
pub fn file(self) -> &'static str { match self { Self::Wayland => "libuu-wayland.so", Self::Portal => "libuu-portal.so" } }
|
||||
fn index(self) -> usize { self as usize }
|
||||
}
|
||||
|
||||
/// Directories searched for engine libraries, in order.
|
||||
fn search_dirs() -> Vec<std::path::PathBuf> {
|
||||
let mut dirs = Vec::new();
|
||||
if let Some(dir) = std::env::var_os("UU_ENGINE_DIR").filter(|d| !d.is_empty()) { dirs.push(dir.into()); }
|
||||
if let Some(exe_dir) = std::env::current_exe().ok().and_then(|exe| exe.parent().map(|d| d.to_path_buf())) {
|
||||
dirs.push(exe_dir.join("../lib/uu-remote-linux"));
|
||||
dirs.push(exe_dir.clone());
|
||||
}
|
||||
if let Some(home) = std::env::var_os("HOME") { dirs.push(std::path::Path::new(&home).join(".local/lib/uu-remote-linux")); }
|
||||
dirs.extend(["/usr/local/lib/uu-remote-linux", "/usr/lib/uu-remote-linux"].map(std::path::PathBuf::from));
|
||||
dirs
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "engine-plugins"))]
|
||||
mod native {
|
||||
use super::Engine;
|
||||
use std::sync::OnceLock;
|
||||
|
||||
static HANDLES: [OnceLock<Result<usize, String>>; 2] = [OnceLock::new(), OnceLock::new()];
|
||||
|
||||
fn dlerror() -> String {
|
||||
let message = unsafe { libc::dlerror() };
|
||||
if message.is_null() { return "unknown dlopen error".into(); }
|
||||
unsafe { std::ffi::CStr::from_ptr(message) }.to_string_lossy().into_owned()
|
||||
}
|
||||
|
||||
fn open(engine: Engine) -> Result<usize, String> {
|
||||
for dir in super::search_dirs() {
|
||||
let path = dir.join(engine.file());
|
||||
if !path.is_file() { continue; }
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
let Ok(c_path) = std::ffi::CString::new(path.as_os_str().as_bytes()) else { continue };
|
||||
let handle = unsafe { libc::dlopen(c_path.as_ptr(), libc::RTLD_NOW | libc::RTLD_LOCAL) };
|
||||
if handle.is_null() {
|
||||
// Usually a missing system library (e.g. libei.so.1) or a too old glibc.
|
||||
return Err(format!("{} could not be loaded: {}", path.display(), dlerror()));
|
||||
}
|
||||
log::info!("Desktop engine loaded: {}", path.display());
|
||||
return Ok(handle as usize);
|
||||
}
|
||||
Err(format!("{} not found (looked next to uuremote-server, in ../lib/uu-remote-linux, ~/.local/lib/uu-remote-linux, /usr/lib/uu-remote-linux; UU_ENGINE_DIR overrides)", engine.file()))
|
||||
}
|
||||
|
||||
pub fn load(engine: Engine) -> Result<(), String> {
|
||||
HANDLES[engine.index()].get_or_init(|| open(engine)).as_ref().map(|_| ()).map_err(Clone::clone)
|
||||
}
|
||||
|
||||
/// Address of `name` (NUL-terminated) in the engine, or 0 when the engine or symbol is missing.
|
||||
pub fn symbol(engine: Engine, name: &'static str) -> usize {
|
||||
let Ok(handle) = HANDLES[engine.index()].get_or_init(|| open(engine)) else { return 0 };
|
||||
let address = unsafe { libc::dlsym(*handle as *mut libc::c_void, name.as_ptr().cast()) };
|
||||
if address.is_null() { log::warn!("Desktop engine {} lacks {}", engine.file(), name.trim_end_matches('\0')); }
|
||||
address as usize
|
||||
}
|
||||
}
|
||||
|
||||
/// Loads `engine`, or explains why it is unavailable. Always Ok when the engines are linked in.
|
||||
pub fn load(engine: Engine) -> Result<(), String> {
|
||||
#[cfg(all(target_os = "linux", feature = "engine-plugins"))]
|
||||
{ native::load(engine) }
|
||||
#[cfg(not(all(target_os = "linux", feature = "engine-plugins")))]
|
||||
{ let _ = engine; Ok(()) }
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "linux", feature = "engine-plugins"))]
|
||||
pub use native::symbol;
|
||||
|
||||
/// Value returned by an engine call whose library could not be loaded (callers check `load` first).
|
||||
pub trait Missing { fn missing() -> Self; }
|
||||
impl Missing for () { fn missing() -> Self {} }
|
||||
impl Missing for i32 { fn missing() -> Self { -1 } }
|
||||
impl<T> Missing for *mut T { fn missing() -> Self { std::ptr::null_mut() } }
|
||||
|
||||
/// Declares engine C functions: an `extern "C"` block when linked statically, or dlsym-resolved
|
||||
/// wrappers with the same names and signatures with `engine-plugins`.
|
||||
#[macro_export]
|
||||
macro_rules! engine_ffi {
|
||||
($engine:expr; $(fn $name:ident($($arg:ident: $ty:ty),* $(,)?) $(-> $ret:ty)?;)*) => {
|
||||
#[cfg(not(feature = "engine-plugins"))]
|
||||
extern "C" { $(fn $name($($arg: $ty),*) $(-> $ret)?;)* }
|
||||
$(
|
||||
#[cfg(feature = "engine-plugins")]
|
||||
unsafe fn $name($($arg: $ty),*) $(-> $ret)? {
|
||||
static ADDRESS: std::sync::OnceLock<usize> = std::sync::OnceLock::new();
|
||||
let address = *ADDRESS.get_or_init(|| $crate::engine_plugin::symbol($engine, concat!(stringify!($name), "\0")));
|
||||
if address == 0 { return $crate::engine_plugin::Missing::missing(); }
|
||||
let function: unsafe extern "C" fn($($ty),*) $(-> $ret)? = unsafe { std::mem::transmute(address) };
|
||||
unsafe { function($($arg),*) }
|
||||
}
|
||||
)*
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn search_prefers_override_then_package_layout() {
|
||||
let dirs = super::search_dirs();
|
||||
let exe_dir = std::env::current_exe().unwrap().parent().unwrap().to_path_buf();
|
||||
assert!(dirs.iter().position(|d| *d == exe_dir.join("../lib/uu-remote-linux")) < dirs.iter().position(|d| *d == exe_dir));
|
||||
assert_eq!(dirs.last().unwrap(), std::path::Path::new("/usr/lib/uu-remote-linux"));
|
||||
}
|
||||
}
|
||||
+15
-1
@@ -360,13 +360,27 @@ impl InputInjector {
|
||||
if self.backend==crate::desktop_backend::DesktopBackend::Wayland { crate::wayland::key(symbol,pressed) }
|
||||
else { unsafe { x11_key_symbol(symbol as libc::c_ulong,i32::from(pressed)) } }
|
||||
}
|
||||
/// Mobile input-method text (`text_input`). X11 only for now; other backends log once.
|
||||
/// Mobile input-method text (`text_input`). X11 types it directly; Wayland re-maps a spare
|
||||
/// keycode in the virtual keyboard's keymap. Other backends log once.
|
||||
pub fn text_input(&self, text: &str) {
|
||||
let _serial=self.serial.lock().unwrap();
|
||||
let Ok(c_text)=std::ffi::CString::new(text.replace('\0',"")) else { return };
|
||||
if self.backend==crate::desktop_backend::DesktopBackend::X11 {
|
||||
let typed=unsafe { x11_type_utf8(c_text.as_ptr()) };
|
||||
log::info!("Desktop text input: chars={} result={}", text.chars().count(), typed);
|
||||
} else if self.backend==crate::desktop_backend::DesktopBackend::Wayland {
|
||||
// Escape hatch: keep the old behaviour without rebuilding.
|
||||
if std::env::var("UU_WAYLAND_TEXT").is_ok_and(|v|v=="0") { return; }
|
||||
let typed=crate::wayland::type_utf8(text);
|
||||
if typed>=0 {
|
||||
log::info!("Desktop text input: chars={} result={}", text.chars().count(), typed);
|
||||
return;
|
||||
}
|
||||
// A keymap whose keycodes are all mapped cannot carry text; report it once.
|
||||
static WARNED:std::sync::atomic::AtomicBool=std::sync::atomic::AtomicBool::new(false);
|
||||
if !WARNED.swap(true,std::sync::atomic::Ordering::Relaxed) {
|
||||
log::warn!("Mobile text input unavailable on the Wayland backend (no spare keycode in this keymap)");
|
||||
}
|
||||
} else {
|
||||
static WARNED:std::sync::atomic::AtomicBool=std::sync::atomic::AtomicBool::new(false);
|
||||
if !WARNED.swap(true,std::sync::atomic::Ordering::Relaxed) {
|
||||
|
||||
+9
-3
@@ -1,6 +1,7 @@
|
||||
//! UU Remote Pure Native Linux Server (Rust Edition)
|
||||
//! Zero-Wine, Zero-Python, Single-Binary, 5 Native Tools Integrated
|
||||
|
||||
mod engine_plugin;
|
||||
mod desktop_backend;
|
||||
mod desktop_session;
|
||||
mod desktop_power;
|
||||
@@ -190,8 +191,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.filter_module("uuremote_server", log::LevelFilter::Info).init();
|
||||
} else { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); }
|
||||
// An unknown argument must never fall through to starting a second full host server.
|
||||
const SUBCOMMANDS: [&str; 13] = ["show", "assist", "desktop-input-probe", "virtual-audio-probe", "login", "unlock-check", "desktop-probe", "desktop-video-probe", "desktop-audio-probe", "wayland-capture",
|
||||
"wayland-input-probe", "clipboard-acceptance", "portal-acceptance"];
|
||||
const SUBCOMMANDS: [&str; 14] = ["show", "assist", "desktop-input-probe", "virtual-audio-probe", "login", "unlock-check", "desktop-probe", "desktop-video-probe", "desktop-audio-probe", "wayland-capture",
|
||||
"wayland-input-probe", "wayland-text-probe", "clipboard-acceptance", "portal-acceptance"];
|
||||
if let Some(arg) = std::env::args().nth(1).filter(|a| !SUBCOMMANDS.contains(&a.as_str())) {
|
||||
let usage = format!("usage: uuremote-server [{}]\n (no argument: run the host)", SUBCOMMANDS.join(" | "));
|
||||
if matches!(arg.as_str(), "help" | "-h" | "--help") { println!("{usage}"); return Ok(()); }
|
||||
@@ -353,6 +354,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
if std::env::args().nth(1).as_deref() == Some("wayland-input-probe") {
|
||||
return wayland::input_probe().map_err(|e|e.into());
|
||||
}
|
||||
if std::env::args().nth(1).as_deref() == Some("wayland-text-probe") {
|
||||
return wayland::text_probe().map_err(|e|e.into());
|
||||
}
|
||||
if std::env::args().nth(1).as_deref() == Some("wayland-capture") {
|
||||
return wayland::capture_stdout().map_err(|e| e.into());
|
||||
}
|
||||
@@ -409,7 +413,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let capture = Arc::new((if desktop_backend::headless() {
|
||||
Err("headless mode (UU_DESKTOP_BACKEND=none)".to_owned())
|
||||
} else if desktop_backend::detect()?==desktop_backend::DesktopBackend::Portal {
|
||||
Err("Portal capture waits for a desktop CONTROL connection".to_owned())
|
||||
Err(if !cfg!(feature = "portal") { portal::NOT_BUILT.to_owned() }
|
||||
else if let Err(reason) = engine_plugin::load(engine_plugin::Engine::Portal) { format!("GNOME/KDE Wayland (portal) engine unavailable: {reason}") }
|
||||
else { "Portal capture waits for a desktop CONTROL connection".to_owned() })
|
||||
} else { ScreenCapture::new() }).unwrap_or_else(|error| {
|
||||
log::warn!("Desktop unavailable; terminal and file tools remain available: {error}");
|
||||
ScreenCapture::unavailable(error)
|
||||
|
||||
+20
-9
@@ -22,7 +22,7 @@ mod permissions;
|
||||
#[cfg(all(target_os = "linux", feature = "portal"))]
|
||||
mod native {
|
||||
use std::{ffi::c_void, ptr::NonNull, sync::{Mutex, MutexGuard, TryLockError}};
|
||||
extern "C" {
|
||||
crate::engine_ffi! { crate::engine_plugin::Engine::Portal;
|
||||
fn uu_portal_open_persist(restore: *const libc::c_char, save: extern "C" fn(*const libc::c_char, *mut c_void), data: *mut c_void, error: *mut i32, width: *mut u32, height: *mut u32) -> *mut c_void;
|
||||
fn uu_portal_open_persist_cancellable(restore: *const libc::c_char, save: extern "C" fn(*const libc::c_char, *mut c_void), save_data: *mut c_void, cancelled: extern "C" fn(*mut c_void) -> i32, cancel_data: *mut c_void, error: *mut i32, width: *mut u32, height: *mut u32) -> *mut c_void;
|
||||
fn uu_portal_clipboard_supported(portal: *mut c_void) -> i32;
|
||||
@@ -116,6 +116,8 @@ mod native {
|
||||
if cancelled.is_some_and(|value| value.load(std::sync::atomic::Ordering::Acquire)) {
|
||||
return Err(super::PortalError { code: 13 });
|
||||
}
|
||||
// engine-plugins: libuu-portal.so (or one of its libraries) may be missing on this host.
|
||||
crate::engine_plugin::load(crate::engine_plugin::Engine::Portal).map_err(|_| super::PortalError { code: 15 })?;
|
||||
let (mut error, mut width, mut height) = (0, 0, 0);
|
||||
let directory = super::permissions::directory();
|
||||
let key = super::permissions::desktop_key();
|
||||
@@ -584,12 +586,20 @@ fn error(code: i32) -> String {
|
||||
8 => "unsupported frame format or size", 9 => "session closed or stream lost",
|
||||
10 => "frame unavailable", 11 => "invalid input or frame buffer",
|
||||
13 => "operation cancelled", 14 => "dimensions changed; reconnect required",
|
||||
15 => return match crate::engine_plugin::load(crate::engine_plugin::Engine::Portal) {
|
||||
Err(reason) if cfg!(feature = "portal") => format!("GNOME/KDE Wayland (portal) engine unavailable: {reason}"),
|
||||
_ => NOT_BUILT.into(),
|
||||
},
|
||||
_ => "operation failed",
|
||||
};
|
||||
format!("Portal {reason} (code {code})")
|
||||
}
|
||||
fn check(code: i32) -> Result<(), String> { if code == 0 { Ok(()) } else { Err(error(code)) } }
|
||||
|
||||
/// GNOME/KDE Wayland selected the portal backend, but this binary was built without it (the release
|
||||
/// package is X11 only): say how to get a picture instead of an opaque "portal unavailable".
|
||||
pub const NOT_BUILT: &str = "this build has no GNOME/KDE Wayland (portal) support: choose the Xorg session \
|
||||
(\"GNOME on Xorg\" / \"Plasma (X11)\") at the login screen, or build with --features wayland,portal";
|
||||
#[cfg(all(target_os = "linux", feature = "portal"))]
|
||||
pub use native::Session as PortalSession;
|
||||
#[cfg(not(all(target_os = "linux", feature = "portal")))]
|
||||
@@ -598,24 +608,24 @@ pub struct PortalSession { pub width: u32, pub height: u32 }
|
||||
impl PortalSession {
|
||||
pub fn clipboard_supported(&self) -> bool { false }
|
||||
pub fn clipboard_ready(&self) -> bool { false }
|
||||
pub fn clipboard_set(&self, _: &str) -> Result<(), String> { Err(error(2)) }
|
||||
pub fn clipboard_set(&self, _: &str) -> Result<(), String> { Err(error(15)) }
|
||||
pub fn clipboard_poll(&self) -> Option<String> { None }
|
||||
pub fn is_alive(&self) -> bool { false }
|
||||
pub fn open() -> Result<Self, String> { Err("Portal backend requires Linux and --features portal".into()) }
|
||||
pub fn open_cancellable(cancelled: &std::sync::atomic::AtomicBool) -> Result<Self, PortalError> {
|
||||
if cancelled.load(std::sync::atomic::Ordering::Acquire) { Err(PortalError { code: 13 }) }
|
||||
else { Err(PortalError { code: 2 }) }
|
||||
else { Err(PortalError { code: 15 }) }
|
||||
}
|
||||
pub fn recover(&self, cancelled: &std::sync::atomic::AtomicBool) -> Result<bool, PortalError> {
|
||||
if cancelled.load(std::sync::atomic::Ordering::Acquire) { Err(PortalError { code: 13 }) }
|
||||
else { Err(PortalError { code: 2 }) }
|
||||
else { Err(PortalError { code: 15 }) }
|
||||
}
|
||||
pub fn pause(&self) {}
|
||||
pub fn capture(&self, _: &mut [u8]) -> Result<(), String> { Err(error(2)) }
|
||||
pub fn capture_changed(&self, _: &mut [u8], _: &mut Option<FrameVersion>) -> Result<bool, String> { Err(error(2)) }
|
||||
pub fn move_pointer(&self, _: f64, _: f64, _: bool) -> Result<(), String> { Err(error(2)) }
|
||||
pub fn button(&self, _: i32, _: bool) -> Result<(), String> { Err(error(2)) }
|
||||
pub fn key(&self, _: u64, _: bool) -> Result<(), String> { Err(error(2)) }
|
||||
pub fn capture(&self, _: &mut [u8]) -> Result<(), String> { Err(error(15)) }
|
||||
pub fn capture_changed(&self, _: &mut [u8], _: &mut Option<FrameVersion>) -> Result<bool, String> { Err(error(15)) }
|
||||
pub fn move_pointer(&self, _: f64, _: f64, _: bool) -> Result<(), String> { Err(error(15)) }
|
||||
pub fn button(&self, _: i32, _: bool) -> Result<(), String> { Err(error(15)) }
|
||||
pub fn key(&self, _: u64, _: bool) -> Result<(), String> { Err(error(15)) }
|
||||
}
|
||||
|
||||
/// Forward frames in-process into encoder stdin. Cancellation drops the Arc;
|
||||
@@ -641,6 +651,7 @@ mod tests {
|
||||
fn errors_never_include_remote_messages_or_identifiers() {
|
||||
assert!(super::check(4).unwrap_err().contains("cancelled or denied"));
|
||||
assert!(super::check(9).unwrap_err().contains("closed or stream lost"));
|
||||
assert!(super::check(15).unwrap_err().contains("--features wayland,portal"));
|
||||
}
|
||||
#[test]
|
||||
fn portal_error_display_is_fixed_and_sanitized() {
|
||||
|
||||
+42
-5
@@ -286,8 +286,22 @@ fn encoder_options(settings: &VideoSettings, encoder: Encoder, gop: &str, rgb: O
|
||||
options.into_iter().map(str::to_owned).collect()
|
||||
}
|
||||
|
||||
fn scale_options(settings: &VideoSettings, encoder: Encoder) -> Vec<String> {
|
||||
if encoder == Encoder::Vaapi { return vec!["-vf".into(), vaapi_filter(settings.output)]; }
|
||||
/// Filter chain for a capture of `source` size (None when the input size is not known yet, e.g.
|
||||
/// the fixed-input probe). H.264/HEVC 4:2:0 encoders — and NVENC's surface allocation — require
|
||||
/// even frame dimensions, but the captured size is not always even: the portal backend reports the
|
||||
/// compositor's logical desktop size, so two stacked monitors at 150% scale capture 2560x2507 and
|
||||
/// every encoder failed to open ("height not divisible by 2 (2560x2507)" from libx264,
|
||||
/// "InitializeEncoder failed: out of memory (10)" from h264_nvenc), leaving the viewer stuck on the
|
||||
/// 正在传输画面 spinner. When the native capture size is odd, pad the odd row/column; the host
|
||||
/// display mode and every reported capture setting stay untouched.
|
||||
fn scale_options(settings: &VideoSettings, encoder: Encoder, source: Option<(u32,u32)>) -> Vec<String> {
|
||||
const EVEN_PAD: &str = "pad=ceil(iw/2)*2:ceil(ih/2)*2:0:0:black";
|
||||
let odd_capture = settings.output.is_none() && source.is_some_and(|(w,h)| w % 2 != 0 || h % 2 != 0);
|
||||
if encoder == Encoder::Vaapi {
|
||||
let filtered = if odd_capture { format!("{EVEN_PAD},{}", vaapi_filter(None)) } else { vaapi_filter(settings.output) };
|
||||
return vec!["-vf".into(), filtered];
|
||||
}
|
||||
if odd_capture { return vec!["-vf".into(), EVEN_PAD.into()]; }
|
||||
settings.output.map_or_else(Vec::new, |(w,h)| vec!["-vf".into(), format!("scale={w}:{h}:flags=bilinear")])
|
||||
}
|
||||
|
||||
@@ -582,6 +596,7 @@ async fn read_encoder_with(
|
||||
display,size.0,size.1,settings.output,settings.fps,config.cq,max_kbps,encoder.name_for(settings.codec));
|
||||
return read_inprocess(config, latest, sequence, idr, budget).await;
|
||||
}
|
||||
let source_size = size;
|
||||
let size = format!("{}x{}", size.0, size.1);
|
||||
let fps = settings.fps.to_string();
|
||||
// Keep the IDR interval at 2 s whatever the frame rate.
|
||||
@@ -605,7 +620,7 @@ async fn read_encoder_with(
|
||||
"-video_size",&size,"-i",&display,"-an"]);
|
||||
}
|
||||
// 其他分辨率: scale the captured desktop (the host display mode is left untouched).
|
||||
command.args(scale_options(&settings, encoder));
|
||||
command.args(scale_options(&settings, encoder, Some(source_size)));
|
||||
command.args(encoder_options(&settings, encoder, &gop, rgb));
|
||||
// x11grab paces against an absolute schedule; after a capture stall it grabs
|
||||
// back-to-back to "catch up" (measured 69 frames in 200ms). vfr on a 1/FPS
|
||||
@@ -768,7 +783,7 @@ fn probe_input_command(spec:&FfmpegSpec,input:&std::ffi::OsStr,loop_input:bool,s
|
||||
if loop_input { command.args(["-stream_loop","-1"]); }
|
||||
// Override source timestamps so clips and image sequences use the same nominal probe rate.
|
||||
command.args(["-r",&settings.fps.to_string(),"-i"]).arg(input).args(["-map","0:v:0","-an"]);
|
||||
command.args(scale_options(settings,encoder));
|
||||
command.args(scale_options(settings,encoder,None));
|
||||
command.args(encoder_options(settings,encoder,&gop_frames(settings.fps,false).to_string(),None));
|
||||
command.args(timing_args(timing,settings.fps));
|
||||
command.args(["-frames:v",&wanted.to_string(),"-f",if settings.codec==VideoCodec::H265 {"hevc"} else {"h264"},"pipe:1"]);
|
||||
@@ -981,6 +996,28 @@ pub async fn stream_desktop(pc: Arc<RTCPeerConnection>, track: Arc<crate::video_
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn native_frame_dimensions_are_padded_to_even() {
|
||||
// A scaled compositor can report an odd logical desktop (e.g. two stacked 150% monitors →
|
||||
// 2560x2507); H.264/HEVC 4:2:0 encoders reject odd dimensions, so a native-size capture
|
||||
// with a known odd size gets a pad filter. Even sizes, explicit output scaling and the
|
||||
// fixed-input probe (size unknown) keep their existing filter chains.
|
||||
let native = VideoSettings { output: None, ..Default::default() };
|
||||
let pad = "pad=ceil(iw/2)*2:ceil(ih/2)*2:0:0:black";
|
||||
for encoder in [Encoder::Cpu, Encoder::Nvenc] {
|
||||
assert_eq!(scale_options(&native, encoder, Some((2560, 2507))), vec!["-vf".to_string(), pad.to_string()]);
|
||||
assert!(scale_options(&native, encoder, Some((2560, 2508))).is_empty());
|
||||
assert!(scale_options(&native, encoder, None).is_empty());
|
||||
}
|
||||
assert_eq!(scale_options(&native, Encoder::Vaapi, Some((2560, 2507))),
|
||||
vec!["-vf".to_string(), format!("{pad},format=nv12,hwupload")]);
|
||||
assert_eq!(scale_options(&native, Encoder::Vaapi, Some((2560, 2508))),
|
||||
vec!["-vf".to_string(), "format=nv12,hwupload".to_string()]);
|
||||
let scaled = VideoSettings { output: Some((1280, 720)), ..Default::default() };
|
||||
assert_eq!(scale_options(&scaled, Encoder::Cpu, Some((2560, 2507))),
|
||||
vec!["-vf".to_string(), "scale=1280:720:flags=bilinear".to_string()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fixed_input_arguments_share_production_encoding_options() {
|
||||
let spec=FfmpegSpec {program:"ffmpeg".into(),ld_library_path:None,path:None};
|
||||
@@ -993,7 +1030,7 @@ mod tests {
|
||||
let args:Vec<_>=command.as_std().get_args().map(|a|a.to_str().unwrap().to_owned()).collect();
|
||||
let expected=encoder_options(&settings,encoder,&gop_frames(30,false).to_string(),None);
|
||||
assert!(args.windows(expected.len()).any(|w|w==expected));
|
||||
let scale=scale_options(&settings,encoder);
|
||||
let scale=scale_options(&settings,encoder,None);
|
||||
assert!(args.windows(scale.len()).any(|w|w==scale));
|
||||
assert!(args.windows(4).any(|w|w==["-r","30","-i","frames/%05d.png"]));
|
||||
assert!(args.windows(2).any(|w|w==["-frames:v","17"]));
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ pub struct Api {
|
||||
}
|
||||
impl Api {
|
||||
pub fn new(signer: UUAuthClient, base: &str) -> Self {
|
||||
Self { signer, base: base.trim_end_matches('/').into(), http: reqwest::Client::builder().timeout(Duration::from_secs(12)).build().unwrap() }
|
||||
Self { signer, base: base.trim_end_matches('/').into(), http: crate::auth::http_client_builder().timeout(Duration::from_secs(12)).build().unwrap() }
|
||||
}
|
||||
pub async fn join_share(&self, connect_id: &str, connect_code: &str) -> Result<JoinData, Error> {
|
||||
if connect_id.trim().is_empty() || connect_code.trim().is_empty() || connect_id.chars().chain(connect_code.chars()).any(char::is_control) { return Err(Error::InvalidAssist); }
|
||||
|
||||
+52
-1
@@ -1,6 +1,6 @@
|
||||
//! Hyprland/wlroots native backend. No XWayland fallback and no input logging.
|
||||
#[cfg(all(target_os="linux", feature="wayland"))]
|
||||
extern "C" {
|
||||
crate::engine_ffi! { crate::engine_plugin::Engine::Wayland;
|
||||
fn uu_wl_init(out_w: *mut i32, out_h: *mut i32) -> i32;
|
||||
fn uu_wl_capture(buffer: *mut u8, length: usize) -> i32;
|
||||
fn uu_wl_move(x: i32, y: i32, relative: i32) -> i32;
|
||||
@@ -8,6 +8,26 @@ extern "C" {
|
||||
fn uu_wl_key(symbol: u64, pressed: i32) -> i32;
|
||||
fn uu_wl_wake() -> i32;
|
||||
fn uu_wl_release_all() -> i32;
|
||||
fn uu_wl_type_utf8(text: *const libc::c_char) -> i32;
|
||||
fn uu_wl_text_ready() -> i32;
|
||||
}
|
||||
/// How many characters one keymap upload can carry; 0 means this keymap has no spare keycode.
|
||||
pub fn text_ready()->i32 {
|
||||
#[cfg(all(target_os="linux",feature="wayland"))]
|
||||
{ return unsafe { uu_wl_text_ready() }; }
|
||||
#[cfg(not(all(target_os="linux",feature="wayland")))]
|
||||
-1
|
||||
}
|
||||
/// Mobile input-method text (#13/#46). Returns the number of characters typed, or a negative code
|
||||
/// when this keymap has no spare keycode to carry them. Never logs the text.
|
||||
pub fn type_utf8(text:&str)->i32 {
|
||||
#[cfg(all(target_os="linux",feature="wayland"))]
|
||||
{
|
||||
let Ok(c_text)=std::ffi::CString::new(text.replace('\0',"")) else { return -1 };
|
||||
return unsafe { uu_wl_type_utf8(c_text.as_ptr()) };
|
||||
}
|
||||
#[cfg(not(all(target_os="linux",feature="wayland")))]
|
||||
{ let _=text; -1 }
|
||||
}
|
||||
pub fn release_all()->i32 {
|
||||
#[cfg(all(target_os="linux",feature="wayland"))]
|
||||
@@ -18,6 +38,7 @@ pub fn release_all()->i32 {
|
||||
pub fn init() -> Result<(u32,u32),String> {
|
||||
#[cfg(all(target_os="linux", feature="wayland"))]
|
||||
{
|
||||
crate::engine_plugin::load(crate::engine_plugin::Engine::Wayland).map_err(|reason| format!("Wayland engine unavailable: {reason}"))?;
|
||||
let (mut w,mut h)=(0,0);
|
||||
let result=unsafe { uu_wl_init(&mut w,&mut h) };
|
||||
if result != 0 || w <= 0 || h <= 0 {
|
||||
@@ -144,3 +165,33 @@ pub fn input_probe()->Result<(),String> {
|
||||
println!("Wayland test events sent; verify the native GTK acceptance report.");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Local diagnostic for the mobile-text path: report the keymap's capacity for it, then type a
|
||||
/// sample into the focused window. Only the built-in sample is echoed; UU_PROBE_TEXT stays private.
|
||||
pub fn text_probe()->Result<(),String> {
|
||||
init()?;
|
||||
let ready=text_ready();
|
||||
if ready<=0 { return Err("this keymap has no spare keycode: mobile text input cannot be carried".into()); }
|
||||
const SAMPLE:&str="uu remote abc 你好世界";
|
||||
let (sample,builtin)=match std::env::var("UU_PROBE_TEXT") {
|
||||
Ok(value)=>(value,false), Err(_)=>(SAMPLE.to_owned(),true),
|
||||
};
|
||||
println!("Wayland text probe: spare keycodes={ready} characters={} bytes={}",sample.chars().count(),sample.len());
|
||||
if builtin { println!("Sample: {sample}"); }
|
||||
// UU_PROBE_SEQUENCE types each |-separated field as its own call - one text_input message each,
|
||||
// the way the phone's input method sends them - with UU_PROBE_STEP_MS between the calls. One
|
||||
// process means one virtual keyboard, exactly as the host has.
|
||||
let step=std::env::var("UU_PROBE_STEP_MS").ok().and_then(|v|v.parse::<u64>().ok()).unwrap_or(0);
|
||||
let sequence=std::env::var("UU_PROBE_SEQUENCE").unwrap_or_else(|_|sample.clone());
|
||||
let mut typed=0;
|
||||
for (index,message) in sequence.split('|').enumerate() {
|
||||
if index>0 && step>0 { std::thread::sleep(std::time::Duration::from_millis(step)); }
|
||||
let one=type_utf8(message);
|
||||
if one<0 { return Err(format!("Wayland text typing failed ({one})")); }
|
||||
typed+=one;
|
||||
}
|
||||
if typed<0 { return Err(format!("Wayland text typing failed ({typed})")); }
|
||||
println!("Typed {typed} of {} characters in {} calls; check that they match.",
|
||||
sequence.chars().filter(|character|*character!='|').count(),sequence.split('|').count());
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user