From de1005acb259789a71b339af6a84a7ea4d57f8cf Mon Sep 17 00:00:00 2001 From: fufesou Date: Mon, 20 Mar 2023 13:58:02 +0800 Subject: [PATCH] do not embed cursor on wayland Signed-off-by: fufesou --- libs/scrap/src/common/wayland.rs | 5 +++-- libs/scrap/src/wayland/pipewire.rs | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/libs/scrap/src/common/wayland.rs b/libs/scrap/src/common/wayland.rs index 86afd5d82..2d3abeeaf 100644 --- a/libs/scrap/src/common/wayland.rs +++ b/libs/scrap/src/common/wayland.rs @@ -22,8 +22,9 @@ pub fn is_cursor_embedded() -> bool { unsafe fn init_cursor_embedded() { use crate::common::wayland::pipewire::get_available_cursor_modes; match get_available_cursor_modes() { - Ok(modes) => { - IS_CURSOR_EMBEDDED = Some((modes & 0x02) > 0); + Ok(_modes) => { + // IS_CURSOR_EMBEDDED = Some((_modes & 0x02) > 0); + IS_CURSOR_EMBEDDED = Some(false) } Err(..) => { IS_CURSOR_EMBEDDED = Some(false); diff --git a/libs/scrap/src/wayland/pipewire.rs b/libs/scrap/src/wayland/pipewire.rs index 9c0ad9774..5583dfef5 100644 --- a/libs/scrap/src/wayland/pipewire.rs +++ b/libs/scrap/src/wayland/pipewire.rs @@ -416,6 +416,12 @@ static mut INIT: bool = false; const RESTORE_TOKEN: &str = "restore_token"; const RESTORE_TOKEN_CONF_KEY: &str = "wayland-restore-token"; +const PORTAL_CURSOR_MODE_HIDDEN: u32 = 1; +#[allow(dead_code)] +const PORTAL_CURSOR_MODE_EMBEDDED: u32 = 2; +#[allow(dead_code)] +const PORTAL_CURSOR_MODE_METADATA: u32 = 4; + pub fn get_available_cursor_modes() -> Result { let conn = SyncConnection::new_session()?; let portal = get_portal(&conn); @@ -485,11 +491,11 @@ fn request_screen_cast( if let Ok(modes) = portal.available_cursor_modes() { available_cursor_modes = modes; } - if capture_cursor { - cursor_mode = 2u32 & available_cursor_modes; - } + // if capture_cursor { + // cursor_mode = PORTAL_CURSOR_MODE_METADATA & available_cursor_modes; + // } if cursor_mode == 0 { - cursor_mode = 1u32 & available_cursor_modes; + cursor_mode = PORTAL_CURSOR_MODE_HIDDEN & available_cursor_modes; } let plasma = std::env::var("DESKTOP_SESSION").map_or(false, |s| s.contains("plasma")); if plasma && capture_cursor {