always block desktop settings page if video connection exists (#10224)

1. Always block desktop settings page if video connection exists, both mouse event and key event are blocked..
2. Server control page always block key event.

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages
2024-12-08 18:26:55 +08:00
committed by GitHub
parent 1c17fddf51
commit d4a712bb32
11 changed files with 126 additions and 53 deletions

View File

@@ -47,6 +47,8 @@ pub struct UiStatus {
pub mouse_time: i64,
#[cfg(not(feature = "flutter"))]
pub id: String,
#[cfg(feature = "flutter")]
pub video_conn_count: usize,
}
#[derive(Debug, Clone, Serialize)]
@@ -65,14 +67,14 @@ lazy_static::lazy_static! {
mouse_time: 0,
#[cfg(not(feature = "flutter"))]
id: "".to_owned(),
#[cfg(feature = "flutter")]
video_conn_count: 0,
}));
static ref ASYNC_JOB_STATUS : Arc<Mutex<String>> = Default::default();
static ref ASYNC_HTTP_STATUS : Arc<Mutex<HashMap<String, String>>> = Arc::new(Mutex::new(HashMap::new()));
static ref TEMPORARY_PASSWD : Arc<Mutex<String>> = Arc::new(Mutex::new("".to_owned()));
}
pub static VIDEO_CONN_COUNT: AtomicUsize = AtomicUsize::new(0);
#[cfg(not(any(target_os = "android", target_os = "ios")))]
lazy_static::lazy_static! {
static ref OPTION_SYNCED: Arc<Mutex<bool>> = Default::default();
@@ -1144,6 +1146,8 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
let mut key_confirmed = false;
let mut rx = rx;
let mut mouse_time = 0;
#[cfg(feature = "flutter")]
let mut video_conn_count = 0;
#[cfg(not(feature = "flutter"))]
let mut id = "".to_owned();
#[cfg(any(
@@ -1204,8 +1208,9 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
*TEMPORARY_PASSWD.lock().unwrap() = value;
}
}
#[cfg(feature = "flutter")]
Ok(Some(ipc::Data::VideoConnCount(Some(n)))) => {
VIDEO_CONN_COUNT.store(n, Ordering::Relaxed);
video_conn_count = n;
}
Ok(Some(ipc::Data::OnlineStatus(Some((mut x, _c))))) => {
if x > 0 {
@@ -1223,6 +1228,8 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
mouse_time,
#[cfg(not(feature = "flutter"))]
id: id.clone(),
#[cfg(feature = "flutter")]
video_conn_count,
};
}
_ => {}
@@ -1236,6 +1243,7 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
c.send(&ipc::Data::Options(None)).await.ok();
c.send(&ipc::Data::Config(("id".to_owned(), None))).await.ok();
c.send(&ipc::Data::Config(("temporary-password".to_owned(), None))).await.ok();
#[cfg(feature = "flutter")]
c.send(&ipc::Data::VideoConnCount(None)).await.ok();
}
}
@@ -1256,6 +1264,8 @@ async fn check_connect_status_(reconnect: bool, rx: mpsc::UnboundedReceiver<ipc:
mouse_time,
#[cfg(not(feature = "flutter"))]
id: id.clone(),
#[cfg(feature = "flutter")]
video_conn_count,
};
sleep(1.).await;
}