feat: add {get|set}AccentColor
on Windows (#48018)
* feat: add setAccentColor on Windows Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * refactor: unify GetSystemAccentColor Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * refactor: remove redundant parsing Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * chore: fixup documentation Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * Update docs/api/browser-window.md Co-authored-by: Will Anderson <andersonw@dropbox.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * Update docs/api/base-window.md Co-authored-by: Will Anderson <andersonw@dropbox.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
b6dbb2bab7
commit
c72e0bd90b
13 changed files with 265 additions and 24 deletions
|
@ -5,7 +5,6 @@
|
|||
#include <iomanip>
|
||||
#include <string_view>
|
||||
|
||||
#include <dwmapi.h>
|
||||
#include <windows.devices.enumeration.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
|
@ -84,14 +83,12 @@ std::string hexColorDWORDToRGBA(DWORD color) {
|
|||
}
|
||||
|
||||
std::string SystemPreferences::GetAccentColor() {
|
||||
DWORD color = 0;
|
||||
BOOL opaque = FALSE;
|
||||
std::optional<DWORD> color = GetSystemAccentColor();
|
||||
|
||||
if (FAILED(DwmGetColorizationColor(&color, &opaque))) {
|
||||
if (!color.has_value())
|
||||
return "";
|
||||
}
|
||||
|
||||
return hexColorDWORDToRGBA(color);
|
||||
return hexColorDWORDToRGBA(color.value());
|
||||
}
|
||||
|
||||
std::string SystemPreferences::GetColor(gin_helper::ErrorThrower thrower,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue