]> repos.lx-s.de Git - winmute.git/commitdiff
Fixed use case if laptop starts with lid closed (e.g. in docked mode) #55
authorlx-s <lx-s@users.noreply.github.com>
Thu, 9 Jul 2026 20:23:17 +0000 (22:23 +0200)
committerlx-s <lx-s@users.noreply.github.com>
Thu, 9 Jul 2026 20:23:17 +0000 (22:23 +0200)
WinMute/MuteControl.cpp
WinMute/MuteControl.h
WinMute/WinMute.cpp

index afcf76361a1f7adbff785c12d3a8b6a574066202..9933084c41fe3dadd4329f41ed4ec7fc9b8491b5 100644 (file)
@@ -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)
index 2a0f53699174820f8394305d38b808927fec92a6..7e813f5e7aeb456ffb1bdcea92141e84d3922850 100644 (file)
@@ -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,
index 5478a8ff58c1065be4a64b881902f0a14cc11827..494f10a98474967428f72e62ae273f177a61a0ca 100644 (file)
@@ -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);
             }
         }
     }