simple refactor
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
2051bee3cf
commit
7bc98ee434
@ -503,7 +503,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
let _wake_lock = get_wake_lock();
|
||||
|
||||
// ensure_inited() is needed because release_resource() may be called.
|
||||
// ensure_inited() is needed because clear() may be called.
|
||||
#[cfg(target_os = "linux")]
|
||||
super::wayland::ensure_inited()?;
|
||||
#[cfg(windows)]
|
||||
@ -624,7 +624,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
}
|
||||
if c.current != *CURRENT_DISPLAY.lock().unwrap() {
|
||||
#[cfg(target_os = "linux")]
|
||||
wayland::clear();
|
||||
super::wayland::clear();
|
||||
*SWITCH.lock().unwrap() = true;
|
||||
bail!("SWITCH");
|
||||
}
|
||||
@ -660,7 +660,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
sp.send(msg_out);
|
||||
log::info!("Displays changed");
|
||||
#[cfg(target_os = "linux")]
|
||||
wayland::clear();
|
||||
super::wayland::clear();
|
||||
*SWITCH.lock().unwrap() = true;
|
||||
bail!("SWITCH");
|
||||
}
|
||||
@ -729,7 +729,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
// Do not reset the capturer for now, as it will cause the prompt to show every few minutes.
|
||||
// https://github.com/rustdesk/rustdesk/issues/4276
|
||||
//
|
||||
// super::wayland::release_resource();
|
||||
// super::wayland::clear();
|
||||
// bail!("Wayland capturer none 100 times, try restart capture");
|
||||
}
|
||||
}
|
||||
@ -739,7 +739,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
if check_display_changed(c.ndisplay, c.current, c.width, c.height) {
|
||||
log::info!("Displays changed");
|
||||
#[cfg(target_os = "linux")]
|
||||
wayland::clear();
|
||||
super::wayland::clear();
|
||||
*SWITCH.lock().unwrap() = true;
|
||||
bail!("SWITCH");
|
||||
}
|
||||
@ -784,9 +784,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
if !scrap::is_x11() {
|
||||
super::wayland::release_resource();
|
||||
}
|
||||
super::wayland::clear();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -186,21 +186,6 @@ pub(super) async fn check_init() -> ResultType<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn clear() {
|
||||
if scrap::is_x11() {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut lock = CAP_DISPLAY_INFO.write().unwrap();
|
||||
if *lock != 0 {
|
||||
unsafe {
|
||||
let cap_display_info = Box::from_raw(*lock as *mut CapDisplayInfo);
|
||||
let _ = Box::from_raw(cap_display_info.capturer.0);
|
||||
}
|
||||
*lock = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn get_displays() -> ResultType<(usize, Vec<DisplayInfo>)> {
|
||||
check_init().await?;
|
||||
let addr = *CAP_DISPLAY_INFO.read().unwrap();
|
||||
@ -230,8 +215,7 @@ pub(super) fn get_primary() -> ResultType<usize> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(super) fn release_resource() {
|
||||
pub fn clear() {
|
||||
if scrap::is_x11() {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user