Minor tweaks.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-05-22 12:19:12 +08:00
parent f26b0322b3
commit 066650f824
3 changed files with 12 additions and 14 deletions

View File

@ -48,7 +48,7 @@ int FramelessQuickHelper::borderWidth() const {
const auto hWnd = reinterpret_cast<HWND>(win->winId());
if (hWnd) {
return WinNativeEventFilter::getSystemMetric(
hWnd, WinNativeEventFilter::SystemMetric::BorderWidth, false);
hWnd, WinNativeEventFilter::SystemMetric::BorderWidth);
}
}
return m_defaultBorderWidth;
@ -83,7 +83,7 @@ int FramelessQuickHelper::borderHeight() const {
const auto hWnd = reinterpret_cast<HWND>(win->winId());
if (hWnd) {
return WinNativeEventFilter::getSystemMetric(
hWnd, WinNativeEventFilter::SystemMetric::BorderHeight, false);
hWnd, WinNativeEventFilter::SystemMetric::BorderHeight);
}
}
return m_defaultBorderHeight;
@ -118,8 +118,7 @@ int FramelessQuickHelper::titleBarHeight() const {
const auto hWnd = reinterpret_cast<HWND>(win->winId());
if (hWnd) {
return WinNativeEventFilter::getSystemMetric(
hWnd, WinNativeEventFilter::SystemMetric::TitleBarHeight,
false);
hWnd, WinNativeEventFilter::SystemMetric::TitleBarHeight);
}
}
return m_defaultTitleBarHeight;

View File

@ -1133,9 +1133,9 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
// identical in most cases, when the scale factor is 1.0, it
// should be eight pixels.
const int bw =
getSystemMetric(msg->hwnd, SystemMetric::BorderWidth);
const int bh =
getSystemMetric(msg->hwnd, SystemMetric::BorderHeight);
getSystemMetric(msg->hwnd, SystemMetric::BorderWidth, true);
const int bh = getSystemMetric(
msg->hwnd, SystemMetric::BorderHeight, true);
clientRect->top += bh;
clientRect->bottom -= bh;
clientRect->left += bw;
@ -1417,13 +1417,13 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
GET_Y_LPARAM(_lParam)};
POINT mouse = globalMouse;
m_lpScreenToClient(_hWnd, &mouse);
// These values are DPI-aware.
// These values should be DPI-aware.
const LONG bw =
getSystemMetric(_hWnd, SystemMetric::BorderWidth);
getSystemMetric(_hWnd, SystemMetric::BorderWidth, true);
const LONG bh =
getSystemMetric(_hWnd, SystemMetric::BorderHeight);
getSystemMetric(_hWnd, SystemMetric::BorderHeight, true);
const LONG tbh =
getSystemMetric(_hWnd, SystemMetric::TitleBarHeight);
getSystemMetric(_hWnd, SystemMetric::TitleBarHeight, true);
const qreal dpr = GetDevicePixelRatioForWindow(_hWnd);
const bool isInIgnoreAreas =
isInSpecificAreas(mouse.x, mouse.y, _data.ignoreAreas, dpr);
@ -1782,8 +1782,7 @@ void WinNativeEventFilter::updateQtFrame(QWindow *const window,
void WinNativeEventFilter::updateQtFrame_internal(const HWND handle) {
ResolveWin32APIs();
if (handle && m_lpIsWindow(handle)) {
const int tbh =
getSystemMetric(handle, SystemMetric::TitleBarHeight, false);
const int tbh = getSystemMetric(handle, SystemMetric::TitleBarHeight);
#ifdef QT_WIDGETS_LIB
const QWidget *const widget =
QWidget::find(reinterpret_cast<WId>(handle));

View File

@ -106,7 +106,7 @@ public:
// System metric value of the given window (if the pointer is null,
// return the system's standard value).
static int getSystemMetric(const HWND handle, const SystemMetric metric,
const bool dpiAware = true);
const bool dpiAware = false);
// Use this function to trigger a frame change event or redraw a
// specific window. Useful when you want to let some changes