From 9b01d7a294139213293f7f3692bf64856e9af9fa Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Fri, 22 May 2020 15:49:17 +0800 Subject: [PATCH] Minor improvements. Maybe this should be the right logic. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- winnativeeventfilter.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 84ce88b..4ddf0d4 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -1427,29 +1427,34 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType, const qreal dpr = GetDevicePixelRatioForWindow(_hWnd); const bool isInIgnoreAreas = isInSpecificAreas(mouse.x, mouse.y, _data.ignoreAreas, dpr); - const bool isInDraggableAreas = _data.draggableAreas.isEmpty() - ? true - : isInSpecificAreas(mouse.x, mouse.y, _data.draggableAreas, - dpr); + const bool customDragAreas = !_data.draggableAreas.isEmpty(); + const bool isInDraggableAreas = customDragAreas + ? isInSpecificAreas(mouse.x, mouse.y, _data.draggableAreas, + dpr) + : true; #if defined(QT_WIDGETS_LIB) || defined(QT_QUICK_LIB) const bool isInIgnoreObjects = isInSpecificObjects( globalMouse.x, globalMouse.y, _data.ignoreObjects, dpr); - const bool isInDraggableObjects = - _data.draggableObjects.isEmpty() - ? true - : isInSpecificObjects(globalMouse.x, globalMouse.y, - _data.draggableObjects, dpr); + const bool customDragObjects = + !_data.draggableObjects.isEmpty(); + const bool isInDraggableObjects = customDragObjects + ? isInSpecificObjects(globalMouse.x, globalMouse.y, + _data.draggableObjects, dpr) + : true; #else // Don't block resizing if both of the Qt Widgets module and Qt // Quick module are not compiled in, although there's not much // significance of using this code in this case. const bool isInIgnoreObjects = false; const bool isInDraggableObjects = true; + const bool customDragObjects = false; #endif + const bool customDrag = customDragAreas || customDragObjects; const bool isResizePermitted = !isInIgnoreAreas && !isInIgnoreObjects; - const bool isTitleBar = (mouse.y <= (tbh + bh)) && - isInDraggableAreas && isInDraggableObjects && + const bool isTitleBar = + (customDrag ? (isInDraggableAreas && isInDraggableObjects) + : (mouse.y <= (tbh + bh))) && isResizePermitted && !_data.disableTitleBar; if (IsMaximized(_hWnd)) { if (isTitleBar) {