diff --git a/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp b/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp index 7f1b78c101d..32f2d8db818 100644 --- a/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp +++ b/src/plugins/platforms/wayland/plugins/decorations/bradient/main.cpp @@ -73,21 +73,21 @@ QWaylandBradientDecoration::QWaylandBradientDecoration() QRectF QWaylandBradientDecoration::closeButtonRect() const { - const int windowRight = waylandWindow()->windowContentGeometry().right() + 1; + const int windowRight = waylandWindow()->surfaceSize().width() - margins(ShadowsOnly).right(); return QRectF(windowRight - BUTTON_WIDTH - BUTTON_SPACING * 0 - BUTTONS_RIGHT_MARGIN, (margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH); } QRectF QWaylandBradientDecoration::maximizeButtonRect() const { - const int windowRight = waylandWindow()->windowContentGeometry().right() + 1; + const int windowRight = waylandWindow()->surfaceSize().width() - margins(ShadowsOnly).right(); return QRectF(windowRight - BUTTON_WIDTH * 2 - BUTTON_SPACING * 1 - BUTTONS_RIGHT_MARGIN, (margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH); } QRectF QWaylandBradientDecoration::minimizeButtonRect() const { - const int windowRight = waylandWindow()->windowContentGeometry().right() + 1; + const int windowRight = waylandWindow()->surfaceSize().width() - margins(ShadowsOnly).right(); return QRectF(windowRight - BUTTON_WIDTH * 3 - BUTTON_SPACING * 2 - BUTTONS_RIGHT_MARGIN, (margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH); } @@ -103,13 +103,14 @@ QMargins QWaylandBradientDecoration::margins(MarginsType marginsType) const void QWaylandBradientDecoration::paint(QPaintDevice *device) { bool active = window()->handle()->isActive(); - QRect wg = waylandWindow()->windowContentGeometry(); + QRect wg = QRect(QPoint(), waylandWindow()->surfaceSize()).marginsRemoved(margins(ShadowsOnly)); + QRect cg = wg.marginsRemoved(margins(ShadowsExcluded)); QRect clips[] = { - QRect(wg.left(), wg.top(), wg.width(), margins().top()), - QRect(wg.left(), (wg.bottom() + 1) - margins().bottom(), wg.width(), margins().bottom()), - QRect(wg.left(), margins().top(), margins().left(), wg.height() - margins().top() - margins().bottom()), - QRect((wg.right() + 1) - margins().right(), wg.top() + margins().top(), margins().right(), wg.height() - margins().top() - margins().bottom()) + QRect(wg.left(), wg.top(), wg.width(), margins(ShadowsExcluded).top()), + QRect(wg.left(), cg.bottom() + 1, wg.width(), margins(ShadowsExcluded).bottom()), + QRect(wg.left(), cg.top(), margins(ShadowsExcluded).left(), cg.height()), + QRect(cg.right() + 1, cg.top(), margins(ShadowsExcluded).right(), cg.height()) }; QRect top = clips[0]; @@ -236,14 +237,14 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c Q_UNUSED(global); // Figure out what area mouse is in - QRect wg = waylandWindow()->windowContentGeometry(); - if (local.y() <= wg.top() + margins().top()) { + QSize ss = waylandWindow()->surfaceSize(); + if (local.y() <= margins().top()) { processPointerTop(inputDevice, local, b, mods, PointerType::Mouse); - } else if (local.y() > wg.bottom() - margins().bottom()) { + } else if (local.y() >= ss.height() - margins().bottom()) { processPointerBottom(inputDevice, local, b, mods, PointerType::Mouse); - } else if (local.x() <= wg.left() + margins().left()) { + } else if (local.x() <= margins().left()) { processPointerLeft(inputDevice, local, b, mods, PointerType::Mouse); - } else if (local.x() > wg.right() - margins().right()) { + } else if (local.x() >= ss.width() - margins().right()) { processPointerRight(inputDevice, local, b, mods, PointerType::Mouse); } else { #if QT_CONFIG(cursor) @@ -260,17 +261,17 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c bool QWaylandBradientDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods) { Q_UNUSED(global); - QRect wg = waylandWindow()->windowContentGeometry(); + QSize ss = waylandWindow()->surfaceSize(); bool handled = state == QEventPoint::Pressed; if (handled) { - if (local.y() <= wg.top() + margins().top()) { + if (local.y() <= margins().top()) { processPointerTop(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch); - } else if (local.y() > wg.bottom() - margins().bottom()) { + } else if (local.y() >= ss.height() - margins().bottom()) { processPointerBottom(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch); - } else if (local.x() <= wg.left() + margins().left()) { + } else if (local.x() <= margins().left()) { processPointerLeft(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch); - } else if (local.x() > wg.right() - margins().right()) { + } else if (local.x() >= ss.width() - margins().right()) { processPointerRight(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch); } else { handled = false; @@ -290,9 +291,9 @@ void QWaylandBradientDecoration::processPointerTop(QWaylandInputDevice *inputDev Q_UNUSED(type); #endif - QRect wg = waylandWindow()->windowContentGeometry(); + QSize ss = waylandWindow()->surfaceSize(); Q_UNUSED(mods); - if (local.y() <= wg.top() + margins().bottom()) { + if (local.y() <= margins().bottom()) { if (local.x() <= margins().left()) { //top left bit #if QT_CONFIG(cursor) @@ -300,7 +301,7 @@ void QWaylandBradientDecoration::processPointerTop(QWaylandInputDevice *inputDev waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor); #endif startResize(inputDevice, Qt::TopEdge | Qt::LeftEdge, b); - } else if (local.x() > wg.right() - margins().right()) { + } else if (local.x() >= ss.width() - margins().right()) { //top right bit #if QT_CONFIG(cursor) if (type == PointerType::Mouse) @@ -315,9 +316,9 @@ void QWaylandBradientDecoration::processPointerTop(QWaylandInputDevice *inputDev #endif startResize(inputDevice, Qt::TopEdge, b); } - } else if (local.x() <= wg.left() + margins().left()) { + } else if (local.x() <= margins().left()) { processPointerLeft(inputDevice, local, b, mods, type); - } else if (local.x() > wg.right() - margins().right()) { + } else if (local.x() >= ss.width() - margins().right()) { processPointerRight(inputDevice, local, b, mods, type); } else if (isRightClicked(b)) { showWindowMenu(inputDevice); @@ -350,6 +351,7 @@ void QWaylandBradientDecoration::processPointerBottom(QWaylandInputDevice *input Q_UNUSED(type); #endif + QSize ss = waylandWindow()->surfaceSize(); if (local.x() <= margins().left()) { //bottom left bit #if QT_CONFIG(cursor) @@ -357,7 +359,7 @@ void QWaylandBradientDecoration::processPointerBottom(QWaylandInputDevice *input waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor); #endif startResize(inputDevice, Qt::BottomEdge | Qt::LeftEdge, b); - } else if (local.x() > window()->width() + margins().left()) { + } else if (local.x() >= ss.width() - margins().right()) { //bottom right bit #if QT_CONFIG(cursor) if (type == PointerType::Mouse)