From ca2a3be39ddc05d9bcb7c638c195504e73d4426c Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sat, 5 Dec 2020 21:55:26 +0800 Subject: [PATCH] Minor tweaks. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- winnativeeventfilter.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 4685827..5cf6d55 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -1003,12 +1003,7 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, *result = 0; return true; } - // If the window bounds change, we're going to relayout and repaint - // anyway. Returning WVR_REDRAW avoids an extra paint before that of - // the old client pixels in the (now wrong) location, and thus makes - // actions like resizing a window from the left edge look slightly - // less broken. - *result = WVR_REDRAW; + bool nonclient = false; const auto clientRect = &(reinterpret_cast(msg->lParam)->rgrc[0]); if (shouldHaveWindowFrame()) { // Store the original top before the default window proc @@ -1048,6 +1043,7 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, clientRect->left += bw; clientRect->right -= bw; } + nonclient = true; } // Attempt to detect if there's an autohide taskbar, and if // there is, reduce our size a bit on the side with the taskbar, @@ -1143,20 +1139,30 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, if (top) { // Peculiarly, when we're fullscreen, clientRect->top += kAutoHideTaskbarThicknessPy; + nonclient = true; } else if (bottom) { clientRect->bottom -= kAutoHideTaskbarThicknessPy; + nonclient = true; } else if (left) { clientRect->left += kAutoHideTaskbarThicknessPx; + nonclient = true; } else if (right) { clientRect->right -= kAutoHideTaskbarThicknessPx; + nonclient = true; } } - // We cannot return WVR_REDRAW when there is nonclient area, or - // Windows exhibits bugs where client pixels and child HWNDs are - // mispositioned by the width/height of the upper-left nonclient - // area. - *result = 0; } + // If the window bounds change, we're going to relayout and repaint + // anyway. Returning WVR_REDRAW avoids an extra paint before that of + // the old client pixels in the (now wrong) location, and thus makes + // actions like resizing a window from the left edge look slightly + // less broken. + // + // We cannot return WVR_REDRAW when there is nonclient area, or + // Windows exhibits bugs where client pixels and child HWNDs are + // mispositioned by the width/height of the upper-left nonclient + // area. + *result = nonclient ? 0 : WVR_REDRAW; return true; } // These undocumented messages are sent to draw themed window