Merge pull request #5016 from fufesou/fix/wayland_change_resolutions

fix, wayland, change resolutions
This commit is contained in:
RustDesk 2023-07-16 11:52:00 +08:00 committed by GitHub
commit bf33b28483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 26 deletions

View File

@ -399,10 +399,10 @@ impl Config2 {
pub fn load_path<T: serde::Serialize + serde::de::DeserializeOwned + Default + std::fmt::Debug>( pub fn load_path<T: serde::Serialize + serde::de::DeserializeOwned + Default + std::fmt::Debug>(
file: PathBuf, file: PathBuf,
) -> T { ) -> T {
let cfg = match confy::load_path(file) { let cfg = match confy::load_path(&file) {
Ok(config) => config, Ok(config) => config,
Err(err) => { Err(err) => {
log::error!("Failed to load config: {}", err); log::error!("Failed to load config '{}': {}", file.display(), err);
T::default() T::default()
} }
}; };
@ -958,7 +958,7 @@ impl PeerConfig {
config config
} }
Err(err) => { Err(err) => {
log::error!("Failed to load config: {}", err); log::error!("Failed to load peer config '{}': {}", id, err);
Default::default() Default::default()
} }
} }

View File

@ -15,7 +15,6 @@ mediacodec = ["ndk"]
linux-pkg-config = ["dep:pkg-config"] linux-pkg-config = ["dep:pkg-config"]
[dependencies] [dependencies]
block = "0.1"
cfg-if = "1.0" cfg-if = "1.0"
num_cpus = "1.15" num_cpus = "1.15"
lazy_static = "1.4" lazy_static = "1.4"
@ -27,6 +26,9 @@ version = "0.3"
default-features = true default-features = true
features = ["dxgi", "dxgi1_2", "dxgi1_5", "d3d11", "winuser", "winerror", "errhandlingapi", "libloaderapi"] features = ["dxgi", "dxgi1_2", "dxgi1_5", "d3d11", "winuser", "winerror", "errhandlingapi", "libloaderapi"]
[target.'cfg(target_os = "macos")'.dependencies]
block = "0.1"
[target.'cfg(target_os = "android")'.dependencies] [target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.13" android_logger = "0.13"
jni = "0.21" jni = "0.21"

View File

@ -503,7 +503,7 @@ fn run(sp: GenericService) -> ResultType<()> {
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
let _wake_lock = get_wake_lock(); 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")] #[cfg(target_os = "linux")]
super::wayland::ensure_inited()?; super::wayland::ensure_inited()?;
#[cfg(windows)] #[cfg(windows)]
@ -623,6 +623,8 @@ fn run(sp: GenericService) -> ResultType<()> {
bail!("SWITCH"); bail!("SWITCH");
} }
if c.current != *CURRENT_DISPLAY.lock().unwrap() { if c.current != *CURRENT_DISPLAY.lock().unwrap() {
#[cfg(target_os = "linux")]
super::wayland::clear();
*SWITCH.lock().unwrap() = true; *SWITCH.lock().unwrap() = true;
bail!("SWITCH"); bail!("SWITCH");
} }
@ -657,6 +659,8 @@ fn run(sp: GenericService) -> ResultType<()> {
if let Some(msg_out) = check_get_displays_changed_msg() { if let Some(msg_out) = check_get_displays_changed_msg() {
sp.send(msg_out); sp.send(msg_out);
log::info!("Displays changed"); log::info!("Displays changed");
#[cfg(target_os = "linux")]
super::wayland::clear();
*SWITCH.lock().unwrap() = true; *SWITCH.lock().unwrap() = true;
bail!("SWITCH"); bail!("SWITCH");
} }
@ -725,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. // 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 // https://github.com/rustdesk/rustdesk/issues/4276
// //
// super::wayland::release_resource(); // super::wayland::clear();
// bail!("Wayland capturer none 100 times, try restart capture"); // bail!("Wayland capturer none 100 times, try restart capture");
} }
} }
@ -734,6 +738,8 @@ fn run(sp: GenericService) -> ResultType<()> {
Err(err) => { Err(err) => {
if check_display_changed(c.ndisplay, c.current, c.width, c.height) { if check_display_changed(c.ndisplay, c.current, c.width, c.height) {
log::info!("Displays changed"); log::info!("Displays changed");
#[cfg(target_os = "linux")]
super::wayland::clear();
*SWITCH.lock().unwrap() = true; *SWITCH.lock().unwrap() = true;
bail!("SWITCH"); bail!("SWITCH");
} }
@ -778,9 +784,7 @@ fn run(sp: GenericService) -> ResultType<()> {
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
if !scrap::is_x11() { super::wayland::clear();
super::wayland::release_resource();
}
Ok(()) Ok(())
} }

View File

@ -186,21 +186,6 @@ pub(super) async fn check_init() -> ResultType<()> {
Ok(()) 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>)> { pub(super) async fn get_displays() -> ResultType<(usize, Vec<DisplayInfo>)> {
check_init().await?; check_init().await?;
let addr = *CAP_DISPLAY_INFO.read().unwrap(); let addr = *CAP_DISPLAY_INFO.read().unwrap();
@ -230,8 +215,7 @@ pub(super) fn get_primary() -> ResultType<usize> {
} }
} }
#[allow(dead_code)] pub fn clear() {
pub(super) fn release_resource() {
if scrap::is_x11() { if scrap::is_x11() {
return; return;
} }