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 1052 Lines • ▼ Show 20 Line(s) | 1158 | { | |||
1204 | QVERIFY(popupSurface); | 1204 | QVERIFY(popupSurface); | ||
1205 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | 1205 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1206 | QVERIFY(popupShellSurface); | 1206 | QVERIFY(popupShellSurface); | ||
1207 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | 1207 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | ||
1208 | QVERIFY(popupDoneSpy.isValid()); | 1208 | QVERIFY(popupDoneSpy.isValid()); | ||
1209 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | 1209 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | ||
1210 | render(popupSurface, positioner.initialSize()); | 1210 | render(popupSurface, positioner.initialSize()); | ||
1211 | QVERIFY(clientAddedSpy.wait()); | 1211 | QVERIFY(clientAddedSpy.wait()); | ||
1212 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1212 | auto popupClient = clientAddedSpy.last().first().value<XdgShellClient *>(); | ||
1213 | QVERIFY(popupClient); | 1213 | QVERIFY(popupClient); | ||
1214 | QVERIFY(popupClient != window); | 1214 | QVERIFY(popupClient != window); | ||
1215 | QCOMPARE(window, workspace()->activeClient()); | 1215 | QCOMPARE(window, workspace()->activeClient()); | ||
1216 | QCOMPARE(popupClient->transientFor(), window); | 1216 | QCOMPARE(popupClient->transientFor(), window); | ||
1217 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | 1217 | QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); | ||
1218 | QCOMPARE(popupClient->hasPopupGrab(), true); | 1218 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||
1219 | 1219 | | |||
1220 | // let's move the pointer into the center of the window | 1220 | // let's move the pointer into the center of the window | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 1240 | { | |||
1295 | QVERIFY(popupSurface); | 1295 | QVERIFY(popupSurface); | ||
1296 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | 1296 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1297 | QVERIFY(popupShellSurface); | 1297 | QVERIFY(popupShellSurface); | ||
1298 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | 1298 | QSignalSpy popupDoneSpy(popupShellSurface, &XdgShellPopup::popupDone); | ||
1299 | QVERIFY(popupDoneSpy.isValid()); | 1299 | QVERIFY(popupDoneSpy.isValid()); | ||
1300 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | 1300 | popupShellSurface->requestGrab(Test::waylandSeat(), 0); // FIXME: Serial. | ||
1301 | render(popupSurface, positioner.initialSize()); | 1301 | render(popupSurface, positioner.initialSize()); | ||
1302 | QVERIFY(clientAddedSpy.wait()); | 1302 | QVERIFY(clientAddedSpy.wait()); | ||
1303 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1303 | auto popupClient = clientAddedSpy.last().first().value<XdgShellClient *>(); | ||
1304 | QVERIFY(popupClient); | 1304 | QVERIFY(popupClient); | ||
1305 | QVERIFY(popupClient != window); | 1305 | QVERIFY(popupClient != window); | ||
1306 | QCOMPARE(window, workspace()->activeClient()); | 1306 | QCOMPARE(window, workspace()->activeClient()); | ||
1307 | QCOMPARE(popupClient->transientFor(), window); | 1307 | QCOMPARE(popupClient->transientFor(), window); | ||
1308 | QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); | 1308 | QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); | ||
1309 | QCOMPARE(popupClient->hasPopupGrab(), true); | 1309 | QCOMPARE(popupClient->hasPopupGrab(), true); | ||
1310 | 1310 | | |||
1311 | // let's move the pointer into the center of the deco | 1311 | // let's move the pointer into the center of the deco | ||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Line(s) | 1320 | { | |||
1357 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | 1357 | positioner.setAnchorEdge(Qt::BottomEdge | Qt::RightEdge); | ||
1358 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | 1358 | positioner.setGravity(Qt::BottomEdge | Qt::RightEdge); | ||
1359 | Surface *popupSurface = Test::createSurface(m_compositor); | 1359 | Surface *popupSurface = Test::createSurface(m_compositor); | ||
1360 | QVERIFY(popupSurface); | 1360 | QVERIFY(popupSurface); | ||
1361 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | 1361 | XdgShellPopup *popupShellSurface = Test::createXdgShellStablePopup(popupSurface, shellSurface, positioner); | ||
1362 | QVERIFY(popupShellSurface); | 1362 | QVERIFY(popupShellSurface); | ||
1363 | render(popupSurface, positioner.initialSize()); | 1363 | render(popupSurface, positioner.initialSize()); | ||
1364 | QVERIFY(clientAddedSpy.wait()); | 1364 | QVERIFY(clientAddedSpy.wait()); | ||
1365 | auto popupClient = clientAddedSpy.last().first().value<ShellClient*>(); | 1365 | auto popupClient = clientAddedSpy.last().first().value<XdgShellClient *>(); | ||
1366 | QVERIFY(popupClient); | 1366 | QVERIFY(popupClient); | ||
1367 | QVERIFY(popupClient != window); | 1367 | QVERIFY(popupClient != window); | ||
1368 | QVERIFY(window->geometry().contains(Cursor::pos())); | 1368 | QVERIFY(window->geometry().contains(Cursor::pos())); | ||
1369 | QVERIFY(popupClient->geometry().contains(Cursor::pos())); | 1369 | QVERIFY(popupClient->geometry().contains(Cursor::pos())); | ||
1370 | QVERIFY(!leftSpy.wait()); | 1370 | QVERIFY(!leftSpy.wait()); | ||
1371 | 1371 | | |||
1372 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | 1372 | kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); | ||
1373 | // now that the button is no longer pressed we should get the leave event | 1373 | // 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) | 1486 | { | |||
1496 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedResize); | 1496 | QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedResize); | ||
1497 | 1497 | | |||
1498 | // create a test client | 1498 | // create a test client | ||
1499 | using namespace KWayland::Client; | 1499 | using namespace KWayland::Client; | ||
1500 | QScopedPointer<Surface> surface(Test::createSurface()); | 1500 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1501 | QVERIFY(!surface.isNull()); | 1501 | QVERIFY(!surface.isNull()); | ||
1502 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 1502 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1503 | QVERIFY(!shellSurface.isNull()); | 1503 | QVERIFY(!shellSurface.isNull()); | ||
1504 | ShellClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1504 | XdgShellClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1505 | QVERIFY(c); | 1505 | QVERIFY(c); | ||
1506 | 1506 | | |||
1507 | // move the cursor to the test position | 1507 | // move the cursor to the test position | ||
1508 | QPoint cursorPos; | 1508 | QPoint cursorPos; | ||
1509 | QFETCH(Qt::Edges, edges); | 1509 | QFETCH(Qt::Edges, edges); | ||
1510 | 1510 | | |||
1511 | if (edges & Qt::LeftEdge) { | 1511 | if (edges & Qt::LeftEdge) { | ||
1512 | cursorPos.setX(c->geometry().left()); | 1512 | cursorPos.setX(c->geometry().left()); | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 1556 | { | |||
1566 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | 1566 | QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); | ||
1567 | 1567 | | |||
1568 | // create a test client | 1568 | // create a test client | ||
1569 | using namespace KWayland::Client; | 1569 | using namespace KWayland::Client; | ||
1570 | QScopedPointer<Surface> surface(Test::createSurface()); | 1570 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
1571 | QVERIFY(!surface.isNull()); | 1571 | QVERIFY(!surface.isNull()); | ||
1572 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 1572 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
1573 | QVERIFY(!shellSurface.isNull()); | 1573 | QVERIFY(!shellSurface.isNull()); | ||
1574 | ShellClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 1574 | XdgShellClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
1575 | QVERIFY(c); | 1575 | QVERIFY(c); | ||
1576 | 1576 | | |||
1577 | // move cursor to the test position | 1577 | // move cursor to the test position | ||
1578 | Cursor::setPos(c->geometry().center()); | 1578 | Cursor::setPos(c->geometry().center()); | ||
1579 | 1579 | | |||
1580 | const PlatformCursorImage arrowCursor = loadReferenceThemeCursor(Qt::ArrowCursor); | 1580 | const PlatformCursorImage arrowCursor = loadReferenceThemeCursor(Qt::ArrowCursor); | ||
1581 | QVERIFY(!arrowCursor.image().isNull()); | 1581 | QVERIFY(!arrowCursor.image().isNull()); | ||
1582 | QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); | 1582 | QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |