mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
Fix. Multi-display connection, resolutions (#7782)
* fix: multi-display, change resolution Signed-off-by: fufesou <shuanglongchen@yeah.net> * fix: multi-displays, resolutions of displays Signed-off-by: fufesou <shuanglongchen@yeah.net> * fix: build Signed-off-by: fufesou <shuanglongchen@yeah.net> * refact: Function rename Signed-off-by: fufesou <shuanglongchen@yeah.net> * refact. Function rename Signed-off-by: fufesou <shuanglongchen@yeah.net> --------- Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -2104,6 +2104,12 @@ pub fn main_check_hwcodec() {
|
||||
check_hwcodec()
|
||||
}
|
||||
|
||||
pub fn session_request_new_display_init_msgs(session_id: SessionID, display: usize) {
|
||||
if let Some(session) = sessions::get_session_by_session_id(&session_id) {
|
||||
session.request_init_msgs(display);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
pub mod server_side {
|
||||
use hbb_common::{config, log};
|
||||
|
||||
@@ -2300,7 +2300,11 @@ 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(None, &r),
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
Some(misc::Union::ChangeDisplayResolution(dr)) => {
|
||||
self.change_resolution(Some(dr.display as _), &dr.resolution)
|
||||
}
|
||||
#[cfg(all(feature = "flutter", feature = "plugin_framework"))]
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
Some(misc::Union::PluginRequest(p)) => {
|
||||
@@ -2343,6 +2347,13 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(misc::Union::MessageQuery(mq)) => {
|
||||
if let Some(msg_out) =
|
||||
video_service::make_display_changed_msg(mq.switch_display as _, None)
|
||||
{
|
||||
self.send(msg_out).await;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
Some(message::Union::AudioFrame(frame)) => {
|
||||
@@ -2472,11 +2483,14 @@ impl Connection {
|
||||
|
||||
#[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(
|
||||
None,
|
||||
&Resolution {
|
||||
width: s.width,
|
||||
height: s.height,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2623,10 +2637,11 @@ impl Connection {
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
fn change_resolution(&mut self, r: &Resolution) {
|
||||
fn change_resolution(&mut self, d: Option<usize>, r: &Resolution) {
|
||||
if self.keyboard {
|
||||
if let Ok(displays) = display_service::try_get_displays() {
|
||||
if let Some(display) = displays.get(self.display_idx) {
|
||||
let display_idx = d.unwrap_or(self.display_idx);
|
||||
if let Some(display) = displays.get(display_idx) {
|
||||
let name = display.name();
|
||||
#[cfg(all(windows, feature = "virtual_display_driver"))]
|
||||
if let Some(_ok) =
|
||||
@@ -2638,11 +2653,18 @@ impl Connection {
|
||||
{
|
||||
return;
|
||||
}
|
||||
display_service::set_last_changed_resolution(
|
||||
&name,
|
||||
(display.width() as _, display.height() as _),
|
||||
(r.width, r.height),
|
||||
);
|
||||
let mut record_changed = true;
|
||||
#[cfg(all(windows, feature = "virtual_display_driver"))]
|
||||
if virtual_display_manager::amyuni_idd::is_my_display(&name) {
|
||||
record_changed = false;
|
||||
}
|
||||
if record_changed {
|
||||
display_service::set_last_changed_resolution(
|
||||
&name,
|
||||
(display.width() as _, display.height() as _),
|
||||
(r.width, r.height),
|
||||
);
|
||||
}
|
||||
if let Err(e) =
|
||||
crate::platform::change_resolution(&name, r.width as _, r.height as _)
|
||||
{
|
||||
|
||||
@@ -1222,7 +1222,7 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
pub fn change_resolution(&self, display: i32, width: i32, height: i32) {
|
||||
*self.last_change_display.lock().unwrap() =
|
||||
ChangeDisplayRecord::new(display, width, height);
|
||||
self.do_change_resolution(width, height);
|
||||
self.do_change_resolution(display, width, height);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -1232,13 +1232,22 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
}
|
||||
}
|
||||
|
||||
fn do_change_resolution(&self, width: i32, height: i32) {
|
||||
fn do_change_resolution(&self, display: i32, width: i32, height: i32) {
|
||||
let mut misc = Misc::new();
|
||||
misc.set_change_resolution(Resolution {
|
||||
let resolution = Resolution {
|
||||
width,
|
||||
height,
|
||||
..Default::default()
|
||||
});
|
||||
};
|
||||
if crate::common::is_support_multi_ui_session_num(self.lc.read().unwrap().version) {
|
||||
misc.set_change_display_resolution(DisplayResolution {
|
||||
display,
|
||||
resolution: Some(resolution).into(),
|
||||
..Default::default()
|
||||
});
|
||||
} else {
|
||||
misc.set_change_resolution(resolution);
|
||||
}
|
||||
let mut msg = Message::new();
|
||||
msg.set_misc(misc);
|
||||
self.send(Data::Message(msg));
|
||||
@@ -1293,6 +1302,22 @@ impl<T: InvokeUiSession> Session<T> {
|
||||
log::error!("selected invalid sid: {}", sid);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn request_init_msgs(&self, display: usize) {
|
||||
self.send_message_query(display);
|
||||
}
|
||||
|
||||
fn send_message_query(&self, display: usize) {
|
||||
let mut misc = Misc::new();
|
||||
misc.set_message_query(MessageQuery {
|
||||
switch_display: display as _,
|
||||
..Default::default()
|
||||
});
|
||||
let mut msg = Message::new();
|
||||
msg.set_misc(misc);
|
||||
self.send(Data::Message(msg));
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InvokeUiSession: Send + Sync + Clone + 'static + Sized + Default {
|
||||
|
||||
@@ -536,6 +536,13 @@ pub mod amyuni_idd {
|
||||
pub fn get_monitor_count() -> usize {
|
||||
windows::get_device_names(Some(super::AMYUNI_IDD_DEVICE_STRING)).len()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_my_display(name: &str) -> bool {
|
||||
windows::get_device_names(Some(super::AMYUNI_IDD_DEVICE_STRING))
|
||||
.iter()
|
||||
.any(|s| windows::is_device_name(s, name))
|
||||
}
|
||||
}
|
||||
|
||||
mod windows {
|
||||
|
||||
Reference in New Issue
Block a user