From: lx-s Date: Thu, 9 Jul 2026 20:23:17 +0000 (+0200) Subject: Fixed use case if laptop starts with lid closed (e.g. in docked mode) #55 X-Git-Tag: 2.6.0.0~63 X-Git-Url: https://repos.lx-s.de/gitweb/?a=commitdiff_plain;h=2d3d59245b687960c70f4c134db6fb5d513ce375;p=winmute.git Fixed use case if laptop starts with lid closed (e.g. in docked mode) #55 --- diff --git a/WinMute/MuteControl.cpp b/WinMute/MuteControl.cpp index afcf763..9933084 100644 --- a/WinMute/MuteControl.cpp +++ b/WinMute/MuteControl.cpp @@ -420,9 +420,12 @@ void MuteControl::NotifyDisplayStandby(bool active) void MuteControl::NotifyLidClosed(bool active) { - WMLog::GetInstance().LogInfo(L"Mute Event: Lid Close {}", - active ? L"start" : L"stop"); - NotifyRestoreCondition(MuteTypeLidClose, active); + if (lidWasOpenedOnce_ || !active) { + WMLog::GetInstance().LogInfo(L"Mute Event: Lid Close {}", + active ? L"start" : L"stop"); + NotifyRestoreCondition(MuteTypeLidClose, active); + lidWasOpenedOnce_ = true; + } } void MuteControl::NotifyBluetoothConnected(bool connected) diff --git a/WinMute/MuteControl.h b/WinMute/MuteControl.h index 2a0f536..7e813f5 100644 --- a/WinMute/MuteControl.h +++ b/WinMute/MuteControl.h @@ -140,6 +140,11 @@ class MuteControl { // We skip the first "was on" message bool displayWasOffOnce_ = false; + // The lid-switch registration also reports the current state + // immediately. Ignore "closed" until the lid was open once, so a + // laptop started docked with its lid closed is not muted on launch. + bool lidWasOpenedOnce_ = false; + const TrayIcon* trayIcon_ = nullptr; void NotifyRestoreCondition(MuteType type, bool active, diff --git a/WinMute/WinMute.cpp b/WinMute/WinMute.cpp index 5478a8f..494f10a 100644 --- a/WinMute/WinMute.cpp +++ b/WinMute/WinMute.cpp @@ -715,7 +715,7 @@ LRESULT WinMute::OnPowerBroadcast(HWND, WPARAM wParam, LPARAM lParam) if (state == 0x0) { // Lid closed muteCtrl_.NotifyLidClosed(true); } else if (state == 0x1) { // Lid open - muteCtrl_.NotifyLidClosed(true); + muteCtrl_.NotifyLidClosed(false); } } }