Windows: Fix title bar size calculation
The title bar calculation is terribly wrong and was missed during review. Change-Id: I0c7a860e747465e6a5e4d8aa5415a9701cf170fd Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit f6af3a581642170f0f4fe0d0563851715e045391) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9e86f73f82
commit
3c0986a34c
@ -889,6 +889,13 @@ static inline bool shouldApplyDarkFrame(const QWindow *w)
|
|||||||
> windowPal.color(QPalette::Window).lightness();
|
> windowPal.color(QPalette::Window).lightness();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int getTitleBarHeight_sys(const UINT dpi)
|
||||||
|
{
|
||||||
|
// According to MS design manual, it should be 32px when DPI is 96.
|
||||||
|
return getResizeBorderThickness(dpi) +
|
||||||
|
::GetSystemMetricsForDpi(SM_CYCAPTION, dpi);
|
||||||
|
}
|
||||||
|
|
||||||
QWindowsWindowData
|
QWindowsWindowData
|
||||||
WindowCreationData::create(const QWindow *w, const WindowData &data, QString title) const
|
WindowCreationData::create(const QWindow *w, const WindowData &data, QString title) const
|
||||||
{
|
{
|
||||||
@ -952,10 +959,12 @@ QWindowsWindowData
|
|||||||
parentHandle, nullptr, appinst, nullptr);
|
parentHandle, nullptr, appinst, nullptr);
|
||||||
|
|
||||||
if (w->flags().testFlags(Qt::ExpandedClientAreaHint)) {
|
if (w->flags().testFlags(Qt::ExpandedClientAreaHint)) {
|
||||||
|
const UINT dpi = ::GetDpiForWindow(result.hwnd);
|
||||||
|
const int titleBarHeight = getTitleBarHeight_sys(dpi);
|
||||||
result.hwndTitlebar = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT,
|
result.hwndTitlebar = CreateWindowEx(WS_EX_LAYERED | WS_EX_TRANSPARENT,
|
||||||
classTitleBarNameUtf16, classTitleBarNameUtf16,
|
classTitleBarNameUtf16, classTitleBarNameUtf16,
|
||||||
WS_POPUP, 0, 0,
|
WS_POPUP, 0, 0,
|
||||||
context->frameWidth, 32,
|
context->frameWidth, titleBarHeight,
|
||||||
result.hwnd, nullptr, appinst, nullptr);
|
result.hwnd, nullptr, appinst, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2190,7 +2199,7 @@ QRect QWindowsWindow::normalGeometry() const
|
|||||||
QMargins QWindowsWindow::safeAreaMargins() const
|
QMargins QWindowsWindow::safeAreaMargins() const
|
||||||
{
|
{
|
||||||
if (m_data.flags.testFlags(Qt::ExpandedClientAreaHint)) {
|
if (m_data.flags.testFlags(Qt::ExpandedClientAreaHint)) {
|
||||||
const int titleBarHeight = SM_CYSIZEFRAME + SM_CYCAPTION;
|
const int titleBarHeight = getTitleBarHeight_sys(savedDpi());
|
||||||
|
|
||||||
return QMargins(0, titleBarHeight, 0, 0);
|
return QMargins(0, titleBarHeight, 0, 0);
|
||||||
}
|
}
|
||||||
@ -2407,7 +2416,8 @@ void QWindowsWindow::handleGeometryChange()
|
|||||||
transitionAnimatedCustomTitleBar();
|
transitionAnimatedCustomTitleBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveWindow(m_data.hwndTitlebar, m_data.geometry.x(), m_data.geometry.y(), m_data.geometry.width(), 32, true);
|
const int titleBarHeight = getTitleBarHeight_sys(savedDpi());
|
||||||
|
MoveWindow(m_data.hwndTitlebar, m_data.geometry.x(), m_data.geometry.y(), m_data.geometry.width(), titleBarHeight, true);
|
||||||
m_windowWasArranged = arranged;
|
m_windowWasArranged = arranged;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3295,8 +3305,8 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
|
|||||||
const int border = (IsZoomed(m_data.hwnd) || isFullScreen_sys()) ? 0 : getResizeBorderThickness(savedDpi());
|
const int border = (IsZoomed(m_data.hwnd) || isFullScreen_sys()) ? 0 : getResizeBorderThickness(savedDpi());
|
||||||
if (isCustomized || isDefaultTitleBar) {
|
if (isCustomized || isDefaultTitleBar) {
|
||||||
*result = HTCLIENT;
|
*result = HTCLIENT;
|
||||||
const int titleBarHeight = SM_CYSIZEFRAME + SM_CYCAPTION;;
|
const int titleBarHeight = getTitleBarHeight_sys(savedDpi());
|
||||||
const int titleButtonWidth = 46;
|
const int titleButtonWidth = titleBarHeight * 1.5;
|
||||||
int buttons = 1;
|
int buttons = 1;
|
||||||
if (globalPos.y() < geom.top() + titleBarHeight) {
|
if (globalPos.y() < geom.top() + titleBarHeight) {
|
||||||
if (m_data.flags.testFlags(Qt::WindowCloseButtonHint) || isDefaultTitleBar) {
|
if (m_data.flags.testFlags(Qt::WindowCloseButtonHint) || isDefaultTitleBar) {
|
||||||
@ -3452,8 +3462,8 @@ void QWindowsWindow::updateCustomTitlebar()
|
|||||||
RECT windowRect;
|
RECT windowRect;
|
||||||
GetWindowRect(hwnd, &windowRect);
|
GetWindowRect(hwnd, &windowRect);
|
||||||
|
|
||||||
const int titleBarHeight = SM_CYSIZEFRAME + SM_CYCAPTION;;
|
const int titleBarHeight = getTitleBarHeight_sys(savedDpi());
|
||||||
const int titleButtonWidth = 46;
|
const int titleButtonWidth = titleBarHeight * 1.5;
|
||||||
const int windowWidth = windowRect.right - windowRect.left;
|
const int windowWidth = windowRect.right - windowRect.left;
|
||||||
|
|
||||||
POINT localPos;
|
POINT localPos;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user