debug restore resolutions
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
e670989e0f
commit
3c2bf2c154
@ -263,9 +263,9 @@ pub struct PeerConfig {
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "deserialize_hashmap_resolutions",
|
||||
skip_serializing_if = "HashMap::is_empty",
|
||||
skip_serializing_if = "HashMap::is_empty"
|
||||
)]
|
||||
pub custom_resolutions: HashMap<i32, Resolution>,
|
||||
pub custom_resolutions: HashMap<String, Resolution>,
|
||||
|
||||
// The other scalar value must before this
|
||||
#[serde(default, deserialize_with = "PeerConfig::deserialize_options")]
|
||||
@ -1509,7 +1509,7 @@ deserialize_default!(deserialize_option_string, Option<String>);
|
||||
deserialize_default!(deserialize_hashmap_string_string, HashMap<String, String>);
|
||||
deserialize_default!(deserialize_hashmap_string_bool, HashMap<String, bool>);
|
||||
deserialize_default!(deserialize_hashmap_string_configoidcprovider, HashMap<String, ConfigOidcProvider>);
|
||||
deserialize_default!(deserialize_hashmap_resolutions, HashMap<i32, Resolution>);
|
||||
deserialize_default!(deserialize_hashmap_resolutions, HashMap<String, Resolution>);
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
@ -1591,12 +1591,13 @@ impl LoginConfigHandler {
|
||||
pub fn get_custom_resolution(&self, display: i32) -> Option<(i32, i32)> {
|
||||
self.config
|
||||
.custom_resolutions
|
||||
.get(&display)
|
||||
.get(&display.to_string())
|
||||
.map(|r| (r.w, r.h))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_custom_resolution(&mut self, display: i32, wh: Option<(i32, i32)>) {
|
||||
let display = display.to_string();
|
||||
let mut config = self.load_config();
|
||||
match wh {
|
||||
Some((w, h)) => {
|
||||
|
@ -1795,11 +1795,14 @@ impl Connection {
|
||||
video_service::switch_display(s.display).await;
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
if s.width != 0 && s.height != 0 {
|
||||
self.change_resolution(&Resolution {
|
||||
width: s.width,
|
||||
height: s.height,
|
||||
..Default::default()
|
||||
});
|
||||
self.change_resolution(
|
||||
&Resolution {
|
||||
width: s.width,
|
||||
height: s.height,
|
||||
..Default::default()
|
||||
},
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
Some(misc::Union::ChatMessage(c)) => {
|
||||
@ -1902,7 +1905,7 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
Some(misc::Union::ChangeResolution(r)) => self.change_resolution(&r),
|
||||
Some(misc::Union::ChangeResolution(r)) => self.change_resolution(&r, false),
|
||||
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
Some(misc::Union::PluginRequest(p)) => {
|
||||
@ -1945,9 +1948,13 @@ impl Connection {
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
fn change_resolution(&mut self, r: &Resolution) {
|
||||
fn change_resolution(&mut self, r: &Resolution, first_display: bool) {
|
||||
if self.keyboard {
|
||||
if let Ok(name) = video_service::get_current_display_name() {
|
||||
if let Ok((_, current, display)) = video_service::get_current_display() {
|
||||
if first_display && current != 0 {
|
||||
return;
|
||||
}
|
||||
let name = display.name();
|
||||
#[cfg(all(windows, feature = "virtual_display_driver"))]
|
||||
if let Some(_ok) =
|
||||
crate::virtual_display_manager::change_resolution_if_is_virtual_display(
|
||||
@ -2173,7 +2180,7 @@ impl Connection {
|
||||
if let Some(custom_resolution) = o.custom_resolution.as_ref() {
|
||||
if Self::alive_conns().len() > 0 {
|
||||
if custom_resolution.width > 0 && custom_resolution.height > 0 {
|
||||
self.change_resolution(&custom_resolution);
|
||||
self.change_resolution(&custom_resolution, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1029,12 +1029,14 @@ pub(super) fn get_current_display_2(mut all: Vec<Display>) -> ResultType<(usize,
|
||||
return Ok((n, current, all.remove(current)));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_current_display() -> ResultType<(usize, usize, Display)> {
|
||||
get_current_display_2(try_get_displays()?)
|
||||
}
|
||||
|
||||
// `try_reset_current_display` is needed because `get_displays` may change the current display,
|
||||
// which may cause the mismatch of current display and the current display name.
|
||||
#[inline]
|
||||
pub fn get_current_display_name() -> ResultType<String> {
|
||||
Ok(get_current_display_2(try_get_displays()?)?.2.name())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user