Skip to content

Commit

Permalink
tweak title bar dark mode adaptation to undocumented Windows changes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Apr 9, 2020
1 parent 98f4887 commit 3aaedf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/winmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ static HRESULT (WINAPI * pSetWindowCompositionAttribute)(HWND, void *) = 0;
static BOOL (WINAPI * pSystemParametersInfo)(UINT, UINT, PVOID, UINT) = 0;

static BOOLEAN (WINAPI * pShouldAppsUseDarkMode)(void) = 0; /* undocumented */
static BOOLEAN (WINAPI * pShouldSystUseDarkMode)(void) = 0; /* undocumented */
static HRESULT (WINAPI * pSetWindowTheme)(HWND, const wchar_t *, const wchar_t *) = 0;

#define HTHEME HANDLE
Expand Down Expand Up @@ -242,6 +243,8 @@ load_dwm_funcs(void)
if (uxtheme) {
pShouldAppsUseDarkMode =
(void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(132)); /* ordinal */
pShouldSystUseDarkMode =
(void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(138)); /* ordinal */
pSetWindowTheme =
(void *)GetProcAddress(uxtheme, "SetWindowTheme");
pOpenThemeData =
Expand Down Expand Up @@ -4934,22 +4937,19 @@ main(int argc, char *argv[])
trace_winsize("createwindow");

// Dark mode support
if (pShouldAppsUseDarkMode) {
if (pShouldSystUseDarkMode) {
HIGHCONTRASTW hc;
hc.cbSize = sizeof hc;
pSystemParametersInfo(SPI_GETHIGHCONTRAST, sizeof hc, &hc, 0);
//printf("High Contrast scheme <%ls>\n", hc.lpszDefaultScheme);

if (!(hc.dwFlags & HCF_HIGHCONTRASTON) && pShouldAppsUseDarkMode()) {
if (!(hc.dwFlags & HCF_HIGHCONTRASTON) && pShouldSystUseDarkMode()) {
pSetWindowTheme(wnd, W("DarkMode_Explorer"), NULL);
BOOL dark = 1;

#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE
#define DWMWA_USE_IMMERSIVE_DARK_MODE 19
#endif

pDwmSetWindowAttribute(wnd, DWMWA_USE_IMMERSIVE_DARK_MODE,
&dark, sizeof dark);
// set DWMWA_USE_IMMERSIVE_DARK_MODE
pDwmSetWindowAttribute(wnd, 20, &dark, sizeof dark);
pDwmSetWindowAttribute(wnd, 19, &dark, sizeof dark);
}
}

Expand Down
1 change: 1 addition & 0 deletions wiki/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Font rendering
* Enable auto-narrowing for Private Use characters (#979, "Nerd Fonts").

Window handling
* Tweak title bar dark mode adaptation to undocumented Windows changes (#983, mintty/wsltty#157).
* DropCommands secured against multiple placeholders.
* DropCommands optionally pastes Windows format paths (#982).
* Drag-and-drop import of itermcolors schemes (mintty/wsltty#227).
Expand Down

0 comments on commit 3aaedf6

Please sign in to comment.