13 Commits
Author SHA1 Message Date
Xuc Pan eb9f35968e chore(release): prepare v0.1.2 2026-09-21 21:31:57 +08:00
Xuc Pan 55eaf98e75 fix(hook): align cursor overlay with GDI screen coordinates 2026-09-21 21:22:19 +08:00
dashanlkk a698c54c66 fix(hook): overlay cursor in X11 GDI captures 2026-09-21 21:22:19 +08:00
Xuc Pan c9cfc479dc fix(wine): prefer bundled msvcp140 for UU 4.41 2026-09-20 22:54:50 +08:00
HTwoOhwater fd2368058f fix(bridge): dispatch concurrent hook input without socket lifetime locking 2026-09-20 22:53:27 +08:00
Xuc Pan fba3fb9604 style(icon): update icon 2026-09-05 21:30:26 +08:00
Xuc Pan c5446a2d32 chore(release): prepare v0.1.1
Bump Cargo, Nix, Alpine, AUR, and documented package versions so the release tag includes the finalized cross-platform release workflow.
2026-09-05 14:24:55 +08:00
Xuc Pan ab8fbf23ca fix(release): run AUR publication as one owner
Provision SSH credentials for the unprivileged builder and run clone, metadata generation, commit, and push under that same account.
2026-09-05 14:18:24 +08:00
Xuc Pan 353511b020 fix(release): support isolated authenticated AUR retries
Use the configured AUR key for clone and push with an explicit known-hosts file, and add an AUR-only dispatch mode that avoids rebuilding release packages.
2026-09-05 14:15:53 +08:00
Xuc Pan c123f3832d fix(release): target repository explicitly when uploading 2026-09-05 14:10:16 +08:00
Xuc Pan 0b095e3826 fix(release): retain makepkg artifacts outside temp build
Canonicalize the Arch package destination before entering makepkg's temporary directory and pass the workspace output path explicitly from CI.
2026-09-05 14:05:05 +08:00
Xuc Pan b594047423 ci(release): build pacman packages with makepkg
Build conventional artifacts on Ubuntu and the Arch package in an Arch container, merge both artifact sets, generate one checksum manifest, and publish them together. Allow an explicit manual rebuild to refresh AUR metadata.
2026-09-05 14:00:15 +08:00
Xuc Pan f94239c6a4 fix(release): install nFPM from verified upstream archive
Replace the nonexistent nfpm-action with the official pinned Linux archive and verify it against the upstream checksum before packaging.
2026-09-05 13:53:10 +08:00
21 changed files with 662 additions and 76 deletions

No files matched your search

