Minor improvements.

Maybe this should be the right logic.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-05-22 15:49:17 +08:00
parent 066650f824
commit 9b01d7a294
1 changed files with 16 additions and 11 deletions

View File

@ -1427,29 +1427,34 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
const qreal dpr = GetDevicePixelRatioForWindow(_hWnd); const qreal dpr = GetDevicePixelRatioForWindow(_hWnd);
const bool isInIgnoreAreas = const bool isInIgnoreAreas =
isInSpecificAreas(mouse.x, mouse.y, _data.ignoreAreas, dpr); isInSpecificAreas(mouse.x, mouse.y, _data.ignoreAreas, dpr);
const bool isInDraggableAreas = _data.draggableAreas.isEmpty() const bool customDragAreas = !_data.draggableAreas.isEmpty();
? true const bool isInDraggableAreas = customDragAreas
: isInSpecificAreas(mouse.x, mouse.y, _data.draggableAreas, ? isInSpecificAreas(mouse.x, mouse.y, _data.draggableAreas,
dpr); dpr)
: true;
#if defined(QT_WIDGETS_LIB) || defined(QT_QUICK_LIB) #if defined(QT_WIDGETS_LIB) || defined(QT_QUICK_LIB)
const bool isInIgnoreObjects = isInSpecificObjects( const bool isInIgnoreObjects = isInSpecificObjects(
globalMouse.x, globalMouse.y, _data.ignoreObjects, dpr); globalMouse.x, globalMouse.y, _data.ignoreObjects, dpr);
const bool isInDraggableObjects = const bool customDragObjects =
_data.draggableObjects.isEmpty() !_data.draggableObjects.isEmpty();
? true const bool isInDraggableObjects = customDragObjects
: isInSpecificObjects(globalMouse.x, globalMouse.y, ? isInSpecificObjects(globalMouse.x, globalMouse.y,
_data.draggableObjects, dpr); _data.draggableObjects, dpr)
: true;
#else #else
// Don't block resizing if both of the Qt Widgets module and Qt // Don't block resizing if both of the Qt Widgets module and Qt
// Quick module are not compiled in, although there's not much // Quick module are not compiled in, although there's not much
// significance of using this code in this case. // significance of using this code in this case.
const bool isInIgnoreObjects = false; const bool isInIgnoreObjects = false;
const bool isInDraggableObjects = true; const bool isInDraggableObjects = true;
const bool customDragObjects = false;
#endif #endif
const bool customDrag = customDragAreas || customDragObjects;
const bool isResizePermitted = const bool isResizePermitted =
!isInIgnoreAreas && !isInIgnoreObjects; !isInIgnoreAreas && !isInIgnoreObjects;
const bool isTitleBar = (mouse.y <= (tbh + bh)) && const bool isTitleBar =
isInDraggableAreas && isInDraggableObjects && (customDrag ? (isInDraggableAreas && isInDraggableObjects)
: (mouse.y <= (tbh + bh))) &&
isResizePermitted && !_data.disableTitleBar; isResizePermitted && !_data.disableTitleBar;
if (IsMaximized(_hWnd)) { if (IsMaximized(_hWnd)) {
if (isTitleBar) { if (isTitleBar) {