fix: ignore (un)lock events for sessions that aren't the current session (#21805)
This commit is contained in:
parent
38947f43de
commit
ebe8bddc31
1 changed files with 14 additions and 4 deletions
|
@ -58,10 +58,20 @@ LRESULT CALLBACK PowerMonitor::WndProc(HWND hwnd,
|
||||||
WPARAM wparam,
|
WPARAM wparam,
|
||||||
LPARAM lparam) {
|
LPARAM lparam) {
|
||||||
if (message == WM_WTSSESSION_CHANGE) {
|
if (message == WM_WTSSESSION_CHANGE) {
|
||||||
if (wparam == WTS_SESSION_LOCK) {
|
bool should_treat_as_current_session = true;
|
||||||
Emit("lock-screen");
|
DWORD current_session_id = 0;
|
||||||
} else if (wparam == WTS_SESSION_UNLOCK) {
|
if (!::ProcessIdToSessionId(::GetCurrentProcessId(), ¤t_session_id)) {
|
||||||
Emit("unlock-screen");
|
LOG(ERROR) << "ProcessIdToSessionId failed, assuming current session";
|
||||||
|
} else {
|
||||||
|
should_treat_as_current_session =
|
||||||
|
(static_cast<DWORD>(lparam) == current_session_id);
|
||||||
|
}
|
||||||
|
if (should_treat_as_current_session) {
|
||||||
|
if (wparam == WTS_SESSION_LOCK) {
|
||||||
|
Emit("lock-screen");
|
||||||
|
} else if (wparam == WTS_SESSION_UNLOCK) {
|
||||||
|
Emit("unlock-screen");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ::DefWindowProc(hwnd, message, wparam, lparam);
|
return ::DefWindowProc(hwnd, message, wparam, lparam);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue