mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 16:50:41 +01:00
Portal: keep the first valid frame on a fresh session (#2); CI builds wayland,portal
A new portal session started with was_locked=true, so the first unlocked capture reset the cached frame. A static desktop delivers no new PipeWire frame, so the viewer stayed black until something redrew. Only an observed lock (or a closed stream) now discards the cached frame; an unknown lock state shows a blank frame without clearing it. CI now also builds and tests --features wayland,portal on ubuntu-24.04. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
bff7ad320e
commit
1a3348dfe9
2 files changed
+29
-4
No files matched your search
+15
-4
@@ -50,13 +50,24 @@ mod native {
|
||||
}
|
||||
let pointer = unsafe { uu_portal_open_persist(token.as_ref().map_or(std::ptr::null(), |v| v.as_ptr()), save_token, &mut cache as *mut _ as *mut c_void, &mut error, &mut width, &mut height) };
|
||||
let handle = NonNull::new(pointer).ok_or_else(|| super::error(error))?;
|
||||
Ok(Self { handle: Mutex::new(Handle(handle)), locked: crate::session_lock::watch_locked(), was_locked: std::sync::atomic::AtomicBool::new(true), retry_at: Mutex::new(None), width, height })
|
||||
// A freshly opened session holds no lock-screen frame: only an observed lock (or a
|
||||
// closed stream) must discard the cached frame. Starting "locked" cleared the first
|
||||
// valid frame, and a static desktop sends no new one, so the viewer stayed black (#2).
|
||||
Ok(Self { handle: Mutex::new(Handle(handle)), locked: crate::session_lock::watch_locked(), was_locked: std::sync::atomic::AtomicBool::new(false), retry_at: Mutex::new(None), width, height })
|
||||
}
|
||||
pub fn capture(&self, frame: &mut [u8]) -> Result<(), String> {
|
||||
let mut handle = self.handle.lock().map_err(|_| "Portal session lock poisoned")?;
|
||||
let locked = *self.locked.borrow() != Some(false);
|
||||
if locked || self.was_locked.swap(locked, std::sync::atomic::Ordering::AcqRel) {
|
||||
self.was_locked.store(locked, std::sync::atomic::Ordering::Release);
|
||||
let state = *self.locked.borrow();
|
||||
if state != Some(false) {
|
||||
// Unknown state (watcher not reported yet): show nothing but keep the cached frame.
|
||||
if state == Some(true) {
|
||||
self.was_locked.store(true, std::sync::atomic::Ordering::Release);
|
||||
unsafe { uu_portal_reset_frame(handle.0.as_ptr()) };
|
||||
}
|
||||
super::blank(frame); return Ok(());
|
||||
}
|
||||
if self.was_locked.swap(false, std::sync::atomic::Ordering::AcqRel) {
|
||||
// First unlocked capture after a real lock: drop frames captured while locked.
|
||||
unsafe { uu_portal_reset_frame(handle.0.as_ptr()) };
|
||||
super::blank(frame); return Ok(());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user