mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-17 01:00:41 +01:00
GNOME Portal:多显示器切换、精确触控、断开后停止共享 (#128)
* portal: switch monitors on GNOME, precise touch, stop sharing when idle GNOME grants one monitor per portal consent and refuses multi-select, so each Mutter monitor gets its own saved consent (gnome@<connector>). The monitors are advertised as screens; a switch opens that monitor's session (silently once consented, GNOME asks on the host the first time) and swaps it into the shared PortalSession, whose frame size follows the monitor. Absolute motion and clicks go through the portal session: a uinput tablet spans every monitor, and clicks on the separate uinput queue could land before the compositor moved the pointer. An idle watch ends the portal session (screen-share indicator off) once no desktop controller is left for two checks; the next one reopens it with the saved consent. Co-Authored-By: Claude Opus 5.5 <[email protected]> * portal: stop screen sharing as soon as the last controller leaves The idle watch stays as the fallback for controllers that vanish without a release event. Co-Authored-By: Claude Opus 5.5 <[email protected]> * portal test: accept the runtime-engine message in portal builds Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e503041dac
commit
47c7728822
11 files changed
+279
-27
No files matched your search
+19
@@ -70,6 +70,8 @@ use webrtc::WebRtcSession;
|
||||
/// Set before a normal return when the host must come back in the other mode (signed in / out).
|
||||
static RESTART: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
|
||||
|
||||
struct AbortOnDrop(tokio::task::AbortHandle);
|
||||
impl Drop for AbortOnDrop { fn drop(&mut self) { self.0.abort(); } }
|
||||
fn superseded_peer_ids(sessions: &HashMap<String, WebRtcSession>, ice: &str, desktop: bool) -> Vec<String> {
|
||||
sessions.iter().filter(|(id, peer)| id.as_str() == ice || (desktop && peer.desktop))
|
||||
.map(|(id, _)| id.clone()).collect()
|
||||
@@ -713,6 +715,21 @@ async fn serve(mut capture: Arc<ScreenCapture>, input: Arc<InputInjector>, shutd
|
||||
assist: &mut Option<assist::Assist>, commands: &mut mpsc::Receiver<assist::Command>, webrtc_sessions: Arc<Mutex<HashMap<String, WebRtcSession>>>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let portal_desktop = (capture.backend == desktop_backend::DesktopBackend::Portal && !desktop_backend::headless())
|
||||
.then(|| Arc::new(desktop_session::PortalDesktop::new(capture.clone())));
|
||||
// Stop sharing the screen once no desktop controller is left. Viewers send stop_capture
|
||||
// before leaving and phones reconnect within seconds, so require two idle checks in a row.
|
||||
let idle_watch = portal_desktop.clone().map(|portal| {
|
||||
let sessions = webrtc_sessions.clone();
|
||||
tokio::spawn(async move {
|
||||
let mut idle = 0u8;
|
||||
loop {
|
||||
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
|
||||
if sessions.lock().await.values().any(|s| s.role.is_desktop()) { idle = 0; continue; }
|
||||
idle = idle.saturating_add(1);
|
||||
if idle >= 2 { portal.end_idle(); }
|
||||
}
|
||||
})
|
||||
});
|
||||
let _idle_watch = idle_watch.map(|task| AbortOnDrop(task.abort_handle()));
|
||||
let mut auth = if let Some(session) = assist.as_ref() { session.client.clone() } else {
|
||||
let creds = match config::file().and_then(Credentials::load) {
|
||||
Ok(creds) => creds,
|
||||
@@ -870,6 +887,8 @@ async fn serve(mut capture: Arc<ScreenCapture>, input: Arc<InputInjector>, shutd
|
||||
let mut desktop_ended = false;
|
||||
for id in ended { if let Some(s) = sessions.remove(&id) { desktop_ended |= s.role.is_desktop(); close_peer(&s.pc).await; } }
|
||||
if desktop_ended && !sessions.values().any(|s| s.role.is_desktop()) { if let Some(s) = assist.as_mut() { s.session_ended()?; } }
|
||||
// The controller left: stop sharing now; reconnecting reopens silently with the saved consent.
|
||||
if !sessions.values().any(|s| s.role.is_desktop()) { if let Some(portal) = &portal_desktop { portal.end_idle(); } }
|
||||
if let Some(s) = assist.as_mut() { s.tick()?; }
|
||||
}
|
||||
SignalingEvent::Connected => {
|
||||
|
||||
Reference in new issue
Block a user