Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/pointer_constraints_test.cpp
Show First 20 Lines • Show All 226 Lines • ▼ Show 20 Line(s) | 138 | { | |||
---|---|---|---|---|---|
227 | // reconfine pointer (this time with persistent life time) | 227 | // reconfine pointer (this time with persistent life time) | ||
228 | confinedPointer.reset(Test::waylandPointerConstraints()->confinePointer(surface.data(), pointer.data(), nullptr, PointerConstraints::LifeTime::Persistent)); | 228 | confinedPointer.reset(Test::waylandPointerConstraints()->confinePointer(surface.data(), pointer.data(), nullptr, PointerConstraints::LifeTime::Persistent)); | ||
229 | QSignalSpy confinedSpy2(confinedPointer.data(), &ConfinedPointer::confined); | 229 | QSignalSpy confinedSpy2(confinedPointer.data(), &ConfinedPointer::confined); | ||
230 | QVERIFY(confinedSpy2.isValid()); | 230 | QVERIFY(confinedSpy2.isValid()); | ||
231 | QSignalSpy unconfinedSpy2(confinedPointer.data(), &ConfinedPointer::unconfined); | 231 | QSignalSpy unconfinedSpy2(confinedPointer.data(), &ConfinedPointer::unconfined); | ||
232 | QVERIFY(unconfinedSpy2.isValid()); | 232 | QVERIFY(unconfinedSpy2.isValid()); | ||
233 | 233 | | |||
234 | // activate it again, this confines again | 234 | // activate it again, this confines again | ||
235 | workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->window().data())); | 235 | workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->focus().data())); | ||
236 | QVERIFY(confinedSpy2.wait()); | 236 | QVERIFY(confinedSpy2.wait()); | ||
237 | QCOMPARE(input()->pointer()->isConstrained(), true); | 237 | QCOMPARE(input()->pointer()->isConstrained(), true); | ||
238 | 238 | | |||
239 | // deactivate the client one more time with the persistent life time constraint, this should unconfine | 239 | // deactivate the client one more time with the persistent life time constraint, this should unconfine | ||
240 | workspace()->activateClient(nullptr); | 240 | workspace()->activateClient(nullptr); | ||
241 | QVERIFY(unconfinedSpy2.wait()); | 241 | QVERIFY(unconfinedSpy2.wait()); | ||
242 | QCOMPARE(input()->pointer()->isConstrained(), false); | 242 | QCOMPARE(input()->pointer()->isConstrained(), false); | ||
243 | // activate it again, this confines again | 243 | // activate it again, this confines again | ||
244 | workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->window().data())); | 244 | workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->focus().data())); | ||
245 | QVERIFY(confinedSpy2.wait()); | 245 | QVERIFY(confinedSpy2.wait()); | ||
246 | QCOMPARE(input()->pointer()->isConstrained(), true); | 246 | QCOMPARE(input()->pointer()->isConstrained(), true); | ||
247 | 247 | | |||
248 | // create a second window and move it above our constrained window | 248 | // create a second window and move it above our constrained window | ||
249 | QScopedPointer<Surface> surface2(Test::createSurface()); | 249 | QScopedPointer<Surface> surface2(Test::createSurface()); | ||
250 | QScopedPointer<QObject> shellSurface2(Test::createShellSurface(type, surface2.data())); | 250 | QScopedPointer<QObject> shellSurface2(Test::createShellSurface(type, surface2.data())); | ||
251 | auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(1280, 1024), Qt::blue); | 251 | auto c2 = Test::renderAndWaitForShown(surface2.data(), QSize(1280, 1024), Qt::blue); | ||
252 | QVERIFY(c2); | 252 | QVERIFY(c2); | ||
Show All 14 Lines | |||||
267 | surface->commit(Surface::CommitFlag::None); | 267 | surface->commit(Surface::CommitFlag::None); | ||
268 | QVERIFY(confinedSpy2.wait()); | 268 | QVERIFY(confinedSpy2.wait()); | ||
269 | QCOMPARE(input()->pointer()->isConstrained(), true); | 269 | QCOMPARE(input()->pointer()->isConstrained(), true); | ||
270 | 270 | | |||
271 | // delete pointer confine | 271 | // delete pointer confine | ||
272 | confinedPointer.reset(nullptr); | 272 | confinedPointer.reset(nullptr); | ||
273 | Test::flushWaylandConnection(); | 273 | Test::flushWaylandConnection(); | ||
274 | 274 | | |||
275 | QSignalSpy constraintsChangedSpy(input()->pointer()->window()->surface(), &KWayland::Server::SurfaceInterface::pointerConstraintsChanged); | 275 | QSignalSpy constraintsChangedSpy(input()->pointer()->focus()->surface(), &KWayland::Server::SurfaceInterface::pointerConstraintsChanged); | ||
276 | QVERIFY(constraintsChangedSpy.isValid()); | 276 | QVERIFY(constraintsChangedSpy.isValid()); | ||
277 | QVERIFY(constraintsChangedSpy.wait()); | 277 | QVERIFY(constraintsChangedSpy.wait()); | ||
278 | 278 | | |||
279 | // should be unconfined | 279 | // should be unconfined | ||
280 | QCOMPARE(input()->pointer()->isConstrained(), false); | 280 | QCOMPARE(input()->pointer()->isConstrained(), false); | ||
281 | 281 | | |||
282 | // confine again | 282 | // confine again | ||
283 | confinedPointer.reset(Test::waylandPointerConstraints()->confinePointer(surface.data(), pointer.data(), nullptr, PointerConstraints::LifeTime::Persistent)); | 283 | confinedPointer.reset(Test::waylandPointerConstraints()->confinePointer(surface.data(), pointer.data(), nullptr, PointerConstraints::LifeTime::Persistent)); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 306 | { | |||
343 | KWin::Cursor::setPos(c->geometry().center() + QPoint(1, 1)); | 343 | KWin::Cursor::setPos(c->geometry().center() + QPoint(1, 1)); | ||
344 | QCOMPARE(KWin::Cursor::pos(), c->geometry().center() + QPoint(1, 1)); | 344 | QCOMPARE(KWin::Cursor::pos(), c->geometry().center() + QPoint(1, 1)); | ||
345 | 345 | | |||
346 | lockedPointer.reset(Test::waylandPointerConstraints()->lockPointer(surface.data(), pointer.data(), nullptr, PointerConstraints::LifeTime::Persistent)); | 346 | lockedPointer.reset(Test::waylandPointerConstraints()->lockPointer(surface.data(), pointer.data(), nullptr, PointerConstraints::LifeTime::Persistent)); | ||
347 | QSignalSpy lockedSpy2(lockedPointer.data(), &LockedPointer::locked); | 347 | QSignalSpy lockedSpy2(lockedPointer.data(), &LockedPointer::locked); | ||
348 | QVERIFY(lockedSpy2.isValid()); | 348 | QVERIFY(lockedSpy2.isValid()); | ||
349 | 349 | | |||
350 | // activate the client again, this should lock again | 350 | // activate the client again, this should lock again | ||
351 | workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->window().data())); | 351 | workspace()->activateClient(static_cast<AbstractClient*>(input()->pointer()->focus().data())); | ||
352 | QVERIFY(lockedSpy2.wait()); | 352 | QVERIFY(lockedSpy2.wait()); | ||
353 | QCOMPARE(input()->pointer()->isConstrained(), true); | 353 | QCOMPARE(input()->pointer()->isConstrained(), true); | ||
354 | 354 | | |||
355 | // try to move the pointer | 355 | // try to move the pointer | ||
356 | QCOMPARE(input()->pointer()->isConstrained(), true); | 356 | QCOMPARE(input()->pointer()->isConstrained(), true); | ||
357 | KWin::Cursor::setPos(c->geometry().center()); | 357 | KWin::Cursor::setPos(c->geometry().center()); | ||
358 | QCOMPARE(KWin::Cursor::pos(), c->geometry().center() + QPoint(1, 1)); | 358 | QCOMPARE(KWin::Cursor::pos(), c->geometry().center() + QPoint(1, 1)); | ||
359 | 359 | | |||
360 | // delete pointer lock | 360 | // delete pointer lock | ||
361 | lockedPointer.reset(nullptr); | 361 | lockedPointer.reset(nullptr); | ||
362 | Test::flushWaylandConnection(); | 362 | Test::flushWaylandConnection(); | ||
363 | 363 | | |||
364 | QSignalSpy constraintsChangedSpy(input()->pointer()->window()->surface(), &KWayland::Server::SurfaceInterface::pointerConstraintsChanged); | 364 | QSignalSpy constraintsChangedSpy(input()->pointer()->focus()->surface(), &KWayland::Server::SurfaceInterface::pointerConstraintsChanged); | ||
365 | QVERIFY(constraintsChangedSpy.isValid()); | 365 | QVERIFY(constraintsChangedSpy.isValid()); | ||
366 | QVERIFY(constraintsChangedSpy.wait()); | 366 | QVERIFY(constraintsChangedSpy.wait()); | ||
367 | 367 | | |||
368 | // moving cursor should be allowed again | 368 | // moving cursor should be allowed again | ||
369 | QCOMPARE(input()->pointer()->isConstrained(), false); | 369 | QCOMPARE(input()->pointer()->isConstrained(), false); | ||
370 | KWin::Cursor::setPos(c->geometry().center()); | 370 | KWin::Cursor::setPos(c->geometry().center()); | ||
371 | QCOMPARE(KWin::Cursor::pos(), c->geometry().center()); | 371 | QCOMPARE(KWin::Cursor::pos(), c->geometry().center()); | ||
372 | } | 372 | } | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |