Add support for overscan

This commit is contained in:
Xaver Hugl 2021-04-10 19:32:20 +02:00
parent d4e5468c70
commit 3905cfe3ee
6 changed files with 116 additions and 1 deletions

View file

@ -19,6 +19,7 @@ OutputChangeSetPrivate::OutputChangeSetPrivate(OutputDeviceInterface *outputdevi
, position(outputDevice->globalPosition())
, scale(outputDevice->scaleF())
, colorCurves(outputDevice->colorCurves())
, overscan(outputDevice->overscan())
{
}
@ -89,4 +90,14 @@ OutputDeviceInterface::ColorCurves OutputChangeSet::colorCurves() const
return d->colorCurves;
}
bool OutputChangeSet::overscanChanged() const
{
return d->overscan != d->outputDevice->overscan();
}
uint32_t OutputChangeSet::overscan() const
{
return d->overscan;
}
}

View file

@ -62,6 +62,11 @@ public:
*/
bool colorCurvesChanged() const;
/** Whether the overscan() property of the outputdevice changed.
* @returns @c true if the overscan() property of the outputdevice has changed
*/
bool overscanChanged() const;
/** The new value for enabled. */
OutputDeviceInterface::Enablement enabled() const;
@ -82,6 +87,9 @@ public:
*/
OutputDeviceInterface::ColorCurves colorCurves() const;
/** the overscan value in % */
uint32_t overscan() const;
private:
friend class OutputConfigurationInterfacePrivate;
explicit OutputChangeSet(OutputDeviceInterface *outputdevice, QObject *parent = nullptr);

View file

@ -24,6 +24,7 @@ public:
QPoint position;
qreal scale;
OutputDeviceInterface::ColorCurves colorCurves;
uint32_t overscan;
};
}

View file

@ -47,6 +47,7 @@ protected:
void org_kde_kwin_outputconfiguration_colorcurves(Resource *resource, wl_resource *outputdevice, wl_array *red, wl_array *green, wl_array *blue) override;
void org_kde_kwin_outputconfiguration_destroy(Resource *resource) override;
void org_kde_kwin_outputconfiguration_destroy_resource(Resource *resource) override;
void org_kde_kwin_outputconfiguration_overscan(Resource *resource, wl_resource *outputdevice, uint32_t overscan) override;
};
void OutputConfigurationInterfacePrivate::org_kde_kwin_outputconfiguration_enable(Resource *resource, wl_resource *outputdevice, int32_t enable)
@ -182,6 +183,17 @@ void OutputConfigurationInterfacePrivate::org_kde_kwin_outputconfiguration_color
pendingChanges(output)->d->colorCurves = cc;
}
void OutputConfigurationInterfacePrivate::org_kde_kwin_outputconfiguration_overscan(Resource *resource, wl_resource *outputdevice, uint32_t overscan)
{
Q_UNUSED(resource)
if (overscan > 100) {
qCWarning(KWAYLAND_SERVER) << "Invalid overscan requested:" << overscan;
return;
}
OutputDeviceInterface *output = OutputDeviceInterface::get(outputdevice);
pendingChanges(output)->d->overscan = overscan;
}
void OutputConfigurationInterfacePrivate::org_kde_kwin_outputconfiguration_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);

View file

