diff --git a/src/engine/src/lib.rs b/src/engine/src/lib.rs
index 329234e7..ee08c354 100644
--- a/src/engine/src/lib.rs
+++ b/src/engine/src/lib.rs
@@ -114,41 +114,35 @@ pub fn run(
ev.run();
})?;
- // Main event loop thread to poll for foreground/system etc. events
- let ev_thread = {
- let config = config.clone();
- let session = session.clone();
- let web_state = web_state.clone();
- thread::Builder::new()
- .name("event_loop_thread".to_string())
- .spawn(move || {
- event_loop(EventLoopArgs {
- config,
- web_state,
- event_tx,
- alert_tx,
- web_change_tx,
- session,
- start,
- })
- .context("event loop")
- .expect("event loop failed");
- })?
- };
-
- rt.clone().block_on(processor(ProcessorArgs {
+ let processor_handle = rt.clone().spawn(processor(ProcessorArgs {
desktop_state,
- web_state,
+ web_state: web_state.clone(),
config: config.clone(),
- rt,
- session,
+ rt: rt.clone(),
+ session: session.clone(),
start,
event_rx,
alert_rx,
web_change_rx,
- }))?;
- // can't turn these to [util::error::Result]s :/
- ev_thread.join().expect("event loop thread");
+ }));
+
+ // Main event loop thread to poll for foreground/system etc. events
+ event_loop(EventLoopArgs {
+ config: config.clone(),
+ web_state,
+ event_tx,
+ alert_tx,
+ web_change_tx,
+ session,
+ start,
+ })
+ .context("event loop")
+ .expect("event loop failed");
+
+ rt.block_on(processor_handle)
+ .expect("processor loop join")
+ .context("processor loop")
+ .expect("processor loop");
it_ev_thread.join().expect("interaction event loop thread");
Ok(())
}
diff --git a/src/platform/src/events/system.rs b/src/platform/src/events/system.rs
index 7d4d9c6f..29a265ba 100644
--- a/src/platform/src/events/system.rs
+++ b/src/platform/src/events/system.rs
@@ -1,6 +1,6 @@
use util::error::{Context, Result};
use util::tracing::{ResultTraceExt, info};
-use windows::Win32::Foundation::HANDLE;
+use windows::Win32::Foundation::{HANDLE, LRESULT};
use windows::Win32::System::Power::{
HPOWERNOTIFY, POWERBROADCAST_SETTING, RegisterPowerSettingNotification,
UnregisterPowerSettingNotification,
@@ -10,9 +10,9 @@ use windows::Win32::System::RemoteDesktop::{
};
use windows::Win32::System::SystemServices::GUID_MONITOR_POWER_ON;
use windows::Win32::UI::WindowsAndMessaging::{
- DEVICE_NOTIFY_WINDOW_HANDLE, ENDSESSION_LOGOFF, PBT_APMRESUMESUSPEND, PBT_APMSUSPEND,
- PBT_POWERSETTINGCHANGE, WM_ENDSESSION, WM_POWERBROADCAST, WM_WTSSESSION_CHANGE,
- WTS_SESSION_LOCK, WTS_SESSION_UNLOCK,
+ DEVICE_NOTIFY_WINDOW_HANDLE, ENDSESSION_CLOSEAPP, ENDSESSION_LOGOFF, PBT_APMRESUMESUSPEND,
+ PBT_APMSUSPEND, PBT_POWERSETTINGCHANGE, WM_ENDSESSION, WM_POWERBROADCAST, WM_QUERYENDSESSION,
+ WM_WTSSESSION_CHANGE, WTS_SESSION_LOCK, WTS_SESSION_UNLOCK,
};
use crate::objects::{Duration, MessageWindow, Timestamp};
@@ -144,7 +144,23 @@ impl<'a> SystemEventWatcher<'a> {
message_window.add_callback(Box::new(move |_, msg, wparam, lparam| {
let timestamp = Timestamp::now();
- if msg == WM_ENDSESSION {
+ if msg == WM_QUERYENDSESSION {
+ // This is for MSI updates (Restart Manager). We need to
+ // indicate that we can handle the end session request.
+ // https://learn.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications
+ if lparam.0 as u32 == ENDSESSION_CLOSEAPP {
+ return Some(LRESULT(1));
+ }
+ } else if msg == WM_ENDSESSION {
+ // End session request received by Restart Manager (MSI Update).
+ // We test the whole lparam to see if it is ENDSESSION_CLOSEAPP instead of bitmask
+ // so that we don't catch logoff / shutdown / restart instead.
+ // https://learn.microsoft.com/en-us/windows/win32/rstmgr/guidelines-for-applications
+ if lparam.0 as u32 == ENDSESSION_CLOSEAPP && wparam.0 as u32 == 1 {
+ info!("end session request received, exiting");
+ std::process::exit(0);
+ }
+
if lparam.0 as u32 & ENDSESSION_LOGOFF != 0 {
state.is_logoff = true;
callback(SystemStateEvent {
diff --git a/src/ui/src-tauri/installer/main.wxs b/src/ui/src-tauri/installer/main.wxs
index 4a96dde9..a13dae51 100644
--- a/src/ui/src-tauri/installer/main.wxs
+++ b/src/ui/src-tauri/installer/main.wxs
@@ -28,13 +28,6 @@
InstallScope="perMachine"
SummaryCodepage="!(loc.TauriCodepage)"/>
-
-
-
-
-