Commit 83d6a64a authored by adrien faveraux's avatar adrien faveraux
Browse files

move output device to the news approach

parent 522e6fd0
Pipeline #53809 passed with stage
in 7 minutes and 16 seconds
......@@ -30,9 +30,6 @@ private Q_SLOTS:
void testRegistry();
void testModeChanges();
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
void testScaleChange_legacy();
#endif
void testScaleChange();
void testColorCurvesChange();
......@@ -76,6 +73,7 @@ TestWaylandOutputDevice::TestWaylandOutputDevice(QObject *parent)
void TestWaylandOutputDevice::init()
{
using namespace KWaylandServer;
qRegisterMetaType<OutputDevice::Enablement>();
delete m_display;
m_display = new Display(this);
m_display->addSocketName(s_socketName);
......@@ -128,8 +126,6 @@ void TestWaylandOutputDevice::init()
}
m_serverOutputDevice->setColorCurves(m_initColorCurves);
m_serverOutputDevice->create();
// setup connection
m_connection = new KWayland::Client::ConnectionThread;
QSignalSpy connectedSpy(m_connection, &KWayland::Client::ConnectionThread::connected);
......@@ -187,7 +183,7 @@ void TestWaylandOutputDevice::testRegistry()
KWayland::Client::OutputDevice output;
QVERIFY(!output.isValid());
QCOMPARE(output.uuid(), QByteArray());
QCOMPARE(output.uuid(), QString());
QCOMPARE(output.geometry(), QRect());
QCOMPARE(output.globalPosition(), QPoint());
QCOMPARE(output.manufacturer(), QString());
......@@ -195,9 +191,6 @@ void TestWaylandOutputDevice::testRegistry()
QCOMPARE(output.physicalSize(), QSize());
QCOMPARE(output.pixelSize(), QSize());
QCOMPARE(output.refreshRate(), 0);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output.scale(), 1);
#endif
QCOMPARE(output.scaleF(), 1.0);
QCOMPARE(output.colorCurves().red, QVector<quint16>());
QCOMPARE(output.colorCurves().green, QVector<quint16>());
......@@ -224,9 +217,6 @@ void TestWaylandOutputDevice::testRegistry()
QCOMPARE(output.physicalSize(), QSize(200, 100));
QCOMPARE(output.pixelSize(), QSize(1024, 768));
QCOMPARE(output.refreshRate(), 60000);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output.scale(), 1);
#endif
QCOMPARE(output.scaleF(), 1.0);
QCOMPARE(output.colorCurves().red, m_initColorCurves.red);
QCOMPARE(output.colorCurves().green, m_initColorCurves.green);
......@@ -238,7 +228,7 @@ void TestWaylandOutputDevice::testRegistry()
QCOMPARE(output.edid(), m_edid);
QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled);
QCOMPARE(output.uuid(), QByteArray("1337"));
QCOMPARE(output.uuid(), QStringLiteral("1337"));
QCOMPARE(output.serialNumber(), m_serialNumber);
QCOMPARE(output.eisaId(), m_eidaId);
}
......@@ -340,46 +330,6 @@ void TestWaylandOutputDevice::testModeChanges()
QCOMPARE(output.pixelSize(), QSize(1280, 1024));
}
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
void TestWaylandOutputDevice::testScaleChange_legacy()
{
KWayland::Client::Registry registry;
QSignalSpy interfacesAnnouncedSpy(&registry, &KWayland::Client::Registry::interfacesAnnounced);
QVERIFY(interfacesAnnouncedSpy.isValid());
QSignalSpy announced(&registry, &KWayland::Client::Registry::outputDeviceAnnounced);
registry.setEventQueue(m_queue);
registry.create(m_connection->display());
QVERIFY(registry.isValid());
registry.setup();
wl_display_flush(m_connection->display());
QVERIFY(interfacesAnnouncedSpy.wait());
KWayland::Client::OutputDevice output;
QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done);
QVERIFY(outputChanged.isValid());
output.setup(registry.bindOutputDevice(announced.first().first().value<quint32>(), announced.first().last().value<quint32>()));
wl_display_flush(m_connection->display());
QVERIFY(outputChanged.wait());
QCOMPARE(output.scale(), 1);
QCOMPARE(output.scaleF(), 1.0);
// change the scale
outputChanged.clear();
m_serverOutputDevice->setScale(2);
QVERIFY(outputChanged.wait());
QCOMPARE(output.scale(), 2);
QCOMPARE(output.scaleF(), 2.0); //check we're forward compatible
// change once more
outputChanged.clear();
m_serverOutputDevice->setScale(4);
QVERIFY(outputChanged.wait());
QCOMPARE(output.scale(), 4);
QCOMPARE(output.scaleF(), 4.0);
}
#endif
void TestWaylandOutputDevice::testScaleChange()
{
KWayland::Client::Registry registry;
......@@ -405,18 +355,12 @@ void TestWaylandOutputDevice::testScaleChange()
outputChanged.clear();
m_serverOutputDevice->setScaleF(2.2);
QVERIFY(outputChanged.wait());
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output.scale(), 2); //check backwards compatibility works
#endif
QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(2.2));
// change once more
outputChanged.clear();
m_serverOutputDevice->setScaleF(4.9);
QVERIFY(outputChanged.wait());
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output.scale(), 5);
#endif
QCOMPARE(wl_fixed_from_double(output.scaleF()), wl_fixed_from_double(4.9));
}
......@@ -652,7 +596,7 @@ void TestWaylandOutputDevice::testId()
wl_display_flush(m_connection->display());
QVERIFY(outputChanged.wait());
QCOMPARE(output.uuid(), QByteArray("1337"));
QCOMPARE(output.uuid(), QStringLiteral("1337"));
QSignalSpy idChanged(&output, &KWayland::Client::OutputDevice::uuidChanged);
QVERIFY(idChanged.isValid());
......@@ -661,13 +605,13 @@ void TestWaylandOutputDevice::testId()
QVERIFY(idChanged.wait());
QCOMPARE(idChanged.first().first().toByteArray(), QByteArray("42"));
idChanged.clear();
QCOMPARE(output.uuid(), QByteArray("42"));
QCOMPARE(output.uuid(), QStringLiteral("42"));
m_serverOutputDevice->setUuid("4711");
QVERIFY(idChanged.wait());
QCOMPARE(idChanged.first().first().toByteArray(), QByteArray("4711"));
idChanged.clear();
QCOMPARE(output.uuid(), QByteArray("4711"));
QCOMPARE(output.uuid(), QStringLiteral("4711"));
}
void TestWaylandOutputDevice::testDone()
......
......@@ -126,7 +126,6 @@ void TestWaylandOutputManagement::init()
outputDeviceInterface->setCurrentMode(1);
outputDeviceInterface->setGlobalPosition(QPoint(0, 1920));
outputDeviceInterface->create();
m_serverOutputs << outputDeviceInterface;
m_outputManagementInterface = new OutputManagementInterface(m_display, this);
......@@ -249,9 +248,6 @@ void TestWaylandOutputManagement::createOutputDevices()
QCOMPARE(output->physicalSize(), QSize());
QCOMPARE(output->pixelSize(), QSize());
QCOMPARE(output->refreshRate(), 0);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output->scale(), 1);
#endif
QCOMPARE(output->scaleF(), 1.0);
QCOMPARE(output->colorCurves().red, QVector<quint16>());
QCOMPARE(output->colorCurves().green, QVector<quint16>());
......@@ -260,7 +256,7 @@ void TestWaylandOutputManagement::createOutputDevices()
QCOMPARE(output->transform(), KWayland::Client::OutputDevice::Transform::Normal);
QCOMPARE(output->enabled(), OutputDevice::Enablement::Enabled);
QCOMPARE(output->edid(), QByteArray());
QCOMPARE(output->uuid(), QByteArray());
QCOMPARE(output->uuid(), QString());
QSignalSpy outputChanged(output, &KWayland::Client::OutputDevice::changed);
QVERIFY(outputChanged.isValid());
......@@ -407,7 +403,7 @@ void TestWaylandOutputManagement::testMultipleSettings()
QVERIFY(configAppliedSpy.isValid());
QVERIFY(configAppliedSpy.wait(200));
QCOMPARE(configAppliedSpy.count(), 1);
QCOMPARE(outputChangedSpy.count(), 6);
QCOMPARE(outputChangedSpy.count(), 5);
config->setMode(output, m_modes.at(1).id);
config->setTransform(output, OutputDevice::Transform::Normal);
......@@ -425,7 +421,7 @@ void TestWaylandOutputManagement::testMultipleSettings()
QVERIFY(configAppliedSpy.wait(200));
QCOMPARE(configAppliedSpy.count(), 2);
QCOMPARE(outputChangedSpy.count(), 12);
QCOMPARE(outputChangedSpy.count(), 10);
}
......@@ -433,11 +429,9 @@ void TestWaylandOutputManagement::testConfigFailed()
{
createConfig();
auto config = m_outputConfiguration;
auto s_o = m_serverOutputs.first();
KWayland::Client::OutputDevice *output = m_clientOutputs.first();
QVERIFY(config->isValid());
QVERIFY(s_o->isValid());
QVERIFY(output->isValid());
QSignalSpy serverApplySpy(m_outputManagementInterface, &OutputManagementInterface::configurationChangeRequested);
......@@ -507,23 +501,7 @@ void TestWaylandOutputManagement::testScale()
QVERIFY(configAppliedSpy.isValid());
QVERIFY(configAppliedSpy.wait(200));
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
QCOMPARE(output->scale(), 2); //test backwards compatibility
#endif
QCOMPARE(wl_fixed_from_double(output->scaleF()), wl_fixed_from_double(2.3));
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
config->setScale(output, 3);
config->apply();
QVERIFY(configAppliedSpy.isValid());
QVERIFY(configAppliedSpy.wait(200));
//will be setApplied using the connect above
QCOMPARE(output->scale(), 3);
QCOMPARE(output->scaleF(), 3.0); //test forward compatibility
#endif
}
......
......@@ -85,9 +85,9 @@ ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
BASENAME output-management
)
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/outputdevice.xml
BASENAME org_kde_kwin_outputdevice
BASENAME org-kde-kwin-outputdevice
)
ecm_add_qtwayland_server_protocol_kde(SERVER_LIB_SRCS
......
......@@ -13,7 +13,7 @@
#include <wayland-server.h>
#include "wayland-output-management-server-protocol.h"
#include "wayland-org_kde_kwin_outputdevice-server-protocol.h"
#include "wayland-org-kde-kwin-outputdevice-server-protocol.h"
#include <QDebug>
#include <QSize>
......
This diff is collapsed.
......@@ -19,6 +19,7 @@ namespace KWaylandServer
{
class Display;
class OutputDeviceInterfacePrivate;
/** @class OutputDeviceInterface
*
......@@ -28,7 +29,7 @@ class Display;
* @see OutputManagementInterface
* @since 5.5
*/
class KWAYLANDSERVER_EXPORT OutputDeviceInterface : public Global
class KWAYLANDSERVER_EXPORT OutputDeviceInterface : public QObject
{
Q_OBJECT
Q_PROPERTY(QSize physicalSize READ physicalSize WRITE setPhysicalSize NOTIFY physicalSizeChanged)
......@@ -42,7 +43,7 @@ class KWAYLANDSERVER_EXPORT OutputDeviceInterface : public Global
Q_PROPERTY(qreal scale READ scaleF WRITE setScaleF NOTIFY scaleFChanged)
Q_PROPERTY(QByteArray edid READ edid WRITE setEdid NOTIFY edidChanged)
Q_PROPERTY(OutputDeviceInterface::Enablement enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QByteArray uuid READ uuid WRITE setUuid NOTIFY uuidChanged)
Q_PROPERTY(QString uuid READ uuid WRITE setUuid NOTIFY uuidChanged)
public:
enum class SubPixel {
Unknown,
......@@ -84,7 +85,7 @@ public:
};
explicit OutputDeviceInterface(Display *display, QObject *parent = nullptr);
virtual ~OutputDeviceInterface();
~OutputDeviceInterface() override;
QSize physicalSize() const;
QPoint globalPosition() const;
......@@ -94,11 +95,7 @@ public:
QString eisaId() const;
QSize pixelSize() const;
int refreshRate() const;
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
/// @deprecated Since 5.50, use scaleF()
KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::scaleF()")
int scale() const;
#endif
/// @since 5.50
qreal scaleF() const;
SubPixel subPixel() const;
......@@ -109,7 +106,7 @@ public:
QByteArray edid() const;
OutputDeviceInterface::Enablement enabled() const;
QByteArray uuid() const;
QString uuid() const;
void setPhysicalSize(const QSize &size);
void setGlobalPosition(const QPoint &pos);
......@@ -117,11 +114,7 @@ public:
void setModel(const QString &model);
void setSerialNumber(const QString &serialNumber);
void setEisaId(const QString &eisaId);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
/// @deprecated Since 5.50, use setScale(qreal)
KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::setScale(qreal)")
void setScale(int scale);
#endif
/// @since 5.50
void setScaleF(qreal scale);
void setSubPixel(SubPixel subPixel);
......@@ -144,7 +137,7 @@ public:
void setEdid(const QByteArray &edid);
void setEnabled(OutputDeviceInterface::Enablement enabled);
void setUuid(const QByteArray &uuid);
void setUuid(const QString &uuid);
static OutputDeviceInterface *get(wl_resource *native);
static QList<OutputDeviceInterface *>list();
......@@ -158,11 +151,7 @@ Q_SIGNALS:
void eisaIdChanged(const QString &);
void pixelSizeChanged(const QSize&);
void refreshRateChanged(int);
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 50)
/// @deprecated Since 5.50, use scaleFChanged(qreal)
KWAYLANDSERVER_DEPRECATED_VERSION(5, 50, "Use OutputDeviceInterface::scaleFChanged(qreal)")
void scaleChanged(int);
#endif
/// @since 5.50
void scaleFChanged(qreal);
void subPixelChanged(SubPixel);
......@@ -176,8 +165,7 @@ Q_SIGNALS:
void uuidChanged();
private:
class Private;
Private *d_func() const;
QScopedPointer<OutputDeviceInterfacePrivate> d;
};
}
......
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