views: win: Use black title bar with dark mode
This commit is contained in:
parent
12d0bccbd4
commit
05930b7bc9
|
@ -22,7 +22,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BUILDFLAG(IS_WIN)
|
#if BUILDFLAG(IS_WIN)
|
||||||
#include "ui/display/screen.h"
|
#include <dwmapi.h>
|
||||||
|
#include "base/win/windows_version.h"
|
||||||
#include "ui/views/win/hwnd_util.h"
|
#include "ui/views/win/hwnd_util.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -99,6 +100,25 @@ class NativeFrameViewEx : public views::NativeFrameView {
|
||||||
return views::NativeFrameView::NonClientHitTest(point);
|
return views::NativeFrameView::NonClientHitTest(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BUILDFLAG(IS_WIN)
|
||||||
|
void OnThemeChanged() override {
|
||||||
|
views::NativeFrameView::OnThemeChanged();
|
||||||
|
|
||||||
|
// Value was 19 prior to Windows 10 20H1, according to
|
||||||
|
// https://stackoverflow.com/a/70693198
|
||||||
|
const DWORD dwAttribute =
|
||||||
|
base::win::GetVersion() >= base::win::Version::WIN10_20H1
|
||||||
|
? DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||||
|
: 19;
|
||||||
|
|
||||||
|
// From BrowserFrameViewWin::SetSystemMicaTitlebarAttributes:
|
||||||
|
const BOOL dark_titlebar_enabled = GetNativeTheme()->ShouldUseDarkColors();
|
||||||
|
DwmSetWindowAttribute(views::HWNDForWidget(widget_), dwAttribute,
|
||||||
|
&dark_titlebar_enabled,
|
||||||
|
sizeof(dark_titlebar_enabled));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Not owned by this object.
|
// Not owned by this object.
|
||||||
views::Widget* widget_;
|
views::Widget* widget_;
|
||||||
|
|
Loading…
Reference in New Issue