fix: wayland delete restore token (#7988)

* fix: wayland delete restore token

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* Wayland close session when clearing restore token

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* fix build

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* Refact Wayland option

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* Wayland clear screen selection, fake token

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* fix build web

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* fix: build

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* chore

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-05-09 11:03:59 +08:00
committed by GitHub
parent a31a68ba17
commit bbe9017318
48 changed files with 392 additions and 25 deletions

View File

@@ -909,6 +909,39 @@ pub fn main_set_local_option(key: String, value: String) {
set_local_option(key, value)
}
// We do use use `main_get_local_option` and `main_set_local_option`.
//
// 1. For get, the value is stored in the server process.
// 2. For clear, we need to need to return the error mmsg from the server process to flutter.
#[cfg(target_os = "linux")]
pub fn main_handle_wayland_screencast_restore_token(key: String, value: String) -> String {
if value == "get" {
match crate::ipc::get_wayland_screencast_restore_token(key) {
Ok(v) => v,
Err(e) => {
log::error!("Failed to get wayland screencast restore token, {}", e);
"".to_owned()
}
}
} else if value == "clear" {
match crate::ipc::clear_wayland_screencast_restore_token(key.clone()) {
Ok(true) => {
set_local_option(key, "".to_owned());
"".to_owned()
}
Ok(false) => "Failed to clear, please try again.".to_owned(),
Err(e) => format!("Failed to clear, {}", e),
}
} else {
"".to_owned()
}
}
#[cfg(not(target_os = "linux"))]
pub fn main_handle_wayland_screencast_restore_token(_key: String, _value: String) -> String {
"".to_owned()
}
pub fn main_get_input_source() -> SyncReturn<String> {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let input_source = get_cur_session_input_source();