Commit 6dd6bdb5 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[wayland] Implement resize_x/resize_y constraint adjustment

Summary:
Since we send the initial configure event after placing xdg-popups, we
can finally implement resize_x and resize_y constraint adjustments.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27049
parent 40dfbb82
......@@ -209,6 +209,27 @@ void TransientPlacementTest::testXdgPopup_data()
positioner.setGravity(Qt::TopEdge);
positioner.setInitialSize(QSize(300, 200));
QTest::newRow("constraintFlipRightNoGravity") << QSize(500, 500) << QPoint(700, 80) << positioner << QRect(700 + 50 - 150, 130, 300, 200);
// ----------------------------------------------------------------
// resize
positioner.setConstraints(XdgPositioner::Constraint::ResizeX | XdgPositioner::Constraint::ResizeY);
positioner.setInitialSize(QSize(200, 200));
positioner.setAnchorEdge(Qt::TopEdge);
positioner.setGravity(Qt::TopEdge);
QTest::newRow("resizeTop") << QSize(500, 500) << QPoint(80, 80) << positioner << QRect(80 + 250 - 100, 0, 200, 130);
positioner.setAnchorEdge(Qt::LeftEdge);
positioner.setGravity(Qt::LeftEdge);
QTest::newRow("resizeLeft") << QSize(500, 500) << QPoint(80, 80) << positioner << QRect(0, 80 + 250 - 100, 130, 200);
positioner.setAnchorEdge(Qt::RightEdge);
positioner.setGravity(Qt::RightEdge);
QTest::newRow("resizeRight") << QSize(500, 500) << QPoint(700, 80) << positioner << QRect(700 + 50 + 400, 80 + 250 - 100, 130, 200);
positioner.setAnchorEdge(Qt::BottomEdge);
positioner.setGravity(Qt::BottomEdge);
QTest::newRow("resizeBottom") << QSize(500, 500) << QPoint(80, 500) << positioner << QRect(80 + 250 - 100, 500 + 50 + 400, 200, 74);
}
void TransientPlacementTest::testXdgPopup()
......@@ -249,7 +270,7 @@ void TransientPlacementTest::testXdgPopup()
QCOMPARE(configureRequestedSpy.first()[0].value<QRect>(), expectedRelativeGeometry);
popup->ackConfigure(configureRequestedSpy.first()[1].toUInt());
auto transient = Test::renderAndWaitForShown(transientSurface, positioner.initialSize(), Qt::red);
auto transient = Test::renderAndWaitForShown(transientSurface, expectedRelativeGeometry.size(), Qt::red);
QVERIFY(transient);
QVERIFY(!transient->isDecorated());
......
......@@ -1712,8 +1712,18 @@ QRect XdgShellClient::transientPlacement(const QRect &bounds) const
}
}
if (constraintAdjustments & PositionerConstraint::ResizeX) {
//TODO
//but we need to sort out when this is run as resize should only happen before first configure
QRect unconstrainedRect = popupPosition;
if (!inBounds(unconstrainedRect, Qt::LeftEdge)) {
unconstrainedRect.setLeft(bounds.left());
}
if (!inBounds(unconstrainedRect, Qt::RightEdge)) {
unconstrainedRect.setRight(bounds.right());
}
if (unconstrainedRect.isValid()) {
popupPosition = unconstrainedRect;
}
}
if (constraintAdjustments & PositionerConstraint::FlipY) {
......@@ -1744,7 +1754,18 @@ QRect XdgShellClient::transientPlacement(const QRect &bounds) const
}
}
if (constraintAdjustments & PositionerConstraint::ResizeY) {
//TODO
QRect unconstrainedRect = popupPosition;
if (!inBounds(unconstrainedRect, Qt::TopEdge)) {
unconstrainedRect.setTop(bounds.top());
}
if (!inBounds(unconstrainedRect, Qt::BottomEdge)) {
unconstrainedRect.setBottom(bounds.bottom());
}
if (unconstrainedRect.isValid()) {
popupPosition = unconstrainedRect;
}
}
return popupPosition;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment