diff options
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); |