Minor improvements

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2021-11-19 14:11:55 +08:00
parent 5be463436c
commit 3aba956d66
3 changed files with 12 additions and 3 deletions

View File

@ -36,7 +36,7 @@ Window {
title: qsTr("Hello, World!") title: qsTr("Hello, World!")
color: "#f0f0f0" 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 property var _win_prev_state: null
FramelessHelper { FramelessHelper {

View File

@ -367,7 +367,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
} }
} }
} }
#if 0 #if 1
// Fix the flickering issue while resizing. // Fix the flickering issue while resizing.
// "clientRect->right += 1;" also works. // "clientRect->right += 1;" also works.
// This small technique is known to have two draw backs: // This small technique is known to have two draw backs:
@ -604,6 +604,14 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
*result = ret; *result = ret;
return true; 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<LPWINDOWPOS>(msg->lParam);
windowPos->flags |= SWP_NOCOPYBITS;
#endif
} break;
default: default:
break; break;
} }

View File

@ -328,7 +328,8 @@ int Utilities::getWindowVisibleFrameBorderThickness(const WId winId)
UINT value = 0; UINT value = 0;
const HRESULT hr = DwmGetWindowAttribute(hWnd, _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, &value, sizeof(value)); const HRESULT hr = DwmGetWindowAttribute(hWnd, _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, &value, sizeof(value));
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
return value; const QWindow *w = findWindow(winId);
return static_cast<int>(qRound(static_cast<qreal>(value) * (w ? w->devicePixelRatio() : 1.0)));
} else { } else {
// We just eat this error because this enum value was introduced in a very // 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 // late Windows 10 version, so querying it's value will always result in