hookDll_(nullptr),
regHook_(nullptr),
unregHook_(nullptr),
+ alreadyNotified_(false),
hookWndMsg_(0)
{ }
}
}
+/* ========================================================================== */
+/* Other */
+/* ========================================================================== */
+
+bool ScreensaverNotifier::IsScreensaverRunning()
+{
+ BOOL isRunning = FALSE;
+ if (SystemParametersInfo(SPI_GETSCREENSAVERRUNNING,
+ 0,
+ &isRunning,
+ FALSE) == NULL) {
+ PrintWindowsError(_T("SystemParametersInfo"));
+ return false;
+ }
+ return isRunning != 0;
+}
+
/* ========================================================================== */
/* Window Proc */
/* ========================================================================== */
}
case WM_TIMER: {
if (wParam == SCRSV_TIMER_ID) {
- BOOL isRunning = FALSE;
- if (SystemParametersInfo(SPI_GETSCREENSAVERRUNNING,
- 0,
- &isRunning,
- FALSE) == NULL) {
- PrintWindowsError(_T("SystemParametersInfo"));
- } else {
- if (!isRunning) {
- StartScreensaverPollTimer(false);
- SendMessage(hNotifyWnd_, WM_SCRNSAVE_CHANGE, SCRNSAVE_STOP, 0);
- }
+ if (!IsScreensaverRunning()) {
+ StartScreensaverPollTimer(false);
+ SendMessage(hNotifyWnd_, WM_SCRNSAVE_CHANGE, SCRNSAVE_STOP, 0);
+ alreadyNotified_ = false;
}
}
return 0;
}
default:
if (hookWndMsg_ != 0 && msg == hookWndMsg_) {
- SendMessage(hNotifyWnd_, WM_SCRNSAVE_CHANGE, SCRNSAVE_START, 0);
- StartScreensaverPollTimer();
+ /* Windows sends SC_SCREENSAVE when it tries to start a screensaver.
+ If screensaver is set to "none" or if another application cancels
+ this event, we would falsely mute windows.
+ To prevent that, we wait for a few milliseconds to and then check
+ if the screensaver has actually started. If yes, then send the
+ notification.
+ */
+ Sleep(500);
+ if (IsScreensaverRunning()) {
+ /* SC_SCREENSAVE might be fired multiple times */
+ if (!alreadyNotified_) {
+ alreadyNotified_ = true;
+ SendMessage(hNotifyWnd_, WM_SCRNSAVE_CHANGE, SCRNSAVE_START, 0);
+ StartScreensaverPollTimer();
+ }
+ }
}
break;
}
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,194,7,50,14
- LTEXT "WinMute v1.4",IDC_STATIC,43,9,67,11
+ LTEXT "WinMute v1.4.1",IDC_STATIC,43,9,67,11
CONTROL "<a href=""http://lx-s.de"">lx-systems - lx-s.de</a>",IDC_LINK_HOMEPAGE,
"SysLink",WS_TABSTOP,43,31,69,13
LTEXT "Copyright © 2014 Alexander Steinhöfer",IDC_STATIC,43,20,148,12
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,4,0,0
- PRODUCTVERSION 1,4,0,0
+ FILEVERSION 1,4,1,0
+ PRODUCTVERSION 1,4,1,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
BEGIN
BLOCK "000004b0"
BEGIN
- VALUE "CompanyName", "lx-s"
+ VALUE "CompanyName", "lx-systems"
VALUE "FileDescription", "Automatic sound muter."
- VALUE "FileVersion", "1.4.0.0"
+ VALUE "FileVersion", "1.4.1.0"
VALUE "InternalName", "WinMute"
- VALUE "LegalCopyright", "Copyright (C) 2013 Alexander Steinhöfer"
+ VALUE "LegalCopyright", "Copyright (C) 2014, Alexander Steinhöfer"
VALUE "OriginalFilename", "WinMute.exe"
VALUE "ProductName", "WinMute"
- VALUE "ProductVersion", "1.4.0.0"
+ VALUE "ProductVersion", "1.4.1.0"
END
BLOCK "040704b0"
BEGIN
- VALUE "CompanyName", "lx-s"
+ VALUE "CompanyName", "lx-systems"
VALUE "FileDescription", "Automatisches Stummschalten bei PC Sperre."
- VALUE "FileVersion", "1.4.0.0"
+ VALUE "FileVersion", "1.4.1.0"
VALUE "InternalName", "WinMute"
- VALUE "LegalCopyright", "Copyright (C) 2013 Alexander Steinhöfer"
+ VALUE "LegalCopyright", "Copyright (C) 2014, Alexander Steinhöfer"
VALUE "OriginalFilename", "WinMute.exe"
VALUE "ProductName", "WinMute"
- VALUE "ProductVersion", "1.4.0.0"
+ VALUE "ProductVersion", "1.4.1.0"
END
END
BLOCK "VarFileInfo"