Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for accent color saturation level #49

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 68 additions & 6 deletions AccentColorizer/AccentColorHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
#include "AccentColorHelper.h"
#include "ColorHelper.h"
#include <cmath>

COLORREF g_dwAccent;
int g_hsvAccentH;
int g_hslAccentH;
double g_hslAccentS;
double g_oldhslAccentS;
double g_balance1hslAccentS;
double g_balance2hslAccentS;
double g_hslAccentL;
double g_oldhslAccentL;
double g_defaulthslAccentH;
double g_defaulthslAccentS;
double g_defaulthslAccentL;

bool UpdateAccentColor()
{
@@ -18,11 +28,63 @@ bool UpdateAccentColor()
return false;
}

if (accentColorChanges >= 1) {
g_oldhslAccentS = g_hslAccentS;
if (g_oldhslAccentS <= 0.0666) {
g_oldhslAccentS = 0.0666;
}
}
else g_oldhslAccentS = 1;

g_dwAccent = dwAccent;
g_hsvAccentH = rgb2hsv({
(double) GetRValue(dwAccent) / 255,
(double) GetGValue(dwAccent) / 255,
(double) GetBValue(dwAccent) / 255 }).h;
if ((double)GetRValue(dwAccent) == (double)GetGValue(dwAccent) && (double)GetGValue(dwAccent) == (double)GetBValue(dwAccent)) {
g_hslAccentH = 210.0;
}
else {
g_hslAccentH = rgb2hsl({
(double)GetRValue(dwAccent) / 255,
(double)GetGValue(dwAccent) / 255,
(double)GetBValue(dwAccent) / 255 }).h;
}
/* if (g_hslAccentH < 0.0) {
g_hslAccentH += 360.0;
}

if (g_hslAccentH > 360.0) {
g_hslAccentH -= 360.0;
} */

g_dwAccent = dwAccent;
if ((double)GetRValue(dwAccent) == (double)GetGValue(dwAccent) && (double)GetGValue(dwAccent) == (double)GetBValue(dwAccent)) {
g_hslAccentS = 0.0667;
}
else {
g_hslAccentS = pow(double(rgb2hsl({
(double)GetRValue(dwAccent) / 254.999999999,
(double)GetGValue(dwAccent) / 254.999999999,
(double)GetBValue(dwAccent) / 254.999999999 }).s), double(0.85));
}


g_balance1hslAccentS = g_hslAccentS;
g_balance2hslAccentS = (1 - g_hslAccentS);

g_defaulthslAccentH = 207;
g_defaulthslAccentS = 1;

if (g_hslAccentS < 0.0666) {
g_hslAccentS = 0.0666;
}
if (accentColorChanges >= 1) {
if (g_hslAccentS > 1) {
g_hslAccentS = g_balance1hslAccentS + g_balance2hslAccentS;
}
}

g_hslAccentL = (double(rgb2hsl({
(double)GetRValue(dwAccent) / 254.999999999,
(double)GetGValue(dwAccent) / 254.999999999,
(double)GetBValue(dwAccent) / 254.999999999 }).l) - (double)0.4215686) * 255; // based on default accent color #0078D7 (RGB 0, 120, 215)

return true;
}
}
12 changes: 11 additions & 1 deletion AccentColorizer/AccentColorHelper.h
Original file line number Diff line number Diff line change
@@ -2,6 +2,16 @@
#include "framework.h"

extern COLORREF g_dwAccent;
extern int g_hsvAccentH;
extern int g_hslAccentH;
extern double g_hslAccentS;
extern double g_oldhslAccentS;
extern double g_balance1hslAccentS;
extern double g_balance2hslAccentS;
extern double g_hslAccentL;
extern double g_oldhslAccentL;
extern double g_defaulthslAccentH;
extern double g_defaulthslAccentS;
extern double g_defaulthslAccentL;
extern int accentColorChanges;

bool UpdateAccentColor();
14 changes: 8 additions & 6 deletions AccentColorizer/AccentColorizer.vcxproj
Original file line number Diff line number Diff line change
@@ -38,40 +38,40 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@@ -222,6 +222,7 @@
<ClInclude Include="ColorHelper.h" />
<ClInclude Include="SettingsHelper.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="StyleColorHelper.h" />
<ClInclude Include="StyleModifier.h" />
<ClInclude Include="SysColorsModifier.h" />
<ClInclude Include="framework.h" />
@@ -233,6 +234,7 @@
<ClCompile Include="BitmapHelper.cpp" />
<ClCompile Include="ColorHelper.cpp" />
<ClCompile Include="SettingsHelper.cpp" />
<ClCompile Include="StyleColorHelper.cpp" />
<ClCompile Include="StyleModifier.cpp" />
<ClCompile Include="SysColorsModifier.cpp" />
<ClCompile Include="SystemHelper.cpp" />
6 changes: 6 additions & 0 deletions AccentColorizer/AccentColorizer.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -25,6 +25,9 @@
<ClCompile Include="SystemHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="StyleColorHelper.cpp">
<Filter>Header Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AccentColorHelper.h">
@@ -54,6 +57,9 @@
<ClInclude Include="SystemHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="StyleColorHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Source Files">
64 changes: 34 additions & 30 deletions AccentColorizer/BitmapHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
#include "BitmapHelper.h"

vector <HBITMAP> hBitmapList;

bool IterateBitmap(HBITMAP hbm, BitmapPixelHandler handler)
{
BITMAP bm;
GetObject(hbm, sizeof(bm), &bm);

if (!hbm || bm.bmBitsPixel != 32)
{
return false;
}
if (count(hBitmapList.begin(), hBitmapList.end(), hbm) < 1) {
hBitmapList.push_back(hbm);
BITMAP bm;
GetObject(hbm, sizeof(bm), &bm);

BYTE* pBits = new BYTE[bm.bmWidth * bm.bmHeight * 4];
GetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits);
if (!hbm || bm.bmBitsPixel != 32)
{
return false;
}

BYTE* pPixel;
int x, y;
int r, g, b, a;
BYTE* pBits = new BYTE[bm.bmWidth * bm.bmHeight * 4];
GetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits);

for (y = 0; y < bm.bmHeight; y++)
{
pPixel = pBits + bm.bmWidth * 4 * y;
BYTE* pPixel;
int x, y;
int r, g, b, a;

for (x = 0; x < bm.bmWidth; x++)
for (y = 0; y < bm.bmHeight; y++)
{
r = pPixel[2] & 0xFFFFFF;
g = pPixel[1] & 0xFFFFFF;
b = pPixel[0] & 0xFFFFFF;
a = pPixel[3] & 0xFFFFFF;
pPixel = pBits + bm.bmWidth * 4 * y;

handler(r, g, b, a);
for (x = 0; x < bm.bmWidth; x++)
{
r = pPixel[2] & 0xFFFFFF;
g = pPixel[1] & 0xFFFFFF;
b = pPixel[0] & 0xFFFFFF;
a = pPixel[3] & 0xFFFFFF;

pPixel[2] = r;
pPixel[1] = g;
pPixel[0] = b;
pPixel[3] = a;
handler(r, g, b, a);

pPixel += 4;
}
}
pPixel[2] = r;
pPixel[1] = g;
pPixel[0] = b;
pPixel[3] = a;

SetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits);
pPixel += 4;
}
}

delete[] pBits;
SetBitmapBits(hbm, bm.bmWidth * bm.bmHeight * 4, pBits);
delete[] pBits;
}
return true;
}
5 changes: 5 additions & 0 deletions AccentColorizer/BitmapHelper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#pragma once
#include "framework.h"
#include <iostream>
#include <vector>

using namespace std;
extern vector <HBITMAP> hBitmapList;

typedef void (*BitmapPixelHandler)(int& r, int& g, int& b, int& a);

178 changes: 110 additions & 68 deletions AccentColorizer/ColorHelper.cpp
Original file line number Diff line number Diff line change
@@ -6,107 +6,149 @@ DWORD rgb2bgr(COLORREF color)
}


// https://stackoverflow.com/a/6930407
// https://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/

hsv_t rgb2hsv(rgb_t in)
hsl_t rgb2hsl(rgb_t in)
{
hsv_t out;
double min, max, delta;
hsl_t out;
double min, max, sigma, delta;

min = in.r < in.g ? in.r : in.g;
min = min < in.b ? min : in.b;

max = in.r > in.g ? in.r : in.g;
max = max > in.b ? max : in.b;

out.v = max; // v
sigma = max + min;
out.l = sigma / 2;
delta = max - min;
if (delta < 0.00001)
{
out.s = 0;
out.h = 0; // undefined, maybe nan?
return out;
}
if (max > 0.0) { // NOTE: if Max is == 0, this divide would cause a crash
out.s = (delta / max); // s
if (max > 0.0) { // NOTE: if max is == 0, this divide would cause a crash
if (out.l <= 0.5)
{
out.s = delta / sigma;
}
if (out.l > 0.5)
{
out.s = delta / (2 - sigma);
}
/* if (out.s > 1)
{
out.s = out.s - (out.s - 1);
}
if (out.s < 0)
{
out.s = (0 - out.s);
} */
}
else {
// if max is 0, then r = g = b = 0
// s = 0, h is undefined
out.s = 0.0;
//out.h = NAN; // its now undefined
return out;
}
if (in.r >= max) // > is bogus, just keeps compilor happy
out.h = (in.g - in.b) / delta; // between yellow & magenta
if (in.r >= max) // ">" is useless, just keeps compiler happy
out.h = (((in.g - in.b) / delta) * 60.0); // between yellow & magenta
else
if (in.g >= max)
out.h = 2.0 + (in.b - in.r) / delta; // between cyan & yellow
out.h = ((2.0 + (in.b - in.r) / delta) * 60.0); // between cyan & yellow
else
out.h = 4.0 + (in.r - in.g) / delta; // between magenta & cyan

out.h *= 60.0; // degrees
out.h = ((4.0 + (in.r - in.g) / delta) * 60.0); // between magenta & cyan

if (out.h < 0.0)
out.h += 360.0;

if (out.h > 360.0)
out.h -= 360.0;

return out;
}

rgb_t hsv2rgb(hsv_t in)
rgb_t hsl2rgb(hsl_t in)
{
double hh, p, q, t, ff;
long i;
double ot, tt, ht, rt, gt, bt; // temporary values one, two, hue, red, green, blue
rgb_t out;

if (in.s <= 0.0) { // < is bogus, just shuts up warnings
out.r = in.v;
out.g = in.v;
out.b = in.v;
/*if (in.s <= 0.0) { // "<" is useless, just shuts up warnings
out.r = in.l;
out.g = in.l;
out.b = in.l;
return out;
}*/ // this was making saturation always return 0
if (in.l < 0.5)
{
ot = in.l * (1.0 + in.s);
}
else if (in.l >= 0.5)
{
ot = in.l + in.s - (in.l * in.s);
}
tt = (2 * in.l) - ot;
ht = in.h /= 360.0;
if (ht > 0.6666667) {
rt = ht - (0.6666667);
}
if (ht <= 0.6666667) {
rt = ht + (0.3333333);
}
gt = ht;
if (ht < 0.3333333) {
bt = ht + (0.6666667);
}
if (ht >= 0.3333333) {
bt = ht - (0.3333333);
}
if (rt * 6 <= 1) {
out.r = tt + (ot - tt) * 6 * rt;
}
else if (rt * 2 <= 1) {
out.r = ot;
}
else if (rt * 3 <= 2) {
out.r = tt + (ot - tt) * (0.6666667 - rt) * 6;
}
hh = in.h;
if (hh >= 360.0) hh = 0.0;
hh /= 60.0;
i = (long)hh;
ff = hh - i;
p = in.v * (1.0 - in.s);
q = in.v * (1.0 - (in.s * ff));
t = in.v * (1.0 - (in.s * (1.0 - ff)));
else
out.r = tt;
if (gt * 6 <= 1) {
out.g = tt + (ot - tt) * 6 * gt;
}
else if (gt * 2 <= 1) {
out.g = ot;
}
else if (gt * 3 <= 2) {
out.g = tt + (ot - tt) * (0.6666667 - gt) * 6;
}
else
out.g = tt;
if (bt * 6 <= 1) {
out.b = tt + (ot - tt) * 6 * bt;
}
else if (bt * 2 <= 1) {
out.b = ot;
}
else if (bt * 3 <= 2) {
out.b = tt + (ot - tt) * (0.6666667 - bt) * 6;
}
else
out.b = tt;

switch (i) {
case 0:
out.r = in.v;
out.g = t;
out.b = p;
break;
case 1:
out.r = q;
out.g = in.v;
out.b = p;
break;
case 2:
out.r = p;
out.g = in.v;
out.b = t;
break;
if (out.r > 255) {
out.r = out.r - (out.r - 255);
}
if (out.g > 255) {
out.g = out.g - (out.g - 255);
}
if (out.b > 255) {
out.b = out.b - (out.b - 255);
}

case 3:
out.r = p;
out.g = q;
out.b = in.v;
break;
case 4:
out.r = t;
out.g = p;
out.b = in.v;
break;
case 5:
default:
out.r = in.v;
out.g = p;
out.b = q;
break;
if (out.r < 0) {
out.r = (0 - out.r);
}
if (out.g < 0) {
out.g = (0 - out.g);
}
if (out.b < 0) {
out.b = (0 - out.b);
}

return out;
}
8 changes: 4 additions & 4 deletions AccentColorizer/ColorHelper.h
Original file line number Diff line number Diff line change
@@ -8,10 +8,10 @@ struct rgb_t
double r, g, b;
};

struct hsv_t
struct hsl_t
{
double h, s, v;
double h, s, l;
};

hsv_t rgb2hsv(rgb_t in);
rgb_t hsv2rgb(hsv_t in);
hsl_t rgb2hsl(rgb_t in);
rgb_t hsl2rgb(hsl_t in);
9 changes: 9 additions & 0 deletions AccentColorizer/StyleColorHelper.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "StyleColorHelper.h"


bool IterateColor(COLORREF color, ColorHandler handler) // dummy code
{
int r, g, b;
GetTextColor;
return true;
}
6 changes: 6 additions & 0 deletions AccentColorizer/StyleColorHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include "framework.h"

typedef void (*ColorHandler)(int& r, int& g, int& b); // dummy code

bool IterateColor(COLORREF color, ColorHandler handler); // dummy code
796 changes: 615 additions & 181 deletions AccentColorizer/StyleModifier.cpp

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions AccentColorizer/SysColorsModifier.cpp
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@
constexpr int aSysElements[] = {
COLOR_ACTIVECAPTION,
COLOR_GRADIENTACTIVECAPTION,
COLOR_INACTIVECAPTION,
COLOR_GRADIENTINACTIVECAPTION,
COLOR_HIGHLIGHT,
COLOR_HOTLIGHT,
COLOR_MENUHILIGHT
@@ -17,7 +19,7 @@ void ModifySysColors()

COLORREF dwCurrentColor;
rgb_t rgbVal;
hsv_t hsvVal;
hsl_t hslVal;

for (int i = 0; i < nSysElements; i++)
{
@@ -28,11 +30,16 @@ void ModifySysColors()
(double)GetGValue(dwCurrentColor),
(double)GetBValue(dwCurrentColor)
};
hsvVal = rgb2hsv(rgbVal);
hslVal = rgb2hsl(rgbVal);

hsvVal.h = g_hsvAccentH;
hslVal.h = g_defaulthslAccentH;
hslVal.s = (double)hslVal.s * (double)(1 / (double)g_oldhslAccentS) * (double)g_defaulthslAccentS;

rgbVal = hsv2rgb(hsvVal);

hslVal.h = g_hslAccentH;
hslVal.s = (double)hslVal.s * (double)g_hslAccentS;

rgbVal = hsl2rgb(hslVal);

aNewColors[i] = RGB(rgbVal.r, rgbVal.g, rgbVal.b);
}
86 changes: 43 additions & 43 deletions AccentColorizer/VersionInfo.rc
Original file line number Diff line number Diff line change
@@ -12,21 +12,57 @@
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// Russian (Russia) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED

#endif // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// Neutral (Default) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
#pragma code_page(1251)
#pragma code_page(1252)

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,0,0
PRODUCTVERSION 1,2,0,0
FILEVERSION 1,3,0,0
PRODUCTVERSION 1,3,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -41,14 +77,14 @@ BEGIN
BEGIN
BLOCK "040004b0"
BEGIN
VALUE "CompanyName", "krlvm"
VALUE "CompanyName", "krlvm, Rounak, WinExperiments"
VALUE "FileDescription", "AccentColorizer"
VALUE "FileVersion", "1.2.0.0"
VALUE "FileVersion", "1.3.0.0"
VALUE "InternalName", "AccentColorizer.exe"
VALUE "LegalCopyright", "Copyright krlvm (C) 2021-2023"
VALUE "LegalCopyright", "Copyright krlvm, Rounak, WinExperiments (C) 2021-2024"
VALUE "OriginalFilename", "AccentColorizer.exe"
VALUE "ProductName", "AccentColorizer"
VALUE "ProductVersion", "1.2.0.0"
VALUE "ProductVersion", "1.3.0.0"
END
END
BLOCK "VarFileInfo"
@@ -61,42 +97,6 @@ END
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// Russian (Russia) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END

3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END

#endif // APSTUDIO_INVOKED

#endif // Russian (Russia) resources
/////////////////////////////////////////////////////////////////////////////



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
18 changes: 13 additions & 5 deletions AccentColorizer/main.cpp
Original file line number Diff line number Diff line change
@@ -3,9 +3,11 @@
#include "StyleModifier.h"
#include "SettingsHelper.h"
#include "SystemHelper.h"
#include "BitmapHelper.h"

constexpr LPCWSTR szWindowClass = L"ACCENTCOLORIZER";
HANDLE hMutex;
int accentColorChanges = 0;

void ApplyAccentColorization()
{
@@ -21,15 +23,15 @@ void ApplyAccentColorization()

ModifySysColors();
ModifyStyles();
hBitmapList.clear();
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_DWMCOLORIZATIONCOLORCHANGED ||
message == WM_DPICHANGED ||
message == WM_THEMECHANGED ||
(message == WM_WTSSESSION_CHANGE && wParam == WTS_SESSION_UNLOCK)
)
)
{
if (message != WM_DWMCOLORIZATIONCOLORCHANGED)
{
@@ -40,15 +42,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// d) Device was turned on after sleep, and colors and bitmaps probably were reset
g_dwAccent = NULL;
}
if (message == WM_DWMCOLORIZATIONCOLORCHANGED || (message == WM_WTSSESSION_CHANGE && wParam == WTS_SESSION_UNLOCK)) {
accentColorChanges++;
}
else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to re-apply colorization if theme has been changed (WM_THEMECHANGED)? I'm not sure, just wondering

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used when you change the accent color in order to find your previous saturation. You can check AccentColorHelper.cpp for why I'm using it.

accentColorChanges = 0;
}
ApplyAccentColorization();
}
return DefWindowProc(hWnd, message, wParam, lParam);
}

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
hMutex = CreateMutex(NULL, TRUE, szWindowClass);
if (!hMutex || ERROR_ALREADY_EXISTS == GetLastError())