Windows: Don't resize diagonally when at least 1 dimension is fixed

If width is fixed and height is not, then when using the corner resize
only width can be changed (and same for fixed height).

Fixes #345
This commit is contained in:
Sergio Martins
2023-03-06 19:53:03 +00:00
parent f6d9ac5606
commit 1b33da8b44
2 changed files with 6 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
- Introduce DockWidget::setFloatingWindowFlags(flags). Allows for different
FloatingWindows to have different window flags. For example, some having
Qt::Tool while others having Qt::Window (#314).
- Fixed fixed-sized windows being able to be resized on Windows (#345)
* v1.6.0 (14 September 2022)
- Minimum Qt6 version is now 6.2.0

View File

@@ -369,6 +369,7 @@ bool WidgetResizeHandler::handleWindowsNativeEvent(QWindow *w, MSG *msg,
const int borderWidth = 8;
const bool hasFixedWidth = w->minimumWidth() == w->maximumWidth();
const bool hasFixedHeight = w->minimumHeight() == w->maximumHeight();
const bool hasFixedWidthOrHeight = hasFixedWidth || hasFixedHeight;
*result = 0;
const int xPos = GET_X_LPARAM(msg->lParam);
@@ -376,13 +377,13 @@ bool WidgetResizeHandler::handleWindowsNativeEvent(QWindow *w, MSG *msg,
RECT rect;
GetWindowRect(reinterpret_cast<HWND>(w->winId()), &rect);
if (xPos >= rect.left && xPos <= rect.left + borderWidth && yPos <= rect.bottom && yPos >= rect.bottom - borderWidth && features.hasResize()) {
if (!hasFixedWidthOrHeight && xPos >= rect.left && xPos <= rect.left + borderWidth && yPos <= rect.bottom && yPos >= rect.bottom - borderWidth && features.hasResize()) {
*result = HTBOTTOMLEFT;
} else if (xPos < rect.right && xPos >= rect.right - borderWidth && yPos <= rect.bottom && yPos >= rect.bottom - borderWidth && features.hasResize()) {
} else if (!hasFixedWidthOrHeight && xPos < rect.right && xPos >= rect.right - borderWidth && yPos <= rect.bottom && yPos >= rect.bottom - borderWidth && features.hasResize()) {
*result = HTBOTTOMRIGHT;
} else if (xPos >= rect.left && xPos <= rect.left + borderWidth && yPos >= rect.top && yPos <= rect.top + borderWidth && features.hasResize()) {
} else if (!hasFixedWidthOrHeight && xPos >= rect.left && xPos <= rect.left + borderWidth && yPos >= rect.top && yPos <= rect.top + borderWidth && features.hasResize()) {
*result = HTTOPLEFT;
} else if (xPos <= rect.right && xPos >= rect.right - borderWidth && yPos >= rect.top && yPos < rect.top + borderWidth && features.hasResize()) {
} else if (!hasFixedWidthOrHeight && xPos <= rect.right && xPos >= rect.right - borderWidth && yPos >= rect.top && yPos < rect.top + borderWidth && features.hasResize()) {
*result = HTTOPRIGHT;
} else if (!hasFixedWidth && xPos >= rect.left && xPos <= rect.left + borderWidth && features.hasResize()) {
*result = HTLEFT;