Commit 042896a7 authored by Martin Flöser's avatar Martin Flöser
Browse files

[server] Add Display::seats() -> QVector<SeatInterface*>

Similar to OutputInterfaces we can have multiple SeatInterfaces so
expose a way to get to all SeatInterfaces.

REVIEW: 126364
parent 9d40118f
......@@ -37,6 +37,7 @@ private Q_SLOTS:
void testPointerPos();
void testDestroyThroughTerminate();
void testRepeatInfo();
void testMultiple();
};
static const QString s_socketName = QStringLiteral("kwin-wayland-server-seat-test-0");
......@@ -197,5 +198,37 @@ void TestWaylandServerSeat::testRepeatInfo()
QCOMPARE(seat->keyRepeatDelay(), 0);
}
void TestWaylandServerSeat::testMultiple()
{
Display display;
display.setSocketName(s_socketName);
display.start();
QVERIFY(display.seats().isEmpty());
SeatInterface *seat1 = display.createSeat();
QCOMPARE(display.seats().count(), 1);
QCOMPARE(display.seats().at(0), seat1);
SeatInterface *seat2 = display.createSeat();
QCOMPARE(display.seats().count(), 2);
QCOMPARE(display.seats().at(0), seat1);
QCOMPARE(display.seats().at(1), seat2);
SeatInterface *seat3 = display.createSeat();
QCOMPARE(display.seats().count(), 3);
QCOMPARE(display.seats().at(0), seat1);
QCOMPARE(display.seats().at(1), seat2);
QCOMPARE(display.seats().at(2), seat3);
delete seat3;
QCOMPARE(display.seats().count(), 2);
QCOMPARE(display.seats().at(0), seat1);
QCOMPARE(display.seats().at(1), seat2);
delete seat2;
QCOMPARE(display.seats().count(), 1);
QCOMPARE(display.seats().at(0), seat1);
delete seat1;
QCOMPARE(display.seats().count(), 0);
}
QTEST_GUILESS_MAIN(TestWaylandServerSeat)
#include "test_seat.moc"
......@@ -69,6 +69,7 @@ public:
bool running = false;
QList<OutputInterface*> outputs;
QList<OutputDeviceInterface*> outputdevices;
QVector<SeatInterface*> seats;
QVector<ClientConnection*> clients;
EGLDisplay eglDisplay = EGL_NO_DISPLAY;
......@@ -235,7 +236,9 @@ OutputManagementInterface *Display::createOutputManagement(QObject *parent)
SeatInterface *Display::createSeat(QObject *parent)
{
SeatInterface *seat = new SeatInterface(this, parent);
connect(seat, &QObject::destroyed, this, [this, seat] { d->seats.removeAll(seat); });
connect(this, &Display::aboutToTerminate, seat, [this,seat] { delete seat; });
d->seats << seat;
return seat;
}
......@@ -376,6 +379,11 @@ QList< OutputDeviceInterface* > Display::outputDevices() const
return d->outputdevices;
}
QVector<SeatInterface*> Display::seats() const
{
return d->seats;
}
ClientConnection *Display::getConnection(wl_client *client)
{
Q_ASSERT(client);
......
......@@ -147,6 +147,11 @@ public:
void createShm();
ShellInterface *createShell(QObject *parent = nullptr);
SeatInterface *createSeat(QObject *parent = nullptr);
/**
* @returns All SeatInterface currently managed on the Display.
* @since 5.6
**/
QVector<SeatInterface*> seats() const;
SubCompositorInterface *createSubCompositor(QObject *parent = nullptr);
DataDeviceManagerInterface *createDataDeviceManager(QObject *parent = nullptr);
OutputManagementInterface *createOutputManagement(QObject *parent = nullptr);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment