mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
prompt foreground window elevation
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -230,7 +230,8 @@ impl Connection {
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
std::thread::spawn(move || Self::handle_input(rx_input, tx_cloned));
|
||||
let mut second_timer = time::interval(Duration::from_secs(1));
|
||||
let mut uac = false;
|
||||
let mut last_uac = false;
|
||||
let mut last_foreground_window_elevated = false;
|
||||
|
||||
loop {
|
||||
tokio::select! {
|
||||
@@ -403,16 +404,23 @@ impl Connection {
|
||||
}
|
||||
},
|
||||
_ = second_timer.tick() => {
|
||||
let is_uac = crate::video_service::IS_UAC_RUNNING.lock().unwrap().clone();
|
||||
if uac != is_uac {
|
||||
if !crate::platform::is_installed() && !crate::platform::is_root() {
|
||||
uac = is_uac;
|
||||
let mut misc = Misc::new();
|
||||
misc.set_uac(uac);
|
||||
let mut msg = Message::new();
|
||||
msg.set_misc(misc);
|
||||
conn.inner.send(msg.into());
|
||||
}
|
||||
let uac = crate::video_service::IS_UAC_RUNNING.lock().unwrap().clone();
|
||||
if last_uac != uac {
|
||||
last_uac = uac;
|
||||
let mut misc = Misc::new();
|
||||
misc.set_uac(uac);
|
||||
let mut msg = Message::new();
|
||||
msg.set_misc(misc);
|
||||
conn.inner.send(msg.into());
|
||||
}
|
||||
let foreground_window_elevated = crate::video_service::IS_FOREGROUND_WINDOW_ELEVATED.lock().unwrap().clone();
|
||||
if last_foreground_window_elevated != foreground_window_elevated {
|
||||
last_foreground_window_elevated = foreground_window_elevated;
|
||||
let mut misc = Misc::new();
|
||||
misc.set_foreground_window_elevated(foreground_window_elevated);
|
||||
let mut msg = Message::new();
|
||||
msg.set_misc(misc);
|
||||
conn.inner.send(msg.into());
|
||||
}
|
||||
}
|
||||
_ = test_delay_timer.tick() => {
|
||||
|
||||
@@ -53,6 +53,7 @@ lazy_static::lazy_static! {
|
||||
static ref IS_CAPTURER_MAGNIFIER_SUPPORTED: bool = is_capturer_mag_supported();
|
||||
pub static ref VIDEO_QOS: Arc<Mutex<VideoQoS>> = Default::default();
|
||||
pub static ref IS_UAC_RUNNING: Arc<Mutex<bool>> = Default::default();
|
||||
pub static ref IS_FOREGROUND_WINDOW_ELEVATED: Arc<Mutex<bool>> = Default::default();
|
||||
}
|
||||
|
||||
fn is_capturer_mag_supported() -> bool {
|
||||
@@ -454,7 +455,7 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
let recorder: Arc<Mutex<Option<Recorder>>> = Default::default();
|
||||
#[cfg(windows)]
|
||||
start_uac_check();
|
||||
start_uac_elevation_check();
|
||||
|
||||
while sp.ok() {
|
||||
#[cfg(windows)]
|
||||
@@ -838,15 +839,21 @@ fn get_current_display() -> ResultType<(usize, usize, Display)> {
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn start_uac_check() {
|
||||
fn start_uac_elevation_check() {
|
||||
static START: Once = Once::new();
|
||||
START.call_once(|| {
|
||||
if !crate::platform::is_installed() && !crate::platform::is_root() {
|
||||
if !crate::platform::is_installed()
|
||||
&& !crate::platform::is_root()
|
||||
&& !crate::platform::is_elevated(None).map_or(false, |b| b)
|
||||
{
|
||||
std::thread::spawn(|| loop {
|
||||
std::thread::sleep(std::time::Duration::from_secs(1));
|
||||
if let Ok(uac) = crate::ui::win_privacy::is_process_consent_running() {
|
||||
*IS_UAC_RUNNING.lock().unwrap() = uac;
|
||||
}
|
||||
if let Ok(elevated) = crate::platform::is_foreground_window_elevated() {
|
||||
*IS_FOREGROUND_WINDOW_ELEVATED.lock().unwrap() = elevated;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user