diff options
author | Yuhang Zhao <2546789017@qq.com> | 2022-10-25 13:44:43 +0800 |
---|---|---|
committer | Yuhang Zhao <yuhangzhao@deepin.org> | 2023-07-12 05:41:50 +0000 |
commit | 47ee4eae6ad361e9d3a1df4415562ff092de6644 (patch) | |
tree | c86ec7ef8d5d10502a022157bf0243cab6561cae | |
parent | 95332cc3765bef23f6c25e7c086e6a2e537f8a15 (diff) |
Windows style: use correct value for title bar height
The title bar height = caption bar height + resize border thickness.
This calculation is used by many open source repositories for quite
a long time, including Microsoft's own famous products such as
Windows Terminal. And if you use AdjustWindowRectEx() to get the
title bar height, the result is also exactly the same, so this should
be the correct calculation.
Normally, when DPI is 96, it should be 23 + (4 + 4) = 31px.
Pick-to: 6.6
Change-Id: I0a2de3b55d5b62327eacc7e2ff5dc23771b8efdb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/plugins/styles/windowsvista/qwindowsvistastyle.cpp | 7 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 13 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index fd099d642d..f94e782924 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -259,11 +259,8 @@ int QWindowsVistaStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, c : QWindowsThemeData::themeSize(widget, nullptr, QWindowsVistaStylePrivate::ProgressTheme, PP_CHUNKVERT).height(); case QStyle::PM_SliderThickness: return QWindowsThemeData::themeSize(widget, nullptr, QWindowsVistaStylePrivate::TrackBarTheme, TKP_THUMB).height(); - case QStyle::PM_TitleBarHeight: { - return widget && (widget->windowType() == Qt::Tool) - ? GetSystemMetrics(SM_CYSMCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME) - : GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME); - } + case QStyle::PM_TitleBarHeight: + return QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PM_TitleBarHeight, option, widget); case QStyle::PM_MdiSubWindowFrameWidth: return QWindowsThemeData::themeSize(widget, nullptr, QWindowsVistaStylePrivate::WindowTheme, WP_FRAMELEFT, FS_ACTIVE).width(); case QStyle::PM_DockWidgetFrameWidth: diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index f79136757a..fd1f8e1c17 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -265,12 +265,13 @@ int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const case QStyle::PM_DockWidgetFrameWidth: return GetSystemMetrics(SM_CXFRAME); - case QStyle::PM_TitleBarHeight: - if (widget && (widget->windowType() == Qt::Tool)) { - // MS always use one less than they say - return GetSystemMetrics(SM_CYSMCAPTION) - 1; - } - return GetSystemMetrics(SM_CYCAPTION) - 1; + case QStyle::PM_TitleBarHeight: { + const int resizeBorderThickness = + GetSystemMetrics(SM_CXSIZEFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER); + if (widget && (widget->windowType() == Qt::Tool)) + return GetSystemMetrics(SM_CYSMCAPTION) + resizeBorderThickness; + return GetSystemMetrics(SM_CYCAPTION) + resizeBorderThickness; + } case QStyle::PM_ScrollBarExtent: { |