Skip to content

Commit

Permalink
Add dark mode support for Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
dristic committed Jun 4, 2022
1 parent 0656497 commit 1f27beb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion druid-shell/src/backend/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use winapi::shared::minwindef::*;
use winapi::shared::windef::*;
use winapi::shared::winerror::*;
use winapi::um::dcomp::{IDCompositionDevice, IDCompositionTarget, IDCompositionVisual};
use winapi::um::dwmapi::DwmExtendFrameIntoClientArea;
use winapi::um::dwmapi::{DwmExtendFrameIntoClientArea, DwmSetWindowAttribute};
use winapi::um::errhandlingapi::GetLastError;
use winapi::um::shellscalingapi::MDT_EFFECTIVE_DPI;
use winapi::um::unknwnbase::*;
Expand Down Expand Up @@ -1516,6 +1516,18 @@ impl WindowBuilder {
}
}

// Dark mode support
// https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/apply-windows-themes
const DWMWA_USE_IMMERSIVE_DARK_MODE: u32 = 20;
let value: BOOL = 1;
let value_ptr = &value as *const _ as *const c_void;
DwmSetWindowAttribute(
hwnd,
DWMWA_USE_IMMERSIVE_DARK_MODE,
value_ptr,
std::mem::size_of::<BOOL>() as u32,
);

self.app.add_window(hwnd);

if let Some(accels) = accels {
Expand Down

0 comments on commit 1f27beb

Please sign in to comment.