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

Zhiyi Zhang zzhang at codeweavers.com
Fri Nov 19 01:39:11 CST 2021


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 at codeweavers.com>
---
 dlls/uxtheme/system.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/uxtheme/system.c b/dlls/uxtheme/system.c
index bf72baccebb..37c484387ec 100644
--- a/dlls/uxtheme/system.c
+++ b/dlls/uxtheme/system.c
@@ -421,7 +421,7 @@ static void UXTHEME_SaveSystemMetrics(struct system_metrics *metrics, BOOL send_
  */
 HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
 {
-    BOOL ret, loaded_before = FALSE;
+    BOOL ret, loaded_before = FALSE, same_theme = FALSE;
     struct system_metrics metrics;
     DWORD size;
     HKEY hKey;
@@ -430,6 +430,9 @@ HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
 
     if(tf) {
         bThemeActive = TRUE;
+        same_theme = !lstrcmpW(szCurrentTheme, tf->szThemeFile)
+                     && !lstrcmpW(szCurrentColor, tf->pszSelectedColor)
+                     && !lstrcmpW(szCurrentSize, tf->pszSelectedSize);
         lstrcpynW(szCurrentTheme, tf->szThemeFile, ARRAY_SIZE(szCurrentTheme));
         lstrcpynW(szCurrentColor, tf->pszSelectedColor, ARRAY_SIZE(szCurrentColor));
         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());
             RegCloseKey(hKey);
         }
+        if (loaded_before && same_theme)
+            return MSSTYLES_SetActiveTheme(tf, FALSE);
 
         if (!loaded_before && ret)
             UXTHEME_SaveUnthemedSystemMetrics(&metrics);
-- 
2.32.0



More information about the wine-devel mailing list