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()); const auto hWnd = reinterpret_cast<HWND>(win->winId());
if (hWnd) { if (hWnd) {
return WinNativeEventFilter::getSystemMetric( return WinNativeEventFilter::getSystemMetric(
hWnd, WinNativeEventFilter::SystemMetric::BorderWidth, false); hWnd, WinNativeEventFilter::SystemMetric::BorderWidth);
} }
} }
return m_defaultBorderWidth; return m_defaultBorderWidth;
@ -83,7 +83,7 @@ int FramelessQuickHelper::borderHeight() const {
const auto hWnd = reinterpret_cast<HWND>(win->winId()); const auto hWnd = reinterpret_cast<HWND>(win->winId());
if (hWnd) { if (hWnd) {
return WinNativeEventFilter::getSystemMetric( return WinNativeEventFilter::getSystemMetric(
hWnd, WinNativeEventFilter::SystemMetric::BorderHeight, false); hWnd, WinNativeEventFilter::SystemMetric::BorderHeight);
} }
} }
return m_defaultBorderHeight; return m_defaultBorderHeight;
@ -118,8 +118,7 @@ int FramelessQuickHelper::titleBarHeight() const {
const auto hWnd = reinterpret_cast<HWND>(win->winId()); const auto hWnd = reinterpret_cast<HWND>(win->winId());
if (hWnd) { if (hWnd) {
return WinNativeEventFilter::getSystemMetric( return WinNativeEventFilter::getSystemMetric(
hWnd, WinNativeEventFilter::SystemMetric::TitleBarHeight, hWnd, WinNativeEventFilter::SystemMetric::TitleBarHeight);
false);
} }
} }
return m_defaultTitleBarHeight; 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 // identical in most cases, when the scale factor is 1.0, it
// should be eight pixels. // should be eight pixels.
const int bw = const int bw =
getSystemMetric(msg->hwnd, SystemMetric::BorderWidth); getSystemMetric(msg->hwnd, SystemMetric::BorderWidth, true);
const int bh = const int bh = getSystemMetric(
getSystemMetric(msg->hwnd, SystemMetric::BorderHeight); msg->hwnd, SystemMetric::BorderHeight, true);
clientRect->top += bh; clientRect->top += bh;
clientRect->bottom -= bh; clientRect->bottom -= bh;
clientRect->left += bw; clientRect->left += bw;
@ -1417,13 +1417,13 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
GET_Y_LPARAM(_lParam)}; GET_Y_LPARAM(_lParam)};
POINT mouse = globalMouse; POINT mouse = globalMouse;
m_lpScreenToClient(_hWnd, &mouse); m_lpScreenToClient(_hWnd, &mouse);
// These values are DPI-aware. // These values should be DPI-aware.
const LONG bw = const LONG bw =
getSystemMetric(_hWnd, SystemMetric::BorderWidth); getSystemMetric(_hWnd, SystemMetric::BorderWidth, true);
const LONG bh = const LONG bh =
getSystemMetric(_hWnd, SystemMetric::BorderHeight); getSystemMetric(_hWnd, SystemMetric::BorderHeight, true);
const LONG tbh = const LONG tbh =
getSystemMetric(_hWnd, SystemMetric::TitleBarHeight); getSystemMetric(_hWnd, SystemMetric::TitleBarHeight, true);
const qreal dpr = GetDevicePixelRatioForWindow(_hWnd); const qreal dpr = GetDevicePixelRatioForWindow(_hWnd);
const bool isInIgnoreAreas = const bool isInIgnoreAreas =
isInSpecificAreas(mouse.x, mouse.y, _data.ignoreAreas, dpr); 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) { void WinNativeEventFilter::updateQtFrame_internal(const HWND handle) {
ResolveWin32APIs(); ResolveWin32APIs();
if (handle && m_lpIsWindow(handle)) { if (handle && m_lpIsWindow(handle)) {
const int tbh = const int tbh = getSystemMetric(handle, SystemMetric::TitleBarHeight);
getSystemMetric(handle, SystemMetric::TitleBarHeight, false);
#ifdef QT_WIDGETS_LIB #ifdef QT_WIDGETS_LIB
const QWidget *const widget = const QWidget *const widget =
QWidget::find(reinterpret_cast<WId>(handle)); 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, // System metric value of the given window (if the pointer is null,
// return the system's standard value). // return the system's standard value).
static int getSystemMetric(const HWND handle, const SystemMetric metric, 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 // Use this function to trigger a frame change event or redraw a
// specific window. Useful when you want to let some changes // specific window. Useful when you want to let some changes