portable service only run on main display (#8525)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-06-29 14:17:24 +08:00
committed by GitHub
parent 1fd170b089
commit d67afa49b4
46 changed files with 123 additions and 183 deletions

View File

@@ -2506,25 +2506,6 @@ impl Connection {
}
async fn handle_switch_display(&mut self, s: SwitchDisplay) {
#[cfg(windows)]
if portable_client::running()
&& *CONN_COUNT.lock().unwrap() > 1
&& s.display != (*display_service::PRIMARY_DISPLAY_IDX as i32)
{
log::info!("Switch to non-primary display is not supported in the elevated mode when there are multiple connections.");
let mut msg_out = Message::new();
let res = MessageBox {
msgtype: "nook-nocancel-hasclose".to_owned(),
title: "Prompt".to_owned(),
text: "switch_display_elevated_connections_tip".to_owned(),
link: "".to_owned(),
..Default::default()
};
msg_out.set_message_box(res);
self.send(msg_out).await;
return;
}
let display_idx = s.display as usize;
if self.display_idx != display_idx {
if let Some(server) = self.server.upgrade() {
@@ -2594,22 +2575,6 @@ impl Connection {
}
async fn capture_displays(&mut self, add: &[usize], sub: &[usize], set: &[usize]) {
#[cfg(windows)]
if portable_client::running() && (add.len() > 0 || set.len() > 1) {
log::info!("Capturing multiple displays is not supported in the elevated mode.");
let mut msg_out = Message::new();
let res = MessageBox {
msgtype: "nook-nocancel-hasclose".to_owned(),
title: "Prompt".to_owned(),
text: "capture_display_elevated_connections_tip".to_owned(),
link: "".to_owned(),
..Default::default()
};
msg_out.set_message_box(res);
self.send(msg_out).await;
return;
}
if let Some(sever) = self.server.upgrade() {
let mut lock = sever.write().unwrap();
for display in add.iter() {

View File

@@ -895,7 +895,7 @@ pub mod client {
if portable_service_running != RUNNING.lock().unwrap().clone() {
log::info!("portable service status mismatch");
}
if portable_service_running {
if portable_service_running && display.is_primary() {
log::info!("Create shared memory capturer");
return Ok(Box::new(CapturerPortable::new(current_display)));
} else {