Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_input.cpp
Show All 24 Lines | |||||
25 | #include "effects.h" | 25 | #include "effects.h" | ||
26 | #include "pointer_input.h" | 26 | #include "pointer_input.h" | ||
27 | #include "options.h" | 27 | #include "options.h" | ||
28 | #include "screenedge.h" | 28 | #include "screenedge.h" | ||
29 | #include "screens.h" | 29 | #include "screens.h" | ||
30 | #include "wayland_cursor_theme.h" | 30 | #include "wayland_cursor_theme.h" | ||
31 | #include "wayland_server.h" | 31 | #include "wayland_server.h" | ||
32 | #include "workspace.h" | 32 | #include "workspace.h" | ||
33 | #include "xdgshellclient.h" | | |||
34 | #include <kwineffects.h> | 33 | #include <kwineffects.h> | ||
35 | 34 | | |||
36 | #include <KWayland/Client/buffer.h> | 35 | #include <KWayland/Client/buffer.h> | ||
37 | #include <KWayland/Client/connection_thread.h> | 36 | #include <KWayland/Client/connection_thread.h> | ||
38 | #include <KWayland/Client/compositor.h> | 37 | #include <KWayland/Client/compositor.h> | ||
39 | #include <KWayland/Client/pointer.h> | 38 | #include <KWayland/Client/pointer.h> | ||
40 | #include <KWayland/Client/seat.h> | 39 | #include <KWayland/Client/seat.h> | ||
41 | #include <KWayland/Client/server_decoration.h> | 40 | #include <KWayland/Client/server_decoration.h> | ||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Line(s) | |||||
135 | private: | 134 | private: | ||
136 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | 135 | void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); | ||
137 | KWayland::Client::Compositor *m_compositor = nullptr; | 136 | KWayland::Client::Compositor *m_compositor = nullptr; | ||
138 | KWayland::Client::Seat *m_seat = nullptr; | 137 | KWayland::Client::Seat *m_seat = nullptr; | ||
139 | }; | 138 | }; | ||
140 | 139 | | |||
141 | void PointerInputTest::initTestCase() | 140 | void PointerInputTest::initTestCase() | ||
142 | { | 141 | { | ||
143 | qRegisterMetaType<KWin::XdgShellClient *>(); | | |||
144 | qRegisterMetaType<KWin::AbstractClient*>(); | 142 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
145 | qRegisterMetaType<KWin::Deleted*>(); | 143 | qRegisterMetaType<KWin::Deleted*>(); | ||
146 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 144 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
147 | QVERIFY(workspaceCreatedSpy.isValid()); | 145 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
148 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 146 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
149 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 147 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
150 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | 148 | QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); | ||
151 | 149 | | |||
▲ Show 20 Lines • Show All 1052 Lines • ▼ Show 20 Line(s) | 1156 | { | |||
1204 | QVERIFY(popupSurface); | 1202 | QVERIFY(popupSurface); | ||
1205 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | 1203 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1206 | QVERIFY(popupShellSurface); | 1204 | QVERIFY(popupShellSurface); | ||
1207 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | 1205 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | ||
1208 | QVERIFY(popupDoneSpy.isValid()); | 1206 | QVERIFY(popupDoneSpy.isValid()); | ||
1209 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | 1207 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | ||
1210 | render(popupSurface, positioner.initialSize()); | 1208 | render(popupSurface, positioner.initialSize()); | ||
1211 | QVERIFY(clientAddedSpy.wait()); | 1209 | QVERIFY(clientAddedSpy.wait()); | ||
1212 | auto popupClient = clientAddedSpy.last().first().value<XdgShellClient *>(); | 1210 | auto popupClient = clientAddedSpy.last().first().value<AbstractClient *>(); | ||
1213 | QVERIFY(popupClient); | 1211 | QVERIFY(popupClient); | ||
1214 | QVERIFY(popupClient != window); | 1212 | QVERIFY(popupClient != window); | ||
1215 | QCOMPARE(window, workspace()->activeClient()); | 1213 | QCOMPARE(window, workspace()->activeClient()); | ||
1216 | QCOMPARE(popupClient->transientFor(), window); | 1214 | QCOMPARE(popupClient->transientFor(), window); | ||
1217 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | 1215 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | ||
1218 | QCOMPARE(popupClient->hasPopupGrab(), true); | 1216 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||
1219 | 1217 | | |||
1220 | // let's move the pointer into the center of the window | 1218 | // let's move the pointer into the center of the window | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 1238 | { | |||
1295 | QVERIFY(popupSurface); | 1293 | QVERIFY(popupSurface); | ||
1296 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | 1294 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1297 | QVERIFY(popupShellSurface); | 1295 | QVERIFY(popupShellSurface); | ||
1298 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | 1296 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | ||
1299 | QVERIFY(popupDoneSpy.isValid()); | 1297 | QVERIFY(popupDoneSpy.isValid()); | ||
1300 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | 1298 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | ||
1301 | render(popupSurface, positioner.initialSize()); | 1299 | render(popupSurface, positioner.initialSize()); | ||
1302 | QVERIFY(clientAddedSpy.wait()); | 1300 | QVERIFY(clientAddedSpy.wait()); | ||
1303 | auto popupClient = clientAddedSpy.last().first().value<XdgShellClient *>(); | 1301 | auto popupClient = clientAddedSpy.last().first().value<AbstractClient *>(); | ||
1304 | QVERIFY(popupClient); | 1302 | QVERIFY(popupClient); | ||
1305 | QVERIFY(popupClient != window); | 1303 | QVERIFY(popupClient != window); | ||
1306 | QCOMPARE(window, workspace()->activeClient()); | 1304 | QCOMPARE(window, workspace()->activeClient()); | ||
1307 | QCOMPARE(popupClient->transientFor(), window); | 1305 | QCOMPARE(popupClient->transientFor(), window); | ||
1308 | QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); | 1306 | QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); | ||
1309 | QCOMPARE(popupClient->hasPopupGrab(), true); | 1307 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||
1310 | 1308 | | |||
1311 | // let's move the pointer into the center of the deco | 1309 | // let's move the pointer into the center of the deco | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 1318 | { | |||
1357 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | 1355 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||
1358 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | 1356 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||
1359 | Surface *popupSurface = Test::createSurface(m_compositor); | 1357 | Surface *popupSurface = Test::createSurface(m_compositor); | ||
1360 | QVERIFY(popupSurface); | 1358 | QVERIFY(popupSurface); | ||
1361 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | 1359 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1362 | QVERIFY(popupShellSurface); | 1360 | QVERIFY(popupShellSurface); | ||
1363 | render(popupSurface, positioner.initialSize()); | 1361 | render(popupSurface, positioner.initialSize()); | ||
1364 | QVERIFY(clientAddedSpy.wait()); | 1362 | QVERIFY(clientAddedSpy.wait()); | ||
1365 | auto popupClient = clientAddedSpy.last().first().value<XdgShellClient *>(); | 1363 | auto popupClient = clientAddedSpy.last().first().value<AbstractClient *>(); | ||
1366 | QVERIFY(popupClient); | 1364 | QVERIFY(popupClient); | ||
1367 | QVERIFY(popupClient != window); | 1365 | QVERIFY(popupClient != window); | ||
1368 | QVERIFY(window->frameGeometry().contains(Cursor::pos())); | 1366 | QVERIFY(window->frameGeometry().contains(Cursor::pos())); | ||
1369 | QVERIFY(popupClient->frameGeometry().contains(Cursor::pos())); | 1367 | QVERIFY(popupClient->frameGeometry().contains(Cursor::pos())); | ||
1370 | QVERIFY(!leftSpy.wait()); | 1368 | QVERIFY(!leftSpy.wait()); | ||
1371 | 1369 | | |||
1372 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1370 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1373 | // now that the button is no longer pressed we should get the leave event | 1371 | // now that the button is no longer pressed we should get the leave event | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 1484 | { | |||
1496 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedResize); | 1494 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedResize); | ||
1497 | 1495 | | |||
1498 | // create a test client | 1496 | // create a test client | ||
1499 | using namespace KWayland::Client; | 1497 | using namespace KWayland::Client; | ||
1500 | QScopedPointer<Surface> surface(Test::createSurface()); | 1498 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1501 | QVERIFY(!surface.isNull()); | 1499 | QVERIFY(!surface.isNull()); | ||
1502 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 1500 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1503 | QVERIFY(!shellSurface.isNull()); | 1501 | QVERIFY(!shellSurface.isNull()); | ||
1504 | XdgShellClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1502 | AbstractClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1505 | QVERIFY(c); | 1503 | QVERIFY(c); | ||
1506 | 1504 | | |||
1507 | // move the cursor to the test position | 1505 | // move the cursor to the test position | ||
1508 | QPoint cursorPos; | 1506 | QPoint cursorPos; | ||
1509 | QFETCH(Qt::Edges, edges); | 1507 | QFETCH(Qt::Edges, edges); | ||
1510 | 1508 | | |||
1511 | if (edges & Qt::LeftEdge) { | 1509 | if (edges & Qt::LeftEdge) { | ||
1512 | cursorPos.setX(c->frameGeometry().left()); | 1510 | cursorPos.setX(c->frameGeometry().left()); | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 1554 | { | |||
1566 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | 1564 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | ||
1567 | 1565 | | |||
1568 | // create a test client | 1566 | // create a test client | ||
1569 | using namespace KWayland::Client; | 1567 | using namespace KWayland::Client; | ||
1570 | QScopedPointer<Surface> surface(Test::createSurface()); | 1568 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1571 | QVERIFY(!surface.isNull()); | 1569 | QVERIFY(!surface.isNull()); | ||
1572 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 1570 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1573 | QVERIFY(!shellSurface.isNull()); | 1571 | QVERIFY(!shellSurface.isNull()); | ||
1574 | XdgShellClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1572 | AbstractClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1575 | QVERIFY(c); | 1573 | QVERIFY(c); | ||
1576 | 1574 | | |||
1577 | // move cursor to the test position | 1575 | // move cursor to the test position | ||
1578 | Cursor::setPos(c->frameGeometry().center()); | 1576 | Cursor::setPos(c->frameGeometry().center()); | ||
1579 | 1577 | | |||
1580 | const PlatformCursorImage arrowCursor = loadReferenceThemeCursor(Qt::ArrowCursor); | 1578 | const PlatformCursorImage arrowCursor = loadReferenceThemeCursor(Qt::ArrowCursor); | ||
1581 | QVERIFY(!arrowCursor.image().isNull()); | 1579 | QVERIFY(!arrowCursor.image().isNull()); | ||
1582 | QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); | 1580 | QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |