summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIlya Fedin <fedin-ilja2010@ya.ru>2023-03-08 18:19:20 +0400
committerIlya Fedin <fedin-ilja2010@ya.ru>2024-03-26 03:53:03 +0400
commit6a94e1fc24687fadb6a14cf4f43c948e9505fbaa (patch)
tree9b9361fb8576317b8aee4694fa88e07cbd58749d /src
parent9fcfe5f9f26dc8d7822aa166de0926fad90fef1b (diff)
Bradient: make drawing coordiantes consistent
Currently some parts of the decoration use surface size (window icon, window controls) while other parts use window content geometry. As backing store paints it from the start of the surface, use surface size everywhere. This is visible when setting custom margins. Change-Id: I22a84fd35bd6e088c30ea265d8cb4af86f14e1a5 Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/decorations/bradient/main.cpp50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/plugins/decorations/bradient/main.cpp b/src/plugins/decorations/bradient/main.cpp
index 7f1b78c10..32f2d8db8 100644
--- a/src/plugins/decorations/bradient/main.cpp
+++ b/src/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)