summaryrefslogtreecommitdiffstats
path: root/source/kde/kde/patch/libkscreen/cf0921f3fbde31cb94b9ccddcaba36da3a488483.patch
blob: 38e932be96752288ae6e4779f00b9fdc6e2dc566 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
From cf0921f3fbde31cb94b9ccddcaba36da3a488483 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A9ven=20Car?= <meven29@gmail.com>
Date: Thu, 2 Dec 2021 16:04:20 +0000
Subject: [PATCH] Under X11 ignore per-screen scale to compute logicalSize

---
 src/config.cpp | 32 ++++++++++++++++++++++++++++++++
 src/config.h   |  4 ++++
 src/output.cpp | 39 +++++++++------------------------------
 src/output.h   | 18 ++++--------------
 4 files changed, 49 insertions(+), 44 deletions(-)
 mode change 100644 => 100755 src/output.h

diff --git a/src/config.cpp b/src/config.cpp
index 37e1038..41abf70 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -325,6 +325,7 @@ void Config::setPrimaryOutput(const OutputPtr &newPrimary)
 void Config::addOutput(const OutputPtr &output)
 {
     d->outputs.insert(output->id(), output);
+    output->setExplicitLogicalSize(logicalSizeForOutput(*output));
     connect(output.data(), &KScreen::Output::isPrimaryChanged, d, &KScreen::Config::Private::onPrimaryOutputChanged);
 
     Q_EMIT outputAdded(output);
@@ -391,6 +392,37 @@ void Config::apply(const ConfigPtr &other)
     setValid(other->isValid());
 }
 
