Skip to content

Commit

Permalink
WM_SETTINGCHANGE msg handling, for dark/light mode detection in windows
Browse files Browse the repository at this point in the history
11.
  • Loading branch information
fxliang committed Dec 30, 2023
1 parent 1d5fef6 commit af27e71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions WeaselIPCServer/WeaselServerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ void ServerImpl::_Finailize()

LRESULT ServerImpl::OnColorChange(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
if(IsUserDarkMode() != m_darkMode) {
m_darkMode = IsUserDarkMode();
m_pRequestHandler->UpdateColorTheme(m_darkMode);
if (uMsg == WM_SETTINGCHANGE && (std::wstring((wchar_t*)lParam) == L"ImmersiveColorSet") || uMsg == WM_DWMCOLORIZATIONCOLORCHANGED) {
if (IsUserDarkMode() != m_darkMode) {
m_darkMode = IsUserDarkMode();
m_pRequestHandler->UpdateColorTheme(m_darkMode);
}
}
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions WeaselIPCServer/WeaselServerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace weasel
MESSAGE_HANDLER(WM_QUERYENDSESSION, OnQueryEndSystemSession)
MESSAGE_HANDLER(WM_ENDSESSION, OnEndSystemSession)
MESSAGE_HANDLER(WM_DWMCOLORIZATIONCOLORCHANGED, OnColorChange)
MESSAGE_HANDLER(WM_SETTINGCHANGE, OnColorChange)
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
END_MSG_MAP()

Expand Down

0 comments on commit af27e71

Please sign in to comment.