Changeset View
Changeset View
Standalone View
Standalone View
autotests/test_screen_edges.cpp
Show First 20 Lines • Show All 462 Lines • ▼ Show 20 Line(s) | 420 | { | |||
---|---|---|---|---|---|
463 | }; | 463 | }; | ||
464 | event.root = XCB_WINDOW_NONE; | 464 | event.root = XCB_WINDOW_NONE; | ||
465 | event.child = XCB_WINDOW_NONE; | 465 | event.child = XCB_WINDOW_NONE; | ||
466 | event.event = (*it)->window(); | 466 | event.event = (*it)->window(); | ||
467 | event.same_screen_focus = 1; | 467 | event.same_screen_focus = 1; | ||
468 | event.time = QDateTime::currentMSecsSinceEpoch(); | 468 | event.time = QDateTime::currentMSecsSinceEpoch(); | ||
469 | setPos(QPoint(0, 50)); | 469 | setPos(QPoint(0, 50)); | ||
470 | auto isEntered = [s] (xcb_enter_notify_event_t *event) { | 470 | auto isEntered = [s] (xcb_enter_notify_event_t *event) { | ||
471 | return s->handleEnterNotifiy(event->event, QPoint(event->root_x, event->root_y), QDateTime::fromMSecsSinceEpoch(event->time)); | 471 | return s->handleEnterNotifiy(event->event, QPoint(event->root_x, event->root_y), QDateTime::fromMSecsSinceEpoch(event->time, Qt::UTC)); | ||
472 | }; | 472 | }; | ||
473 | QVERIFY(isEntered(&event)); | 473 | QVERIFY(isEntered(&event)); | ||
474 | // doesn't trigger as the edge was not triggered yet | 474 | // doesn't trigger as the edge was not triggered yet | ||
475 | QVERIFY(spy.isEmpty()); | 475 | QVERIFY(spy.isEmpty()); | ||
476 | QCOMPARE(Cursor::pos(), QPoint(1, 50)); | 476 | QCOMPARE(Cursor::pos(), QPoint(1, 50)); | ||
477 | 477 | | |||
478 | // test doesn't trigger due to too much offset | 478 | // test doesn't trigger due to too much offset | ||
479 | QTest::qWait(160); | 479 | QTest::qWait(160); | ||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 567 | { | |||
569 | auto s = ScreenEdges::self(); | 569 | auto s = ScreenEdges::self(); | ||
570 | s->init(); | 570 | s->init(); | ||
571 | TestObject callback; | 571 | TestObject callback; | ||
572 | QSignalSpy spy(&callback, &TestObject::gotCallback); | 572 | QSignalSpy spy(&callback, &TestObject::gotCallback); | ||
573 | QVERIFY(spy.isValid()); | 573 | QVERIFY(spy.isValid()); | ||
574 | s->reserve(ElectricLeft, &callback, "callback"); | 574 | s->reserve(ElectricLeft, &callback, "callback"); | ||
575 | 575 | | |||
576 | // check activating a different edge doesn't do anything | 576 | // check activating a different edge doesn't do anything | ||
577 | s->check(QPoint(50, 0), QDateTime::currentDateTime(), true); | 577 | s->check(QPoint(50, 0), QDateTime::currentDateTimeUtc(), true); | ||
578 | QVERIFY(spy.isEmpty()); | 578 | QVERIFY(spy.isEmpty()); | ||
579 | 579 | | |||
580 | // try a direct activate without pushback | 580 | // try a direct activate without pushback | ||
581 | Cursor::setPos(0, 50); | 581 | Cursor::setPos(0, 50); | ||
582 | s->check(QPoint(0, 50), QDateTime::currentDateTime(), true); | 582 | s->check(QPoint(0, 50), QDateTime::currentDateTimeUtc(), true); | ||
583 | QCOMPARE(spy.count(), 1); | 583 | QCOMPARE(spy.count(), 1); | ||
584 | QEXPECT_FAIL("", "Argument says force no pushback, but it gets pushed back. Needs investigation", Continue); | 584 | QEXPECT_FAIL("", "Argument says force no pushback, but it gets pushed back. Needs investigation", Continue); | ||
585 | QCOMPARE(Cursor::pos(), QPoint(0, 50)); | 585 | QCOMPARE(Cursor::pos(), QPoint(0, 50)); | ||
586 | 586 | | |||
587 | // use a different edge, this time with pushback | 587 | // use a different edge, this time with pushback | ||
588 | s->reserve(KWin::ElectricRight, &callback, "callback"); | 588 | s->reserve(KWin::ElectricRight, &callback, "callback"); | ||
589 | Cursor::setPos(99, 50); | 589 | Cursor::setPos(99, 50); | ||
590 | s->check(QPoint(99, 50), QDateTime::currentDateTime()); | 590 | s->check(QPoint(99, 50), QDateTime::currentDateTimeUtc()); | ||
591 | QCOMPARE(spy.count(), 1); | 591 | QCOMPARE(spy.count(), 1); | ||
592 | QCOMPARE(spy.last().first().value<ElectricBorder>(), ElectricLeft); | 592 | QCOMPARE(spy.last().first().value<ElectricBorder>(), ElectricLeft); | ||
593 | QCOMPARE(Cursor::pos(), QPoint(98, 50)); | 593 | QCOMPARE(Cursor::pos(), QPoint(98, 50)); | ||
594 | // and trigger it again | 594 | // and trigger it again | ||
595 | QTest::qWait(160); | 595 | QTest::qWait(160); | ||
596 | Cursor::setPos(99, 50); | 596 | Cursor::setPos(99, 50); | ||
597 | s->check(QPoint(99, 50), QDateTime::currentDateTime()); | 597 | s->check(QPoint(99, 50), QDateTime::currentDateTimeUtc()); | ||
598 | QCOMPARE(spy.count(), 2); | 598 | QCOMPARE(spy.count(), 2); | ||
599 | QCOMPARE(spy.last().first().value<ElectricBorder>(), ElectricRight); | 599 | QCOMPARE(spy.last().first().value<ElectricBorder>(), ElectricRight); | ||
600 | QCOMPARE(Cursor::pos(), QPoint(98, 50)); | 600 | QCOMPARE(Cursor::pos(), QPoint(98, 50)); | ||
601 | } | 601 | } | ||
602 | 602 | | |||
603 | void TestScreenEdges::testPushBack_data() | 603 | void TestScreenEdges::testPushBack_data() | ||
604 | { | 604 | { | ||
605 | QTest::addColumn<KWin::ElectricBorder>("border"); | 605 | QTest::addColumn<KWin::ElectricBorder>("border"); | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 652 | auto isEntered = [s] (xcb_enter_notify_event_t *event) { | |||
653 | return s->handleEnterNotifiy(event->event, QPoint(event->root_x, event->root_y), QDateTime::fromMSecsSinceEpoch(event->time)); | 653 | return s->handleEnterNotifiy(event->event, QPoint(event->root_x, event->root_y), QDateTime::fromMSecsSinceEpoch(event->time)); | ||
654 | }; | 654 | }; | ||
655 | QVERIFY(isEntered(&event)); | 655 | QVERIFY(isEntered(&event)); | ||
656 | QVERIFY(spy.isEmpty()); | 656 | QVERIFY(spy.isEmpty()); | ||
657 | QTEST(Cursor::pos(), "expected"); | 657 | QTEST(Cursor::pos(), "expected"); | ||
658 | 658 | | |||
659 | // do the same without the event, but the check method | 659 | // do the same without the event, but the check method | ||
660 | Cursor::setPos(trigger); | 660 | Cursor::setPos(trigger); | ||
661 | s->check(trigger, QDateTime::currentDateTime()); | 661 | s->check(trigger, QDateTime::currentDateTimeUtc()); | ||
662 | QVERIFY(spy.isEmpty()); | 662 | QVERIFY(spy.isEmpty()); | ||
663 | QTEST(Cursor::pos(), "expected"); | 663 | QTEST(Cursor::pos(), "expected"); | ||
664 | } | 664 | } | ||
665 | 665 | | |||
666 | void TestScreenEdges::testFullScreenBlocking() | 666 | void TestScreenEdges::testFullScreenBlocking() | ||
667 | { | 667 | { | ||
668 | using namespace KWin; | 668 | using namespace KWin; | ||
669 | MockWorkspace ws; | 669 | MockWorkspace ws; | ||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | 857 | for (auto e : s->findChildren<Edge*>()) { | |||
858 | QVERIFY(!e->client()); | 858 | QVERIFY(!e->client()); | ||
859 | } | 859 | } | ||
860 | QCOMPARE(client.isHiddenInternal(), true); | 860 | QCOMPARE(client.isHiddenInternal(), true); | ||
861 | 861 | | |||
862 | // now let's try to trigger the client showing with the check method instead of enter notify | 862 | // now let's try to trigger the client showing with the check method instead of enter notify | ||
863 | s->reserve(&client, KWin::ElectricTop); | 863 | s->reserve(&client, KWin::ElectricTop); | ||
864 | QCOMPARE(client.isHiddenInternal(), true); | 864 | QCOMPARE(client.isHiddenInternal(), true); | ||
865 | Cursor::setPos(50, 0); | 865 | Cursor::setPos(50, 0); | ||
866 | s->check(QPoint(50, 0), QDateTime::currentDateTime()); | 866 | s->check(QPoint(50, 0), QDateTime::currentDateTimeUtc()); | ||
867 | QCOMPARE(client.isHiddenInternal(), false); | 867 | QCOMPARE(client.isHiddenInternal(), false); | ||
868 | QCOMPARE(Cursor::pos(), QPoint(50, 1)); | 868 | QCOMPARE(Cursor::pos(), QPoint(50, 1)); | ||
869 | 869 | | |||
870 | // unreserve by setting to none edge | 870 | // unreserve by setting to none edge | ||
871 | s->reserve(&client, KWin::ElectricNone); | 871 | s->reserve(&client, KWin::ElectricNone); | ||
872 | // check on previous edge again, should fail | 872 | // check on previous edge again, should fail | ||
873 | client.setHiddenInternal(true); | 873 | client.setHiddenInternal(true); | ||
874 | Cursor::setPos(50, 0); | 874 | Cursor::setPos(50, 0); | ||
875 | s->check(QPoint(50, 0), QDateTime::currentDateTime()); | 875 | s->check(QPoint(50, 0), QDateTime::currentDateTimeUtc()); | ||
876 | QCOMPARE(client.isHiddenInternal(), true); | 876 | QCOMPARE(client.isHiddenInternal(), true); | ||
877 | QCOMPARE(Cursor::pos(), QPoint(50, 0)); | 877 | QCOMPARE(Cursor::pos(), QPoint(50, 0)); | ||
878 | 878 | | |||
879 | // set to windows can cover | 879 | // set to windows can cover | ||
880 | client.setFrameGeometry(screens()->geometry()); | 880 | client.setFrameGeometry(screens()->geometry()); | ||
881 | client.setHiddenInternal(false); | 881 | client.setHiddenInternal(false); | ||
882 | client.setKeepBelow(true); | 882 | client.setKeepBelow(true); | ||
883 | s->reserve(&client, KWin::ElectricLeft); | 883 | s->reserve(&client, KWin::ElectricLeft); | ||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | 905 | { | |||
955 | }; | 955 | }; | ||
956 | event.root = XCB_WINDOW_NONE; | 956 | event.root = XCB_WINDOW_NONE; | ||
957 | event.child = XCB_WINDOW_NONE; | 957 | event.child = XCB_WINDOW_NONE; | ||
958 | event.event = (*it)->window(); | 958 | event.event = (*it)->window(); | ||
959 | event.same_screen_focus = 1; | 959 | event.same_screen_focus = 1; | ||
960 | event.time = QDateTime::currentMSecsSinceEpoch(); | 960 | event.time = QDateTime::currentMSecsSinceEpoch(); | ||
961 | setPos(QPoint(0, 50)); | 961 | setPos(QPoint(0, 50)); | ||
962 | auto isEntered = [s] (xcb_enter_notify_event_t *event) { | 962 | auto isEntered = [s] (xcb_enter_notify_event_t *event) { | ||
963 | return s->handleEnterNotifiy(event->event, QPoint(event->root_x, event->root_y), QDateTime::fromMSecsSinceEpoch(event->time)); | 963 | return s->handleEnterNotifiy(event->event, QPoint(event->root_x, event->root_y), QDateTime::fromMSecsSinceEpoch(event->time, Qt::UTC)); | ||
964 | }; | 964 | }; | ||
965 | QCOMPARE(isEntered(&event), false); | 965 | QCOMPARE(isEntered(&event), false); | ||
966 | QVERIFY(approachingSpy.isEmpty()); | 966 | QVERIFY(approachingSpy.isEmpty()); | ||
967 | // let's also verify the check | 967 | // let's also verify the check | ||
968 | s->check(QPoint(0, 50), QDateTime::currentDateTime(), false); | 968 | s->check(QPoint(0, 50), QDateTime::currentDateTimeUtc(), false); | ||
969 | QVERIFY(approachingSpy.isEmpty()); | 969 | QVERIFY(approachingSpy.isEmpty()); | ||
970 | 970 | | |||
971 | s->gestureRecognizer()->startSwipeGesture(QPoint(0, 50)); | 971 | s->gestureRecognizer()->startSwipeGesture(QPoint(0, 50)); | ||
972 | QCOMPARE(approachingSpy.count(), 1); | 972 | QCOMPARE(approachingSpy.count(), 1); | ||
973 | s->gestureRecognizer()->cancelSwipeGesture(); | 973 | s->gestureRecognizer()->cancelSwipeGesture(); | ||
974 | QCOMPARE(approachingSpy.count(), 2); | 974 | QCOMPARE(approachingSpy.count(), 2); | ||
975 | 975 | | |||
976 | // let's reconfigure | 976 | // let's reconfigure | ||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |