mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-12-12 18:29:10 +08:00
fix/change_display_resolution, send change resolution message
Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
parent
21f7d6c9b9
commit
4d537b2a9a
@ -60,7 +60,9 @@ impl SyncDisplaysInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function is really useful, though a duplicate check if display changed.
|
// This function is really useful, though a duplicate check if display changed.
|
||||||
// Because the video server will send the supported resolutions of the {idx} display to the subscribers.
|
// The video server will then send the following messages to the client:
|
||||||
|
// 1. the supported resolutions of the {idx} display
|
||||||
|
// 2. the switch resolution message, so that the client can record the custom resolution.
|
||||||
pub(super) fn check_display_changed(
|
pub(super) fn check_display_changed(
|
||||||
ndisplay: usize,
|
ndisplay: usize,
|
||||||
idx: usize,
|
idx: usize,
|
||||||
|
@ -298,7 +298,6 @@ fn check_uac_switch(privacy_mode_id: i32, capturer_privacy_mode_id: i32) -> Resu
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct CapturerInfo {
|
pub(super) struct CapturerInfo {
|
||||||
pub name: String,
|
|
||||||
pub origin: (i32, i32),
|
pub origin: (i32, i32),
|
||||||
pub width: usize,
|
pub width: usize,
|
||||||
pub height: usize,
|
pub height: usize,
|
||||||
@ -390,7 +389,6 @@ fn get_capturer(
|
|||||||
portable_service_running,
|
portable_service_running,
|
||||||
)?;
|
)?;
|
||||||
Ok(CapturerInfo {
|
Ok(CapturerInfo {
|
||||||
name,
|
|
||||||
origin,
|
origin,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@ -489,6 +487,7 @@ fn run(vs: VideoService) -> ResultType<()> {
|
|||||||
drop(video_qos);
|
drop(video_qos);
|
||||||
|
|
||||||
if sp.is_option_true(OPTION_REFRESH) {
|
if sp.is_option_true(OPTION_REFRESH) {
|
||||||
|
let _ = try_broadcast_display_changed(&sp, display_idx, &c);
|
||||||
bail!("SWITCH");
|
bail!("SWITCH");
|
||||||
}
|
}
|
||||||
if codec_name != Encoder::negotiated_codec() {
|
if codec_name != Encoder::negotiated_codec() {
|
||||||
@ -510,15 +509,7 @@ fn run(vs: VideoService) -> ResultType<()> {
|
|||||||
let now = time::Instant::now();
|
let now = time::Instant::now();
|
||||||
if last_check_displays.elapsed().as_millis() > 1000 {
|
if last_check_displays.elapsed().as_millis() > 1000 {
|
||||||
last_check_displays = now;
|
last_check_displays = now;
|
||||||
if let Some(display) = check_display_changed(
|
try_broadcast_display_changed(&sp, display_idx, &c)?;
|
||||||
c.ndisplay,
|
|
||||||
c.current,
|
|
||||||
(c.origin.0, c.origin.1, c.width, c.height),
|
|
||||||
) {
|
|
||||||
log::info!("Display {} changed", display);
|
|
||||||
broadcast_display_changed(display_idx, &sp, display);
|
|
||||||
bail!("SWITCH");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_controller.reset();
|
frame_controller.reset();
|
||||||
@ -595,15 +586,7 @@ fn run(vs: VideoService) -> ResultType<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if let Some(display) = check_display_changed(
|
try_broadcast_display_changed(&sp, display_idx, &c)?;
|
||||||
c.ndisplay,
|
|
||||||
c.current,
|
|
||||||
(c.origin.0, c.origin.1, c.width, c.height),
|
|
||||||
) {
|
|
||||||
log::info!("Display {} changed", display);
|
|
||||||
broadcast_display_changed(display_idx, &sp, display);
|
|
||||||
bail!("SWITCH");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
if !c.is_gdi() {
|
if !c.is_gdi() {
|
||||||
@ -858,11 +841,24 @@ fn get_wake_lock() -> crate::platform::WakeLock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn broadcast_display_changed(display_idx: usize, sp: &GenericService, display: DisplayInfo) {
|
fn try_broadcast_display_changed(
|
||||||
|
sp: &GenericService,
|
||||||
|
display_idx: usize,
|
||||||
|
cap: &CapturerInfo,
|
||||||
|
) -> ResultType<()> {
|
||||||
|
if let Some(display) = check_display_changed(
|
||||||
|
cap.ndisplay,
|
||||||
|
cap.current,
|
||||||
|
(cap.origin.0, cap.origin.1, cap.width, cap.height),
|
||||||
|
) {
|
||||||
|
log::info!("Display {} changed", display);
|
||||||
if let Some(msg_out) = make_display_changed_msg(display_idx, Some(display)) {
|
if let Some(msg_out) = make_display_changed_msg(display_idx, Some(display)) {
|
||||||
sp.send(msg_out);
|
sp.send(msg_out);
|
||||||
|
bail!("SWITCH");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn make_display_changed_msg(
|
pub fn make_display_changed_msg(
|
||||||
display_idx: usize,
|
display_idx: usize,
|
||||||
|
Loading…
Reference in New Issue
Block a user