aboutsummaryrefslogtreecommitdiffstats
path: root/src/win.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-01-12 15:30:44 -0500
committerDavid Robillard <d@drobilla.net>2023-01-14 11:53:28 -0500
commit1e48f8bbfdb0f1ce2f9132d604405fb72d160d9d (patch)
tree2fbb2e70f5bf5e7f7e021dafb51dd508944426f2 /src/win.c
parentbd4f79646f623e929e6aa22bea028952b515aeef (diff)
downloadpugl-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/win.c')
-rw-r--r--src/win.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/win.c b/src/win.c
index db3f98c..e9c621e 100644
--- a/src/win.c
+++ b/src/win.c
@@ -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);