windows, custom resolution

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-05-19 20:48:47 +08:00
parent 5f10d1aae6
commit df2de0fd61
7 changed files with 218 additions and 94 deletions

View File

@@ -1940,6 +1940,16 @@ impl Connection {
fn change_resolution(&mut self, r: &Resolution) {
if self.keyboard {
if let Ok(name) = video_service::get_current_display_name() {
#[cfg(target_os = "windows")]
if let Some(_ok) =
crate::virtual_display_manager::change_resolution_if_is_virtual_display(
&name,
r.width as _,
r.height as _,
)
{
return;
}
if let Err(e) =
crate::platform::change_resolution(&name, r.width as _, r.height as _)
{

View File

@@ -897,7 +897,11 @@ pub fn handle_one_frame_encoded(
#[inline]
fn get_original_resolution(display_name: &str, w: usize, h: usize) -> MessageField<Resolution> {
Some(if is_virtual_display(&display_name) {
#[cfg(target_os = "windows")]
let is_virtual_display = crate::virtual_display_manager::is_virtual_display(&display_name);
#[cfg(not(target_os = "windows"))]
let is_virtual_display = false;
Some(if is_virtual_display {
Resolution {
width: 0,
height: 0,
@@ -909,24 +913,6 @@ fn get_original_resolution(display_name: &str, w: usize, h: usize) -> MessageFie
.into()
}
#[inline]
#[cfg(target_os = "windows")]
fn is_virtual_display(name: &str) -> bool {
match crate::platform::windows::is_virtual_display(&name) {
Ok(b) => b,
Err(e) => {
log::error!("Failed to check is virtual display for '{}': {}", &name, e);
false
}
}
}
#[inline]
#[cfg(not(target_os = "windows"))]
fn is_virtual_display(_name: &str) -> bool {
false
}
pub(super) fn get_displays_2(all: &Vec<Display>) -> (usize, Vec<DisplayInfo>) {
let mut displays = Vec::new();
let mut primary = 0;