From 5b7c144796433c3e3cc42de6400e4ea5d23faff1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 27 Oct 2022 19:26:51 -0500 Subject: [PATCH] Add workaround for DWM dark mode bug on Win10 --- app/streaming/session.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 1c3a8860..028b0393 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -1463,6 +1463,13 @@ void Session::execInternal() if (FAILED(DwmSetWindowAttribute(info.info.win.window, DWMWA_USE_IMMERSIVE_DARK_MODE, &darkModeEnabled, sizeof(darkModeEnabled)))) { DwmSetWindowAttribute(info.info.win.window, DWMWA_USE_IMMERSIVE_DARK_MODE_OLD, &darkModeEnabled, sizeof(darkModeEnabled)); } + + // Toggle non-client rendering off and back on to ensure dark mode takes effect on Windows 10. + // DWM doesn't seem to correctly invalidate the non-client area after enabling dark mode. + DWMNCRENDERINGPOLICY ncPolicy = DWMNCRP_DISABLED; + DwmSetWindowAttribute(info.info.win.window, DWMWA_NCRENDERING_POLICY, &ncPolicy, sizeof(ncPolicy)); + ncPolicy = DWMNCRP_ENABLED; + DwmSetWindowAttribute(info.info.win.window, DWMWA_NCRENDERING_POLICY, &ncPolicy, sizeof(ncPolicy)); } } }