fix resolutions query on linux
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
c63e757b76
commit
6b4cc6443f
@ -1556,11 +1556,11 @@ mod tests {
|
|||||||
scroll_style = "scrollbar"
|
scroll_style = "scrollbar"
|
||||||
custom_resolution = true
|
custom_resolution = true
|
||||||
"#;
|
"#;
|
||||||
let mut compare_config = default_peer_config.clone();
|
let mut cfg_to_compare = default_peer_config.clone();
|
||||||
compare_config.view_style = "adaptive".to_string();
|
cfg_to_compare.view_style = "adaptive".to_string();
|
||||||
compare_config.scroll_style = "scrollbar".to_string();
|
cfg_to_compare.scroll_style = "scrollbar".to_string();
|
||||||
let cfg = toml::from_str::<PeerConfig>(wrong_type_str);
|
let cfg = toml::from_str::<PeerConfig>(wrong_type_str);
|
||||||
assert_eq!(cfg, Ok(compare_config), "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_resolution]
|
||||||
@ -1569,10 +1569,10 @@ mod tests {
|
|||||||
hello = "world"
|
hello = "world"
|
||||||
[ui_flutter]
|
[ui_flutter]
|
||||||
"#;
|
"#;
|
||||||
let mut compare_config = default_peer_config.clone();
|
let mut cfg_to_compare = default_peer_config.clone();
|
||||||
compare_config.custom_resolution = Some(Resolution { w: 1920, h: 1080 });
|
cfg_to_compare.custom_resolution = Some(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(compare_config), "Failed to test wrong_field_str");
|
assert_eq!(cfg, Ok(cfg_to_compare), "Failed to test wrong_field_str");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -774,6 +774,12 @@ pub fn resolutions(name: &str) -> Vec<Resolution> {
|
|||||||
Virtual2 disconnected (normal left inverted right x axis y axis)
|
Virtual2 disconnected (normal left inverted right x axis y axis)
|
||||||
Virtual3 disconnected (normal left inverted right x axis y axis)
|
Virtual3 disconnected (normal left inverted right x axis y axis)
|
||||||
|
|
||||||
|
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
|
||||||
|
eDP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
|
||||||
|
1920x1080 60.01*+ 60.01 59.97 59.96 59.93
|
||||||
|
1680x1050 59.95 59.88
|
||||||
|
1600x1024 60.17
|
||||||
|
|
||||||
XWAYLAND0 connected primary 1920x984+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
|
XWAYLAND0 connected primary 1920x984+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
|
||||||
Virtual1 connected primary 1920x984+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
|
Virtual1 connected primary 1920x984+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
|
||||||
HDMI-0 connected (normal left inverted right x axis y axis)
|
HDMI-0 connected (normal left inverted right x axis y axis)
|
||||||
@ -783,7 +789,7 @@ pub fn resolutions(name: &str) -> Vec<Resolution> {
|
|||||||
if let Some(caps) = re.captures(&xrandr_output) {
|
if let Some(caps) = re.captures(&xrandr_output) {
|
||||||
if let Some(resolutions) = caps.name("resolutions") {
|
if let Some(resolutions) = caps.name("resolutions") {
|
||||||
let resolution_pat =
|
let resolution_pat =
|
||||||
r"\s*(?P<width>\d+)x(?P<height>\d+)\s+(?P<rates>(\d+\.\d+[* ]*)+)\s*\n";
|
r"\s*(?P<width>\d+)x(?P<height>\d+)\s+(?P<rates>(\d+\.\d+[*+ ]*)+)\s*\n";
|
||||||
let resolution_re = Regex::new(&format!(r"{}", resolution_pat)).unwrap();
|
let resolution_re = Regex::new(&format!(r"{}", resolution_pat)).unwrap();
|
||||||
for resolution_caps in resolution_re.captures_iter(resolutions.as_str()) {
|
for resolution_caps in resolution_re.captures_iter(resolutions.as_str()) {
|
||||||
if let Some((width, height)) =
|
if let Some((width, height)) =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user