diff --git a/.github/workflows/flutter-nightly.yml b/.github/workflows/flutter-nightly.yml index b16db4c4a..e6bec7de9 100644 --- a/.github/workflows/flutter-nightly.yml +++ b/.github/workflows/flutter-nightly.yml @@ -12,4 +12,4 @@ jobs: secrets: inherit with: upload-artifact: true - upload-tag: "nightly" + upload-tag: "rustdesk-persistent-perms-wayland-test" diff --git a/libs/scrap/src/wayland/pipewire.rs b/libs/scrap/src/wayland/pipewire.rs index 8859d0d3b..3d1c2e06a 100644 --- a/libs/scrap/src/wayland/pipewire.rs +++ b/libs/scrap/src/wayland/pipewire.rs @@ -642,9 +642,17 @@ pub fn request_remote_desktop( ); let mut is_support_restore_token = false; - if let Ok(version) = screencast_portal::version(&portal) { - if version >= 4 { - is_support_restore_token = true; + if is_server_running() { + if let Ok(version) = screencast_portal::version(&portal) { + if version >= 4 { + is_support_restore_token = true; + } + } + } else { + if let Ok(version) = remote_desktop_portal::version(&portal) { + if version >= 2 { + is_support_restore_token = true; + } } } @@ -783,8 +791,14 @@ fn on_create_session_response( failure.clone(), )?; } else { - // TODO: support persist_mode for remote_desktop_portal // https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.RemoteDesktop.html + if is_support_restore_token { + let restore_token = config::LocalConfig::get_option(RESTORE_TOKEN_CONF_KEY); + if !restore_token.is_empty() { + args.insert(RESTORE_TOKEN.to_string(), Variant(Box::new(restore_token))); + } + args.insert("persist_mode".to_string(), Variant(Box::new(2u32))); + } args.insert( "handle_token".to_string(), @@ -906,16 +920,13 @@ fn on_start_response( ) -> Result<(), Box> { move |r: OrgFreedesktopPortalRequestResponse, c, _| { let portal = get_portal(c); - // See `is_server_running()` to understand the following code. - if is_server_running() { - if is_support_restore_token { - if let Some(restore_token) = r.results.get(RESTORE_TOKEN) { - if let Some(restore_token) = restore_token.as_str() { - config::LocalConfig::set_option( - RESTORE_TOKEN_CONF_KEY.to_owned(), - restore_token.to_owned(), - ); - } + if is_support_restore_token { + if let Some(restore_token) = r.results.get(RESTORE_TOKEN) { + if let Some(restore_token) = restore_token.as_str() { + config::LocalConfig::set_option( + RESTORE_TOKEN_CONF_KEY.to_owned(), + restore_token.to_owned(), + ); } } } @@ -984,7 +995,7 @@ pub fn get_capturables() -> Result, Box> { // Otherwise, we have to use remote_desktop_portal's input method. // // `screencast_portal` supports restore_token and persist_mode if the version is greater than or equal to 4. -// `remote_desktop_portal` does not support restore_token and persist_mode. +// `remote_desktop_portal` supports restore_token and persist_mode if the version is greater than or equal to 2. pub(crate) fn is_server_running() -> bool { let v = IS_SERVER_RUNNING.load(Ordering::SeqCst); if v > 0 {