From 4d025b68022405ce889b563ed67646ccbfe4a658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Mon, 29 Nov 2021 17:15:26 +0100 Subject: [PATCH 1/4] Compute logicalSize taking into account current config BUG: 441417 --- kcm/output_identifier.cpp | 2 +- kcm/output_model.cpp | 23 +++++++++++++++-------- kded/output.cpp | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/kcm/output_identifier.cpp b/kcm/output_identifier.cpp index a672995..ba51470 100644 --- a/kcm/output_identifier.cpp +++ b/kcm/output_identifier.cpp @@ -56,7 +56,7 @@ OutputIdentifier::OutputIdentifier(KScreen::ConfigPtr config, QObject *parent) } if (config->supportedFeatures() & KScreen::Config::Feature::PerOutputScaling) { // Scale adjustment is not needed on Wayland, we use logical size. - logicalSize = output->logicalSize().toSize(); + logicalSize = output->explicitLogicalSize().toSize(); } else { logicalSize = deviceSize / view->effectiveDevicePixelRatio(); } diff --git a/kcm/output_model.cpp b/kcm/output_model.cpp index a497c90..020b96f 100644 --- a/kcm/output_model.cpp +++ b/kcm/output_model.cpp @@ -161,10 +161,13 @@ bool OutputModel::setData(const QModelIndex &index, const QVariant &value, int r bool ok; const qreal scale = value.toReal(&ok); if (ok && !qFuzzyCompare(output.ptr->scale(), scale)) { - const auto oldSize = output.ptr->logicalSize().toSize(); + const auto oldSize = output.ptr->explicitLogicalSize().toSize(); + output.ptr->setScale(scale); m_config->setScale(output.ptr, scale); - const auto newSize = output.ptr->logicalSize().toSize(); + + const auto newSize = m_config->config()->logicalSizeForOutput(*output.ptr).toSize(); + output.ptr->setExplicitLogicalSize(newSize); maintainSnapping(output, oldSize, newSize); @@ -385,9 +388,11 @@ bool OutputModel::setResolution(int outputIndex, int resIndex) if (output.ptr->currentModeId() == id) { return false; } - const auto oldSize = output.ptr->logicalSize().toSize(); + const auto oldSize = output.ptr->explicitLogicalSize().toSize(); output.ptr->setCurrentModeId(id); - const auto newSize = output.ptr->logicalSize().toSize(); + + const auto newSize = m_config->config()->logicalSizeForOutput(*output.ptr).toSize(); + output.ptr->setExplicitLogicalSize(newSize); maintainSnapping(output, oldSize, newSize); @@ -466,9 +471,11 @@ bool OutputModel::setRotation(int outputIndex, KScreen::Output::Rotation rotatio if (output.ptr->rotation() == rotation) { return false; } - const auto oldSize = output.ptr->logicalSize().toSize(); + const auto oldSize = output.ptr->explicitLogicalSize().toSize(); output.ptr->setRotation(rotation); - const auto newSize = output.ptr->logicalSize().toSize(); + + const auto newSize = m_config->config()->logicalSizeForOutput(*output.ptr).toSize(); + output.ptr->setExplicitLogicalSize(newSize); maintainSnapping(output, oldSize, newSize); @@ -653,7 +660,7 @@ bool OutputModel::setReplicationSourceIndex(int outputIndex, int sourceIndex) return false; } m_config->setReplicationSource(output.ptr, nullptr); - output.ptr->setLogicalSize(QSizeF()); + output.ptr->setExplicitLogicalSize(QSizeF()); resetPosition(output); } else { const auto source = m_outputs[sourceIndex].ptr; @@ -664,7 +671,7 @@ bool OutputModel::setReplicationSourceIndex(int outputIndex, int sourceIndex) m_config->setReplicationSource(output.ptr, source); output.posReset = output.ptr->pos(); output.ptr->setPos(source->pos()); - output.ptr->setLogicalSize(source->logicalSize()); + output.ptr->setExplicitLogicalSize(m_config->config()->logicalSizeForOutput(*source)); } reposition(); diff --git a/kded/output.cpp b/kded/output.cpp index 7463b8a..44251e5 100644 --- a/kded/output.cpp +++ b/kded/output.cpp @@ -404,9 +404,9 @@ void Output::readInOutputs(KScreen::ConfigPtr config, const QVariantList &output auto replicationSource = control.getReplicationSource(output); if (replicationSource) { output->setPos(replicationSource->pos()); - output->setLogicalSize(replicationSource->logicalSize()); + output->setExplicitLogicalSize(config->logicalSizeForOutput(*replicationSource)); } else { - output->setLogicalSize(QSizeF()); + output->setExplicitLogicalSize(QSizeF()); } } -- GitLab From 3b90217f21e62285e78fff86ae562c692799e28f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Tue, 30 Nov 2021 14:58:40 +0100 Subject: [PATCH 2/4] Update screen size when mode changes --- kcm/output_model.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/kcm/output_model.cpp b/kcm/output_model.cpp index 020b96f..ae01307 100644 --- a/kcm/output_model.cpp +++ b/kcm/output_model.cpp @@ -390,6 +390,7 @@ bool OutputModel::setResolution(int outputIndex, int resIndex) } const auto oldSize = output.ptr->explicitLogicalSize().toSize(); output.ptr->setCurrentModeId(id); + output.ptr->setSize(output.ptr->currentMode()->size()); const auto newSize = m_config->config()->logicalSizeForOutput(*output.ptr).toSize(); output.ptr->setExplicitLogicalSize(newSize); -- GitLab From ad8d66c2c39c15a9fd668a0a292f4cd970731123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Wed, 1 Dec 2021 13:39:21 +0100 Subject: [PATCH 3/4] Ensure to set outputs explicitLogicalSize upon loading config --- kcm/config_handler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kcm/config_handler.cpp b/kcm/config_handler.cpp index d7e7c7c..dabbcb2 100644 --- a/kcm/config_handler.cpp +++ b/kcm/config_handler.cpp @@ -78,6 +78,8 @@ void ConfigHandler::resetScale(const KScreen::OutputPtr &output) void ConfigHandler::initOutput(const KScreen::OutputPtr &output) { + output->setExplicitLogicalSize(config()->logicalSizeForOutput(*output)); + if (output->isConnected()) { resetScale(output); m_outputs->add(output); -- GitLab From ad7dda0b64c6f76066cdd199b0aa6ed2e2982f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9ven=20Car?= Date: Wed, 1 Dec 2021 14:40:32 +0100 Subject: [PATCH 4/4] Fix output identifier window positioning in wayland with some scale --- kcm/output_identifier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kcm/output_identifier.cpp b/kcm/output_identifier.cpp index ba51470..d21d36f 100644 --- a/kcm/output_identifier.cpp +++ b/kcm/output_identifier.cpp @@ -56,7 +56,7 @@ OutputIdentifier::OutputIdentifier(KScreen::ConfigPtr config, QObject *parent) } if (config->supportedFeatures() & KScreen::Config::Feature::PerOutputScaling) { // Scale adjustment is not needed on Wayland, we use logical size. - logicalSize = output->explicitLogicalSize().toSize(); + logicalSize = config->logicalSizeForOutput(*output.data()).toSize(); } else { logicalSize = deviceSize / view->effectiveDevicePixelRatio(); } -- GitLab