diff --git a/libs/scrap/src/wayland/pipewire.rs b/libs/scrap/src/wayland/pipewire.rs index 76666faa8..7cf18bdd0 100644 --- a/libs/scrap/src/wayland/pipewire.rs +++ b/libs/scrap/src/wayland/pipewire.rs @@ -110,17 +110,7 @@ pub struct RdpSessionInfo { pub session: dbus::Path<'static>, pub is_support_restore_token: bool, pub resolution: Arc>>, - inhibit_request_path: Option>, } - -impl Drop for RdpSessionInfo { - fn drop(&mut self) { - if let Some(ref path) = self.inhibit_request_path { - release_inhibit(&self.conn, path); - } - } -} - #[derive(Debug, Clone, Copy)] pub struct PwStreamInfo { pub path: u64, @@ -970,41 +960,6 @@ fn on_start_response( } } -fn request_inhibit(conn: &SyncConnection) -> Option> { - let proxy = conn.with_proxy( - "org.freedesktop.portal.Desktop", - "/org/freedesktop/portal/desktop", - Duration::from_millis(1000), - ); - let mut args: PropMap = HashMap::new(); - args.insert("handle_token".to_string(), Variant(Box::new("inhibit1".to_string())),); - // flags: 8 = inhibit idle, 4 = inhibit suspend - // Based on current testing, Dim Screen will forcibly terminate the session. - // Solving this problem requires preventing entry into the idle state. - // However, for future considerations, entering the suspended state is also prevented here. - match proxy.method_call::<(dbus::Path<'static>,), _, _, _>("org.freedesktop.portal.Inhibit", "Inhibit", ("", 12u32, args)) { - Ok((path,)) => { - debug!("Inhibit requested, request path: {:?}", path); - Some(path) - } - Err(e) => { - warn!("Failed to request inhibit: {}", e); - None - } - } -} - -fn release_inhibit(conn: &SyncConnection, path: &dbus::Path<'static>) { - let proxy = conn.with_proxy( - "org.freedesktop.portal.Desktop", - path, - Duration::from_millis(1000), - ); - if let Err(e) = proxy.method_call::<(), _, _, _>("org.freedesktop.portal.Request", "Close", ()) { - warn!("Failed to release inhibit: {}", e); - } -} - pub fn get_capturables() -> Result, Box> { let mut rdp_connection = match RDP_SESSION_INFO.lock() { Ok(conn) => conn, @@ -1014,9 +969,6 @@ pub fn get_capturables() -> Result, Box> { if rdp_connection.is_none() { let (conn, fd, streams, session, is_support_restore_token) = request_remote_desktop(false)?; let conn = Arc::new(conn); - // to-do: Add an option like "Keep awake while RustDesk is running" to avoid - // impacting users whose sessions are not automatically terminated upon entering the Dim Screen. - let inhibit_path = if !is_server_running() { request_inhibit(&conn) } else { None }; let rdp_info = RdpSessionInfo { conn, @@ -1025,7 +977,6 @@ pub fn get_capturables() -> Result, Box> { session, is_support_restore_token, resolution: Arc::new(Mutex::new(None)), - inhibit_request_path: inhibit_path, }; *rdp_connection = Some(rdp_info); }