+2
View File
@@ -20,6 +20,8 @@ jobs:
cargo test --locked --all-targets
cc -std=c11 -O2 -Wall -Wextra -Werror tests/frame-protocol.c -o /tmp/frame-protocol
/tmp/frame-protocol
cc -std=c11 -O2 -Wall -Wextra -Werror tests/cursor-overlay.c -o /tmp/cursor-overlay
/tmp/cursor-overlay
- name: Build
run: cargo build --locked --release
+123 -34
View File
@@ -9,12 +9,23 @@ on:
description: Existing GitHub Release tag to rebuild
required: true
type: string
publish_aur:
description: Publish or refresh the AUR package metadata
required: false
default: false
type: boolean
only_aur:
description: Skip package builds and only publish AUR metadata
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
packages:
conventional-packages:
if: ${{ !inputs.only_aur }}
runs-on: ubuntu-22.04
env:
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }}
@@ -30,51 +41,129 @@ jobs:
binutils-mingw-w64-x86-64 gcc libpipewire-0.3-dev \
gcc-mingw-w64-x86-64 pkg-config zstd
- name: Install nFPM
uses: goreleaser/nfpm-action@v2
with:
version: latest
env:
NFPM_VERSION: 2.47.0
run: |
base="https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}"
archive="nfpm_${NFPM_VERSION}_Linux_x86_64.tar.gz"
curl -fsSLO "$base/$archive"
curl -fsSLO "$base/checksums.txt"
grep " $archive$" checksums.txt | sha256sum --check --strict
sudo tar -xzf "$archive" -C /usr/local/bin nfpm
nfpm --version
- name: Build distribution packages
run: ./packaging/build-packages.sh
- name: Publish GitHub release assets
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "$RELEASE_TAG" \
dist/*.tar.zst dist/*.deb dist/*.rpm dist/SHA256SUMS \
--clobber
- uses: actions/upload-artifact@v4
with:
name: conventional-packages
path: |
dist/*.deb
dist/*.rpm
dist/*-linux-*.tar.zst
if-no-files-found: error
aur:
needs: packages
arch-package:
if: ${{ !inputs.only_aur }}
runs-on: ubuntu-latest
container: archlinux:base-devel
if: ${{ github.event_name == 'release' }}
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}
ref: ${{ github.event.release.tag_name || inputs.tag }}
- name: Install Arch build dependencies
run: |
pacman -Syu --noconfirm \
cargo rust gcc pkgconf pipewire \
mingw-w64-gcc mingw-w64-binutils
- name: Build native pacman package with makepkg
run: |
useradd --create-home builder
chown -R builder:builder "$GITHUB_WORKSPACE"
runuser -u builder -- bash -lc '
cd "$1"
CARGO_BUILD_JOBS=2 cargo build --release --locked
./hook/build.sh
./capture/build.sh
./packaging/build-arch-package.sh "$1/dist"
' _ "$GITHUB_WORKSPACE"
- uses: actions/upload-artifact@v4
with:
name: arch-package
path: |
dist/*.pkg.tar.zst
!dist/uur-debug-*.pkg.tar.zst
if-no-files-found: error
publish:
needs: [conventional-packages, arch-package]
if: ${{ !inputs.only_aur }}
runs-on: ubuntu-latest
env:
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }}
steps:
- uses: actions/download-artifact@v4
with:
pattern: '*-package*'
path: release-assets
merge-multiple: true
- name: Generate combined checksums
working-directory: release-assets
run: sha256sum -- *.deb *.rpm *.tar.zst > SHA256SUMS
- name: Publish GitHub release assets
env:
GH_TOKEN: ${{ github.token }}
run: >-
gh release upload "$RELEASE_TAG" release-assets/* --clobber
--repo "$GITHUB_REPOSITORY"
aur:
needs: publish
runs-on: ubuntu-latest
container: archlinux:base-devel
if: >-
${{ always() && (github.event_name == 'release' || inputs.publish_aur)
&& (inputs.only_aur || needs.publish.result == 'success') }}
env:
RELEASE_TAG: ${{ github.event.release.tag_name || inputs.tag }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name || inputs.tag }}
- name: Install publication tools
run: pacman -Syu --noconfirm curl git openssh
- name: Publish AUR metadata
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
install -Dm0600 /dev/null ~/.ssh/aur
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
git clone ssh://[email protected]/uur.git aur
cp packaging/aur/PKGBUILD packaging/aur/uur.install aur/
version="${RELEASE_TAG#v}"
sed -i "s/^pkgver=.*/pkgver=$version/" aur/PKGBUILD
source_url="https://github.com/${GITHUB_REPOSITORY}/archive/refs/tags/${RELEASE_TAG}.tar.gz"
digest="$(curl -fsSL "$source_url" | sha256sum | cut -d' ' -f1)"
sed -i "s/^sha256sums=.*/sha256sums=('$digest')/" aur/PKGBUILD
useradd --create-home builder
chown -R builder:builder aur
runuser -u builder -- bash -lc 'cd "$1" && makepkg --printsrcinfo > .SRCINFO' _ "$PWD/aur"
git -C aur config user.name uur-release-bot
git -C aur config user.email [email protected]
git -C aur add PKGBUILD uur.install .SRCINFO
git -C aur commit -m "uur $version"
GIT_SSH_COMMAND='ssh -i ~/.ssh/aur -o IdentitiesOnly=yes' git -C aur push
install -d -o builder -g builder -m0700 /home/builder/.ssh
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > /home/builder/.ssh/aur
ssh-keyscan -H aur.archlinux.org > /home/builder/.ssh/known_hosts
chown builder:builder /home/builder/.ssh/aur /home/builder/.ssh/known_hosts
chmod 0600 /home/builder/.ssh/aur /home/builder/.ssh/known_hosts
git_ssh='ssh -i /home/builder/.ssh/aur -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=/home/builder/.ssh/known_hosts'
runuser -u builder -- env \
HOME=/home/builder \
GIT_SSH_COMMAND="$git_ssh" \
RELEASE_TAG="$RELEASE_TAG" \
GITHUB_REPOSITORY="$GITHUB_REPOSITORY" \
bash -lc '
git clone ssh://[email protected]/uur.git "$HOME/aur"
cp "$1/packaging/aur/PKGBUILD" "$1/packaging/aur/uur.install" "$HOME/aur/"
cd "$HOME/aur"
version="${RELEASE_TAG#v}"
sed -i "s/^pkgver=.*/pkgver=$version/" PKGBUILD
source_url="https://github.com/${GITHUB_REPOSITORY}/archive/refs/tags/${RELEASE_TAG}.tar.gz"
digest="$(curl -fsSL "$source_url" | sha256sum | cut -d" " -f1)"
sed -i "s/^sha256sums=.*/sha256sums=(\"$digest\")/" PKGBUILD
makepkg --printsrcinfo > .SRCINFO
git config user.name uur-release-bot
git config user.email [email protected]
git add PKGBUILD uur.install .SRCINFO
if git diff --cached --quiet; then
echo "AUR metadata is already current"
exit 0
fi
git commit -m "uur $version"
git push
' _ "$GITHUB_WORKSPACE"
Generated
+1 -1
View File
@@ -1413,7 +1413,7 @@ dependencies = [
[[package]]
name = "uur"
version = "0.1.0"
version = "0.1.2"
dependencies = [
"anyhow",
"ashpd",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "uur"
version = "0.1.0"
version = "0.1.2"
edition = "2021"
description = "Native Linux companion for NetEase UU Remote: X11/Wayland input and capture, packaged as a regular desktop app"
license = "MIT"
+4 -4
View File
@@ -69,7 +69,7 @@ recipes and release artifacts share one version and filesystem layout.
Install a downloaded release package with pacman:
```bash
sudo pacman -U ./dist/uur-0.1.0-1-x86_64.pkg.tar.zst
sudo pacman -U ./dist/uur-0.1.2-1-x86_64.pkg.tar.zst
```
### AUR
@@ -83,13 +83,13 @@ paru -S uur
### Debian and Ubuntu package family
```bash
sudo apt install ./uur_0.1.0_amd64.deb
sudo apt install ./uur_0.1.2_amd64.deb
```
### Fedora and compatible RPM systems
```bash
sudo dnf install ./uur-0.1.0-1.x86_64.rpm
sudo dnf install ./uur-0.1.2-1.x86_64.rpm
```
On systems with different RPM dependency names, install the dependencies
@@ -98,7 +98,7 @@ manually or use the portable archive.
### Portable archive
```bash
sudo tar --zstd -C / -xf ./uur-0.1.0-linux-x86_64.tar.zst
sudo tar --zstd -C / -xf ./uur-0.1.2-linux-x86_64.tar.zst
```
### Nix and NixOS
+4 -4
View File
@@ -66,7 +66,7 @@ uur run
使用 pacman 安装下载的正式发布包:
```bash
sudo pacman -U ./dist/uur-0.1.0-1-x86_64.pkg.tar.zst
sudo pacman -U ./dist/uur-0.1.2-1-x86_64.pkg.tar.zst
```
### AUR
@@ -80,13 +80,13 @@ paru -S uur
### Debian、Ubuntu 及兼容发行版
```bash
sudo apt install ./uur_0.1.0_amd64.deb
sudo apt install ./uur_0.1.2_amd64.deb
```
### Fedora 及兼容 RPM 发行版
```bash
sudo dnf install ./uur-0.1.0-1.x86_64.rpm
sudo dnf install ./uur-0.1.2-1.x86_64.rpm
```
如果发行版的 RPM 依赖名称不同,请手动安装依赖或使用通用压缩包。
@@ -94,7 +94,7 @@ sudo dnf install ./uur-0.1.0-1.x86_64.rpm
### 通用压缩包
```bash
sudo tar --zstd -C / -xf ./uur-0.1.0-linux-x86_64.tar.zst
sudo tar --zstd -C / -xf ./uur-0.1.2-linux-x86_64.tar.zst
```
### Nix 与 NixOS
Binary file not shown.

Before

Width:  |  Height:  |  Size: 539 KiB

After

Width:  |  Height:  |  Size: 993 KiB

+5 -5
View File
@@ -12,13 +12,13 @@ needed for system-wide package installation.
paru -S uur
# Downloaded release package
sudo pacman -U ./uur-0.1.0-1-x86_64.pkg.tar.zst
sudo pacman -U ./uur-0.1.2-1-x86_64.pkg.tar.zst
```
## Debian, Ubuntu, and derivatives
```bash
sudo apt install ./uur_0.1.0_amd64.deb
sudo apt install ./uur_0.1.2_amd64.deb
```
The same release artifact covers Debian, Ubuntu, Linux Mint, Pop!_OS, KDE neon,
@@ -28,10 +28,10 @@ derivatives.
## Fedora, RHEL, and openSUSE families
```bash
sudo dnf install ./uur-0.1.0-1.x86_64.rpm
sudo dnf install ./uur-0.1.2-1.x86_64.rpm
# openSUSE
sudo zypper install ./uur-0.1.0-1.x86_64.rpm
sudo zypper install ./uur-0.1.2-1.x86_64.rpm
```
This format also covers Fedora derivatives and RPM systems whose repositories
@@ -42,7 +42,7 @@ provide the declared Wine, GLib, PipeWire, and portal dependencies.
The portable archive targets conventional glibc/FHS systems:
```bash
sudo tar --zstd -C / -xf ./uur-0.1.0-linux-x86_64.tar.zst
sudo tar --zstd -C / -xf ./uur-0.1.2-linux-x86_64.tar.zst
```
## Nix and NixOS
+5 -5
View File
@@ -46,7 +46,7 @@ paru -S uur
From a downloaded Arch package:
```bash
sudo pacman -U ./uur-0.1.0-1-x86_64.pkg.tar.zst
sudo pacman -U ./uur-0.1.2-1-x86_64.pkg.tar.zst
```
Install the portal backend supplied or recommended by the selected desktop.
@@ -60,7 +60,7 @@ Zorin OS, elementary OS, KDE neon, TUXEDO OS, Kali Linux, MX Linux, and other
compatible derivatives:
```bash
sudo apt install ./uur_0.1.0_amd64.deb
sudo apt install ./uur_0.1.2_amd64.deb
```
The package manager resolves Wine, PipeWire, and the portal frontend. Install
@@ -74,10 +74,10 @@ dependency names. Install it with the native frontend:
```bash
# Fedora and compatible systems
sudo dnf install ./uur-0.1.0-1.x86_64.rpm
sudo dnf install ./uur-0.1.2-1.x86_64.rpm
# openSUSE family
sudo zypper install ./uur-0.1.0-1.x86_64.rpm
sudo zypper install ./uur-0.1.2-1.x86_64.rpm
```
RHEL, CentOS Stream, Rocky Linux, AlmaLinux, Oracle Linux, Nobara, Ultramarine,
@@ -91,7 +91,7 @@ PCLinuxOS, and similar mutable/FHS systems can use the portable archive when
they provide compatible glibc, Wine, PipeWire, and portal libraries:
```bash
sudo tar --zstd -C / -xf ./uur-0.1.0-linux-x86_64.tar.zst
sudo tar --zstd -C / -xf ./uur-0.1.2-linux-x86_64.tar.zst
```
Alternatively, build and install for one user:
+83
View File
@@ -0,0 +1,83 @@
#ifndef UUR_CURSOR_OVERLAY_H
#define UUR_CURSOR_OVERLAY_H
#include <limits.h>
#include <stdint.h>
typedef struct uur_cursor_rect {
int x;
int y;
int width;
int height;
} uur_cursor_rect;
typedef struct uur_cursor_shape {
/* The hotspot is in the same screen coordinates as the GDI source DC. */
int x;
int y;
int width;
int height;
int hotspot_x;
int hotspot_y;
} uur_cursor_shape;
static inline int uur_cursor_bitmap_height(int mask_height, int has_color)
{
return has_color ? mask_height : mask_height / 2;
}
static inline int uur_map_cursor_overlay(const uur_cursor_rect *source,
const uur_cursor_rect *destination,
const uur_cursor_shape *cursor,
uur_cursor_rect *overlay)
{
int64_t left;
int64_t top;
int64_t scaled_hotspot_x;
int64_t scaled_hotspot_y;
int64_t scaled_width;
int64_t scaled_height;
int64_t mapped_x;
int64_t mapped_y;
if (source->width <= 0 || source->height <= 0 ||
destination->width <= 0 || destination->height <= 0 ||
cursor->width <= 0 || cursor->height <= 0)
return 0;
left = (int64_t)cursor->x - cursor->hotspot_x;
top = (int64_t)cursor->y - cursor->hotspot_y;
/* Keep partially visible cursors at the edges of the captured region. */
if (left >= (int64_t)source->x + source->width ||
top >= (int64_t)source->y + source->height ||
left + cursor->width <= source->x ||
top + cursor->height <= source->y)
return 0;
scaled_hotspot_x = ((int64_t)cursor->hotspot_x * destination->width +
source->width / 2) / source->width;
scaled_hotspot_y = ((int64_t)cursor->hotspot_y * destination->height +
source->height / 2) / source->height;
scaled_width = ((int64_t)cursor->width * destination->width +
source->width / 2) / source->width;
scaled_height = ((int64_t)cursor->height * destination->height +
source->height / 2) / source->height;
mapped_x = (int64_t)destination->x +
(((int64_t)cursor->x - source->x) * destination->width) /
source->width - scaled_hotspot_x;
mapped_y = (int64_t)destination->y +
(((int64_t)cursor->y - source->y) * destination->height) /
source->height - scaled_hotspot_y;
if (mapped_x < INT_MIN || mapped_x > INT_MAX || mapped_y < INT_MIN ||
mapped_y > INT_MAX || scaled_width > INT_MAX ||
scaled_height > INT_MAX)
return 0;
overlay->x = (int)mapped_x;
overlay->y = (int)mapped_y;
overlay->width = scaled_width > 0 ? (int)scaled_width : 1;
overlay->height = scaled_height > 0 ? (int)scaled_height : 1;
return 1;
}
#endif
+73 -4
View File
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "cursor-overlay.h"
#include "frame-protocol.h"
#define UUR_MAGIC 0x50495555u
@@ -328,6 +329,63 @@ static BOOL source_is_screen_dc(HDC source)
GetDeviceCaps(source, TECHNOLOGY) == DT_RASDISPLAY;
}
/* GDI screen captures do not include the X11 hardware cursor. Keep the
* cursor visible in the fallback path used on X11 by compositing Wine's
* current cursor onto the capture destination after the desktop blit. */
static void draw_cursor_overlay(HDC hdc_dest, int x, int y, int width, int height,
int source_x, int source_y, int source_width,
int source_height)
{
CURSORINFO cursor;
ICONINFO icon;
BITMAP mask;
POINT position;
uur_cursor_rect source = {source_x, source_y, source_width, source_height};
uur_cursor_rect destination = {x, y, width, height};
uur_cursor_rect overlay;
uur_cursor_shape shape;
if (hdc_dest == NULL || width <= 0 || height <= 0 || source_width <= 0 ||
source_height <= 0 || source_is_screen_dc(hdc_dest))
return;
ZeroMemory(&cursor, sizeof(cursor));
cursor.cbSize = sizeof(cursor);
if (!GetCursorInfo(&cursor) || !(cursor.flags & CURSOR_SHOWING) ||
!GetCursorPos(&position))
return;
/* Wine can report a visible cursor with a null handle until the first
* real window has selected a class cursor. A generic arrow is preferable
* to dropping the cursor from the remote frame altogether. */
if (cursor.hCursor == NULL)
cursor.hCursor = LoadCursor(NULL, IDC_ARROW);
if (cursor.hCursor == NULL)
return;
ZeroMemory(&icon, sizeof(icon));
if (!GetIconInfo(cursor.hCursor, &icon))
return;
/* GetIconInfo's mask holds the cursor's actual bitmap dimensions. For a
* monochrome cursor the AND/XOR masks are stacked vertically. */
if (icon.hbmMask != NULL &&
GetObjectW(icon.hbmMask, sizeof(mask), &mask) == sizeof(mask)) {
shape.x = position.x;
shape.y = position.y;
shape.width = mask.bmWidth;
shape.height = uur_cursor_bitmap_height(mask.bmHeight,
icon.hbmColor != NULL);
shape.hotspot_x = (int)icon.xHotspot;
shape.hotspot_y = (int)icon.yHotspot;
if (uur_map_cursor_overlay(&source, &destination, &shape, &overlay))
DrawIconEx(hdc_dest, overlay.x, overlay.y, cursor.hCursor,
overlay.width, overlay.height, 0, NULL, DI_NORMAL);
}
if (icon.hbmColor != NULL)
DeleteObject(icon.hbmColor);
if (icon.hbmMask != NULL)
DeleteObject(icon.hbmMask);
}
/* Feed the newest desktop frame into the capture destination by drawing
* our shared-memory frame with StretchDIBits. Works regardless of the
* destination bitmap type (DDB or DIB section). */
@@ -436,21 +494,32 @@ static BOOL try_capture_feed(HDC hdc_dest, int x, int y, DWORD rop,
BOOL WINAPI hook_bit_blt(HDC hdc_dest, int x, int y, int width, int height,
HDC hdc_src, int x_src, int y_src, DWORD rop)
{
BOOL result;
if (try_capture_feed(hdc_dest, x, y, rop, hdc_src, width, height, x_src,
y_src, width, height))
return TRUE;
return original_bit_blt(hdc_dest, x, y, width, height, hdc_src, x_src,
y_src, rop);
result = original_bit_blt(hdc_dest, x, y, width, height, hdc_src, x_src,
y_src, rop);
if (result && (rop & 0x00ffffffu) == SRCCOPY && hdc_src != NULL &&
source_is_screen_dc(hdc_src))
draw_cursor_overlay(hdc_dest, x, y, width, height, x_src, y_src,
width, height);
return result;
}
BOOL WINAPI hook_stretch_blt(HDC hdc_dest, int x, int y, int w, int h,
HDC hdc_src, int xs, int ys, int sw, int sh,
DWORD rop)
{
BOOL result;
if (try_capture_feed(hdc_dest, x, y, rop, hdc_src, w, h, xs, ys, sw, sh))
return TRUE;
return original_stretch_blt(hdc_dest, x, y, w, h, hdc_src, xs, ys, sw,
sh, rop);
result = original_stretch_blt(hdc_dest, x, y, w, h, hdc_src, xs, ys, sw,
sh, rop);
if (result && (rop & 0x00ffffffu) == SRCCOPY && hdc_src != NULL &&
source_is_screen_dc(hdc_src))
draw_cursor_overlay(hdc_dest, x, y, w, h, xs, ys, sw, sh);
return result;
}
/* ---- diagnostics ------------------------------------------------------ */
+1 -1
View File
@@ -23,7 +23,7 @@ let
in
rustPlatform.buildRustPackage {
pname = "uur";
version = "0.1.0";
version = "0.1.2";
src = lib.cleanSource ../.;
cargoLock.lockFile = ../Cargo.lock;
+1 -1
View File
@@ -1,7 +1,7 @@
# Contributor: uur contributors
# Maintainer: uur contributors
pkgname=uur
pkgver=0.1.0
pkgver=0.1.2
pkgrel=0
pkgdesc="Native Linux companion for NetEase UU Remote"
url="https://github.com/panxuc/uur"
+2 -2
View File
@@ -1,6 +1,6 @@
pkgbase = uur
pkgdesc = Native Linux companion for NetEase UU Remote (X11/Wayland input and capture bridge)
pkgver = 0.1.0
pkgver = 0.1.2
pkgrel = 1
url = https://github.com/panxuc/uur
install = uur.install
@@ -31,7 +31,7 @@ pkgbase = uur
optdepends = libva-utils: VA-API capability diagnostics
optdepends = vulkan-tools: Vulkan and Vulkan Video capability diagnostics
optdepends = nvidia-utils: NVENC and NVDEC capability diagnostics on NVIDIA GPUs
source = uur-0.1.0.tar.gz::https://github.com/panxuc/uur/archive/refs/tags/v0.1.0.tar.gz
source = uur-0.1.2.tar.gz::https://github.com/panxuc/uur/archive/refs/tags/v0.1.2.tar.gz
sha256sums = SKIP
pkgname = uur
+1 -1
View File
@@ -8,7 +8,7 @@
# `uur setup` (it is never redistributed by this package).
pkgname=uur
pkgver=0.1.0
pkgver=0.1.2
pkgrel=1
pkgdesc="Native Linux companion for NetEase UU Remote (X11/Wayland input and capture bridge)"
arch=('x86_64')
+3 -1
View File
@@ -4,6 +4,9 @@ set -euo pipefail
project_root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd -P)
version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' "$project_root/Cargo.toml" | head -n1)
output=${1:-$project_root/dist}
mkdir -p "$output"
output=$(cd -- "$output" && pwd -P)
readonly output
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/uur-makepkg.XXXXXX")
trap 'rm -rf -- "$build_dir"' EXIT
@@ -12,7 +15,6 @@ command -v makepkg >/dev/null 2>&1 || {
exit 2
}
mkdir -p "$output"
sed -e "s|@UUR_VERSION@|$version|g" \
-e "s|@UUR_PROJECT_ROOT@|$project_root|g" \
"$project_root/packaging/arch/PKGBUILD.in" >"$build_dir/PKGBUILD"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 57 KiB

+3
View File
@@ -12,5 +12,8 @@ cargo test --manifest-path "$project_root/Cargo.toml" --all-targets
cc -std=c11 -O2 -Wall -Wextra -Werror \
"$project_root/tests/frame-protocol.c" -o "$temporary/frame-protocol"
"$temporary/frame-protocol"
cc -std=c11 -O2 -Wall -Wextra -Werror \
"$project_root/tests/cursor-overlay.c" -o "$temporary/cursor-overlay"
"$temporary/cursor-overlay"
"$project_root/hook/build.sh"
"$project_root/capture/build.sh"
+277 -7
View File
@@ -1,12 +1,122 @@
use anyhow::{Context, Result};
use std::collections::{HashMap, HashSet};
use std::io::Read;
use std::net::{TcpListener, TcpStream};
use std::sync::{Arc, Mutex};
use std::thread;
use crate::config::Config;
use crate::input;
use crate::protocol::{self, RECORD_BYTES, RECORD_HELLO};
struct SharedInput {
backend: Box<dyn input::InputBackend>,
keys: HashMap<u16, usize>,
buttons: HashMap<u16, usize>,
}
struct ConnectionInput {
shared: Arc<Mutex<SharedInput>>,
name: &'static str,
keys: HashSet<u16>,
buttons: HashSet<u16>,
}
impl ConnectionInput {
fn press(&mut self, code: u16, down: bool, keyboard: bool) -> Result<()> {
let mut shared = self.shared.lock().unwrap();
let held = if keyboard {
&mut self.keys
} else {
&mut self.buttons
};
let owners = if keyboard {
&shared.keys
} else {
&shared.buttons
};
let count = owners.get(&code).copied().unwrap_or(0);
if !down && !held.contains(&code) {
return Ok(());
}
if down || count <= 1 {
if keyboard {
shared.backend.key(code, down)?;
} else {
shared.backend.button(code, down)?;
}
}
let owners = if keyboard {
&mut shared.keys
} else {
&mut shared.buttons
};
if down {
if held.insert(code) {
*owners.entry(code).or_default() += 1;
}
} else {
held.remove(&code);
if count <= 1 {
owners.remove(&code);
} else {
owners.insert(code, count - 1);
}
}
Ok(())
}
}
impl input::InputBackend for ConnectionInput {
fn name(&self) -> &'static str {
self.name
}
fn key(&mut self, code: u16, down: bool) -> Result<()> {
self.press(code, down, true)
}
fn button(&mut self, code: u16, down: bool) -> Result<()> {
self.press(code, down, false)
}
fn motion(&mut self, absolute: bool, x: i32, y: i32) -> Result<()> {
self.shared.lock().unwrap().backend.motion(absolute, x, y)
}
fn wheel(&mut self, horizontal: bool, delta: i32) -> Result<()> {
self.shared.lock().unwrap().backend.wheel(horizontal, delta)
}
fn release_all(&mut self) -> Result<()> {
let mut error = None;
for code in self.keys.clone() {
if let Err(e) = self.key(code, false) {
error = Some(e);
}
}
for code in self.buttons.clone() {
if let Err(e) = self.button(code, false) {
error = Some(e);
}
}
// A disconnected client must not retain ownership if a release fails.
let mut shared = self.shared.lock().unwrap();
for code in self.keys.drain() {
if let Some(count) = shared.keys.get_mut(&code) {
*count -= 1;
if *count == 0 {
shared.keys.remove(&code);
}
}
}
for code in self.buttons.drain() {
if let Some(count) = shared.buttons.get_mut(&code) {
*count -= 1;
if *count == 0 {
shared.buttons.remove(&code);
}
}
}
error.map_or(Ok(()), Err)
}
}
/// Print the X11 pointer position — the before/after observable for hook
/// verification.
pub fn print_pointer() -> Result<()> {
@@ -19,8 +129,8 @@ pub fn print_pointer() -> Result<()> {
Ok(())
}
/// Serve the in-client hook: one authenticated loopback connection at a
/// time, records dispatched to the selected input backend.
/// Serve authenticated loopback hook connections, serializing individual
/// input events without holding the backend lock while waiting for records.
pub fn serve() -> Result<()> {
let config = Config::load()?;
let preferred =
@@ -29,7 +139,12 @@ pub fn serve() -> Result<()> {
if let Some(path) = std::env::var_os("UUR_BACKEND_STATUS") {
std::fs::write(path, selected.name()).context("writing backend status")?;
}
let backend = std::sync::Arc::new(std::sync::Mutex::new(selected));
let backend_name = selected.name();
let backend = Arc::new(Mutex::new(SharedInput {
backend: selected,
keys: HashMap::new(),
buttons: HashMap::new(),
}));
let backend_handle = backend.clone();
let addr = format!("127.0.0.1:{}", config.bridge_port);
let listener = TcpListener::bind(&addr).with_context(|| format!("binding {addr}"))?;
@@ -52,9 +167,16 @@ pub fn serve() -> Result<()> {
Ok(false) => return,
Err(_) => return,
}
let mut guard = backend_handle.lock().unwrap();
println!("{}", t!("bridge.connected", backend = guard.name()));
match pump(&mut stream, guard.as_mut()) {
use input::InputBackend;
// Read sockets without holding the shared desktop input lock.
let mut connection = ConnectionInput {
shared: backend_handle,
name: backend_name,
keys: HashSet::new(),
buttons: HashSet::new(),
};
println!("{}", t!("bridge.connected", backend = connection.name()));
match pump(&mut stream, &mut connection) {
Ok(count) => {
println!("{}", t!("bridge.session_summary", count = count));
println!("{}", t!("bridge.disconnected_clean"));
@@ -66,7 +188,7 @@ pub fn serve() -> Result<()> {
);
}
}
let _ = guard.release_all();
let _ = connection.release_all();
});
}
Ok(())
@@ -165,3 +287,151 @@ fn tokens_differ(a: &[u8; 32], b: &[u8; 32]) -> bool {
}
diff != 0
}
#[cfg(test)]
mod tests {
use super::*;
use crate::input::InputBackend;
use std::io::Write;
use std::sync::mpsc;
use std::time::Duration;
struct Recorder(mpsc::Sender<String>);
impl InputBackend for Recorder {
fn name(&self) -> &'static str {
"test"
}
fn key(&mut self, code: u16, down: bool) -> Result<()> {
self.0.send(format!("key {code} {down}"))?;
Ok(())
}
fn button(&mut self, code: u16, down: bool) -> Result<()> {
self.0.send(format!("button {code} {down}"))?;
Ok(())
}
fn motion(&mut self, _: bool, _: i32, _: i32) -> Result<()> {
self.0.send("motion".into())?;
Ok(())
}
fn wheel(&mut self, _: bool, _: i32) -> Result<()> {
Ok(())
}
fn release_all(&mut self) -> Result<()> {
panic!("must release only owned inputs")
}
}
fn connection(shared: &Arc<Mutex<SharedInput>>) -> ConnectionInput {
ConnectionInput {
shared: shared.clone(),
name: "test",
keys: HashSet::new(),
buttons: HashSet::new(),
}
}
fn shared() -> (Arc<Mutex<SharedInput>>, mpsc::Receiver<String>) {
let (tx, rx) = mpsc::channel();
(
Arc::new(Mutex::new(SharedInput {
backend: Box::new(Recorder(tx)),
keys: HashMap::new(),
buttons: HashMap::new(),
})),
rx,
)
}
#[test]
fn idle_connection_does_not_block_another_connections_motion() {
let (shared, events) = shared();
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let mut client = TcpStream::connect(listener.local_addr().unwrap()).unwrap();
let (mut server, _) = listener.accept().unwrap();
let mut idle = connection(&shared);
let thread = thread::spawn(move || pump(&mut server, &mut idle).unwrap());
let mut packet = Vec::new();
for value in [
protocol::MAGIC,
1,
protocol::RECORD_MOUSE,
16,
protocol::RECORD_MOUSE,
] {
packet.extend_from_slice(&value.to_le_bytes());
}
packet.extend_from_slice(&0xffffu16.to_le_bytes());
packet.extend_from_slice(&0u16.to_le_bytes());
packet.extend_from_slice(&1i32.to_le_bytes());
packet.extend_from_slice(&0i32.to_le_bytes());
client.write_all(&packet).unwrap();
assert_eq!(
events.recv_timeout(Duration::from_secs(2)).unwrap(),
"motion"
);
let mut other = connection(&shared);
let other_thread = thread::spawn(move || other.motion(false, 1, 0).unwrap());
let delivered = events.recv_timeout(Duration::from_secs(2));
drop(client);
thread.join().unwrap();
other_thread.join().unwrap();
assert_eq!(delivered.unwrap(), "motion");
}
#[test]
fn disconnect_preserves_keys_and_buttons_held_by_another_connection() {
let (shared, events) = shared();
let mut first = connection(&shared);
let mut second = connection(&shared);
first.key(65, true).unwrap();
second.key(65, true).unwrap();
first.button(1, true).unwrap();
second.button(1, true).unwrap();
first.release_all().unwrap();
assert_eq!(
events.try_iter().collect::<Vec<_>>(),
[
"key 65 true",
"key 65 true",
"button 1 true",
"button 1 true"
]
);
second.release_all().unwrap();
assert_eq!(
events.try_iter().collect::<Vec<_>>(),
["key 65 false", "button 1 false"]
);
}
#[test]
fn disconnect_forgets_ownership_when_backend_release_fails() {
let (shared, events) = shared();
let mut client = connection(&shared);
client.key(65, true).unwrap();
client.button(1, true).unwrap();
drop(events);
assert!(client.release_all().is_err());
assert!(client.keys.is_empty());
assert!(client.buttons.is_empty());
let shared = shared.lock().unwrap();
assert!(shared.keys.is_empty());
assert!(shared.buttons.is_empty());
}
#[test]
fn repeated_press_is_released_once_and_unowned_release_is_ignored() {
let (shared, events) = shared();
let mut first = connection(&shared);
let mut second = connection(&shared);
first.key(65, true).unwrap();
first.key(65, true).unwrap();
second.key(65, false).unwrap();
first.release_all().unwrap();
assert_eq!(
events.try_iter().collect::<Vec<_>>(),
["key 65 true", "key 65 true", "key 65 false"]
);
assert!(shared.lock().unwrap().keys.is_empty());
}
}
+35 -5
View File
@@ -141,13 +141,15 @@ pub fn setup(accept_eula: bool) -> Result<()> {
/// - GameViewerServer.exe sees Windows 10 because current UU terminal builds
/// gate their ConPTY transport on the OS version. Native input and display
/// adapters handle the hardware capabilities separately;
/// - the UU client and service prefer their bundled msvcp140 runtime. Wine 10's
/// builtin implementation can stall UU 4.41 before the WebView starts;
/// - the service must auto-start;
/// - X11 focus/XIM tuning and CJK font substitution keep the controller
/// usable.
type RegistryEntry = (String, Vec<(&'static str, &'static str, &'static str)>);
pub fn apply_registry_compat(prefix: &Path) -> Result<()> {
let entries: Vec<RegistryEntry> = vec![
fn registry_compat_entries() -> Vec<RegistryEntry> {
vec![
(
r#"Software\Wine\AppDefaults\msedgewebview2.exe"#.to_string(),
vec![("Version", "REG_SZ", "win8")],
@@ -156,6 +158,14 @@ pub fn apply_registry_compat(prefix: &Path) -> Result<()> {
r#"Software\Wine\AppDefaults\GameViewerServer.exe"#.to_string(),
vec![("Version", "REG_SZ", "win10")],
),
(
r#"Software\Wine\AppDefaults\gameviewer.exe\DllOverrides"#.to_string(),
vec![("msvcp140", "REG_SZ", "native,builtin")],
),
(
r#"Software\Wine\AppDefaults\GameViewerServer.exe\DllOverrides"#.to_string(),
vec![("msvcp140", "REG_SZ", "native,builtin")],
),
(
r"System\CurrentControlSet\Services\GameViewerService".to_string(),
vec![("Start", "REG_DWORD", "2")],
@@ -175,15 +185,17 @@ pub fn apply_registry_compat(prefix: &Path) -> Result<()> {
("MS Shell Dlg 2", "REG_SZ", "Noto Sans CJK SC"),
],
),
];
]
}
for (key, values) in &entries {
pub fn apply_registry_compat(prefix: &Path) -> Result<()> {
for (key, values) in registry_compat_entries() {
let full = if key.starts_with("System") {
format!("HKLM\\{key}")
} else {
format!("HKCU\\{key}")
};
for (value, reg_type, data) in values {
for (value, reg_type, data) in &values {
let _ = Command::new("wine")
.env("WINEPREFIX", prefix)
.env("WINEDEBUG", wine_debug())
@@ -407,3 +419,21 @@ fn purge_wine_shortcuts() {
}
}
}
#[cfg(test)]
mod tests {
use super::registry_compat_entries;
#[test]
fn bundled_cpp_runtime_is_preferred_for_both_uu_processes() {
let entries = registry_compat_entries();
for executable in ["gameviewer.exe", "GameViewerServer.exe"] {
let key = format!(r"Software\Wine\AppDefaults\{executable}\DllOverrides");
let values = entries
.iter()
.find_map(|(entry, values)| (entry == &key).then_some(values))
.unwrap_or_else(|| panic!("missing DLL overrides for {executable}"));
assert!(values.contains(&("msvcp140", "REG_SZ", "native,builtin")));
}
}
}
+38
View File
@@ -0,0 +1,38 @@
#include <assert.h>
#include "../hook/cursor-overlay.h"
int main(void)
{
uur_cursor_rect source = {0, 0, 1920, 1080};
uur_cursor_rect destination = {0, 0, 1920, 1080};
uur_cursor_rect overlay;
uur_cursor_shape cursor = {100, 200, 64, 48, 16, 8};
/* A negative virtual-screen origin must not shift a primary-screen blit. */
assert(uur_map_cursor_overlay(&source, &destination, &cursor, &overlay));
assert(overlay.x == 84 && overlay.y == 192);
assert(overlay.width == 64 && overlay.height == 48);
source.x = -1920;
cursor.x = -1820;
assert(uur_map_cursor_overlay(&source, &destination, &cursor, &overlay));
assert(overlay.x == 84);
/* StretchBlt scales the cursor bitmap and hotspot together. */
destination.width = 960;
destination.height = 540;
assert(uur_map_cursor_overlay(&source, &destination, &cursor, &overlay));
assert(overlay.x == 42 && overlay.y == 96);
assert(overlay.width == 32 && overlay.height == 24);
/* A cursor overlapping the capture edge remains partially visible. */
cursor.x = -1925;
assert(uur_map_cursor_overlay(&source, &destination, &cursor, &overlay));
cursor.x = -2000;
assert(!uur_map_cursor_overlay(&source, &destination, &cursor, &overlay));
assert(uur_cursor_bitmap_height(48, 1) == 48);
assert(uur_cursor_bitmap_height(96, 0) == 48);
return 0;
}