diff --git a/autotests/configs/multipleoutput.json b/autotests/configs/multipleoutput.json --- a/autotests/configs/multipleoutput.json +++ b/autotests/configs/multipleoutput.json @@ -119,6 +119,7 @@ "width" : 1920, "height" : 1080 }, + "scale" : 1.4, "currentModeId" : 4, "preferredModes" : [4], "rotation" : 1, diff --git a/autotests/testscreenconfig.cpp b/autotests/testscreenconfig.cpp --- a/autotests/testscreenconfig.cpp +++ b/autotests/testscreenconfig.cpp @@ -109,6 +109,7 @@ QCOMPARE(output->currentModeId(), QLatin1String("3")); QCOMPARE(output->preferredModeId(), QLatin1String("3")); QCOMPARE(output->rotation(), Output::None); + QCOMPARE(output->scale(), 1.0); QCOMPARE(output->isConnected(), true); QCOMPARE(output->isEnabled(), true); QCOMPARE(output->isPrimary(), true); @@ -159,6 +160,7 @@ QCOMPARE(output->currentModeId(), QLatin1String("4")); QCOMPARE(output->preferredModeId(), QLatin1String("4")); QCOMPARE(output->rotation(), Output::None); + QCOMPARE(output->scale(), 1.4); QCOMPARE(output->isConnected(), true); QCOMPARE(output->isEnabled(), true); QCOMPARE(output->isPrimary(), false); diff --git a/backends/fake/parser.cpp b/backends/fake/parser.cpp --- a/backends/fake/parser.cpp +++ b/backends/fake/parser.cpp @@ -189,6 +189,12 @@ map.remove(QLatin1Literal("size")); } + if (map.contains("scale")) { + qDebug() << "Scale found:" << map["scale"].toReal(); + output->setScale(map["scale"].toReal()); + map.remove(QLatin1Literal("size")); + } + //Remove some extra properties that we do not want or need special treatment map.remove(QLatin1Literal("edid")); diff --git a/src/output.h b/src/output.h --- a/src/output.h +++ b/src/output.h @@ -58,6 +58,8 @@ Q_PROPERTY(QList clones READ clones WRITE setClones NOTIFY clonesChanged) Q_PROPERTY(KScreen::Edid* edid READ edid CONSTANT) Q_PROPERTY(QSize sizeMm READ sizeMm CONSTANT) + Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) + enum Type { Unknown, @@ -192,6 +194,23 @@ */ QRect geometry() const; + /** + * returns the scaling factor to use for this output + * + * @since 5.9 + */ + qreal scale() const; + + /** + * Set the scaling factor for this output. + * + * @arg factor Scale factor to use for this output, the backend may or may not + * be able to deal with non-integer values, in that case, the factor gets rounded. + * + * @since 5.9 + */ + void setScale(qreal factor); + void apply(const OutputPtr &other); Q_SIGNALS: void outputChanged(); @@ -203,6 +222,7 @@ void isEnabledChanged(); void isPrimaryChanged(); void clonesChanged(); + void scaleChanged(); /** The mode list changed. * diff --git a/src/output.cpp b/src/output.cpp --- a/src/output.cpp +++ b/src/output.cpp @@ -37,6 +37,7 @@ id(0), type(Unknown), rotation(None), + scale(1.0), connected(false), enabled(false), primary(false), @@ -56,6 +57,7 @@ pos(other.pos), size(other.size), rotation(other.rotation), + scale(other.scale), connected(other.connected), enabled(other.enabled), primary(other.primary) @@ -84,6 +86,7 @@ QPoint pos; QSize size; Rotation rotation; + qreal scale; bool connected; bool enabled; bool primary; @@ -377,6 +380,20 @@ Q_EMIT rotationChanged(); } +qreal Output::scale() const +{ + return d->scale; +} + +void Output::setScale(qreal factor) +{ + if (d->scale == factor) { + return; + } + d->scale = factor; + emit scaleChanged(); +} + bool Output::isConnected() const { return d->connected;