win32: fix fixed size behavior
The code was from 2.0 and due to we changed solution in 2.1, it needs to be tweaked accordingly but was forgotten. Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
059013a338
commit
aad6957a52
|
@ -103,6 +103,12 @@ FRAMELESSHELPER_STRING_CONSTANT(FindWindowW)
|
||||||
const Win32HelperData data = g_win32Helper()->data.value(parentWindowId);
|
const Win32HelperData data = g_win32Helper()->data.value(parentWindowId);
|
||||||
g_win32Helper()->mutex.unlock();
|
g_win32Helper()->mutex.unlock();
|
||||||
const auto parentWindowHandle = reinterpret_cast<HWND>(parentWindowId);
|
const auto parentWindowHandle = reinterpret_cast<HWND>(parentWindowId);
|
||||||
|
// We only use this drag bar window to activate the snap layouts feature, if the parent
|
||||||
|
// window is not resizable, the snap layouts feature should also be disabled at the same time,
|
||||||
|
// hence forward everything to the parent window, we don't need to handle anything here.
|
||||||
|
if (data.params.isWindowFixedSize()) {
|
||||||
|
return SendMessageW(parentWindowHandle, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
const auto releaseButtons = [&data]() -> void {
|
const auto releaseButtons = [&data]() -> void {
|
||||||
static constexpr const auto defaultButtonState = ButtonState::Unspecified;
|
static constexpr const auto defaultButtonState = ButtonState::Unspecified;
|
||||||
data.params.setSystemButtonState(SystemButtonType::WindowIcon, defaultButtonState);
|
data.params.setSystemButtonState(SystemButtonType::WindowIcon, defaultButtonState);
|
||||||
|
@ -823,10 +829,6 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// color, our homemade top border can almost have exactly the same
|
// color, our homemade top border can almost have exactly the same
|
||||||
// appearance with the system's one.
|
// appearance with the system's one.
|
||||||
|
|
||||||
if (data.params.isWindowFixedSize()) {
|
|
||||||
*result = HTCLIENT;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
const POINT nativeGlobalPos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
const POINT nativeGlobalPos = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
|
||||||
POINT nativeLocalPos = nativeGlobalPos;
|
POINT nativeLocalPos = nativeGlobalPos;
|
||||||
if (ScreenToClient(hWnd, &nativeLocalPos) == FALSE) {
|
if (ScreenToClient(hWnd, &nativeLocalPos) == FALSE) {
|
||||||
|
@ -843,6 +845,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
const bool leftButtonPressed = (buttonSwapped ?
|
const bool leftButtonPressed = (buttonSwapped ?
|
||||||
(GetAsyncKeyState(VK_RBUTTON) < 0) : (GetAsyncKeyState(VK_LBUTTON) < 0));
|
(GetAsyncKeyState(VK_RBUTTON) < 0) : (GetAsyncKeyState(VK_LBUTTON) < 0));
|
||||||
const bool isTitleBar = (data.params.isInsideTitleBarDraggableArea(qtScenePos) && leftButtonPressed);
|
const bool isTitleBar = (data.params.isInsideTitleBarDraggableArea(qtScenePos) && leftButtonPressed);
|
||||||
|
const bool fixedSize = data.params.isWindowFixedSize();
|
||||||
if (frameBorderVisible) {
|
if (frameBorderVisible) {
|
||||||
// This will handle the left, right and bottom parts of the frame
|
// This will handle the left, right and bottom parts of the frame
|
||||||
// because we didn't change them.
|
// because we didn't change them.
|
||||||
|
@ -851,11 +854,6 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
*result = originalRet;
|
*result = originalRet;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// At this point, we know that the cursor is inside the client area
|
|
||||||
// so it has to be either the little border at the top of our custom
|
|
||||||
// title bar or the drag bar. Apparently, it must be the drag bar or
|
|
||||||
// the little border at the top which the user can use to move or
|
|
||||||
// resize the window.
|
|
||||||
if (full) {
|
if (full) {
|
||||||
*result = HTCLIENT;
|
*result = HTCLIENT;
|
||||||
return true;
|
return true;
|
||||||
|
@ -864,7 +862,12 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
*result = (isTitleBar ? HTCAPTION : HTCLIENT);
|
*result = (isTitleBar ? HTCAPTION : HTCLIENT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isTop) {
|
// At this point, we know that the cursor is inside the client area
|
||||||
|
// so it has to be either the little border at the top of our custom
|
||||||
|
// title bar or the drag bar. Apparently, it must be the drag bar or
|
||||||
|
// the little border at the top which the user can use to move or
|
||||||
|
// resize the window.
|
||||||
|
if (isTop && !fixedSize) {
|
||||||
*result = HTTOP;
|
*result = HTTOP;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -883,6 +886,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
*result = (isTitleBar ? HTCAPTION : HTCLIENT);
|
*result = (isTitleBar ? HTCAPTION : HTCLIENT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (!fixedSize) {
|
||||||
RECT clientRect = {0, 0, 0, 0};
|
RECT clientRect = {0, 0, 0, 0};
|
||||||
if (GetClientRect(hWnd, &clientRect) == FALSE) {
|
if (GetClientRect(hWnd, &clientRect) == FALSE) {
|
||||||
qWarning() << Utils::getSystemErrorMessage(kGetClientRect);
|
qWarning() << Utils::getSystemErrorMessage(kGetClientRect);
|
||||||
|
@ -929,6 +933,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
*result = HTRIGHT;
|
*result = HTRIGHT;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (isTitleBar) {
|
if (isTitleBar) {
|
||||||
*result = HTCAPTION;
|
*result = HTCAPTION;
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue