Commit 6abd23ed authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Make it possible to have a separate cursor for the tablet

Summary:
As is KWin only had 1 Cursor which was a singleton. This made it impossible for
us to properly implement the tablet (as in drawing tablets) support and show where
we're drawing.
This patch makes it possible to have different Cursors in KWin, it makes all the
current code still follow the mouse but the tablet can still render a cursor.

Test Plan: Tests pass, been using it and works as well as before but with beautiful tablet cursors.

Reviewers: #kwin, cblack, davidedmundson

Reviewed By: #kwin, cblack, davidedmundson

Subscribers: davidedmundson, cblack, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28155
parent 08a21ae7
......@@ -1430,14 +1430,14 @@ void AbstractClient::setupWindowManagementInterface()
connect(w, &PlasmaWindowInterface::closeRequested, this, [this] { closeWindow(); });
connect(w, &PlasmaWindowInterface::moveRequested, this,
[this] {
Cursor::setPos(frameGeometry().center());
performMouseCommand(Options::MouseMove, Cursor::pos());
Cursors::self()->mouse()->setPos(frameGeometry().center());
performMouseCommand(Options::MouseMove, Cursors::self()->mouse()->pos());
}
);
connect(w, &PlasmaWindowInterface::resizeRequested, this,
[this] {
Cursor::setPos(frameGeometry().bottomRight());
performMouseCommand(Options::MouseResize, Cursor::pos());
Cursors::self()->mouse()->setPos(frameGeometry().bottomRight());
performMouseCommand(Options::MouseResize, Cursors::self()->mouse()->pos());
}
);
connect(w, &PlasmaWindowInterface::virtualDesktopRequested, this,
......@@ -2060,7 +2060,7 @@ void AbstractClient::keyPressEvent(uint key_code)
bool is_alt = key_code & Qt::ALT;
key_code = key_code & ~Qt::KeyboardModifierMask;
int delta = is_control ? 1 : is_alt ? 32 : 8;
QPoint pos = Cursor::pos();
QPoint pos = Cursors::self()->mouse()->pos();
switch(key_code) {
case Qt::Key_Left:
pos.rx() -= delta;
......@@ -2089,7 +2089,7 @@ void AbstractClient::keyPressEvent(uint key_code)
default:
return;
}
Cursor::setPos(pos);
Cursors::self()->mouse()->setPos(pos);
}
QSize AbstractClient::resizeIncrements() const
......@@ -2659,7 +2659,7 @@ void AbstractClient::setElectricBorderMaximizing(bool maximizing)
{
m_electricMaximizing = maximizing;
if (maximizing)
outline()->show(electricBorderMaximizeGeometry(Cursor::pos(), desktop()), moveResizeGeometry());
outline()->show(electricBorderMaximizeGeometry(Cursors::self()->mouse()->pos(), desktop()), moveResizeGeometry());
else
outline()->hide();
elevate(maximizing);
......@@ -2694,7 +2694,7 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
return;
}
workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event
workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event
GeometryUpdatesBlocker blocker(this);
......@@ -2736,7 +2736,7 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
setMaximize(false, false);
setFrameGeometry(electricBorderMaximizeGeometry(keyboard ? frameGeometry().center() : Cursor::pos(), desktop()), geom_mode);
setFrameGeometry(electricBorderMaximizeGeometry(keyboard ? frameGeometry().center() : Cursors::self()->mouse()->pos(), desktop()), geom_mode);
// Store the mode change
m_quickTileMode = mode;
} else {
......@@ -2750,7 +2750,7 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
}
if (mode != QuickTileMode(QuickTileFlag::None)) {
QPoint whichScreen = keyboard ? frameGeometry().center() : Cursor::pos();
QPoint whichScreen = keyboard ? frameGeometry().center() : Cursors::self()->mouse()->pos();
// If trying to tile to the side that the window is already tiled to move the window to the next
// screen if it exists, otherwise toggle the mode (set QuickTileFlag::None)
......
......@@ -238,7 +238,7 @@ void Workspace::setActiveClient(AbstractClient* c)
}
StackingUpdatesBlocker blocker(this);
++set_active_client_recursion;
updateFocusMousePosition(Cursor::pos());
updateFocusMousePosition(Cursors::self()->mouse()->pos());
if (active_client != nullptr) {
// note that this may call setActiveClient( NULL ), therefore the recursion counter
active_client->setActive(false);
......@@ -430,7 +430,7 @@ AbstractClient *Workspace::clientUnderMouse(int screen) const
client->isOnCurrentActivity() && client->isOnScreen(screen)))
continue;
if (client->frameGeometry().contains(Cursor::pos())) {
if (client->frameGeometry().contains(Cursors::self()->mouse()->pos())) {
return client;
}
}
......
......@@ -167,6 +167,7 @@ ecm_mark_as_test(testBuiltInEffectLoader)
include_directories(${KWin_SOURCE_DIR})
set(testScriptedEffectLoader_SRCS
../effectloader.cpp
../cursor.cpp
../screens.cpp
../scripting/scriptedeffect.cpp
../scripting/scripting_logging.cpp
......@@ -244,6 +245,7 @@ target_link_libraries(effectversionplugin kwineffects)
########################################################
set(testScreens_SRCS
../screens.cpp
../cursor.cpp
../x11eventfilter.cpp
mock_abstract_client.cpp
mock_screens.cpp
......@@ -282,6 +284,7 @@ set(testScreenEdges_SRCS
../screenedge.cpp
../screens.cpp
../virtualdesktops.cpp
../cursor.cpp
../xcbutils.cpp # init of extensions
mock_abstract_client.cpp
mock_screens.cpp
......
......@@ -78,7 +78,7 @@ void ActivationTest::init()
QVERIFY(Test::setupWaylandConnection());
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void ActivationTest::cleanup()
......
......@@ -88,7 +88,7 @@ void ActivitiesTest::cleanupTestCase()
void ActivitiesTest::init()
{
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void ActivitiesTest::cleanup()
......
......@@ -165,7 +165,7 @@ void DecorationInputTest::init()
QVERIFY(Test::waitForWaylandPointer());
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DecorationInputTest::cleanup()
......@@ -556,7 +556,7 @@ void DecorationInputTest::testResizeOutsideWindow()
default:
break;
}
QVERIFY(!c->frameGeometry().contains(KWin::Cursor::pos()));
QVERIFY(!c->frameGeometry().contains(KWin::Cursors::self()->mouse()->pos()));
// pressing should trigger resize
PRESS;
......@@ -641,7 +641,7 @@ void DecorationInputTest::testModifierClickUnrestrictedMove()
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
// move cursor on window
Cursor::setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
// simulate modifier+click
quint32 timestamp = 1;
......@@ -711,7 +711,7 @@ void DecorationInputTest::testModifierScrollOpacity()
QVERIFY(!c->noBorder());
c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2));
// move cursor on window
Cursor::setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2));
// set the opacity to 0.5
c->setOpacity(0.5);
QCOMPARE(c->opacity(), 0.5);
......@@ -797,7 +797,7 @@ void DecorationInputTest::testTouchEvents()
QCOMPARE(c->isMove(), false);
// let's check that a hover motion is sent if the pointer is on deco, when touch release
Cursor::setPos(tapPoint);
Cursors::self()->mouse()->setPos(tapPoint);
QCOMPARE(hoverMoveSpy.count(), 2);
kwinApp()->platform()->touchDown(0, tapPoint, timestamp++);
QCOMPARE(hoverMoveSpy.count(), 3);
......
......@@ -72,7 +72,7 @@ void X11DesktopWindowTest::initTestCase()
void X11DesktopWindowTest::init()
{
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void X11DesktopWindowTest::cleanup()
......
......@@ -83,7 +83,7 @@ void DontCrashAuroraeDestroyDecoTest::initTestCase()
void DontCrashAuroraeDestroyDecoTest::init()
{
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashAuroraeDestroyDecoTest::testBorderlessMaximizedWindows()
......
......@@ -56,7 +56,7 @@ void DontCrashCursorPhysicalSizeEmpty::init()
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashCursorPhysicalSizeEmpty::cleanup()
......@@ -110,9 +110,9 @@ void DontCrashCursorPhysicalSizeEmpty::testMoveCursorOverDeco()
auto output = display->outputs().first();
output->setPhysicalSize(QSize(0, 0));
// and fake a cursor theme change, so that the theme gets recreated
emit KWin::Cursor::self()->themeChanged();
emit KWin::Cursors::self()->mouse()->themeChanged();
KWin::Cursor::setPos(QPoint(c->frameGeometry().center().x(), c->clientPos().y() / 2));
KWin::Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->clientPos().y() / 2));
}
WAYLANDTEST_MAIN(DontCrashCursorPhysicalSizeEmpty)
......
......@@ -74,7 +74,7 @@ void DontCrashEmptyDecorationTest::initTestCase()
void DontCrashEmptyDecorationTest::init()
{
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashEmptyDecorationTest::testBug361551()
......
......@@ -87,7 +87,7 @@ void DontCrashNoBorder::init()
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration));
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void DontCrashNoBorder::cleanup()
......
......@@ -79,7 +79,7 @@ void TestDontCrashUseractionsMenu::init()
QVERIFY(Test::setupWaylandConnection());
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(1280, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(1280, 512));
}
void TestDontCrashUseractionsMenu::cleanup()
......
......@@ -162,7 +162,7 @@ void TranslucencyTest::testMoveAfterDesktopChange()
workspace()->sendClientToDesktop(client, 2, false);
effects->setCurrentDesktop(2);
QVERIFY(!m_translucencyEffect->isActive());
KWin::Cursor::setPos(client->frameGeometry().center());
KWin::Cursors::self()->mouse()->setPos(client->frameGeometry().center());
workspace()->performWindowOperation(client, Options::MoveOp);
QVERIFY(m_translucencyEffect->isActive());
QTest::qWait(200);
......
......@@ -168,19 +168,19 @@ void WobblyWindowsShadeTest::testShadeMove()
// send some key events, not going through input redirection
client->keyPressEvent(Qt::Key_Right);
client->updateMoveResize(KWin::Cursor::pos());
client->updateMoveResize(KWin::Cursors::self()->mouse()->pos());
// wait for frame rendered
QTest::qWait(100);
client->keyPressEvent(Qt::Key_Right);
client->updateMoveResize(KWin::Cursor::pos());
client->updateMoveResize(KWin::Cursors::self()->mouse()->pos());
// wait for frame rendered
QTest::qWait(100);
client->keyPressEvent(Qt::Key_Down | Qt::ALT);
client->updateMoveResize(KWin::Cursor::pos());
client->updateMoveResize(KWin::Cursors::self()->mouse()->pos());
// wait for frame rendered
QTest::qWait(100);
......
......@@ -82,7 +82,7 @@ void GlobalShortcutsTest::init()
{
QVERIFY(Test::setupWaylandConnection());
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void GlobalShortcutsTest::cleanup()
......
......@@ -84,7 +84,7 @@ void InputStackingOrderTest::init()
QVERIFY(Test::waitForWaylandPointer());
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void InputStackingOrderTest::cleanup()
......
......@@ -201,7 +201,7 @@ void InternalWindowTest::initTestCase()
void InternalWindowTest::init()
{
Cursor::setPos(QPoint(1280, 512));
Cursors::self()->mouse()->setPos(QPoint(1280, 512));
QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat));
QVERIFY(Test::waitForWaylandKeyboard());
}
......@@ -617,7 +617,7 @@ void InternalWindowTest::testModifierClickUnrestrictedMove()
QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove);
// move cursor on window
Cursor::setPos(internalClient->frameGeometry().center());
Cursors::self()->mouse()->setPos(internalClient->frameGeometry().center());
// simulate modifier+click
quint32 timestamp = 1;
......@@ -653,7 +653,7 @@ void InternalWindowTest::testModifierScroll()
workspace()->slotReconfigure();
// move cursor on window
Cursor::setPos(internalClient->frameGeometry().center());
Cursors::self()->mouse()->setPos(internalClient->frameGeometry().center());
// set the opacity to 0.5
internalClient->setOpacity(0.5);
......
......@@ -74,7 +74,7 @@ void KWinBindingsTest::init()
{
QVERIFY(Test::setupWaylandConnection());
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void KWinBindingsTest::cleanup()
......
......@@ -213,7 +213,7 @@ void LockScreenTest::init()
m_seat = Test::waylandSeat();
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void LockScreenTest::cleanup()
......
......@@ -85,7 +85,7 @@ void TestMaximized::init()
Test::AdditionalWaylandInterface::PlasmaShell));
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(1280, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(1280, 512));
}
void TestMaximized::cleanup()
......
......@@ -107,7 +107,7 @@ void ModifierOnlyShortcutTest::initTestCase()
void ModifierOnlyShortcutTest::init()
{
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void ModifierOnlyShortcutTest::cleanup()
......
......@@ -164,27 +164,27 @@ void MoveResizeWindowTest::testMove()
QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50));
// send some key events, not going through input redirection
const QPoint cursorPos = Cursor::pos();
const QPoint cursorPos = Cursors::self()->mouse()->pos();
c->keyPressEvent(Qt::Key_Right);
c->updateMoveResize(Cursor::pos());
QCOMPARE(Cursor::pos(), cursorPos + QPoint(8, 0));
c->updateMoveResize(Cursors::self()->mouse()->pos());
QCOMPARE(Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
QEXPECT_FAIL("", "First event is ignored", Continue);
QCOMPARE(clientStepUserMovedResizedSpy.count(), 1);
clientStepUserMovedResizedSpy.clear();
windowStepUserMovedResizedSpy.clear();
c->keyPressEvent(Qt::Key_Right);
c->updateMoveResize(Cursor::pos());
QCOMPARE(Cursor::pos(), cursorPos + QPoint(16, 0));
c->updateMoveResize(Cursors::self()->mouse()->pos());
QCOMPARE(Cursors::self()->mouse()->pos(), cursorPos + QPoint(16, 0));
QCOMPARE(clientStepUserMovedResizedSpy.count(), 1);
QCOMPARE(windowStepUserMovedResizedSpy.count(), 1);
c->keyPressEvent(Qt::Key_Down | Qt::ALT);
c->updateMoveResize(Cursor::pos());
c->updateMoveResize(Cursors::self()->mouse()->pos());
QCOMPARE(clientStepUserMovedResizedSpy.count(), 2);
QCOMPARE(windowStepUserMovedResizedSpy.count(), 2);
QCOMPARE(c->frameGeometry(), QRect(16, 32, 100, 50));
QCOMPARE(Cursor::pos(), cursorPos + QPoint(16, 32));
QCOMPARE(Cursors::self()->mouse()->pos(), cursorPos + QPoint(16, 32));
// let's end
QCOMPARE(clientFinishUserMovedResizedSpy.count(), 0);
......@@ -266,10 +266,10 @@ void MoveResizeWindowTest::testResize()
QVERIFY(states.testFlag(XdgShellSurface::State::Resizing));
// Trigger a change.
const QPoint cursorPos = Cursor::pos();
const QPoint cursorPos = Cursors::self()->mouse()->pos();
c->keyPressEvent(Qt::Key_Right);
c->updateMoveResize(Cursor::pos());
QCOMPARE(Cursor::pos(), cursorPos + QPoint(8, 0));
c->updateMoveResize(Cursors::self()->mouse()->pos());
QCOMPARE(Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 0));
// The client should receive a configure event with the new size.
QVERIFY(configureRequestedSpy.wait());
......@@ -290,8 +290,8 @@ void MoveResizeWindowTest::testResize()
// Go down.
c->keyPressEvent(Qt::Key_Down);
c->updateMoveResize(Cursor::pos());
QCOMPARE(Cursor::pos(), cursorPos + QPoint(8, 8));
c->updateMoveResize(Cursors::self()->mouse()->pos());
QCOMPARE(Cursors::self()->mouse()->pos(), cursorPos + QPoint(8, 8));
// The client should receive another configure event.
QVERIFY(configureRequestedSpy.wait());
......@@ -556,7 +556,7 @@ void MoveResizeWindowTest::testClientSideMove_data()
void MoveResizeWindowTest::testClientSideMove()
{
using namespace KWayland::Client;
Cursor::setPos(640, 512);
Cursors::self()->mouse()->setPos(640, 512);
QScopedPointer<Pointer> pointer(Test::waylandSeat()->createPointer());
QSignalSpy pointerEnteredSpy(pointer.data(), &Pointer::entered);
QVERIFY(pointerEnteredSpy.isValid());
......@@ -573,7 +573,7 @@ void MoveResizeWindowTest::testClientSideMove()
// move pointer into center of geometry
const QRect startGeometry = c->frameGeometry();
Cursor::setPos(startGeometry.center());
Cursors::self()->mouse()->setPos(startGeometry.center());
QVERIFY(pointerEnteredSpy.wait());
QCOMPARE(pointerEnteredSpy.first().last().toPoint(), QPoint(49, 24));
// simulate press
......@@ -681,8 +681,8 @@ void MoveResizeWindowTest::testNetMove()
const QRect origGeo = client->frameGeometry();
// let's move the cursor outside the window
Cursor::setPos(screens()->geometry(0).center());
QVERIFY(!origGeo.contains(Cursor::pos()));
Cursors::self()->mouse()->setPos(screens()->geometry(0).center());
QVERIFY(!origGeo.contains(Cursors::self()->mouse()->pos()));
QSignalSpy moveStartSpy(client, &X11Client::clientStartUserMovedResized);
QVERIFY(moveStartSpy.isValid());
......@@ -701,10 +701,10 @@ void MoveResizeWindowTest::testNetMove()
QCOMPARE(workspace()->moveResizeClient(), client);
QVERIFY(client->isMove());
QCOMPARE(client->geometryRestore(), origGeo);
QCOMPARE(Cursor::pos(), origGeo.center());
QCOMPARE(Cursors::self()->mouse()->pos(), origGeo.center());
// let's move a step
Cursor::setPos(Cursor::pos() + QPoint(10, 10));
Cursors::self()->mouse()->setPos(Cursors::self()->mouse()->pos() + QPoint(10, 10));
QCOMPARE(moveStepSpy.count(), 1);
QCOMPARE(moveStepSpy.first().last().toRect(), origGeo.translated(10, 10));
......
......@@ -117,7 +117,7 @@ void NoGlobalShortcutsTest::initTestCase()
void NoGlobalShortcutsTest::init()
{
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(640, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void NoGlobalShortcutsTest::cleanup()
......
......@@ -80,7 +80,7 @@ void TestPlacement::init()
Test::AdditionalWaylandInterface::PlasmaShell));
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(512, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(512, 512));
}
void TestPlacement::cleanup()
......@@ -267,8 +267,8 @@ void TestPlacement::testPlaceUnderMouse()
group.sync();
workspace()->slotReconfigure();
KWin::Cursor::setPos(QPoint(200, 300));
QCOMPARE(KWin::Cursor::pos(), QPoint(200, 300));
KWin::Cursors::self()->mouse()->setPos(QPoint(200, 300));
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), QPoint(200, 300));
QScopedPointer<Surface> surface(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data()));
......
......@@ -85,7 +85,7 @@ void PlasmaSurfaceTest::init()
m_compositor = Test::waylandCompositor();
m_plasmaShell = Test::waylandPlasmaShell();
KWin::Cursor::setPos(640, 512);
KWin::Cursors::self()->mouse()->setPos(640, 512);
}
void PlasmaSurfaceTest::cleanup()
......@@ -391,7 +391,7 @@ void PlasmaSurfaceTest::testPanelWindowsCanCover()
QVERIFY(stackingOrderChangedSpy.isValid());
// trigger screenedge
QFETCH(QPoint, triggerPoint);
KWin::Cursor::setPos(triggerPoint);
KWin::Cursors::self()->mouse()->setPos(triggerPoint);
QCOMPARE(stackingOrderChangedSpy.count(), 1);
stackingOrder = workspace()->stackingOrder();
QCOMPARE(stackingOrder.count(), 2);
......
......@@ -91,7 +91,7 @@ void PlasmaWindowTest::init()
m_compositor = Test::waylandCompositor();
screens()->setCurrent(0);
Cursor::setPos(QPoint(640, 512));
Cursors::self()->mouse()->setPos(QPoint(640, 512));
}
void PlasmaWindowTest::cleanup()
......
......@@ -51,17 +51,17 @@ void PlatformCursorTest::testPos()
// that is QCursor should work just like KWin::Cursor
// cursor should be centered on screen
QCOMPARE(Cursor::pos(), QPoint(639, 511));
QCOMPARE(QCursor::pos(), QPoint(639, 511));
QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(639, 511));
QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(639, 511));
// let's set the pos through QCursor API
QCursor::setPos(QPoint(10, 10));
QCOMPARE(Cursor::pos(), QPoint(10, 10));
QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(10, 10));
QCOMPARE(QCursor::pos(), QPoint(10, 10));
// and let's set the pos through Cursor API
QCursor::setPos(QPoint(20, 20));
QCOMPARE(Cursor::pos(), QPoint(20, 20));
QCOMPARE(Cursors::self()->mouse()->pos(), QPoint(20, 20));
QCOMPARE(QCursor::pos(), QPoint(20, 20));
}
......
......@@ -99,7 +99,7 @@ void TestPointerConstraints::init()
QVERIFY(Test::waitForWaylandPointer());
screens()->setCurrent(0);
KWin::Cursor::setPos(QPoint(1280, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(1280, 512));
}
void TestPointerConstraints::cleanup()
......@@ -144,37 +144,37 @@ void TestPointerConstraints::testConfinedPointer()
if (c->pos() == QPoint(0, 0)) {
c->move(QPoint(1, 1));
}
QVERIFY(!c->frameGeometry().contains(KWin::Cursor::pos()));
QVERIFY(!c->frameGeometry().contains(KWin::Cursors::self()->mouse()->pos()));
// now let's confine
QCOMPARE(input()->pointer()->isConstrained(), false);
KWin::Cursor::setPos(c->frameGeometry().center());
KWin::Cursors::self()->mouse()->setPos(c->frameGeometry().center());
QCOMPARE(input()->pointer()->isConstrained(), true);
QVERIFY(confinedSpy.wait());
// picking a position outside the window geometry should not move pointer
QSignalSpy pointerPositionChangedSpy(input(), &InputRedirection::globalPointerChanged);
QVERIFY(pointerPositionChangedSpy.isValid());
KWin::Cursor::setPos(QPoint(1280, 512));
KWin::Cursors::self()->mouse()->setPos(QPoint(1280, 512));
QVERIFY(pointerPositionChangedSpy.isEmpty());
QCOMPARE(KWin::Cursor::pos(), c->frameGeometry().center());
QCOMPARE(KWin::Cursors::self()->mouse()->pos(), c->frameGeometry().center());