From 3aba956d6662207dfbff2b7cc10b77b5b80e79b8 Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 19 Nov 2021 14:11:55 +0800 Subject: [PATCH] Minor improvements Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- examples/quick/qml/main.qml | 2 +- framelesshelper_win32.cpp | 10 +++++++++- utilities_win32.cpp | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/quick/qml/main.qml b/examples/quick/qml/main.qml index 5c413e5..3d1328a 100644 --- a/examples/quick/qml/main.qml +++ b/examples/quick/qml/main.qml @@ -36,7 +36,7 @@ Window { title: qsTr("Hello, World!") color: "#f0f0f0" - property real _flh_margin: ((window.visibility === Window.Maximized) | (window.visibility === Window.FullScreen)) ? 0.0 : (1.0 / Screen.devicePixelRatio) + property real _flh_margin: ((window.visibility === Window.Maximized) | (window.visibility === Window.FullScreen)) ? 0.0 : Math.max(1.0, Screen.devicePixelRatio) property var _win_prev_state: null FramelessHelper { diff --git a/framelesshelper_win32.cpp b/framelesshelper_win32.cpp index 6943f99..991e070 100644 --- a/framelesshelper_win32.cpp +++ b/framelesshelper_win32.cpp @@ -367,7 +367,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me } } } -#if 0 +#if 1 // Fix the flickering issue while resizing. // "clientRect->right += 1;" also works. // This small technique is known to have two draw backs: @@ -604,6 +604,14 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me *result = ret; return true; } + case WM_WINDOWPOSCHANGING: { +#if (QT_VERSION < QT_VERSION_CHECK(6, 2, 2)) + // Tell Windows to discard the entire contents of the client area, as re-using + // parts of the client area would lead to jitter during resize. + const auto windowPos = reinterpret_cast(msg->lParam); + windowPos->flags |= SWP_NOCOPYBITS; +#endif + } break; default: break; } diff --git a/utilities_win32.cpp b/utilities_win32.cpp index 2886970..6bcf364 100644 --- a/utilities_win32.cpp +++ b/utilities_win32.cpp @@ -328,7 +328,8 @@ int Utilities::getWindowVisibleFrameBorderThickness(const WId winId) UINT value = 0; const HRESULT hr = DwmGetWindowAttribute(hWnd, _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, &value, sizeof(value)); if (SUCCEEDED(hr)) { - return value; + const QWindow *w = findWindow(winId); + return static_cast(qRound(static_cast(value) * (w ? w->devicePixelRatio() : 1.0))); } else { // We just eat this error because this enum value was introduced in a very // late Windows 10 version, so querying it's value will always result in