diff --git a/CHANGELOG.md b/CHANGELOG.md index a025933..6f3b6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Tested on OS build 22000.434. * Possibility to disable the icon in the weather widget (.1) * The weather widget defaults to showing in the preferred language set in Windows, instead of English (#734) (.2) * The weather widget shows an error screen when an error happens (like, using an incorrect location, or the network not working etc) (.3) +* The weather widget supports dark mode (thanks @krlvm) (#755) (.4) #### Fixes diff --git a/ExplorerPatcher/dllmain.c b/ExplorerPatcher/dllmain.c index 1484120..2b2598a 100644 --- a/ExplorerPatcher/dllmain.c +++ b/ExplorerPatcher/dllmain.c @@ -108,6 +108,8 @@ DWORD dwWeatherViewMode = EP_WEATHER_VIEW_ICONTEXT; DWORD dwWeatherTemperatureUnit = EP_WEATHER_TUNIT_CELSIUS; DWORD dwWeatherUpdateSchedule = EP_WEATHER_UPDATE_NORMAL; DWORD bWeatherFixedSize = FALSE; +DWORD dwWeatherTheme = 0; +DWORD dwWeatherGeolocationMode = 0; WCHAR* wszWeatherTerm = NULL; WCHAR* wszWeatherLanguage = NULL; WCHAR* wszEPWeatherKillswitch = NULL; @@ -3733,9 +3735,9 @@ SIZE WINAPI PeopleButton_CalculateMinimumSizeHook(void* _this, SIZE* pSz) RECT rcWeatherFlyoutWindow; rcWeatherFlyoutWindow.left = mi.rcWork.left; rcWeatherFlyoutWindow.top = mi.rcWork.top; - rcWeatherFlyoutWindow.right = rcWeatherFlyoutWindow.left + MulDiv(EP_WEATHER_HEIGHT, dpiX, 96); - rcWeatherFlyoutWindow.bottom = rcWeatherFlyoutWindow.top + MulDiv(EP_WEATHER_WIDTH, dpiX, 96); - if (FAILED(epw->lpVtbl->Initialize(epw, wszEPWeatherKillswitch, bAllocConsole, EP_WEATHER_PROVIDER_GOOGLE, rt, rt, dwWeatherTemperatureUnit, dwWeatherUpdateSchedule * 1000, rcWeatherFlyoutWindow, &hWndWeatherFlyout))) + rcWeatherFlyoutWindow.right = rcWeatherFlyoutWindow.left + MulDiv(EP_WEATHER_WIDTH, dpiX, 96); + rcWeatherFlyoutWindow.bottom = rcWeatherFlyoutWindow.top + MulDiv(EP_WEATHER_HEIGHT, dpiX, 96); + if (FAILED(epw->lpVtbl->Initialize(epw, wszEPWeatherKillswitch, bAllocConsole, EP_WEATHER_PROVIDER_GOOGLE, rt, rt, dwWeatherTemperatureUnit, dwWeatherUpdateSchedule * 1000, rcWeatherFlyoutWindow, dwWeatherTheme, dwWeatherGeolocationMode, &hWndWeatherFlyout))) { epw->lpVtbl->Release(epw); } @@ -5542,6 +5544,42 @@ void WINAPI LoadSettings(LPARAM lParam) { dwRefreshUIMask |= REFRESHUI_PEOPLE; } + + DWORD dwOldWeatherTheme = dwWeatherTheme; + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("WeatherTheme"), + 0, + NULL, + &dwWeatherTheme, + &dwSize + ); + if (dwWeatherTheme != dwOldWeatherTheme && PeopleButton_LastHWND) + { + if (epw) + { + epw->lpVtbl->SetDarkMode(epw, (LONG64)dwWeatherTheme, TRUE); + } + } + + DWORD dwOldWeatherGeolocationMode = dwWeatherGeolocationMode; + dwSize = sizeof(DWORD); + RegQueryValueExW( + hKey, + TEXT("WeatherLocationType"), + 0, + NULL, + &dwWeatherGeolocationMode, + &dwSize + ); + if (dwWeatherGeolocationMode != dwOldWeatherGeolocationMode && PeopleButton_LastHWND) + { + if (epw) + { + epw->lpVtbl->SetGeolocationMode(epw, (LONG64)dwWeatherGeolocationMode); + } + } #endif dwTemp = TASKBARGLOMLEVEL_DEFAULT; diff --git a/ExplorerPatcher/settings.reg b/ExplorerPatcher/settings.reg index 1af04cd..b7bc8d0 100644 --- a/ExplorerPatcher/settings.reg +++ b/ExplorerPatcher/settings.reg @@ -375,13 +375,22 @@ ;x 1 Fahrenheit "WeatherTemperatureUnit"=dword:00000000 ;w Location -;Search City or Zip Code; the program looks up "weather in /* what you typed */" on Google. Leave blank for the default value (IP-based current location). +;Search City or Zip Code; the program looks up "weather in /* what you typed */" on Google. Leave blank for the default value (current location). ;Current location (default) "WeatherLocation"="" +;;;c 2 Location accuracy +;;;x 0 Generic (based on the IP address) (default) +;;;x 1 Precise (geolocation) +;;"WeatherLocationType"=dword:00000000 ;w Language ;Type the short code for the language you'd like the weather data to be displayed in. For example, try "en", "ro", "de", "fr" etc. Leave blank for the default value (English). ;en (default) "WeatherLanguage"="" +;c 3 Color scheme +;x 0 Follow system setting (default) +;x 1 Light +;x 2 Dark +"WeatherTheme"=dword:00000000 ;q ;t Weather data courtesy of Google, and weather.com. ;y Learn more about the Weather taskbar widget 🡕 diff --git a/ep_weather_host/ep_weather.c b/ep_weather_host/ep_weather.c index b5d2097..42481b2 100644 --- a/ep_weather_host/ep_weather.c +++ b/ep_weather_host/ep_weather.c @@ -6,6 +6,12 @@ HMODULE epw_hModule; DWORD epw_OutstandingObjects = 0; DWORD epw_LockCount = 0; +void(*RefreshImmersiveColorPolicyState)(); +void(*SetPreferredAppMode)(INT64 bAllowDark); +void(*AllowDarkModeForWindow)(HWND hWnd, INT64 bAllowDark); +BOOL(*ShouldAppsUseDarkMode)(); +BOOL(*ShouldSystemUseDarkMode)(); + #ifdef _WIN64 #pragma comment(linker, "/export:DllRegisterServer=_DllRegisterServer") #else diff --git a/ep_weather_host/ep_weather.h b/ep_weather_host/ep_weather.h index 96b5a8f..c6b1cc1 100644 --- a/ep_weather_host/ep_weather.h +++ b/ep_weather_host/ep_weather.h @@ -50,7 +50,8 @@ DEFINE_GUID(IID_IEPWeather, #define EP_WEATHER_UPDATE_REDUCED 3600 #define EP_WEATHER_WM_FETCH_DATA (WM_USER + 10) +#define EP_WEATHER_WM_SET_BROWSER_THEME (WM_USER + 11) -#define EP_WEATHER_WIDTH 425 -#define EP_WEATHER_HEIGHT 690 +#define EP_WEATHER_HEIGHT 391 +#define EP_WEATHER_WIDTH 690 #endif diff --git a/ep_weather_host/ep_weather_error_html.h b/ep_weather_host/ep_weather_error_html.h index 75d2f51..6213c43 100644 --- a/ep_weather_host/ep_weather_error_html.h +++ b/ep_weather_host/ep_weather_error_html.h @@ -7,6 +7,7 @@ LPCWSTR ep_weather_error_html = L"\ \n\
\n\ \n\ +\n\