@ -17,7 +17,7 @@
namespace KWaylandServer
{
static const quint32 s_version = 2;
static const quint32 s_version = 3;
class OutputDeviceInterfacePrivate : public QtWaylandServer::org_kde_kwin_outputdevice
{
@ -33,6 +33,8 @@ public:
void updateColorCurves();
void updateEisaId();
void updateSerialNumber();
void updateCapabilities();
void updateOverscan();
void sendGeometry(Resource *resource);
void sendMode(Resource *resource, const OutputDeviceInterface::Mode &mode);
@ -44,6 +46,8 @@ public:
void sendColorCurves(Resource *resource);
void sendEisaId(Resource *resource);
void sendSerialNumber(Resource *resource);
void sendCapabilities(Resource *resource);
void sendOverscan(Resource *resource);
static OutputDeviceInterface *get(wl_resource *native);
@ -63,6 +67,8 @@ public:
QByteArray edid;
OutputDeviceInterface::Enablement enabled = OutputDeviceInterface::Enablement::Enabled;
QUuid uuid;
OutputDeviceInterface::Capabilities capabilities;
uint32_t overscan = 0;
QPointer<Display> display;
OutputDeviceInterface *q;
@ -315,6 +321,8 @@ void OutputDeviceInterfacePrivate::org_kde_kwin_outputdevice_bind_resource(Resou
sendUuid(resource);
sendEdid(resource);
sendEnabled(resource);
sendCapabilities(resource);
sendOverscan(resource);
sendDone(resource);
}
@ -633,6 +641,66 @@ void OutputDeviceInterfacePrivate::updateEisaId()
}
}
uint32_t OutputDeviceInterface::overscan() const
{
return d->overscan;
}
OutputDeviceInterface::Capabilities OutputDeviceInterface::capabilities() const
{
return d->capabilities;
}
void OutputDeviceInterface::setCapabilities(Capabilities cap)
{
if (d->capabilities != cap) {
d->capabilities = cap;
d->updateCapabilities();
emit capabilitiesChanged();
}
}
void OutputDeviceInterfacePrivate::sendCapabilities(Resource *resource)
{
if (resource->version() < ORG_KDE_KWIN_OUTPUTDEVICE_CAPABILITIES_SINCE_VERSION) {
return;
}
send_capabilities(resource->handle, static_cast<uint32_t>(capabilities));
}
void OutputDeviceInterfacePrivate::updateCapabilities()
{
const auto clientResources = resourceMap();
for (const auto &resource : clientResources) {
sendCapabilities(resource);
}
}
void OutputDeviceInterface::setOverscan(uint32_t overscan)
{
if (d->overscan != overscan) {
d->overscan = overscan;
d->updateOverscan();
emit overscanChanged();
}
}
void OutputDeviceInterfacePrivate::sendOverscan(Resource *resource)
{
if (resource->version() < ORG_KDE_KWIN_OUTPUTDEVICE_OVERSCAN_SINCE_VERSION) {
return;
}
send_overscan(resource->handle, static_cast<uint32_t>(overscan));
}
void OutputDeviceInterfacePrivate::updateOverscan()
{
const auto clientResources = resourceMap();
for (const auto &resource : clientResources) {
sendOverscan(resource);
}
}
OutputDeviceInterface *OutputDeviceInterfacePrivate::get(wl_resource *native)
{
if (auto devicePrivate = resource_cast<OutputDeviceInterfacePrivate *>(native)) {

View file

@ -43,6 +43,8 @@ class KWAYLANDSERVER_EXPORT OutputDeviceInterface : public QObject
Q_PROPERTY(QByteArray edid READ edid WRITE setEdid NOTIFY edidChanged)
Q_PROPERTY(OutputDeviceInterface::Enablement enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QUuid uuid READ uuid WRITE setUuid NOTIFY uuidChanged)
Q_PROPERTY(Capabilities capabilities READ capabilities WRITE setCapabilities NOTIFY capabilitiesChanged)
Q_PROPERTY(uint32_t overscan READ overscan WRITE setOverscan NOTIFY overscanChanged)
public:
enum class SubPixel {
Unknown,
@ -82,6 +84,10 @@ public:
bool operator==(const ColorCurves &cc) const;
bool operator!=(const ColorCurves &cc) const;
};
enum class Capability {
Overscan = 0x1,
};
Q_DECLARE_FLAGS(Capabilities, Capability)
explicit OutputDeviceInterface(Display *display, QObject *parent = nullptr);
~OutputDeviceInterface() override;
@ -106,6 +112,9 @@ public:
OutputDeviceInterface::Enablement enabled() const;
QUuid uuid() const;
Capabilities capabilities() const;
uint32_t overscan() const;
void setPhysicalSize(const QSize &size);
void setGlobalPosition(const QPoint &pos);
void setManufacturer(const QString &manufacturer);
@ -136,6 +145,9 @@ public:
void setEnabled(OutputDeviceInterface::Enablement enabled);
void setUuid(const QUuid &uuid);
void setCapabilities(Capabilities cap);
void setOverscan(uint32_t overscan);
static OutputDeviceInterface *get(wl_resource *native);
static QList<OutputDeviceInterface *>list();
@ -160,6 +172,9 @@ Q_SIGNALS:
void enabledChanged();
void uuidChanged();
void capabilitiesChanged();
void overscanChanged();
private:
QScopedPointer<OutputDeviceInterfacePrivate> d;
};