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>
This commit is contained in:
parent
d5252fff74
commit
298c81ef7d
@ -73,21 +73,21 @@ QWaylandBradientDecoration::QWaylandBradientDecoration()
|
|||||||
|
|
||||||
QRectF QWaylandBradientDecoration::closeButtonRect() const
|
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,
|
return QRectF(windowRight - BUTTON_WIDTH - BUTTON_SPACING * 0 - BUTTONS_RIGHT_MARGIN,
|
||||||
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QWaylandBradientDecoration::maximizeButtonRect() const
|
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,
|
return QRectF(windowRight - BUTTON_WIDTH * 2 - BUTTON_SPACING * 1 - BUTTONS_RIGHT_MARGIN,
|
||||||
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QWaylandBradientDecoration::minimizeButtonRect() const
|
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,
|
return QRectF(windowRight - BUTTON_WIDTH * 3 - BUTTON_SPACING * 2 - BUTTONS_RIGHT_MARGIN,
|
||||||
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
(margins().top() - BUTTON_WIDTH) / 2, BUTTON_WIDTH, BUTTON_WIDTH);
|
||||||
}
|
}
|
||||||
@ -103,13 +103,14 @@ QMargins QWaylandBradientDecoration::margins(MarginsType marginsType) const
|
|||||||
void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
void QWaylandBradientDecoration::paint(QPaintDevice *device)
|
||||||
{
|
{
|
||||||
bool active = window()->handle()->isActive();
|
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 clips[] =
|
||||||
{
|
{
|
||||||
QRect(wg.left(), wg.top(), wg.width(), margins().top()),
|
QRect(wg.left(), wg.top(), wg.width(), margins(ShadowsExcluded).top()),
|
||||||
QRect(wg.left(), (wg.bottom() + 1) - margins().bottom(), wg.width(), margins().bottom()),
|
QRect(wg.left(), cg.bottom() + 1, wg.width(), margins(ShadowsExcluded).bottom()),
|
||||||
QRect(wg.left(), margins().top(), margins().left(), wg.height() - margins().top() - margins().bottom()),
|
QRect(wg.left(), cg.top(), margins(ShadowsExcluded).left(), cg.height()),
|
||||||
QRect((wg.right() + 1) - margins().right(), wg.top() + margins().top(), margins().right(), wg.height() - margins().top() - margins().bottom())
|
QRect(cg.right() + 1, cg.top(), margins(ShadowsExcluded).right(), cg.height())
|
||||||
};
|
};
|
||||||
|
|
||||||
QRect top = clips[0];
|
QRect top = clips[0];
|
||||||
@ -236,14 +237,14 @@ bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, c
|
|||||||
Q_UNUSED(global);
|
Q_UNUSED(global);
|
||||||
|
|
||||||
// Figure out what area mouse is in
|
// Figure out what area mouse is in
|
||||||
QRect wg = waylandWindow()->windowContentGeometry();
|
QSize ss = waylandWindow()->surfaceSize();
|
||||||
if (local.y() <= wg.top() + margins().top()) {
|
if (local.y() <= margins().top()) {
|
||||||
processPointerTop(inputDevice, local, b, mods, PointerType::Mouse);
|
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);
|
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);
|
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);
|
processPointerRight(inputDevice, local, b, mods, PointerType::Mouse);
|
||||||
} else {
|
} else {
|
||||||
#if QT_CONFIG(cursor)
|
#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)
|
bool QWaylandBradientDecoration::handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods)
|
||||||
{
|
{
|
||||||
Q_UNUSED(global);
|
Q_UNUSED(global);
|
||||||
QRect wg = waylandWindow()->windowContentGeometry();
|
QSize ss = waylandWindow()->surfaceSize();
|
||||||
|
|
||||||
bool handled = state == QEventPoint::Pressed;
|
bool handled = state == QEventPoint::Pressed;
|
||||||
if (handled) {
|
if (handled) {
|
||||||
if (local.y() <= wg.top() + margins().top()) {
|
if (local.y() <= margins().top()) {
|
||||||
processPointerTop(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch);
|
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);
|
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);
|
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);
|
processPointerRight(inputDevice, local, Qt::LeftButton, mods, PointerType::Touch);
|
||||||
} else {
|
} else {
|
||||||
handled = false;
|
handled = false;
|
||||||
@ -290,9 +291,9 @@ void QWaylandBradientDecoration::processPointerTop(QWaylandInputDevice *inputDev
|
|||||||
Q_UNUSED(type);
|
Q_UNUSED(type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QRect wg = waylandWindow()->windowContentGeometry();
|
QSize ss = waylandWindow()->surfaceSize();
|
||||||
Q_UNUSED(mods);
|
Q_UNUSED(mods);
|
||||||
if (local.y() <= wg.top() + margins().bottom()) {
|
if (local.y() <= margins().bottom()) {
|
||||||
if (local.x() <= margins().left()) {
|
if (local.x() <= margins().left()) {
|
||||||
//top left bit
|
//top left bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
@ -300,7 +301,7 @@ void QWaylandBradientDecoration::processPointerTop(QWaylandInputDevice *inputDev
|
|||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeFDiagCursor);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::TopEdge | Qt::LeftEdge, b);
|
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
|
//top right bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
if (type == PointerType::Mouse)
|
if (type == PointerType::Mouse)
|
||||||
@ -315,9 +316,9 @@ void QWaylandBradientDecoration::processPointerTop(QWaylandInputDevice *inputDev
|
|||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::TopEdge, b);
|
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);
|
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);
|
processPointerRight(inputDevice, local, b, mods, type);
|
||||||
} else if (isRightClicked(b)) {
|
} else if (isRightClicked(b)) {
|
||||||
showWindowMenu(inputDevice);
|
showWindowMenu(inputDevice);
|
||||||
@ -350,6 +351,7 @@ void QWaylandBradientDecoration::processPointerBottom(QWaylandInputDevice *input
|
|||||||
Q_UNUSED(type);
|
Q_UNUSED(type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QSize ss = waylandWindow()->surfaceSize();
|
||||||
if (local.x() <= margins().left()) {
|
if (local.x() <= margins().left()) {
|
||||||
//bottom left bit
|
//bottom left bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
@ -357,7 +359,7 @@ void QWaylandBradientDecoration::processPointerBottom(QWaylandInputDevice *input
|
|||||||
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
|
waylandWindow()->setMouseCursor(inputDevice, Qt::SizeBDiagCursor);
|
||||||
#endif
|
#endif
|
||||||
startResize(inputDevice, Qt::BottomEdge | Qt::LeftEdge, b);
|
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
|
//bottom right bit
|
||||||
#if QT_CONFIG(cursor)
|
#if QT_CONFIG(cursor)
|
||||||
if (type == PointerType::Mouse)
|
if (type == PointerType::Mouse)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user