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