diff options
author | David Robillard <d@drobilla.net> | 2023-01-12 15:30:44 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-01-14 11:53:28 -0500 |
commit | 1e48f8bbfdb0f1ce2f9132d604405fb72d160d9d (patch) | |
tree | 2fbb2e70f5bf5e7f7e021dafb51dd508944426f2 /src | |
parent | bd4f79646f623e929e6aa22bea028952b515aeef (diff) | |
download | pugl-1e48f8bbfdb0f1ce2f9132d604405fb72d160d9d.tar.gz pugl-1e48f8bbfdb0f1ce2f9132d604405fb72d160d9d.tar.bz2 pugl-1e48f8bbfdb0f1ce2f9132d604405fb72d160d9d.zip |
Windows: Add PUGL_DARK_FRAME hint
This allows dark applications to visually integrate more nicely in Windows 10.
A little thing, but it really goes a long way to make programs not look out of
place and half-baked.
Diffstat (limited to 'src')
-rw-r--r-- | src/win.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -8,6 +8,7 @@ #include "pugl/pugl.h" +#include <dwmapi.h> #include <windows.h> #include <windowsx.h> @@ -30,6 +31,11 @@ # define GWLP_USERDATA (-21) #endif +#define PRE_20H1_DWMWA_USE_IMMERSIVE_DARK_MODE 19 +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +# define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + #define PUGL_LOCAL_CLOSE_MSG (WM_USER + 50) #define PUGL_LOCAL_MARK_MSG (WM_USER + 51) #define PUGL_LOCAL_CLIENT_MSG (WM_USER + 52) @@ -280,12 +286,26 @@ puglRealize(PuglView* view) } // Set basic window hints and attributes + puglSetViewString(view, PUGL_WINDOW_TITLE, view->strings[PUGL_WINDOW_TITLE]); puglSetTransientParent(view, view->transientParent); view->impl->scaleFactor = puglWinGetViewScaleFactor(view); view->impl->cursor = LoadCursor(NULL, IDC_ARROW); + if (view->hints[PUGL_DARK_FRAME]) { + const BOOL useDarkMode = TRUE; + if ((DwmSetWindowAttribute(view->impl->hwnd, + DWMWA_USE_IMMERSIVE_DARK_MODE, + &useDarkMode, + sizeof(useDarkMode)) != S_OK)) { + DwmSetWindowAttribute(view->impl->hwnd, + PRE_20H1_DWMWA_USE_IMMERSIVE_DARK_MODE, + &useDarkMode, + sizeof(useDarkMode)); + } + } + SetWindowLongPtr(impl->hwnd, GWLP_USERDATA, (LONG_PTR)view); return puglDispatchSimpleEvent(view, PUGL_REALIZE); |