+QRect Config::outputGeometryForOutput(const KScreen::Output &output) const
+{
+    QSize size = logicalSizeForOutput(output).toSize();
+    if (!size.isValid()) {
+        return QRect();
+    }
+
+    return QRect(output.pos(), size);
+}
+
+QSizeF Config::logicalSizeForOutput(const KScreen::Output &output) const
+{
+    QSizeF size = output.enforcedModeSize();
+    if (!size.isValid()) {
+        return QSizeF();
+    }
+    // ignore scale where scaling is not per-output
+    if (supportedFeatures().testFlag(Feature::PerOutputScaling)) {
+        size = size / output.scale();
+    }
+
+    // We can't use output.size(), because it does not reflect the actual rotation() set by caller.
+    // It is only updated when we get update from KScreen, but not when user changes mode or
+    // rotation manually.
+
+    if (!output.isHorizontal()) {
+        size = size.transposed();
+    }
+    return size;
+}
+
 QDebug operator<<(QDebug dbg, const KScreen::ConfigPtr &config)
 {
     if (config) {
diff --git a/src/config.h b/src/config.h
index 551d7d0..4629dab 100644
--- a/src/config.h
+++ b/src/config.h
@@ -190,6 +190,10 @@ public:
      */
     void setTabletModeEngaged(bool engaged);
 
+    QRect outputGeometryForOutput(const KScreen::Output &output) const;
+
+    QSizeF logicalSizeForOutput(const KScreen::Output &output) const;
+
 Q_SIGNALS:
     void outputAdded(const KScreen::OutputPtr &output);
     void outputRemoved(int outputId);
diff --git a/src/output.cpp b/src/output.cpp
index c7f5949..a0fae28 100644
--- a/src/output.cpp
+++ b/src/output.cpp
@@ -13,6 +13,7 @@
 #include "mode.h"
 
 #include <QCryptographicHash>
+#include <QGuiApplication>
 #include <QRect>
 #include <QScopedPointer>
 #include <QStringList>
@@ -28,7 +29,7 @@ public:
         , replicationSource(0)
         , rotation(None)
         , scale(1.0)
-        , logicalSize(QSizeF())
+        , explicitLogicalSize(QSizeF())
         , connected(false)
         , enabled(false)
         , primary(false)
@@ -87,7 +88,7 @@ public:
     QSize size;
     Rotation rotation;
     qreal scale;
-    QSizeF logicalSize;
+    QSizeF explicitLogicalSize;
     bool connected;
     bool enabled;
     bool primary;
@@ -459,40 +460,18 @@ void Output::setScale(qreal factor)
     Q_EMIT scaleChanged();
 }
 
-QSizeF Output::logicalSize() const
-{
-    if (d->logicalSize.isValid()) {
-        return d->logicalSize;
-    }
-
-    QSizeF size = enforcedModeSize();
-    if (!size.isValid()) {
-        return QSizeF();
-    }
-    size = size / d->scale;
-
-    // We can't use d->size, because d->size does not reflect the actual rotation() set by caller.
-    // It is only updated when we get update from KScreen, but not when user changes mode or
-    // rotation manually.
-
-    if (!isHorizontal()) {
-        size = size.transposed();
-    }
-    return size;
-}
-
 QSizeF Output::explicitLogicalSize() const
 {
-    return d->logicalSize;
+    return d->explicitLogicalSize;
 }
 
-void Output::setLogicalSize(const QSizeF &size)
+void Output::setExplicitLogicalSize(const QSizeF &size)
 {
-    if (qFuzzyCompare(d->logicalSize.width(), size.width()) && qFuzzyCompare(d->logicalSize.height(), size.height())) {
+    if (qFuzzyCompare(d->explicitLogicalSize.width(), size.width()) && qFuzzyCompare(d->explicitLogicalSize.height(), size.height())) {
         return;
     }
-    d->logicalSize = size;
-    Q_EMIT logicalSizeChanged();
+    d->explicitLogicalSize = size;
+    Q_EMIT explicitLogicalSizeChanged();
 }
 
 bool Output::isConnected() const
@@ -628,7 +607,7 @@ QSize Output::enforcedModeSize() const
 
 QRect Output::geometry() const
 {
-    QSize size = logicalSize().toSize();
+    QSize size = explicitLogicalSize().toSize();
     if (!size.isValid()) {
         return QRect();
     }
diff --git a/src/output.h b/src/output.h
old mode 100644
new mode 100755
index 2b23ac4..7edb74c
--- a/src/output.h
+++ b/src/output.h
@@ -47,7 +47,7 @@ public:
     Q_PROPERTY(QSize sizeMm READ sizeMm CONSTANT)
     Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
     Q_PROPERTY(bool followPreferredMode READ followPreferredMode WRITE setFollowPreferredMode NOTIFY followPreferredModeChanged)
-    Q_PROPERTY(QSizeF logicalSize READ logicalSize WRITE setLogicalSize NOTIFY logicalSizeChanged)
+    Q_PROPERTY(QSizeF explicitLogicalSize READ explicitLogicalSize WRITE setExplicitLogicalSize NOTIFY explicitLogicalSizeChanged)
     Q_PROPERTY(Capabilities capabilities READ capabilities NOTIFY capabilitiesChanged)
     Q_PROPERTY(uint32_t overscan READ overscan WRITE setOverscan NOTIFY overscanChanged)
     Q_PROPERTY(VrrPolicy vrrPolicy READ vrrPolicy WRITE setVrrPolicy NOTIFY vrrPolicyChanged)
@@ -311,16 +311,6 @@ public:
      */
     void setScale(qreal factor);
 
-    /**
-     * The logical size is the output's representation internal to the display server and its
-     * overall screen geometry.
-     *
-     * returns the logical size of this output
-     *
-     * @since 5.18
-     */
-    QSizeF logicalSize() const;
-
     /**
      * The logical size is the output's representation internal to the display server and its
      * overall screen geometry.
@@ -338,9 +328,9 @@ public:
      *
      * @param size of this output in logical space
      *
-     * @since 5.18
+     * @since 5.24
      */
-    void setLogicalSize(const QSizeF &size);
+    void setExplicitLogicalSize(const QSizeF &size);
 
     /**
      * @returns whether the mode should be changed to the new preferred mode
@@ -421,7 +411,7 @@ Q_SIGNALS:
     void clonesChanged();
     void replicationSourceChanged();
     void scaleChanged();
-    void logicalSizeChanged();
+    void explicitLogicalSizeChanged();
     void followPreferredModeChanged(bool followPreferredMode);
     void capabilitiesChanged();
     void overscanChanged();
-- 
GitLab