Verified Commit e004156a authored by Xuetian Weng's avatar Xuetian Weng
Browse files

Add explicit done to OutputInterface and deprecate zxdg_output_v1.done if version 3 is used.

In zxdg_output_v1 version 3, done is deprecated and should be replaced
with wl_output.done. This makes automatically send done upon change not
suitable for the usage. OutputInterface user should now use done()
explicitly to send the update.

CCBUG: 433224
parent 44ca4155
Pipeline #54907 passed with stage
in 7 minutes and 10 seconds
......@@ -146,6 +146,7 @@ void TestWaylandOutput::testRegistry()
// changing again should not trigger signal
m_serverOutput->setPhysicalSize(QSize(200, 100));
QCOMPARE(physicalSizeChangedSpy.count(), 1);
m_serverOutput->done();
KWayland::Client::Registry registry;
QSignalSpy announced(&registry, &KWayland::Client::Registry::outputAnnounced);
......@@ -252,6 +253,7 @@ void TestWaylandOutput::testModeChanges()
QSignalSpy modeChangedSpy(&output, &KWayland::Client::Output::modeChanged);
QVERIFY(modeChangedSpy.isValid());
m_serverOutput->setCurrentMode(QSize(800, 600));
m_serverOutput->done();
QVERIFY(modeChangedSpy.wait());
if (modeChangedSpy.size() == 1) {
QVERIFY(modeChangedSpy.wait());
......@@ -283,6 +285,7 @@ void TestWaylandOutput::testModeChanges()
modeChangedSpy.clear();
m_serverOutput->setCurrentMode(QSize(1280, 1024), 90000);
QCOMPARE(m_serverOutput->refreshRate(), 90000);
m_serverOutput->done();
QVERIFY(modeChangedSpy.wait());
if (modeChangedSpy.size() == 1) {
QVERIFY(modeChangedSpy.wait());
......@@ -325,6 +328,7 @@ void TestWaylandOutput::testScaleChange()
QVERIFY(serverScaleChanged.isValid());
m_serverOutput->setScale(2);
QCOMPARE(m_serverOutput->scale(), 2);
m_serverOutput->done();
QCOMPARE(serverScaleChanged.count(), 1);
QVERIFY(outputChanged.wait());
QCOMPARE(output.scale(), 2);
......@@ -336,6 +340,7 @@ void TestWaylandOutput::testScaleChange()
// change once more
outputChanged.clear();
m_serverOutput->setScale(4);
m_serverOutput->done();
QVERIFY(outputChanged.wait());
QCOMPARE(output.scale(), 4);
}
......@@ -392,6 +397,7 @@ void TestWaylandOutput::testSubPixel()
outputChanged.clear();
m_serverOutput->setSubPixel(OutputInterface::SubPixel::Unknown);
QCOMPARE(m_serverOutput->subPixel(), OutputInterface::SubPixel::Unknown);
m_serverOutput->done();
QCOMPARE(serverSubPixelChangedSpy.count(), 2);
if (outputChanged.isEmpty()) {
QVERIFY(outputChanged.wait());
......@@ -452,6 +458,7 @@ void TestWaylandOutput::testTransform()
outputChanged.clear();
m_serverOutput->setTransform(OutputInterface::Transform::Normal);
QCOMPARE(m_serverOutput->transform(), OutputInterface::Transform::Normal);
m_serverOutput->done();
QCOMPARE(serverTransformChangedSpy.count(), 2);
if (outputChanged.isEmpty()) {
QVERIFY(outputChanged.wait());
......
......@@ -156,6 +156,7 @@ void TestXdgOutput::testChanges()
// names cannot dynamically change according to the spec
m_serverXdgOutput->done();
m_serverOutput->done();
QVERIFY(xdgOutputChanged.wait());
QCOMPARE(xdgOutputChanged.count(), 1);
......
......@@ -129,9 +129,7 @@ OutputInterface::OutputInterface(Display *display, QObject *parent)
}
for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
d->sendMode((*it).resource, *currentModeIt);
d->sendDone(*it);
}
wl_display_flush_clients(*(d->display));
}
);
connect(this, &OutputInterface::subPixelChanged, this, [d] { d->updateGeometry(); });
......@@ -403,7 +401,6 @@ void OutputInterface::Private::updateGeometry()
{
for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
sendGeometry((*it).resource);
sendDone(*it);
}
}
......@@ -411,7 +408,6 @@ void OutputInterface::Private::updateScale()
{
for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) {
sendScale(*it);
sendDone(*it);
}
}
......@@ -537,6 +533,13 @@ bool OutputInterface::isEnabled() const
return d->dpms.mode == DpmsMode::On;
}
void OutputInterface::done() {
Q_D();
for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
d->sendDone(*it);
}
}
OutputInterface *OutputInterface::get(wl_resource* native)
{
return Private::get(native);
......
......@@ -119,6 +119,12 @@ public:
*/
bool isEnabled() const;
/**
* Submit changes to all clients.
* @since 5.22
*/
void done();
static OutputInterface *get(wl_resource *native);
Q_SIGNALS:
......
......@@ -12,11 +12,12 @@
#include <QHash>
#include <QDebug>
#include <QPointer>
namespace KWaylandServer
{
static const quint32 s_version = 2;
static const quint32 s_version = 3;
class XdgOutputManagerV1InterfacePrivate : public QtWaylandServer::zxdg_output_manager_v1
{
......@@ -34,12 +35,15 @@ protected:
class XdgOutputV1InterfacePrivate : public QtWaylandServer::zxdg_output_v1
{
public:
XdgOutputV1InterfacePrivate(OutputInterface *wlOutput) : output(wlOutput) {}
QPoint pos;
QSize size;
QString name;
QString description;
bool dirty = false;
bool doneOnce = false;
QPointer<OutputInterface> output;
protected:
void zxdg_output_v1_bind_resource(Resource *resource) override;
......@@ -60,7 +64,7 @@ XdgOutputV1Interface * XdgOutputManagerV1Interface::createXdgOutput(OutputInterf
{
Q_ASSERT_X(!d->outputs.contains(output), "createXdgOutput", "An XdgOuputInterface already exists for this output");
auto xdgOutput = new XdgOutputV1Interface(parent);
auto xdgOutput = new XdgOutputV1Interface(output, parent);
d->outputs[output] = xdgOutput;
//as XdgOutput lifespan is managed by user, delete our mapping when either
......@@ -100,9 +104,9 @@ void XdgOutputManagerV1InterfacePrivate::zxdg_output_manager_v1_destroy(Resource
wl_resource_destroy(resource->handle);
}
XdgOutputV1Interface::XdgOutputV1Interface(QObject *parent)
XdgOutputV1Interface::XdgOutputV1Interface(OutputInterface *output, QObject *parent)
: QObject(parent)
, d(new XdgOutputV1InterfacePrivate())
, d(new XdgOutputV1InterfacePrivate(output))
{
}
......@@ -178,7 +182,9 @@ void XdgOutputV1Interface::done()
}
d->dirty = false;
for (auto resource : d->resourceMap()) {
d->send_done(resource->handle);
if (wl_resource_get_version(resource->handle) < 3) {
d->send_done(resource->handle);
}
}
}
......@@ -197,8 +203,15 @@ void XdgOutputV1InterfacePrivate::zxdg_output_v1_bind_resource(Resource *resourc
if (resource->version() >= ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION) {
send_description(resource->handle, description);
}
if (doneOnce) {
send_done(resource->handle);
if (wl_resource_get_version(resource->handle) >= 3) {
if (output) {
output->done();
}
} else {
send_done(resource->handle);
}
}
}
......
......@@ -112,7 +112,7 @@ public:
void done();
private:
explicit XdgOutputV1Interface(QObject *parent);
explicit XdgOutputV1Interface(OutputInterface *output, QObject *parent);
friend class XdgOutputManagerV1Interface;
friend class XdgOutputManagerV1InterfacePrivate;
......
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