Skip to content

Commit

Permalink
Merge pull request rustdesk#6446 from fufesou/fix/do_not_get_displays…
Browse files Browse the repository at this point in the history
…_on_start

Fix. Do not get displays on server start.
  • Loading branch information
rustdesk authored Nov 17, 2023
2 parents 35eaa94 + f2f6493 commit 0b5f48b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ pub fn new() -> ServerPtr {
server.add_service(Box::new(audio_service::new()));
#[cfg(not(target_os = "ios"))]
server.add_service(Box::new(display_service::new()));
server.add_service(Box::new(video_service::new(
*display_service::PRIMARY_DISPLAY_IDX,
)));
#[cfg(not(any(target_os = "android", target_os = "ios")))]
{
server.add_service(Box::new(clipboard_service::new()));
Expand Down Expand Up @@ -262,6 +259,16 @@ impl Server {
name.starts_with(video_service::NAME)
}

pub fn try_add_primay_video_service(&mut self) {
let primary_video_service_name =
video_service::get_service_name(*display_service::PRIMARY_DISPLAY_IDX);
if !self.contains(&primary_video_service_name) {
self.add_service(Box::new(video_service::new(
*display_service::PRIMARY_DISPLAY_IDX,
)));
}
}

pub fn add_connection(&mut self, conn: ConnInner, noperms: &Vec<&'static str>) {
let primary_video_service_name =
video_service::get_service_name(*display_service::PRIMARY_DISPLAY_IDX);
Expand Down
1 change: 1 addition & 0 deletions src/server/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,7 @@ impl Connection {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
let _h = try_start_record_cursor_pos();
self.auto_disconnect_timer = Self::get_auto_disconenct_timer();
s.try_add_primay_video_service();
s.add_connection(self.inner.clone(), &noperms);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/display_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ lazy_static::lazy_static! {
static ref IS_CAPTURER_MAGNIFIER_SUPPORTED: bool = is_capturer_mag_supported();
static ref CHANGED_RESOLUTIONS: Arc<RwLock<HashMap<String, ChangedResolution>>> = Default::default();
// Initial primary display index.
// It should only be updated when the rustdesk server is started, and should not be updated when displays changed.
// It should should not be updated when displays changed.
pub static ref PRIMARY_DISPLAY_IDX: usize = get_primary();
static ref SYNC_DISPLAYS: Arc<Mutex<SyncDisplaysInfo>> = Default::default();
}
Expand Down

0 comments on commit 0b5f48b

Please sign in to comment.