Skip to content

Commit efb5432

Browse files
fix: system accent color parsing hex order (#48107)
fix: system accent color parsing Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <[email protected]>
1 parent 23a0293 commit efb5432

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

shell/common/color_util.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
#if BUILDFLAG(IS_WIN)
1414
#include <dwmapi.h>
15+
16+
#include "base/win/registry.h"
1517
#endif
1618

1719
namespace {
@@ -68,12 +70,18 @@ std::string ToRGBAHex(SkColor color, bool include_hash) {
6870

6971
#if BUILDFLAG(IS_WIN)
7072
std::optional<DWORD> GetSystemAccentColor() {
71-
DWORD color = 0;
72-
BOOL opaque = FALSE;
73+
base::win::RegKey key;
74+
if (key.Open(HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft\\Windows\\DWM",
75+
KEY_READ) != ERROR_SUCCESS) {
76+
return std::nullopt;
77+
}
7378

74-
if (FAILED(DwmGetColorizationColor(&color, &opaque)))
79+
DWORD accent_color = 0;
80+
if (key.ReadValueDW(L"AccentColor", &accent_color) != ERROR_SUCCESS) {
7581
return std::nullopt;
76-
return color;
82+
}
83+
84+
return accent_color;
7785
}
7886
#endif
7987

0 commit comments

Comments
 (0)