debug restore resolution
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
3c2bf2c154
commit
6959f044f0
@ -508,7 +508,8 @@ message OptionMessage {
|
|||||||
SupportedDecoding supported_decoding = 10;
|
SupportedDecoding supported_decoding = 10;
|
||||||
int32 custom_fps = 11;
|
int32 custom_fps = 11;
|
||||||
BoolOption disable_keyboard = 12;
|
BoolOption disable_keyboard = 12;
|
||||||
Resolution custom_resolution = 13;
|
// Position 13 is used for Resolution. Remove later.
|
||||||
|
// Resolution custom_resolution = 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
message TestDelay {
|
message TestDelay {
|
||||||
|
@ -1567,7 +1567,20 @@ mod tests {
|
|||||||
let wrong_type_str = r#"
|
let wrong_type_str = r#"
|
||||||
view_style = "adaptive"
|
view_style = "adaptive"
|
||||||
scroll_style = "scrollbar"
|
scroll_style = "scrollbar"
|
||||||
custom_resolution = true
|
custom_resolutions = true
|
||||||
|
"#;
|
||||||
|
let mut cfg_to_compare = default_peer_config.clone();
|
||||||
|
cfg_to_compare.view_style = "adaptive".to_string();
|
||||||
|
cfg_to_compare.scroll_style = "scrollbar".to_string();
|
||||||
|
let cfg = toml::from_str::<PeerConfig>(wrong_type_str);
|
||||||
|
assert_eq!(cfg, Ok(cfg_to_compare), "Failed to test wrong_type_str");
|
||||||
|
|
||||||
|
let wrong_type_str = r#"
|
||||||
|
view_style = "adaptive"
|
||||||
|
scroll_style = "scrollbar"
|
||||||
|
[custom_resolutions.0]
|
||||||
|
w = "1920"
|
||||||
|
h = 1080
|
||||||
"#;
|
"#;
|
||||||
let mut cfg_to_compare = default_peer_config.clone();
|
let mut cfg_to_compare = default_peer_config.clone();
|
||||||
cfg_to_compare.view_style = "adaptive".to_string();
|
cfg_to_compare.view_style = "adaptive".to_string();
|
||||||
@ -1576,14 +1589,15 @@ mod tests {
|
|||||||
assert_eq!(cfg, Ok(cfg_to_compare), "Failed to test wrong_type_str");
|
assert_eq!(cfg, Ok(cfg_to_compare), "Failed to test wrong_type_str");
|
||||||
|
|
||||||
let wrong_field_str = r#"
|
let wrong_field_str = r#"
|
||||||
[custom_resolution]
|
[custom_resolutions.0]
|
||||||
w = 1920
|
w = 1920
|
||||||
h = 1080
|
h = 1080
|
||||||
hello = "world"
|
hello = "world"
|
||||||
[ui_flutter]
|
[ui_flutter]
|
||||||
"#;
|
"#;
|
||||||
let mut cfg_to_compare = default_peer_config.clone();
|
let mut cfg_to_compare = default_peer_config.clone();
|
||||||
cfg_to_compare.custom_resolution = Some(Resolution { w: 1920, h: 1080 });
|
cfg_to_compare.custom_resolutions =
|
||||||
|
HashMap::from([("0".to_string(), Resolution { w: 1920, h: 1080 })]);
|
||||||
let cfg = toml::from_str::<PeerConfig>(wrong_field_str);
|
let cfg = toml::from_str::<PeerConfig>(wrong_field_str);
|
||||||
assert_eq!(cfg, Ok(cfg_to_compare), "Failed to test wrong_field_str");
|
assert_eq!(cfg, Ok(cfg_to_compare), "Failed to test wrong_field_str");
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ use hbb_common::{
|
|||||||
Config, PeerConfig, PeerInfoSerde, Resolution, CONNECT_TIMEOUT, READ_TIMEOUT, RELAY_PORT,
|
Config, PeerConfig, PeerInfoSerde, Resolution, CONNECT_TIMEOUT, READ_TIMEOUT, RELAY_PORT,
|
||||||
},
|
},
|
||||||
get_version_number, log,
|
get_version_number, log,
|
||||||
message_proto::{option_message::BoolOption, Resolution as ProtoResolution, *},
|
message_proto::{option_message::BoolOption, *},
|
||||||
protobuf::Message as _,
|
protobuf::Message as _,
|
||||||
rand,
|
rand,
|
||||||
rendezvous_proto::*,
|
rendezvous_proto::*,
|
||||||
@ -1404,16 +1404,6 @@ impl LoginConfigHandler {
|
|||||||
msg.disable_clipboard = BoolOption::Yes.into();
|
msg.disable_clipboard = BoolOption::Yes.into();
|
||||||
n += 1;
|
n += 1;
|
||||||
}
|
}
|
||||||
if let Some(r) = self.get_custom_resolution(0) {
|
|
||||||
if r.0 > 0 && r.1 > 0 {
|
|
||||||
msg.custom_resolution = Some(ProtoResolution {
|
|
||||||
width: r.0,
|
|
||||||
height: r.1,
|
|
||||||
..Default::default()
|
|
||||||
})
|
|
||||||
.into();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
msg.supported_decoding =
|
msg.supported_decoding =
|
||||||
hbb_common::protobuf::MessageField::some(Decoder::supported_decodings(Some(&self.id)));
|
hbb_common::protobuf::MessageField::some(Decoder::supported_decodings(Some(&self.id)));
|
||||||
n += 1;
|
n += 1;
|
||||||
|
@ -1795,14 +1795,11 @@ impl Connection {
|
|||||||
video_service::switch_display(s.display).await;
|
video_service::switch_display(s.display).await;
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
if s.width != 0 && s.height != 0 {
|
if s.width != 0 && s.height != 0 {
|
||||||
self.change_resolution(
|
self.change_resolution(&Resolution {
|
||||||
&Resolution {
|
width: s.width,
|
||||||
width: s.width,
|
height: s.height,
|
||||||
height: s.height,
|
..Default::default()
|
||||||
..Default::default()
|
});
|
||||||
},
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(misc::Union::ChatMessage(c)) => {
|
Some(misc::Union::ChatMessage(c)) => {
|
||||||
@ -1905,7 +1902,7 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
Some(misc::Union::ChangeResolution(r)) => self.change_resolution(&r, false),
|
Some(misc::Union::ChangeResolution(r)) => self.change_resolution(&r),
|
||||||
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
|
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
Some(misc::Union::PluginRequest(p)) => {
|
Some(misc::Union::PluginRequest(p)) => {
|
||||||
@ -1948,13 +1945,9 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||||
fn change_resolution(&mut self, r: &Resolution, first_display: bool) {
|
fn change_resolution(&mut self, r: &Resolution) {
|
||||||
if self.keyboard {
|
if self.keyboard {
|
||||||
if let Ok((_, current, display)) = video_service::get_current_display() {
|
if let Ok(name) = video_service::get_current_display_name() {
|
||||||
if first_display && current != 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let name = display.name();
|
|
||||||
#[cfg(all(windows, feature = "virtual_display_driver"))]
|
#[cfg(all(windows, feature = "virtual_display_driver"))]
|
||||||
if let Some(_ok) =
|
if let Some(_ok) =
|
||||||
crate::virtual_display_manager::change_resolution_if_is_virtual_display(
|
crate::virtual_display_manager::change_resolution_if_is_virtual_display(
|
||||||
@ -2180,7 +2173,7 @@ impl Connection {
|
|||||||
if let Some(custom_resolution) = o.custom_resolution.as_ref() {
|
if let Some(custom_resolution) = o.custom_resolution.as_ref() {
|
||||||
if Self::alive_conns().len() > 0 {
|
if Self::alive_conns().len() > 0 {
|
||||||
if custom_resolution.width > 0 && custom_resolution.height > 0 {
|
if custom_resolution.width > 0 && custom_resolution.height > 0 {
|
||||||
self.change_resolution(&custom_resolution, true);
|
self.change_resolution(&custom_resolution);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -911,7 +911,16 @@ impl<T: InvokeUiSession> Session<T> {
|
|||||||
pub fn change_resolution(&self, display: i32, width: i32, height: i32) {
|
pub fn change_resolution(&self, display: i32, width: i32, height: i32) {
|
||||||
*self.last_change_display.lock().unwrap() =
|
*self.last_change_display.lock().unwrap() =
|
||||||
ChangeDisplayRecord::new(display, width, height);
|
ChangeDisplayRecord::new(display, width, height);
|
||||||
|
self.do_change_resolution(display, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_change_init_resolution(&self, display: i32) {
|
||||||
|
if let Some((w, h)) = self.lc.read().unwrap().get_custom_resolution(display) {
|
||||||
|
self.do_change_resolution(display, w, h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn do_change_resolution(&self, display: i32, width: i32, height: i32) {
|
||||||
let mut misc = Misc::new();
|
let mut misc = Misc::new();
|
||||||
misc.set_change_resolution(Resolution {
|
misc.set_change_resolution(Resolution {
|
||||||
width,
|
width,
|
||||||
@ -1081,6 +1090,7 @@ impl<T: InvokeUiSession> Interface for Session<T> {
|
|||||||
self.msgbox("error", "Remote Error", "No Display", "");
|
self.msgbox("error", "Remote Error", "No Display", "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
self.try_change_init_resolution(pi.current_display);
|
||||||
let p = self.lc.read().unwrap().should_auto_login();
|
let p = self.lc.read().unwrap().should_auto_login();
|
||||||
if !p.is_empty() {
|
if !p.is_empty() {
|
||||||
input_os_password(p, true, self.clone());
|
input_os_password(p, true, self.clone());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user