Minor improvement.

Fixes: #7

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-05-03 21:20:24 +08:00
parent 092f7147ab
commit a3d4df1ebf
1 changed files with 9 additions and 5 deletions

View File

@ -1253,22 +1253,26 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
: isInSpecificObjects(mouse.x, mouse.y, : isInSpecificObjects(mouse.x, mouse.y,
_data->windowData.draggableObjects, _data->windowData.draggableObjects,
dpr); dpr);
const bool isTitlebar = (mouse.y <= tbh) && !isInIgnoreAreas && const bool isResizePermitted = !isInIgnoreAreas &&
isInDraggableAreas && !isInIgnoreObjects && isInDraggableAreas && !isInIgnoreObjects &&
isInDraggableObjects; isInDraggableObjects;
const bool isTitlebar = (mouse.y <= tbh) && isResizePermitted;
if (IsMaximized(_hWnd)) { if (IsMaximized(_hWnd)) {
if (isTitlebar) { if (isTitlebar) {
return HTCAPTION; return HTCAPTION;
} }
return HTCLIENT; return HTCLIENT;
} }
const bool isTop = mouse.y <= bh; const bool isTop = (mouse.y <= bh) && isResizePermitted;
const bool isBottom = mouse.y >= (wh - bh); const bool isBottom =
(mouse.y >= (wh - bh)) && isResizePermitted;
// Make the border a little wider to let the user easy to resize // Make the border a little wider to let the user easy to resize
// on corners. // on corners.
const int factor = (isTop || isBottom) ? 2 : 1; const int factor = (isTop || isBottom) ? 2 : 1;
const bool isLeft = mouse.x <= (bw * factor); const bool isLeft =
const bool isRight = mouse.x >= (ww - (bw * factor)); (mouse.x <= (bw * factor)) && isResizePermitted;
const bool isRight =
(mouse.x >= (ww - (bw * factor))) && isResizePermitted;
const bool fixedSize = _data->windowData.fixedSize; const bool fixedSize = _data->windowData.fixedSize;
const auto getBorderValue = [fixedSize](int value) -> int { const auto getBorderValue = [fixedSize](int value) -> int {
// HTBORDER: non-resizeable window border. // HTBORDER: non-resizeable window border.