| 819 | } |
| 820 | |
| 821 | void PointerInputTest::testFocusFollowsMouse() |
| 822 | { |
| 823 | // need to create a pointer, otherwise it doesn't accept focus |
| 824 | auto pointer = m_seat->createPointer(m_seat); |
| 825 | QVERIFY(pointer); |
| 826 | QVERIFY(pointer->isValid()); |
| 827 | // move cursor out of the way of first window to be created |
| 828 | input()->pointer()->warp(QPointF(900, 900)); |
| 829 | |
| 830 | // first modify the config for this run |
| 831 | KConfigGroup group = kwinApp()->config()->group(QStringLiteral("Windows")); |
| 832 | group.writeEntry("AutoRaise", true); |
| 833 | group.writeEntry("AutoRaiseInterval", 20); |
| 834 | group.writeEntry("DelayFocusInterval", 200); |
| 835 | group.writeEntry("FocusPolicy", "FocusFollowsMouse"); |
| 836 | group.sync(); |
| 837 | workspace()->slotReconfigure(); |
| 838 | // verify the settings |
| 839 | QCOMPARE(options->focusPolicy(), Options::FocusFollowsMouse); |
| 840 | QVERIFY(options->isAutoRaise()); |
| 841 | QCOMPARE(options->autoRaiseInterval(), 20); |
| 842 | QCOMPARE(options->delayFocusInterval(), 200); |
| 843 | |
| 844 | // create two windows |
| 845 | QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded); |
| 846 | std::unique_ptr<KWayland::Client::Surface> surface1 = Test::createSurface(); |
| 847 | QVERIFY(surface1); |
| 848 | std::unique_ptr<Test::XdgToplevel> shellSurface1 = Test::createXdgToplevelSurface(surface1.get()); |
| 849 | QVERIFY(shellSurface1); |
| 850 | render(surface1.get(), QSize(800, 800)); |
| 851 | QVERIFY(windowAddedSpy.wait()); |
| 852 | Window *window1 = workspace()->activeWindow(); |
| 853 | QVERIFY(window1); |
| 854 | std::unique_ptr<KWayland::Client::Surface> surface2 = Test::createSurface(); |
| 855 | QVERIFY(surface2); |
| 856 | std::unique_ptr<Test::XdgToplevel> shellSurface2 = Test::createXdgToplevelSurface(surface2.get()); |
| 857 | QVERIFY(shellSurface2); |
| 858 | render(surface2.get(), QSize(800, 800)); |
| 859 | QVERIFY(windowAddedSpy.wait()); |
| 860 | Window *window2 = workspace()->activeWindow(); |
| 861 | QVERIFY(window2); |
| 862 | QVERIFY(window1 != window2); |
| 863 | QCOMPARE(workspace()->topWindowOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2); |
| 864 | // geometry of the two windows should be overlapping |
| 865 | QVERIFY(window1->frameGeometry().intersects(window2->frameGeometry())); |
| 866 | |
| 867 | // signal spies for active window changed and stacking order changed |
| 868 | QSignalSpy activeWindowChangedSpy(workspace(), &Workspace::windowActivated); |
| 869 | QSignalSpy stackingOrderChangedSpy(workspace(), &Workspace::stackingOrderChanged); |
| 870 | |
| 871 | QVERIFY(!window1->isActive()); |
| 872 | QVERIFY(window2->isActive()); |
| 873 | |
| 874 | // move on top of first window |
| 875 | QVERIFY(window1->frameGeometry().contains(QPointF(10, 10))); |
| 876 | QVERIFY(!window2->frameGeometry().contains(QPointF(10, 10))); |
| 877 | input()->pointer()->warp(QPointF(10, 10)); |
| 878 | QVERIFY(stackingOrderChangedSpy.wait()); |
nothing calls this directly
no test coverage detected