Commit 7292af3d authored by David Edmundson's avatar David Edmundson
Browse files

Use floating geometry throughout

With fractional scaling integer based logical geometry may not match
device pixels. Once we have a floating point base we can fix that. This
also is
important for our X11 scale override, with a scale of 2 we could
get logical sizes with halves.

We already have all input being floating point, this doubles down on it
for all remaining geometry.

- Outputs remain integer to ensure that any screen on the right remains
aligned.
 - Placement also remains integer based for now.
- Repainting is untouched as we always expand outwards
 			   (QRectF::toAdjustedRect().
 - Decoration is untouched for now
 - Rules are integer in the config, but floating in the adjusting/API
This should also be fine.

At some point we'll add a method to snap to the device pixel
grid. Effectively `round(value * dpr)  / dpr` though right now things
mostly work.

This also gets rid of a lot of hacks for QRect right and bottom which
are very
confusing.

Parts to watch out in the port are:
 QRectF::contains...
parent 1527a0cf
Pipeline #204911 failed with stage
in 20 minutes and 33 seconds
......@@ -391,7 +391,7 @@ void DecorationInputTest::testPressToMove()
QVERIFY(!window->isInteractiveMove());
QFETCH(QPoint, offset);
MOTION(QPoint(window->frameGeometry().center().x(), window->y() + window->clientPos().y() / 2) + offset);
const QPoint oldPos = window->pos();
const QPointF oldPos = window->pos();
QVERIFY(window->isInteractiveMove());
QCOMPARE(startMoveResizedSpy.count(), 1);
......@@ -450,7 +450,7 @@ void DecorationInputTest::testTapToMove()
QFETCH(QPoint, offset);
QCOMPARE(input()->touch()->decorationPressId(), 0);
Test::touchMotion(0, p + offset, timestamp++);
const QPoint oldPos = window->pos();
const QPointF oldPos = window->pos();
QVERIFY(window->isInteractiveMove());
QCOMPARE(startMoveResizedSpy.count(), 1);
......
......@@ -137,7 +137,7 @@ void MinimizeAnimationTest::testMinimizeUnminimize()
const QRect iconRect = QRect(0, 0, 42, 36);
plasmaWindow->setMinimizedGeometry(panelSurface.data(), iconRect);
Test::flushWaylandConnection();
QTRY_COMPARE(window->iconGeometry(), iconRect.translated(panel->frameGeometry().topLeft()));
QTRY_COMPARE(window->iconGeometry(), iconRect.translated(panel->frameGeometry().topLeft().toPoint()));
// Load effect that will be tested.
QFETCH(QString, effectName);
......
......@@ -807,7 +807,7 @@ void InternalWindowTest::testReentrantMoveResize()
// Let's pretend that there is a script that really wants the window to be at (100, 100).
connect(window, &Window::frameGeometryChanged, this, [window]() {
window->moveResize(QRect(QPoint(100, 100), window->size()));
window->moveResize(QRectF(QPointF(100, 100), window->size()));
});
// Trigger the lambda above.
......
......@@ -116,7 +116,7 @@ void LayerShellV1WindowTest::testOutput()
QVERIFY(window);
// Verify that the window is on the requested screen.
QVERIFY(output->geometry().contains(window->frameGeometry()));
QVERIFY(output->geometry().contains(window->frameGeometry().toRect()));
// Destroy the window.
shellSurface.reset();
......@@ -126,31 +126,31 @@ void LayerShellV1WindowTest::testOutput()
void LayerShellV1WindowTest::testAnchor_data()
{
QTest::addColumn<int>("anchor");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<QRectF>("expectedGeometry");
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 450, 280, 124);
<< QRectF(0, 450, 280, 124);
QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 0, 280, 124);
<< QRectF(0, 0, 280, 124);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top)
<< QRect(500, 0, 280, 124);
<< QRectF(500, 0, 280, 124);
QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right)
<< QRect(1000, 0, 280, 124);
<< QRectF(1000, 0, 280, 124);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right)
<< QRect(1000, 450, 280, 124);
<< QRectF(1000, 450, 280, 124);
QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_right)
<< QRect(1000, 900, 280, 124);
<< QRectF(1000, 900, 280, 124);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom)
<< QRect(500, 900, 280, 124);
<< QRectF(500, 900, 280, 124);
QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_left)
<< QRect(0, 900, 280, 124);
<< QRectF(0, 900, 280, 124);
}
void LayerShellV1WindowTest::testAnchor()
......@@ -189,39 +189,39 @@ void LayerShellV1WindowTest::testMargins_data()
{
QTest::addColumn<int>("anchor");
QTest::addColumn<QMargins>("margins");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<QRectF>("expectedGeometry");
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 0, 0, 0)
<< QRect(100, 450, 280, 124);
<< QRectF(100, 450, 280, 124);
QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 200, 0, 0)
<< QRect(100, 200, 280, 124);
<< QRectF(100, 200, 280, 124);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top)
<< QMargins(0, 200, 0, 0)
<< QRect(500, 200, 280, 124);
<< QRectF(500, 200, 280, 124);
QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right)
<< QMargins(0, 200, 300, 0)
<< QRect(700, 200, 280, 124);
<< QRectF(700, 200, 280, 124);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right)
<< QMargins(0, 0, 300, 0)
<< QRect(700, 450, 280, 124);
<< QRectF(700, 450, 280, 124);
QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_right)
<< QMargins(0, 0, 300, 400)
<< QRect(700, 500, 280, 124);
<< QRectF(700, 500, 280, 124);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom)
<< QMargins(0, 0, 0, 400)
<< QRect(500, 500, 280, 124);
<< QRectF(500, 500, 280, 124);
QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_left)
<< QMargins(100, 0, 0, 400)
<< QRect(100, 500, 280, 124);
<< QRectF(100, 500, 280, 124);
}
void LayerShellV1WindowTest::testMargins()
......@@ -303,12 +303,12 @@ void LayerShellV1WindowTest::testPlacementArea_data()
{
QTest::addColumn<int>("anchor");
QTest::addColumn<int>("exclusiveZone");
QTest::addColumn<QRect>("placementArea");
QTest::addColumn<QRectF>("placementArea");
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) << 300 << QRect(300, 0, 980, 1024);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) << 300 << QRect(0, 300, 1280, 724);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) << 300 << QRect(0, 0, 980, 1024);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom) << 300 << QRect(0, 0, 1280, 724);
QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) << 300 << QRectF(300, 0, 980, 1024);
QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) << 300 << QRectF(0, 300, 1280, 724);
QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) << 300 << QRectF(0, 0, 980, 1024);
QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom) << 300 << QRectF(0, 0, 1280, 724);
}
void LayerShellV1WindowTest::testPlacementArea()
......@@ -348,19 +348,19 @@ void LayerShellV1WindowTest::testFill_data()
{
QTest::addColumn<int>("anchor");
QTest::addColumn<QSize>("desiredSize");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<QRectF>("expectedGeometry");
QTest::addRow("horizontal") << (Test::LayerSurfaceV1::anchor_left | Test::LayerSurfaceV1::anchor_right)
<< QSize(0, 124)
<< QRect(0, 450, 1280, 124);
<< QRectF(0, 450, 1280, 124);
QTest::addRow("vertical") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_bottom)
<< QSize(280, 0)
<< QRect(500, 0, 280, 1024);
<< QRectF(500, 0, 280, 1024);
QTest::addRow("all") << (Test::LayerSurfaceV1::anchor_left | Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right | Test::LayerSurfaceV1::anchor_bottom)
<< QSize(0, 0)
<< QRect(0, 0, 1280, 1024);
<< QRectF(0, 0, 1280, 1024);
}
void LayerShellV1WindowTest::testFill()
......
......@@ -265,7 +265,7 @@ void TestMaximized::testBorderlessMaximizedWindow()
QVERIFY(!states.testFlag(Test::XdgToplevel::State::Maximized));
// Maximize the window.
const QRect maximizeRestoreGeometry = window->frameGeometry();
const QRectF maximizeRestoreGeometry = window->frameGeometry();
workspace()->slotWindowMaximize();
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
......
......@@ -319,12 +319,12 @@ void MoveResizeWindowTest::testResize()
void MoveResizeWindowTest::testPackTo_data()
{
QTest::addColumn<QString>("methodCall");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<QRectF>("expectedGeometry");
QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(0, 487, 100, 50);
QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 0, 100, 50);
QTest::newRow("right") << QStringLiteral("slotWindowMoveRight") << QRect(1180, 487, 100, 50);
QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 974, 100, 50);
QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRectF(0, 487, 100, 50);
QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRectF(590, 0, 100, 50);
QTest::newRow("right") << QStringLiteral("slotWindowMoveRight") << QRectF(1180, 487, 100, 50);
QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRectF(590, 974, 100, 50);
}
void MoveResizeWindowTest::testPackTo()
......@@ -357,12 +357,12 @@ void MoveResizeWindowTest::testPackTo()
void MoveResizeWindowTest::testPackAgainstClient_data()
{
QTest::addColumn<QString>("methodCall");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<QRectF>("expectedGeometry");
QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(10, 487, 100, 50);
QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 10, 100, 50);
QTest::newRow("right") << QStringLiteral("slotWindowMoveRight") << QRect(1170, 487, 100, 50);
QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 964, 100, 50);
QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRectF(10, 487, 100, 50);
QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRectF(590, 10, 100, 50);
QTest::newRow("right") << QStringLiteral("slotWindowMoveRight") << QRectF(1170, 487, 100, 50);
QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRectF(590, 964, 100, 50);
}
void MoveResizeWindowTest::testPackAgainstClient()
......@@ -424,12 +424,12 @@ void MoveResizeWindowTest::testPackAgainstClient()
void MoveResizeWindowTest::testGrowShrink_data()
{
QTest::addColumn<QString>("methodCall");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<QRectF>("expectedGeometry");
QTest::newRow("grow vertical") << QStringLiteral("slotWindowExpandVertical") << QRect(590, 487, 100, 537);
QTest::newRow("grow horizontal") << QStringLiteral("slotWindowExpandHorizontal") << QRect(590, 487, 690, 50);
QTest::newRow("shrink vertical") << QStringLiteral("slotWindowShrinkVertical") << QRect(590, 487, 100, 23);
QTest::newRow("shrink horizontal") << QStringLiteral("slotWindowShrinkHorizontal") << QRect(590, 487, 40, 50);
QTest::newRow("grow vertical") << QStringLiteral("slotWindowExpandVertical") << QRectF(590, 487, 100, 537);
QTest::newRow("grow horizontal") << QStringLiteral("slotWindowExpandHorizontal") << QRectF(590, 487, 690, 50);
QTest::newRow("shrink vertical") << QStringLiteral("slotWindowShrinkVertical") << QRectF(590, 487, 100, 23);
QTest::newRow("shrink horizontal") << QStringLiteral("slotWindowShrinkHorizontal") << QRectF(590, 487, 40, 50);
}
void MoveResizeWindowTest::testGrowShrink()
......@@ -551,10 +551,10 @@ void MoveResizeWindowTest::testClientSideMove()
QVERIFY(window);
// move pointer into center of geometry
const QRect startGeometry = window->frameGeometry();
const QRectF startGeometry = window->frameGeometry();
Cursors::self()->mouse()->setPos(startGeometry.center());
QVERIFY(pointerEnteredSpy.wait());
QCOMPARE(pointerEnteredSpy.first().last().toPoint(), QPoint(49, 24));
QCOMPARE(pointerEnteredSpy.first().last().toPoint(), QPoint(50, 25));
// simulate press
quint32 timestamp = 1;
Test::pointerButtonPressed(BTN_LEFT, timestamp++);
......@@ -569,7 +569,7 @@ void MoveResizeWindowTest::testClientSideMove()
// move a bit
QSignalSpy clientMoveStepSpy(window, &Window::clientStepUserMovedResized);
QVERIFY(clientMoveStepSpy.isValid());
const QPoint startPoint = startGeometry.center();
const QPointF startPoint = startGeometry.center();
const int dragDistance = QApplication::startDragDistance();
// Why?
Test::pointerMotion(startPoint + QPoint(dragDistance, dragDistance) + QPoint(6, 6), timestamp++);
......@@ -580,7 +580,7 @@ void MoveResizeWindowTest::testClientSideMove()
QVERIFY(pointerEnteredSpy.wait());
QCOMPARE(window->isInteractiveMove(), false);
QCOMPARE(window->frameGeometry(), startGeometry.translated(QPoint(dragDistance, dragDistance) + QPoint(6, 6)));
QCOMPARE(pointerEnteredSpy.last().last().toPoint(), QPoint(49, 24));
QCOMPARE(pointerEnteredSpy.last().last().toPoint(), QPoint(50, 25));
}
void MoveResizeWindowTest::testPlasmaShellSurfaceMovable_data()
......@@ -657,7 +657,7 @@ void MoveResizeWindowTest::testNetMove()
X11Window *window = windowCreatedSpy.first().first().value<X11Window *>();
QVERIFY(window);
QCOMPARE(window->window(), windowId);
const QRect origGeo = window->frameGeometry();
const QRectF origGeo = window->frameGeometry();
// let's move the cursor outside the window
Cursors::self()->mouse()->setPos(workspace()->activeOutput()->geometry().center());
......@@ -762,7 +762,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingX11Panel()
QVERIFY(testWindow->isMovable());
// panel is not yet hidden, we should snap against it
QFETCH(QPoint, targetPoint);
QTEST(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false), "expectedAdjustedPoint");
QTEST(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false).toPoint(), "expectedAdjustedPoint");
// now let's hide the panel
QSignalSpy panelHiddenSpy(panel, &Window::windowHidden);
......@@ -843,7 +843,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingWaylandPanel()
QVERIFY(testWindow->isMovable());
// panel is not yet hidden, we should snap against it
QFETCH(QPoint, targetPoint);
QTEST(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false), "expectedAdjustedPoint");
QTEST(Workspace::self()->adjustWindowPosition(testWindow, targetPoint, false).toPoint(), "expectedAdjustedPoint");
// now let's hide the panel
QSignalSpy panelHiddenSpy(panel, &Window::windowHidden);
......
......@@ -27,9 +27,9 @@ static const QString s_socketName = QStringLiteral("wayland_test_kwin_placement-
struct PlaceWindowResult
{
QSize initiallyConfiguredSize;
QSizeF initiallyConfiguredSize;
Test::XdgToplevel::States initiallyConfiguredStates;
QRect finalGeometry;
QRectF finalGeometry;
};
class TestPlacement : public QObject
......@@ -119,13 +119,13 @@ PlaceWindowResult TestPlacement::createAndPlaceWindow(const QSize &defaultSize,
rc.initiallyConfiguredStates = toplevelConfigureRequestedSpy[0][1].value<Test::XdgToplevel::States>();
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy[0][0].toUInt());
QSize size = rc.initiallyConfiguredSize;
QSizeF size = rc.initiallyConfiguredSize;
if (size.isEmpty()) {
size = defaultSize;
}
auto window = Test::renderAndWaitForShown(surface, size, Qt::red);
auto window = Test::renderAndWaitForShown(surface, size.toSize(), Qt::red);
rc.finalGeometry = window->frameGeometry();
return rc;
......@@ -148,8 +148,8 @@ void TestPlacement::testPlaceSmart()
// exact placement isn't a defined concept that should be tested
// but the goal of smart placement is to make sure windows don't overlap until they need to
// 4 windows of 600, 500 should fit without overlap
QVERIFY(!usedArea.intersects(windowPlacement.finalGeometry));
usedArea += windowPlacement.finalGeometry;
QVERIFY(!usedArea.intersects(windowPlacement.finalGeometry.toRect()));
usedArea += windowPlacement.finalGeometry.toRect();
}
}
......@@ -264,7 +264,7 @@ void TestPlacement::testPlaceUnderMouse()
QScopedPointer<Test::XdgToplevel> shellSurface(Test::createXdgToplevelSurface(surface.data()));
Window *window = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::red);
QVERIFY(window);
QCOMPARE(window->frameGeometry(), QRect(151, 276, 100, 50));
QCOMPARE(window->frameGeometry(), QRect(150, 275, 100, 50));
shellSurface.reset();
QVERIFY(Test::waitForWindowDestroyed(window));
......
......@@ -246,13 +246,13 @@ void PlasmaSurfaceTest::testPanelTypeHasStrut_data()
{
QTest::addColumn<KWayland::Client::PlasmaShellSurface::PanelBehavior>("panelBehavior");
QTest::addColumn<bool>("expectedStrut");
QTest::addColumn<QRect>("expectedMaxArea");
QTest::addColumn<QRectF>("expectedMaxArea");
QTest::addColumn<KWin::Layer>("expectedLayer");
QTest::newRow("always visible - xdgWmBase") << KWayland::Client::PlasmaShellSurface::PanelBehavior::AlwaysVisible << true << QRect(0, 50, 1280, 974) << KWin::DockLayer;
QTest::newRow("autohide - xdgWmBase") << KWayland::Client::PlasmaShellSurface::PanelBehavior::AutoHide << false << QRect(0, 0, 1280, 1024) << KWin::AboveLayer;
QTest::newRow("windows can cover - xdgWmBase") << KWayland::Client::PlasmaShellSurface::PanelBehavior::WindowsCanCover << false << QRect(0, 0, 1280, 1024) << KWin::NormalLayer;
QTest::newRow("windows go below - xdgWmBase") << KWayland::Client::PlasmaShellSurface::PanelBehavior::WindowsGoBelow << false << QRect(0, 0, 1280, 1024) << KWin::AboveLayer;
QTest::newRow("always visible - xdgWmBase") << KWayland::Client::PlasmaShellSurface::PanelBehavior::AlwaysVisible << true << QRectF(0, 50, 1280, 974) << KWin::DockLayer;
QTest::newRow("autohide - xdgWmBase") << KWayland::Client::PlasmaShellSurface::PanelBehavior::AutoHide << false << QRectF(0, 0, 1280, 1024) << KWin::AboveLayer;
QTest::newRow("windows can cover - xdgWmBase") << KWayland::Client::PlasmaShellSurface::PanelBehavior::WindowsCanCover << false << QRectF(0, 0, 1280, 1024) << KWin::NormalLayer;
QTest::newRow("windows go below - xdgWmBase") << KWayland::Client::PlasmaShellSurface::PanelBehavior::WindowsGoBelow << false << QRectF(0, 0, 1280, 1024) << KWin::AboveLayer;
}
void PlasmaSurfaceTest::testPanelTypeHasStrut()
......
......@@ -155,7 +155,7 @@ void PlasmaWindowTest::testCreateDestroyX11PlasmaWindow()
QVERIFY(destroyedSpy.isValid());
// now shade the window
const QRect geoBeforeShade = window->frameGeometry();
const QRectF geoBeforeShade = window->frameGeometry();
QVERIFY(geoBeforeShade.isValid());
QVERIFY(!geoBeforeShade.isEmpty());
workspace()->slotWindowShade();
......
......@@ -35,7 +35,7 @@
using namespace KWin;
using namespace KWayland::Client;
typedef std::function<QPoint(const QRect &)> PointerFunc;
typedef std::function<QPointF(const QRectF &)> PointerFunc;
Q_DECLARE_METATYPE(PointerFunc)
static const QString s_socketName = QStringLiteral("wayland_test_kwin_pointer_constraints-0");
......@@ -100,10 +100,18 @@ void TestPointerConstraints::testConfinedPointer_data()
QTest::addColumn<PointerFunc>("positionFunction");
QTest::addColumn<int>("xOffset");
QTest::addColumn<int>("yOffset");
PointerFunc bottomLeft = &QRect::bottomLeft;
PointerFunc bottomRight = &QRect::bottomRight;
PointerFunc topRight = &QRect::topRight;
PointerFunc topLeft = &QRect::topLeft;
PointerFunc bottomLeft = [](const QRectF &rect) {
return rect.toRect().bottomLeft();
};
PointerFunc bottomRight = [](const QRectF &rect) {
return rect.toRect().bottomRight();
};
PointerFunc topRight = [](const QRectF &rect) {
return rect.toRect().topRight();
};
PointerFunc topLeft = [](const QRectF &rect) {
return rect.toRect().topLeft();
};
QTest::newRow("XdgWmBase - bottomLeft") << bottomLeft << -1 << 1;
QTest::newRow("XdgWmBase - bottomRight") << bottomRight << 1 << 1;
......@@ -147,7 +155,7 @@ void TestPointerConstraints::testConfinedPointer()
// TODO: test relative motion
QFETCH(PointerFunc, positionFunction);
const QPoint position = positionFunction(window->frameGeometry());
const QPointF position = positionFunction(window->frameGeometry());
KWin::Cursors::self()->mouse()->setPos(position);
QCOMPARE(pointerPositionChangedSpy.count(), 1);
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), position);
......
......@@ -340,7 +340,7 @@ void PointerInputTest::testWarpingBetweenWindows()
Test::pointerMotion(window1->frameGeometry().center(), timestamp++);
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 1);
QCOMPARE(enteredSpy.last().at(1).toPointF(), QPointF(49, 24));
QCOMPARE(enteredSpy.last().at(1), QPoint(50, 25));
QCOMPARE(leftSpy.count(), 0);
QCOMPARE(motionSpy.count(), 0);
QCOMPARE(pointer->enteredSurface(), surface1.data());
......@@ -349,7 +349,7 @@ void PointerInputTest::testWarpingBetweenWindows()
Test::pointerMotion(window2->frameGeometry().center(), timestamp++);
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.count(), 2);
QCOMPARE(enteredSpy.last().at(1).toPointF(), QPointF(99, 49));
QCOMPARE(enteredSpy.last().at(1).toPointF(), QPointF(100, 50));
QCOMPARE(leftSpy.count(), 1);
QCOMPARE(motionSpy.count(), 0);
QCOMPARE(pointer->enteredSurface(), surface2.data());
......@@ -1662,7 +1662,7 @@ void PointerInputTest::testResizeCursor()
if (edges & Qt::LeftEdge) {
cursorPos.setX(window->frameGeometry().left());
} else if (edges & Qt::RightEdge) {
cursorPos.setX(window->frameGeometry().right());
cursorPos.setX(window->frameGeometry().right() - 1);
} else {
cursorPos.setX(window->frameGeometry().center().x());
}
......@@ -1670,7 +1670,7 @@ void PointerInputTest::testResizeCursor()
if (edges & Qt::TopEdge) {
cursorPos.setY(window->frameGeometry().top());
} else if (edges & Qt::BottomEdge) {
cursorPos.setY(window->frameGeometry().bottom());
cursorPos.setY(window->frameGeometry().bottom() - 1);
} else {
cursorPos.setY(window->frameGeometry().center().y());
}
......
......@@ -125,23 +125,23 @@ void QuickTilingTest::cleanup()
void QuickTilingTest::testQuickTiling_data()
{
QTest::addColumn<QuickTileMode>("mode");
QTest::addColumn<QRect>("expectedGeometry");
QTest::addColumn<QRectF>("expectedGeometry");
QTest::addColumn<QRect>("secondScreen");
QTest::addColumn<QuickTileMode>("expectedModeAfterToggle");
#define FLAG(name) QuickTileMode(QuickTileFlag::name)
QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024) << FLAG(Right);
QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512) << FLAG(Top);
QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << QuickTileMode();
QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << QRect(1280, 512, 1280, 512) << FLAG(Bottom);
QTest::newRow("left") << FLAG(Left) << QRectF(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024) << FLAG(Right);
QTest::newRow("top") << FLAG(Top) << QRectF(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512) << FLAG(Top);
QTest::newRow("right") << FLAG(Right) << QRectF(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << QuickTileMode();
QTest::newRow("bottom") << FLAG(Bottom) << QRectF(0, 512, 1280, 512) << QRect(1280, 512, 1280, 512) << FLAG(Bottom);
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << QRect(1280, 0, 640, 512) << (FLAG(Right) | FLAG(Top));
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << QuickTileMode();
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << QRect(1280, 512, 640, 512) << (FLAG(Right) | FLAG(Bottom));
QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << QRect(1920, 512, 640, 512) << QuickTileMode();
QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRectF(0, 0, 640, 512) << QRect(1280, 0, 640, 512) << (FLAG(Right) | FLAG(Top));
QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRectF(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << QuickTileMode();
QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRectF(0, 512, 640, 512) << QRect(1280, 512, 640, 512) << (FLAG(Right) | FLAG(Bottom));
QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRectF(640, 512, 640, 512) << QRect(1920, 512, 640, 512) << QuickTileMode();
QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024) << QuickTileMode();
QTest::newRow("maximize") << FLAG(Maximize) << QRectF(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024) << QuickTileMode();
#undef FLAG
}
......@@ -175,7 +175,7 @@ void QuickTilingTest::testQuickTiling()
QVERIFY(frameGeometryChangedSpy.isValid());
QFETCH(QuickTileMode, mode);
QFETCH(QRect, expectedGeometry);
QFETCH(QRectF, expectedGeometry);
window->setQuickTileMode(mode, true);
QCOMPARE(quickTileChangedSpy.count(), 1);
// at this point the geometry did not yet change
......@@ -190,7 +190,7 @@ void QuickTilingTest::testQuickTiling()
// attach a new image
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Test::render(surface.data(), expectedGeometry.size(), Qt::red);
Test::render(surface.data(), expectedGeometry.size().toSize(), Qt::red);
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(frameGeometryChangedSpy.count(), 1);
......@@ -203,7 +203,7 @@ void QuickTilingTest::testQuickTiling()
QCOMPARE(window->output(), outputs[1]);
// quick tile should not be changed
QCOMPARE(window->quickTileMode(), mode);
QTEST(window->frameGeometry(), "secondScreen");
QTEST(window->frameGeometry().toRect(), "secondScreen");
// now try to toggle again
window->setQuickTileMode(mode, true);
......@@ -354,7 +354,7 @@ void QuickTilingTest::testQuickTilingKeyboardMove()
workspace()->performWindowOperation(window, Options::UnrestrictedMoveOp);
QCOMPARE(window, workspace()->moveResizeWindow());
QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(49, 24));
QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(50, 25));
QFETCH(QPoint, targetPos);
quint32 timestamp = 1;
......@@ -425,7 +425,7 @@ void QuickTilingTest::testQuickTilingPointerMove()
QSignalSpy quickTileChangedSpy(window, &Window::quickTileModeChanged);
workspace()->performWindowOperation(window, Options::UnrestrictedMoveOp);
QCOMPARE(window, workspace()->moveResizeWindow());
QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(49, 24));
QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(50, 25));
QFETCH(QPoint, pointerPos);
QFETCH(QSize, tileSize);
......@@ -602,11 +602,11 @@ void QuickTilingTest::testX11QuickTiling()
// now quick tile
QSignalSpy quickTileChangedSpy(window, &Window::quickTileModeChanged);
QVERIFY(quickTileChangedSpy.isValid());
const QRect origGeo = window->frameGeometry();
const QRectF origGeo = window->frameGeometry();
QFETCH(QuickTileMode, mode);
window->setQuickTileMode(mode, true);
QCOMPARE(window->quickTileMode(), mode);
QTEST(window->frameGeometry(), "expectedGeometry");
QTEST(window->frameGeometry().toRect(), "expectedGeometry");
QCOMPARE(window->geometryRestore(), origGeo);
QEXPECT_FAIL("maximize", "For maximize we get two changed signals", Continue);
QCOMPARE(quickTileChangedSpy.count(), 1);
......@@ -681,7 +681,7 @@ void QuickTilingTest::testX11QuickTilingAfterVertMaximize()
QVERIFY(window);
QCOMPARE(window->window(), windowId);
const QRect origGeo = window->frameGeometry();
const QRectF origGeo = window->frameGeometry();
QCOMPARE(window->maximizeMode(), MaximizeRestore);
// vertically maximize the window
window->maximize(window->maximizeMode() ^ MaximizeVertical);
......@@ -695,7 +695,7 @@ void QuickTilingTest::testX11QuickTilingAfterVertMaximize()
QFETCH(QuickTileMode, mode);