Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-04-09 13:31:36 +08:00
parent 2f4686a63c
commit fe9ee701db
1 changed files with 32 additions and 36 deletions

View File

@ -473,48 +473,44 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
} }
return HTCLIENT; return HTCLIENT;
} }
if (_data->windowData.fixedSize) {
if (isTitlebar) {
return HTCAPTION;
} else {
// Un-resizeable border.
return HTBORDER;
}
} else {
const bool isTop = isInsideWindow && (mouse.y < bh); const bool isTop = isInsideWindow && (mouse.y < bh);
const bool isBottom = isInsideWindow && (mouse.y > (wh - bh)); const bool isBottom = isInsideWindow && (mouse.y > (wh - bh));
// Make the border wider to let the user easy to resize on corners. // Make the border wider to let the user easy to resize on corners.
const int factor = (isTop || isBottom) ? 2 : 1; const int factor = (isTop || isBottom) ? 2 : 1;
const bool isLeft = isInsideWindow && (mouse.x < (bw * factor)); const bool isLeft = isInsideWindow && (mouse.x < (bw * factor));
const bool isRight = isInsideWindow && (mouse.x > (ww - (bw * factor))); const bool isRight = isInsideWindow && (mouse.x > (ww - (bw * factor)));
const bool fixedSize = _data->windowData.fixedSize;
const auto getBorderValue = [fixedSize](int value) -> int {
// HTBORDER: un-resizeable window border.
return fixedSize ? HTBORDER : value;
};
if (isTop) { if (isTop) {
if (isLeft) { if (isLeft) {
return HTTOPLEFT; return getBorderValue(HTTOPLEFT);
} }
if (isRight) { if (isRight) {
return HTTOPRIGHT; return getBorderValue(HTTOPRIGHT);
} }
return HTTOP; return getBorderValue(HTTOP);
} }
if (isBottom) { if (isBottom) {
if (isLeft) { if (isLeft) {
return HTBOTTOMLEFT; return getBorderValue(HTBOTTOMLEFT);
} }
if (isRight) { if (isRight) {
return HTBOTTOMRIGHT; return getBorderValue(HTBOTTOMRIGHT);
} }
return HTBOTTOM; return getBorderValue(HTBOTTOM);
} }
if (isLeft) { if (isLeft) {
return HTLEFT; return getBorderValue(HTLEFT);
} }
if (isRight) { if (isRight) {
return HTRIGHT; return getBorderValue(HTRIGHT);
} }
if (isTitlebar) { if (isTitlebar) {
return HTCAPTION; return HTCAPTION;
} }
}
return HTCLIENT; return HTCLIENT;
}; };
*result = getHTResult(msg->hwnd, msg->lParam, data); *result = getHTResult(msg->hwnd, msg->lParam, data);