mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 16:50:41 +01:00
* viewer: decode at the host's native size and filter window scaling Every frame was scaled into a fixed 1920x1080 canvas and SDL then stretched it to the window with nearest-neighbour sampling, so remote text looked uneven and blurry. Decode at the native size (read from ffmpeg's verbose scaler line), restart the decoder when the host resolution changes, and use linear render scaling. UU_VIEWER_SIZE keeps the fixed canvas, now resampled with Lanczos. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Add Chinese/English UI language All GTK windows (viewer launcher, tool windows, host main window and QR login) and viewer messages are available in Chinese and English. The language comes from UU_LANG, the choice saved in Settings -> General, then the locale. README: document the fork's changes and language selection. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Host main window: add the language selector Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer: control center, network status, loading screen, device previews In-window chrome drawn on the SDL canvas with a fontconfig font (ab_glyph): - loading animation with the connection stage instead of a black window - control center (Ctrl+Alt+M or the top tab): quality, fps, true color, resolution, fit/1:1, volume, auto lock and host mute (SimpleAction 19, 14/18/16), system shortcut grab, file transfer, watch mode, full screen, disconnect - network status panel (Ctrl+Alt+G): time, route, fps, bitrate, RTT, loss - launcher device previews from the last remote picture (local 0600 cache) - viewer sign-in keeps the local host user service running, so this computer joins the account's device list; the settings switch controls it Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer: compact cascading control center Narrow category list with an options card beside the selected row, sized to its content; opaque cards with a hairline border and soft shadow, so the remote picture no longer shows through. Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer: keep the control center responsive; resync on a key frame The menu was rasterized on every mouse event just to hit-test it; hit testing now uses the layout alone and the drawn menu is cached until what it shows changes. A stalled UI overflowed the access-unit queue, and the reset decoder then smeared P-frames into blocks; after a reset it now waits for an IDR/IRAP while requesting key frames. The tab icon is drawn, since fonts without U+2630 showed a box. Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer: measured RTT, no crash on closing tool windows, account card webrtc-ice never measured the round trip, so the network panel always read 'RTT --'. Binding responses now record it on their pair, and the selected pair is pinged when the sample is older than the keepalive interval, since a streaming pair never idles (vendor/webrtc-ice/PATCHES.md). On Wayland, libdecor's GTK plugin drew SDL's title bar with GTK3 from SDL's thread while the file window ran gtk_main on its own; closing that window crashed in GTK's style code. GTK builds now offer libdecor only the cairo plugin unless LIBDECOR_PLUGIN_DIR is set. Settings > General gets an Account card with the signed-in user and Sign out. Co-Authored-By: Claude Opus 5.5 <[email protected]> * README: keep the language section, without the fork notes Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer: English server errors in the English UI; stable type_ipc tests UU servers answer in Chinese only. The English UI now translates the known messages (2002 target already controlled, assistance refusals) and shows the code for unknown ones instead of Chinese text. type_ipc tests shared one temp directory per process and read XDG_RUNTIME_DIR while another test pointed it at a planted directory; each call now gets its own directory and socket tests hold the environment lock. Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer launcher: switching the language restarts the launcher The choice was saved but took effect only on the next start, so the window seemed to ignore it. The launcher now re-executes itself in place; session windows are separate processes and stay connected. Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer: show pictures as soon as decoded; coalesce mouse motion The raw-stream parser closed an access unit only when the next began, and frames were collected only when another one arrived, so a single remote change (a typed letter) waited for the next one. An access unit delimiter now follows each unit and the loop drains finished frames between units. Motions within one 8 ms poll collapse to the newest position (click order kept), so a drag no longer queues behind itself on a relayed path. Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer launcher: hosting is opt-in Signing in to the viewer no longer installs or enables uuremote-native.service. Only the Settings switch enables or disables it, and the unit's enabled state is the saved choice, so turning it off survives a restart. A new sign-in restarts the host only when the user turned it on and it is running. PATCHES.md: the RTT keepalive also runs on the host; checked with the official Android client controlling a Linux host. Co-Authored-By: Claude Opus 5.5 <[email protected]> * viewer: drop SDL event types sdl2 0.37 does not define sdl2 0.37 transmutes every event type into SDL_EventType. sdl2-compat on SDL3 delivers types SDL 2 does not define (0x207), which is undefined behaviour and aborts with debug checks (clipboard_requests_use_existing_window on Fedora 44). Poll raw events and skip those types before the crate converts them. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Keep the package version at 0.2.39 The maintainer sets the version at release time. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
59 lines
3.5 KiB
Rust
59 lines
3.5 KiB
Rust
//! Device preview pictures for the launcher, like the official client's device card: the desktop
|
|
//! window saves a small PNG of the last remote picture. Local only (`$XDG_CACHE_HOME/uuremote/thumbs`,
|
|
//! 0700 directory, 0600 files); `UU_VIEWER_THUMBNAILS=0` turns it off.
|
|
use std::path::PathBuf;
|
|
|
|
pub fn enabled() -> bool { std::env::var("UU_VIEWER_THUMBNAILS").as_deref() != Ok("0") }
|
|
fn dir() -> Option<PathBuf> {
|
|
let base = std::env::var_os("XDG_CACHE_HOME").map(PathBuf::from).filter(|p| p.is_absolute())
|
|
.or_else(|| std::env::var_os("HOME").map(|h| PathBuf::from(h).join(".cache")))?;
|
|
Some(base.join("uuremote").join("thumbs"))
|
|
}
|
|
pub fn path(device: &str) -> Option<PathBuf> { Some(dir()?.join(format!("{}.png", &super::type_ipc::device_key(device)[..32]))) }
|
|
pub fn existing(device: &str) -> Option<PathBuf> { enabled().then(|| path(device)).flatten().filter(|p| p.is_file()) }
|
|
|
|
/// Box-filtered downscale of the content rectangle to at most `max_w` pixels wide.
|
|
pub fn downscale(width: u32, height: u32, rgb: &[u8], content: (u32, u32, u32, u32), max_w: u32) -> (u32, u32, Vec<u8>) {
|
|
let (cx, cy, cw, ch) = content;
|
|
let ratio = (cw as f64 / max_w as f64).max(1.);
|
|
let (w, h) = (((cw as f64 / ratio).round() as u32).max(1), ((ch as f64 / ratio).round() as u32).max(1));
|
|
let mut out = Vec::with_capacity(w as usize * h as usize * 3);
|
|
for y in 0..h { for x in 0..w {
|
|
let (x0, x1) = (cx + (x as f64 * ratio) as u32, (cx + ((x + 1) as f64 * ratio) as u32).max(cx + (x as f64 * ratio) as u32 + 1).min(cx + cw).min(width));
|
|
let (y0, y1) = (cy + (y as f64 * ratio) as u32, (cy + ((y + 1) as f64 * ratio) as u32).max(cy + (y as f64 * ratio) as u32 + 1).min(cy + ch).min(height));
|
|
let mut sum = [0u64; 3]; let mut n = 0u64;
|
|
for sy in y0..y1 { for sx in x0..x1 {
|
|
let i = (sy as usize * width as usize + sx as usize) * 3;
|
|
for k in 0..3 { sum[k] += u64::from(rgb[i + k]); } n += 1;
|
|
}}
|
|
for k in 0..3 { out.push((sum[k] / n.max(1)) as u8); }
|
|
}}
|
|
(w, h, out)
|
|
}
|
|
|
|
pub fn save(device: &str, frame: &super::desktop::Frame) -> Result<(), String> {
|
|
if !enabled() { return Ok(()) }
|
|
let path = path(device).ok_or("No cache directory")?;
|
|
let dir = path.parent().ok_or("No cache directory")?;
|
|
use std::os::unix::fs::{DirBuilderExt, PermissionsExt};
|
|
std::fs::DirBuilder::new().recursive(true).mode(0o700).create(dir).map_err(|_| "Cannot create the thumbnail directory")?;
|
|
let _ = std::fs::set_permissions(dir, std::fs::Permissions::from_mode(0o700));
|
|
let content = super::input::content_rect((frame.width, frame.height), frame.content.unwrap_or((frame.width, frame.height)))
|
|
.map_or((0, 0, frame.width, frame.height), |(x, y, w, h)| (x as u32, y as u32, w as u32, h as u32));
|
|
let (w, h, rgb) = downscale(frame.width, frame.height, &frame.rgb, content, 640);
|
|
// Write then rename, so the launcher never reads a half-written file.
|
|
let tmp = path.with_extension("tmp");
|
|
let _ = std::fs::remove_file(&tmp);
|
|
super::type_ipc::write_png_rgb(&tmp, w, h, &rgb, true)?;
|
|
std::fs::rename(&tmp, &path).map_err(|_| "Cannot store the thumbnail".into())
|
|
}
|
|
|
|
#[cfg(test)] mod tests {
|
|
#[test] fn downscale_averages_and_keeps_aspect(){
|
|
let rgb:Vec<u8>=(0..4*2).flat_map(|i|if i%2==0{[0,0,0]}else{[200,100,50]}).collect();
|
|
let (w,h,out)=super::downscale(4,2,&rgb,(0,0,4,2),2);
|
|
assert_eq!((w,h),(2,1));assert_eq!(&out[..3],&[100,50,25]);
|
|
assert_eq!(super::downscale(4,2,&rgb,(0,0,4,2),640).0,4);
|
|
}
|
|
}
|