Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 2c1303a0 authored by David Edmundson's avatar David Edmundson

Automatic scaling selection

The generator code is run by the KDED when we don't have a profile for a
monitor setup.

If we don't have a config this sets the screen scaling to 2 when it has
an DPI > 1.5*normal DPI. The vertical resolution is also checked that it
matches what you'd find on a high resolution screen to hopefully avoid
issues with bogus EDID.

We may need to tweak this heuristic based on feedback, especially when
want to support fractional scaling.

Test Plan:
Removed configs.
Laptop screen looked like it should.
Normal screen was 1x

Reviewers: #plasma, broulik, sebas

Reviewed By: #plasma, broulik, sebas

Subscribers: sebas, broulik, plasma-devel

Tags: #plasma

Differential Revision:
parent 46ab5b1b
......@@ -155,6 +155,14 @@ KScreen::ConfigPtr Generator::displaySwitch(DisplaySwitchAction action)
KScreen::OutputList connectedOutputs = config->connectedOutputs();
//the scale will generally be independent no matter where the output is
//scale will affect geometry, so do this first
if (config->supportedFeatures().testFlag(KScreen::Config::Feature::PerOutputScaling)) {
for(auto output: qAsConst(connectedOutputs)) {
// There's not much else we can do with only one output
if (connectedOutputs.count() < 2) {
......@@ -536,6 +544,18 @@ KScreen::ModePtr Generator::bestModeForSize(const KScreen::ModeList &modes, cons
return bestMode;
qreal Generator::bestScaleForOutput(const KScreen::OutputPtr &output) {
const auto mode = bestModeForOutput(output);
const qreal dpi = mode->size().height() / (output->sizeMm().height() / 25.4);
//if reported DPI is closer to two times normal DPI, followed by a sanity check of having the sort of vertical resolution
//you'd find in a high res screen
if (dpi > 96 * 1.5 && mode->size().height() >= 1440) {
return 2.0;
return 1.0;
KScreen::ModePtr Generator::bestModeForOutput(const KScreen::OutputPtr &output)
if (output->preferredMode()) {
......@@ -73,6 +73,7 @@ class Generator : public QObject
KScreen::ModePtr bestModeForSize(const KScreen::ModeList& modes, const QSize &size);
KScreen::ModePtr bestModeForOutput(const KScreen::OutputPtr &output);
qreal bestScaleForOutput(const KScreen::OutputPtr &output);
KScreen::OutputPtr biggestOutput(const KScreen::OutputList &connectedOutputs);
KScreen::OutputPtr embeddedOutput(const KScreen::OutputList &connectedOutputs);
Markdown is supported
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