Commit 6a49c175 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Port SeatInterface to the new approach

This rewrites the wl_seat protocol implementation to adhere to the new
design principles.

Effectively, we've been supporting wl_seat v7 so the version was also
bumped from 5 to 7.
parent 55d04219
......@@ -110,8 +110,6 @@ void TestDataDevice::init()
m_seatInterface = new SeatInterface(m_display, m_display);
m_seatInterface->setHasPointer(true);
m_seatInterface->create();
QVERIFY(m_seatInterface->isValid());
QVERIFY(seatSpy.wait());
m_seat = registry.createSeat(seatSpy.first().first().value<quint32>(),
......
......@@ -81,8 +81,6 @@ void TestDragAndDrop::init()
m_seatInterface = new SeatInterface(m_display, m_display);
m_seatInterface->setHasPointer(true);
m_seatInterface->setHasTouch(true);
m_seatInterface->create();
QVERIFY(m_seatInterface->isValid());
m_dataDeviceManagerInterface = new DataDeviceManagerInterface(m_display, m_display);
m_display->createShm();
......
......@@ -55,7 +55,6 @@ void IdleTest::init()
m_display->createShm();
m_seatInterface = new SeatInterface(m_display);
m_seatInterface->setName(QStringLiteral("seat0"));
m_seatInterface->create();
m_idleInterface = new IdleInterface(m_display);
// setup connection
......
......@@ -69,7 +69,6 @@ void TestPointerConstraints::init()
m_display->createShm();
m_seatInterface = new SeatInterface(m_display, m_display);
m_seatInterface->setHasPointer(true);
m_seatInterface->create();
m_compositorInterface = new CompositorInterface(m_display, m_display);
m_pointerConstraintsInterface = new PointerConstraintsV1Interface(m_display, m_display);
......
......@@ -70,7 +70,6 @@ void SelectionTest::init()
m_compositorInterface = new CompositorInterface(m_display, m_display);
m_seatInterface = new SeatInterface(m_display, m_display);
m_seatInterface->setHasKeyboard(true);
m_seatInterface->create();
m_ddmInterface = new DataDeviceManagerInterface(m_display, m_display);
// setup connection
......
......@@ -78,7 +78,6 @@ void TextInputTest::init()
m_seatInterface = new SeatInterface(m_display, m_display);
m_seatInterface->setHasKeyboard(true);
m_seatInterface->setHasTouch(true);
m_seatInterface->create();
m_compositorInterface = new CompositorInterface(m_display, m_display);
m_textInputManagerV2Interface = new TextInputManagerV2Interface(m_display, m_display);
......
......@@ -162,8 +162,6 @@ void TestWaylandSeat::init()
m_seatInterface = new SeatInterface(m_display);
QVERIFY(m_seatInterface);
m_seatInterface->setName(QStringLiteral("seat0"));
m_seatInterface->create();
QVERIFY(m_seatInterface->isValid());
QVERIFY(seatSpy.wait());
m_compositor = new KWayland::Client::Compositor(this);
......
......@@ -103,7 +103,6 @@ void XdgShellTest::init()
m_seatInterface->setHasKeyboard(true);
m_seatInterface->setHasPointer(true);
m_seatInterface->setHasTouch(true);
m_seatInterface->create();
m_compositorInterface = new CompositorInterface(m_display, m_display);
m_xdgShellInterface = new XdgShellInterface(m_display, m_display);
......
......@@ -150,7 +150,6 @@ void DataControlInterfaceTest::init()
QVERIFY(m_display->isRunning());
m_seat = new SeatInterface(m_display, this);
m_seat->create();
m_serverCompositor = new CompositorInterface(m_display, this);
m_dataControlDeviceManagerInterface = new DataControlDeviceManagerV1Interface(m_display, this);
......
......@@ -177,7 +177,6 @@ void TestInputMethodInterface::initTestCase()
QVERIFY(m_display.isRunning());
m_seat = new SeatInterface(&m_display, this);
m_seat->create();
m_serverCompositor = new CompositorInterface(&m_display, this);
m_inputMethodIface = new InputMethodV1Interface(&m_display, this);
m_inputPanelIface = new InputPanelV1Interface(&m_display, this);
......
......@@ -100,7 +100,6 @@ void TestKeyboardShortcutsInhibitorInterface::initTestCase()
QVERIFY(m_display.isRunning());
m_seat = new SeatInterface(&m_display, this);
m_seat->create();
m_serverCompositor = new CompositorInterface(&m_display, this);
m_manager = new KeyboardShortcutsInhibitManagerV1Interface(&m_display, this);
......
......@@ -7,6 +7,7 @@
#include <QtTest>
// WaylandServer
#include "../../src/server/display.h"
#include "../../src/server/keyboard_interface.h"
#include "../../src/server/pointer_interface.h"
#include "../../src/server/seat_interface.h"
......
......@@ -176,7 +176,6 @@ void TestTabletInterface::initTestCase()
QVERIFY(m_display.isRunning());
m_seat = new SeatInterface(&m_display, this);
m_seat->create();
m_serverCompositor = new CompositorInterface(&m_display, this);
m_tabletManager = new TabletManagerV2Interface(&m_display, this);
......
......@@ -121,7 +121,6 @@ void TestTextInputV3Interface::initTestCase()
m_seat = new SeatInterface(&m_display, this);
m_seat->setHasKeyboard(true);
m_seat->create();
m_serverCompositor = new CompositorInterface(&m_display, this);
new TextInputManagerV3Interface(&m_display);
......
......@@ -96,7 +96,8 @@ DataControlDeviceV1Interface::DataControlDeviceV1Interface(SeatInterface *seat,
: QObject()
, d(new DataControlDeviceV1InterfacePrivate(this, seat, resource))
{
seat->d_func()->registerDataControlDevice(this);
SeatInterfacePrivate *seatPrivate = SeatInterfacePrivate::get(seat);
seatPrivate->registerDataControlDevice(this);
}
DataControlDeviceV1Interface::~DataControlDeviceV1Interface() = default;
......
......@@ -183,7 +183,8 @@ DataDeviceInterface::DataDeviceInterface(SeatInterface *seat, wl_resource *resou
: QObject(nullptr)
, d(new DataDeviceInterfacePrivate(seat, this, resource))
{
seat->d_func()->registerDataDevice(this);
SeatInterfacePrivate *seatPrivate = SeatInterfacePrivate::get(seat);
seatPrivate->registerDataDevice(this);
}
DataDeviceInterface::~DataDeviceInterface() = default;
......
......@@ -212,7 +212,7 @@ void KeyboardInterface::keyPressed(quint32 key)
}
const QList<KeyboardInterfacePrivate::Resource *> keyboards = d->keyboardsForClient(d->focusedSurface->client());
const quint32 serial = d->seat->d_func()->nextSerial();
const quint32 serial = d->seat->display()->nextSerial();
for (KeyboardInterfacePrivate::Resource *keyboardResource : keyboards) {
d->send_key(keyboardResource->handle, serial, d->seat->timestamp(), key, KeyboardInterfacePrivate::key_state::key_state_pressed);
}
......@@ -229,7 +229,7 @@ void KeyboardInterface::keyReleased(quint32 key)
}
const QList<KeyboardInterfacePrivate::Resource *> keyboards = d->keyboardsForClient(d->focusedSurface->client());
const quint32 serial = d->seat->d_func()->nextSerial();
const quint32 serial = d->seat->display()->nextSerial();
for (KeyboardInterfacePrivate::Resource *keyboardResource : keyboards) {
d->send_key(keyboardResource->handle, serial, d->seat->timestamp(), key, KeyboardInterfacePrivate::key_state::key_state_released);
}
......@@ -255,7 +255,7 @@ void KeyboardInterface::updateModifiers(quint32 depressed, quint32 latched, quin
return;
}
d->modifiers.serial = d->seat->d_func()->nextSerial();
d->modifiers.serial = d->seat->display()->nextSerial();
d->sendModifiers(depressed, latched, locked, group, d->modifiers.serial);
}
......
......@@ -102,7 +102,8 @@ PrimarySelectionDeviceV1Interface::PrimarySelectionDeviceV1Interface(SeatInterfa
: QObject()
, d(new PrimarySelectionDeviceV1InterfacePrivate(this, seat, resource))
{
seat->d_func()->registerPrimarySelectionDevice(this);
SeatInterfacePrivate *seatPrivate = SeatInterfacePrivate::get(seat);
seatPrivate->registerPrimarySelectionDevice(this);
}
PrimarySelectionDeviceV1Interface::~PrimarySelectionDeviceV1Interface() = default;
......
This diff is collapsed.
/*
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include <KWaylandServer/kwaylandserver_export.h>
#include <QObject>
#include <QPoint>
#include <QMatrix4x4>
#include <KWaylandServer/kwaylandserver_export.h>
#include "global.h"
#include "keyboard_interface.h"
#include "pointer_interface.h"
#include "touch_interface.h"
struct wl_client;
struct wl_resource;
namespace KWaylandServer
{
class DataDeviceInterface;
class AbstractDataSource;
class DataDeviceInterface;
class Display;
class KeyboardInterface;
class PointerInterface;
class SeatInterfacePrivate;
class SurfaceInterface;
class TextInputV2Interface;
class TextInputV3Interface;
class TouchInterface;
/**
* Describes the source types for axis events. This indicates to the
......@@ -103,7 +104,7 @@ enum class PointerAxisSource {
* @see TouchInterface
* @see SurfaceInterface
**/
class KWAYLANDSERVER_EXPORT SeatInterface : public Global
class KWAYLANDSERVER_EXPORT SeatInterface : public QObject
{
Q_OBJECT
/**
......@@ -139,6 +140,7 @@ public:
explicit SeatInterface(Display *display, QObject *parent = nullptr);
virtual ~SeatInterface();
Display *display() const;
QString name() const;
bool hasPointer() const;
bool hasKeyboard() const;
......@@ -692,14 +694,8 @@ Q_SIGNALS:
void focusedTextInputSurfaceChanged();
private:
friend class DataControlDeviceV1Interface;
friend class DataDeviceInterface;
friend class PrimarySelectionDeviceV1Interface;
friend class TextInputManagerV2InterfacePrivate;
friend class KeyboardInterface;
class Private;
Private *d_func() const;
QScopedPointer<SeatInterfacePrivate> d;
friend class SeatInterfacePrivate;
};
}
......
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