Skip to content

Commit

Permalink
System: Redraw skins when a user session changes
Browse files Browse the repository at this point in the history
Fixes issue with certain builds of Windows 7 where the skin window would appear to disappear when returning from the Windows "Switch user" screen
https://forum.rainmeter.net/viewtopic.php?t=39722#p203252
  • Loading branch information
brianferguson committed Jan 28, 2022
1 parent d5e1f48 commit 9c4eee8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Library/Library.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<AdditionalDependencies>Bcrypt.lib;comctl32.lib;dwmapi.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;ws2_32.lib;PowrProf.lib;netapi32.lib;Ntdll.lib;shlwapi.lib;d3d11.lib;d2d1.lib;dwrite.lib;windowscodecs.lib;Version.lib;Imagehlp.lib;Urlmon.lib;psapi.lib;dxguid.lib;Rpcrt4.lib;wlanapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>Bcrypt.lib;comctl32.lib;dwmapi.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;ws2_32.lib;PowrProf.lib;netapi32.lib;Ntdll.lib;shlwapi.lib;d3d11.lib;d2d1.lib;dwrite.lib;windowscodecs.lib;Version.lib;Imagehlp.lib;Urlmon.lib;psapi.lib;dxguid.lib;Rpcrt4.lib;wlanapi.lib;Wtsapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>Bcrypt.dll;dwmapi.dll;Iphlpapi.dll;Winmm.dll;Version.dll;Imagehlp.dll;Urlmon.dll;psapi.dll;wlanapi.dll;$(DelayLoadTestDLL)</DelayLoadDLLs>
<ModuleDefinitionFile>Exports.def</ModuleDefinitionFile>
</Link>
Expand Down
16 changes: 16 additions & 0 deletions Library/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "MeasureNet.h"
#include "../Common/PathUtil.h"
#include <TlHelp32.h>
#include <WtsApi32.h>

using namespace Gdiplus;

Expand Down Expand Up @@ -88,6 +89,8 @@ void System::Initialize(HINSTANCE instance)
instance,
nullptr);

WTSRegisterSessionNotification(c_Window, NOTIFY_FOR_THIS_SESSION);

SetWindowPos(c_Window, HWND_BOTTOM, 0, 0, 0, 0, ZPOS_FLAGS);
SetWindowPos(c_HelperWindow, HWND_BOTTOM, 0, 0, 0, 0, ZPOS_FLAGS);

Expand Down Expand Up @@ -133,6 +136,7 @@ void System::Finalize()

if (c_Window)
{
WTSUnRegisterSessionNotification(c_Window);
DestroyWindow(c_Window);
c_Window = nullptr;
}
Expand Down Expand Up @@ -983,6 +987,18 @@ LRESULT CALLBACK System::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
return TRUE;

case WM_WTSSESSION_CHANGE:
LogDebugF(L"System: User session change detected! Session ID: 0x%08X Type: 0x%08X", lParam, wParam);
if (GetRainmeter().IsRedrawable())
{
std::map<std::wstring, Skin*>::const_iterator iter = GetRainmeter().GetAllSkins().begin();
for (; iter != GetRainmeter().GetAllSkins().end(); ++iter)
{
(*iter).second->RedrawWindow();
}
}
break;

default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Expand Down

0 comments on commit 9c4eee8

Please sign in to comment.