UI: On Win11 Use WM Window Decoration Styles API
On Windows 11 use the new WM Window Decoration Styles API, introduced
in ce42d92503. This will match the OS Title bar color to that of the
main window top bar and also do similar color matching with content
in separate windows like Preferences. Note that this will not have any
effect on versions of Windows prior to 11.
Pull Request: https://projects.blender.org/blender/blender/pulls/134054
This commit is contained in:
committed by
Harley Acheson
parent
b7ce997574
commit
3f4a1cabbf
@@ -586,10 +586,7 @@ GHOST_TCapabilityFlag GHOST_SystemWin32::getCapabilities() const
|
||||
return GHOST_TCapabilityFlag(GHOST_CAPABILITY_FLAG_ALL &
|
||||
~(
|
||||
/* WIN32 has no support for a primary selection clipboard. */
|
||||
GHOST_kCapabilityPrimaryClipboard |
|
||||
/* This WIN32 backend has not yet implemented support for window
|
||||
* decoration styles. */
|
||||
GHOST_kCapabilityWindowDecorationStyles));
|
||||
GHOST_kCapabilityPrimaryClipboard));
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_SystemWin32::init()
|
||||
|
||||
@@ -403,6 +403,23 @@ std::string GHOST_WindowWin32::getTitle() const
|
||||
return title;
|
||||
}
|
||||
|
||||
GHOST_TSuccess GHOST_WindowWin32::applyWindowDecorationStyle()
|
||||
{
|
||||
/* DWMWINDOWATTRIBUTE::DWMWA_CAPTION_COLOR */
|
||||
constexpr DWORD caption_color_attr = 35;
|
||||
|
||||
if (m_windowDecorationStyleFlags & GHOST_kDecorationColoredTitleBar) {
|
||||
const float *color = m_windowDecorationStyleSettings.colored_titlebar_bg_color;
|
||||
const COLORREF colorref = RGB(
|
||||
char(color[0] * 255.0f), char(color[1] * 255.0f), char(color[2] * 255.0f));
|
||||
if (!SUCCEEDED(DwmSetWindowAttribute(m_hWnd, caption_color_attr, &colorref, sizeof(colorref))))
|
||||
{
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
}
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
void GHOST_WindowWin32::getWindowBounds(GHOST_Rect &bounds) const
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
@@ -127,6 +127,11 @@ class GHOST_WindowWin32 : public GHOST_Window {
|
||||
*/
|
||||
std::string getTitle() const;
|
||||
|
||||
/**
|
||||
* Apply the window decoration style using the current flags and settings.
|
||||
*/
|
||||
GHOST_TSuccess applyWindowDecorationStyle() override;
|
||||
|
||||
/**
|
||||
* Returns the window rectangle dimensions.
|
||||
* The dimensions are given in screen coordinates that are
|
||||
|
||||
Reference in New Issue
Block a user