From 3a28c02f287f4acdde77508aa716ca01a3be7514 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 28 Sep 2022 13:55:32 +0200 Subject: [PATCH] x11window: don't change size for centering windows with maximization --- src/utils/xcbutils.h | 4 ++-- src/x11window.cpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/utils/xcbutils.h b/src/utils/xcbutils.h index 43348acf2e..43f09b02e0 100644 --- a/src/utils/xcbutils.h +++ b/src/utils/xcbutils.h @@ -1025,9 +1025,9 @@ public: QSizeF resizeIncrements() const { if (!hasResizeIncrements()) { - return QSize(1, 1); + return fromXNative(QSize(1, 1)); } - return QSizeF(qMax(fromXNative(m_sizeHints->widthInc), 1.), qMax(fromXNative(m_sizeHints->heightInc), 1.)); + return Xcb::fromXNative(QSize(std::max(m_sizeHints->widthInc, 1), std::max(m_sizeHints->heightInc, 1))); } xcb_gravity_t windowGravity() const { diff --git a/src/x11window.cpp b/src/x11window.cpp index 7143c60f51..403c96aa82 100644 --- a/src/x11window.cpp +++ b/src/x11window.cpp @@ -4487,32 +4487,33 @@ void X11Window::maximize(MaximizeMode mode) if (closeHeight) { bool tryBottom = titlePos == Qt::BottomEdge; if ((overHeight && titlePos == Qt::TopEdge) || screenArea.top() == clientArea.top()) { - r.setTop(clientArea.top()); + r.moveTop(clientArea.top()); } else { tryBottom = true; } if (tryBottom && (overHeight || screenArea.bottom() == clientArea.bottom())) { - r.setBottom(clientArea.bottom()); + r.moveBottom(clientArea.bottom()); } } if (closeWidth) { bool tryLeft = titlePos == Qt::LeftEdge; if ((overWidth && titlePos == Qt::RightEdge) || screenArea.right() == clientArea.right()) { - r.setRight(clientArea.right()); + r.moveRight(clientArea.right()); } else { tryLeft = true; } if (tryLeft && (overWidth || screenArea.left() == clientArea.left())) { - r.setLeft(clientArea.left()); + r.moveLeft(clientArea.left()); } } } } r.moveTopLeft(rules()->checkPosition(r.topLeft())); + // The above code tries to center align the window followed by setting top and bottom + // it's possible that we're in between two pixels + r.setX(Xcb::nativeFloor(r.x())); + r.setY(Xcb::nativeFloor(r.y())); } - // The above code tries to center align the window followed by setting top and bottom - // it's possible that we no longer have a valid size - r = Xcb::nativeFloor(r); moveResize(r); if (options->electricBorderMaximize() && r.top() == clientArea.top()) {