Bug 610643 - Refresh button metrics when the theme changes. r=neil, a=final.
authorJim Mathies <jmathies@mozilla.com>
Mon, 29 Nov 2010 10:19:17 -0600
changeset 58327 d9cf761c6af47fd7cccac6f2ce9a1fa875ed387b
parent 58326 6f14ee0618153673f08cc30c9451abd189fa4ba6
child 58328 c0d1cdc4553a2dabcddcbf5b08611bb3f1673732
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersneil, final
bugs610643
milestone2.0b8pre
Bug 610643 - Refresh button metrics when the theme changes. r=neil, a=final.
widget/src/windows/nsUXThemeData.cpp
widget/src/windows/nsWindow.cpp
widget/src/windows/nsWindowDefs.h
--- a/widget/src/windows/nsUXThemeData.cpp
+++ b/widget/src/windows/nsUXThemeData.cpp
@@ -260,20 +260,20 @@ nsUXThemeData::InitTitlebarInfo()
   // the current theme, but they insure the buttons at least show up.
   sCommandButtons[0].cx = GetSystemMetrics(SM_CXSIZE);
   sCommandButtons[0].cy = GetSystemMetrics(SM_CYSIZE);
   sCommandButtons[1].cx = sCommandButtons[2].cx = sCommandButtons[0].cx;
   sCommandButtons[1].cy = sCommandButtons[2].cy = sCommandButtons[0].cy;
   sCommandButtons[3].cx = sCommandButtons[0].cx * 3;
   sCommandButtons[3].cy = sCommandButtons[0].cy;
 
-  // Use system metrics for pre-vista
-  if (nsWindow::GetWindowsVersion() < VISTA_VERSION) {
-    sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed = PR_TRUE;
-  }
+  // Use system metrics for pre-vista, otherwise trigger a
+  // refresh on the next layout.
+  sTitlebarInfoPopulatedAero = sTitlebarInfoPopulatedThemed =
+    (nsWindow::GetWindowsVersion() < VISTA_VERSION);
 }
 
 // static
 void
 nsUXThemeData::UpdateTitlebarInfo(HWND aWnd)
 {
   if (!aWnd)
     return;
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -4578,20 +4578,21 @@ PRBool nsWindow::ProcessMessage(UINT msg
             DispatchStandardEvent(NS_TABCHANGE);
             result = PR_TRUE;
           }
           break;
         }
     }
     break;
 
-    case WM_XP_THEMECHANGED:
+    case WM_THEMECHANGED:
     {
       // Update non-client margin offsets 
       UpdateNonClientMargins();
+      nsUXThemeData::InitTitlebarInfo();
       nsUXThemeData::UpdateNativeThemeInfo();
 
       DispatchStandardEvent(NS_THEMECHANGED);
 
       // Invalidate the window so that the repaint will
       // pick up the new theme.
       Invalidate(PR_FALSE);
     }
--- a/widget/src/windows/nsWindowDefs.h
+++ b/widget/src/windows/nsWindowDefs.h
@@ -59,17 +59,19 @@
 
 // GetWindowsVersion constants
 #define WIN2K_VERSION                     0x500
 #define WINXP_VERSION                     0x501
 #define WIN2K3_VERSION                    0x502
 #define VISTA_VERSION                     0x600
 #define WIN7_VERSION                      0x601
 
-#define WM_XP_THEMECHANGED                0x031A
+#ifndef WM_THEMECHANGED
+#define WM_THEMECHANGED                   0x031A
+#endif
 
 #ifndef WM_GETOBJECT
 #define WM_GETOBJECT                      0x03d
 #endif
 
 #ifndef PBT_APMRESUMEAUTOMATIC
 #define PBT_APMRESUMEAUTOMATIC            0x0012
 #endif