From 606894465722f16d972e4dfdcb2b502093ef456d Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sun, 28 Nov 2021 20:22:08 +0800 Subject: [PATCH] Win32: always return 0 in WM_NCCALCSIZE Otherwise will cause bugs. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- framelesshelper_win32.cpp | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/framelesshelper_win32.cpp b/framelesshelper_win32.cpp index 991e070..589a5dd 100644 --- a/framelesshelper_win32.cpp +++ b/framelesshelper_win32.cpp @@ -245,7 +245,6 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me const auto clientRect = ((static_cast(msg->wParam) == FALSE) ? reinterpret_cast(msg->lParam) : &(reinterpret_cast(msg->lParam))->rgrc[0]); - bool nonClientAreaExists = false; // We don't need this correction when we're fullscreen. We will // have the WS_POPUP size, so we don't have to worry about // borders, and the default frame will be fine. @@ -261,7 +260,6 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me clientRect->bottom -= resizeBorderThickness; clientRect->left += resizeBorderThickness; clientRect->right -= resizeBorderThickness; - nonClientAreaExists = 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, @@ -354,16 +352,12 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me if (top) { // Peculiarly, when we're fullscreen, clientRect->top += kAutoHideTaskbarThickness; - nonClientAreaExists = true; } else if (bottom) { clientRect->bottom -= kAutoHideTaskbarThickness; - nonClientAreaExists = true; } else if (left) { clientRect->left += kAutoHideTaskbarThickness; - nonClientAreaExists = true; } else if (right) { clientRect->right -= kAutoHideTaskbarThickness; - nonClientAreaExists = true; } } } @@ -382,17 +376,10 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me // is not correct. It confuses QPA's internal logic. clientRect->bottom += 1; #endif - // 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 = (((static_cast(msg->wParam) == FALSE) || nonClientAreaExists) ? 0 : WVR_REDRAW); + // We cannot return WVR_REDRAW otherwise Windows exhibits bugs where + // client pixels and child windows are mispositioned by the width/height + // of the upper-left nonclient area. + *result = 0; return true; } // These undocumented messages are sent to draw themed window