MCPcopy Create free account
hub / github.com/KDE/kwin / testMouseActionInactiveWindow

Method testMouseActionInactiveWindow

autotests/integration/pointer_input.cpp:910–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

908}
909
910void PointerInputTest::testMouseActionInactiveWindow()
911{
912 // this test performs the mouse button window action on an inactive window
913 // it should activate the window and raise it
914
915 // first modify the config for this run - disable FocusFollowsMouse
916 KConfigGroup group = kwinApp()->config()->group(QStringLiteral("Windows"));
917 group.writeEntry("FocusPolicy", "ClickToFocus");
918 group.sync();
919 group = kwinApp()->config()->group(QStringLiteral("MouseBindings"));
920 group.writeEntry("CommandWindow1", "Activate, raise and pass click");
921 group.writeEntry("CommandWindow2", "Activate, raise and pass click");
922 group.writeEntry("CommandWindow3", "Activate, raise and pass click");
923 group.sync();
924 workspace()->slotReconfigure();
925
926 // create two windows
927 QSignalSpy windowAddedSpy(workspace(), &Workspace::windowAdded);
928 std::unique_ptr<KWayland::Client::Surface> surface1 = Test::createSurface();
929 QVERIFY(surface1);
930 std::unique_ptr<Test::XdgToplevel> shellSurface1 = Test::createXdgToplevelSurface(surface1.get());
931 QVERIFY(shellSurface1);
932 render(surface1.get(), QSize(800, 800));
933 QVERIFY(windowAddedSpy.wait());
934 Window *window1 = workspace()->activeWindow();
935 QVERIFY(window1);
936 std::unique_ptr<KWayland::Client::Surface> surface2 = Test::createSurface();
937 QVERIFY(surface2);
938 std::unique_ptr<Test::XdgToplevel> shellSurface2 = Test::createXdgToplevelSurface(surface2.get());
939 QVERIFY(shellSurface2);
940 render(surface2.get(), QSize(800, 800));
941 QVERIFY(windowAddedSpy.wait());
942 Window *window2 = workspace()->activeWindow();
943 QVERIFY(window2);
944 QVERIFY(window1 != window2);
945 QCOMPARE(workspace()->topWindowOnDesktop(VirtualDesktopManager::self()->currentDesktop()), window2);
946 // geometry of the two windows should be overlapping
947 QVERIFY(window1->frameGeometry().intersects(window2->frameGeometry()));
948
949 // signal spies for active window changed and stacking order changed
950 QSignalSpy activeWindowChangedSpy(workspace(), &Workspace::windowActivated);
951 QSignalSpy stackingOrderChangedSpy(workspace(), &Workspace::stackingOrderChanged);
952
953 QVERIFY(!window1->isActive());
954 QVERIFY(window2->isActive());
955
956 // move on top of first window
957 QVERIFY(window1->frameGeometry().contains(QPointF(10, 10)));
958 QVERIFY(!window2->frameGeometry().contains(QPointF(10, 10)));
959 input()->pointer()->warp(QPointF(10, 10));
960 // no focus follows mouse
961 QVERIFY(stackingOrderChangedSpy.isEmpty());
962 QVERIFY(activeWindowChangedSpy.isEmpty());
963 QVERIFY(window2->isActive());
964 // and click
965 quint32 timestamp = 1;
966 QFETCH(quint32, button);
967 Test::pointerButtonPressed(button, timestamp++);

Callers

nothing calls this directly

Calls 15

kwinAppFunction · 0.85
workspaceFunction · 0.85
createSurfaceFunction · 0.85
createXdgToplevelSurfaceFunction · 0.85
renderFunction · 0.85
selfFunction · 0.85
QPointFClass · 0.85
inputFunction · 0.85
pointerButtonPressedFunction · 0.85
pointerButtonReleasedFunction · 0.85
writeEntryMethod · 0.80
slotReconfigureMethod · 0.80

Tested by

no test coverage detected