uxtheme: Do not overwrite system metrics when loading the same theme.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51986
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52025
Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2021-11-19 15:39:11 +08:00 committed by Alexandre Julliard
parent a9e00347b7
commit ea71625cf1
1 changed files with 6 additions and 1 deletions

View File

@ -421,7 +421,7 @@ static void UXTHEME_SaveSystemMetrics(struct system_metrics *metrics, BOOL send_
*/ */
HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf) HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
{ {
BOOL ret, loaded_before = FALSE; BOOL ret, loaded_before = FALSE, same_theme = FALSE;
struct system_metrics metrics; struct system_metrics metrics;
DWORD size; DWORD size;
HKEY hKey; HKEY hKey;
@ -430,6 +430,9 @@ HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
if(tf) { if(tf) {
bThemeActive = TRUE; bThemeActive = TRUE;
same_theme = !lstrcmpW(szCurrentTheme, tf->szThemeFile)
&& !lstrcmpW(szCurrentColor, tf->pszSelectedColor)
&& !lstrcmpW(szCurrentSize, tf->pszSelectedSize);
lstrcpynW(szCurrentTheme, tf->szThemeFile, ARRAY_SIZE(szCurrentTheme)); lstrcpynW(szCurrentTheme, tf->szThemeFile, ARRAY_SIZE(szCurrentTheme));
lstrcpynW(szCurrentColor, tf->pszSelectedColor, ARRAY_SIZE(szCurrentColor)); lstrcpynW(szCurrentColor, tf->pszSelectedColor, ARRAY_SIZE(szCurrentColor));
lstrcpynW(szCurrentSize, tf->pszSelectedSize, ARRAY_SIZE(szCurrentSize)); lstrcpynW(szCurrentSize, tf->pszSelectedSize, ARRAY_SIZE(szCurrentSize));
@ -446,6 +449,8 @@ HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
WARN("Failed to get LoadedBefore: %d\n", GetLastError()); WARN("Failed to get LoadedBefore: %d\n", GetLastError());
RegCloseKey(hKey); RegCloseKey(hKey);
} }
if (loaded_before && same_theme)
return MSSTYLES_SetActiveTheme(tf, FALSE);
if (!loaded_before && ret) if (!loaded_before && ret)
UXTHEME_SaveUnthemedSystemMetrics(&metrics); UXTHEME_SaveUnthemedSystemMetrics(&metrics);