From bdb7a87326ac37f3ee24bd6cd45aeb8786024600 Mon Sep 17 00:00:00 2001 From: Jacob Halsey Date: Sat, 20 Jan 2024 12:22:52 +0000 Subject: [PATCH] Fix deadlock on exit button (#30) --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/event_watcher/windows.rs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ede91b4..5da3e8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3445,7 +3445,7 @@ dependencies = [ [[package]] name = "solar-screen-brightness" -version = "2.2.0" +version = "2.3.0" dependencies = [ "anyhow", "brightness", diff --git a/Cargo.toml b/Cargo.toml index 0ba73f8..8cdcf7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solar-screen-brightness" -version = "2.2.0" +version = "2.3.0" authors = ["Jacob Halsey "] edition = "2021" build = "build.rs" diff --git a/src/event_watcher/windows.rs b/src/event_watcher/windows.rs index fa958db..ec2f479 100644 --- a/src/event_watcher/windows.rs +++ b/src/event_watcher/windows.rs @@ -11,7 +11,7 @@ use windows::Win32::Foundation::{HWND, LPARAM, LRESULT, WPARAM}; use windows::Win32::System::LibraryLoader::GetModuleHandleW; use windows::Win32::System::RemoteDesktop::WTSRegisterSessionNotification; use windows::Win32::UI::WindowsAndMessaging::{ - CreateWindowExW, DefWindowProcA, DispatchMessageA, GetMessageA, PostQuitMessage, + CreateWindowExW, DefWindowProcA, DispatchMessageW, GetMessageW, PostQuitMessage, RegisterClassW, RegisterWindowMessageW, SendMessageW, SetWindowLongPtrW, CW_USEDEFAULT, GWLP_USERDATA, MSG, WINDOW_EX_STYLE, WINDOW_STYLE, WM_APP, WM_DISPLAYCHANGE, WM_WTSSESSION_CHANGE, WNDCLASSW, WTS_SESSION_LOCK, WTS_SESSION_UNLOCK, @@ -81,11 +81,11 @@ impl EventWatcher { WTSRegisterSessionNotification(hwnd, 0).unwrap(); let mut message = MSG::default(); - while GetMessageA(&mut message, hwnd, 0, 0).into() { - DispatchMessageA(&message); + while GetMessageW(&mut message, None, 0, 0).into() { + DispatchMessageW(&message); } } - log::info!("EventWatcher thread exiting"); + log::debug!("EventWatcher thread exiting"); }); let hwnd = rx.recv().unwrap(); @@ -126,7 +126,7 @@ unsafe extern "system" fn wndproc( .unwrap(); } EXIT_LOOP => { - log::info!("Received EXIT_LOOP message"); + log::debug!("Received EXIT_LOOP message"); PostQuitMessage(0); } WM_WTSSESSION_CHANGE => match wparam.0 as u32 {