From a2254382138c5bde1ea10bc7661fc7465719047f Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 8 Aug 2018 18:37:09 +0100 Subject: [PATCH] Sync set/send/update methods Summary: Currently whenever a single client binds we would incorrectly send an EDID/uuid/enabled update to every client. This syncs every property into following the same set/send/update pattern everywhere. Test Plan: Existing unit tests Reviewers: #kwin, romangg Reviewed By: #kwin, romangg Subscribers: romangg, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D14505 --- src/wayland/server/outputdevice_interface.cpp | 84 ++++++++++++------- 1 file changed, 55 insertions(+), 29 deletions(-) diff --git a/src/wayland/server/outputdevice_interface.cpp b/src/wayland/server/outputdevice_interface.cpp index 77fd006121..6602328eaf 100644 --- a/src/wayland/server/outputdevice_interface.cpp +++ b/src/wayland/server/outputdevice_interface.cpp @@ -41,17 +41,26 @@ public: Private(OutputDeviceInterface *q, Display *d); ~Private(); - void sendMode(wl_resource *resource, const Mode &mode); - void sendDone(const ResourceData &data); + void updateGeometry(); + void updateUuid(); + void updateEdid(); + void updateEnabled(); void updateScale(); void updateColorCurves(); - void updateSerialNumber(); void updateEisaId(); + void updateSerialNumber(); - void sendUuid(); - void sendEdid(); - void sendEnabled(); + void sendGeometry(wl_resource *resource); + void sendMode(wl_resource *resource, const Mode &mode); + void sendDone(const ResourceData &data); + void sendUuid(const ResourceData &data); + void sendEdid(const ResourceData &data); + void sendEnabled(const ResourceData &data); + void sendScale(const ResourceData &data); + void sendColorCurves(const ResourceData &data); + void sendEisaId(const ResourceData &data); + void sendSerialNumber(const ResourceData &data); QSize physicalSize; QPoint globalPosition; @@ -78,11 +87,6 @@ private: void bind(wl_client *client, uint32_t version, uint32_t id) override; int32_t toTransform() const; int32_t toSubPixel() const; - void sendGeometry(wl_resource *resource); - void sendScale(const ResourceData &data); - void sendColorCurves(const ResourceData &data); - void sendEisaId(const ResourceData &data); - void sendSerialNumber(const ResourceData &data); static const quint32 s_version; OutputDeviceInterface *q; @@ -363,9 +367,9 @@ void OutputDeviceInterface::Private::bind(wl_client *client, uint32_t version, u sendMode(resource, *currentModeIt); } - sendUuid(); - sendEdid(); - sendEnabled(); + sendUuid(r); + sendEdid(r); + sendEnabled(r); sendDone(r); c->flush(); @@ -650,7 +654,7 @@ void OutputDeviceInterface::setEdid(const QByteArray &edid) { Q_D(); d->edid = edid; - d->sendEdid(); + d->updateEdid(); emit edidChanged(); } @@ -665,7 +669,7 @@ void OutputDeviceInterface::setEnabled(OutputDeviceInterface::Enablement enabled Q_D(); if (d->enabled != enabled) { d->enabled = enabled; - d->sendEnabled(); + d->updateEnabled(); emit enabledChanged(); } } @@ -681,7 +685,7 @@ void OutputDeviceInterface::setUuid(const QByteArray &uuid) Q_D(); if (d->uuid != uuid) { d->uuid = uuid; - d->sendUuid(); + d->updateUuid(); emit uuidChanged(); } } @@ -692,32 +696,54 @@ QByteArray OutputDeviceInterface::uuid() const return d->uuid; } -void KWayland::Server::OutputDeviceInterface::Private::sendEdid() +void KWayland::Server::OutputDeviceInterface::Private::sendEdid(const ResourceData &data) { - for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) { - org_kde_kwin_outputdevice_send_edid((*it).resource, - edid.toBase64().constData()); - } - + org_kde_kwin_outputdevice_send_edid(data.resource, + edid.toBase64().constData()); } -void KWayland::Server::OutputDeviceInterface::Private::sendEnabled() +void KWayland::Server::OutputDeviceInterface::Private::sendEnabled(const ResourceData &data) { int _enabled = 0; if (enabled == OutputDeviceInterface::Enablement::Enabled) { _enabled = 1; } - for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) { - org_kde_kwin_outputdevice_send_enabled((*it).resource, _enabled); - } + org_kde_kwin_outputdevice_send_enabled(data.resource, _enabled); } -void OutputDeviceInterface::Private::sendUuid() +void OutputDeviceInterface::Private::sendUuid(const ResourceData &data) +{ + org_kde_kwin_outputdevice_send_uuid(data.resource, uuid.constData()); +} + +void KWayland::Server::OutputDeviceInterface::Private::updateEnabled() { for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) { - org_kde_kwin_outputdevice_send_uuid((*it).resource, uuid.constData()); + sendEnabled(*it); } } +void KWayland::Server::OutputDeviceInterface::Private::updateEdid() +{ + for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) { + sendEdid(*it); + } +} + +void KWayland::Server::OutputDeviceInterface::Private::updateUuid() +{ + for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) { + sendUuid(*it); + } +} + +void KWayland::Server::OutputDeviceInterface::Private::updateEisaId() +{ + for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) { + sendEisaId(*it); + } +} + + } }