MCPcopy Create free account
hub / github.com/Sonic-DE/sonic-win / readOutputConfig

Function readOutputConfig

src/kscreenintegration.cpp:180–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180std::optional<std::pair<OutputConfiguration, QList<Output *>>> readOutputConfig(const QList<Output *> &outputs, const QString &hash)
181{
182 const auto outputsInfo = outputsConfig(outputs, hash);
183 if (outputsInfo.isEmpty()) {
184 return std::nullopt;
185 }
186 std::vector<std::pair<uint32_t, Output *>> outputOrder;
187 OutputConfiguration cfg;
188 // default position goes from left to right
189 QPoint pos(0, 0);
190 for (const auto &output : std::as_const(outputs)) {
191 if (output->isPlaceholder() || output->isNonDesktop()) {
192 continue;
193 }
194 auto props = cfg.changeSet(output);
195 const QJsonObject outputInfo = outputsInfo[output];
196 const auto globalOutputInfo = globalOutputConfig(output);
197 qCDebug(KWIN_CORE) << "Reading output configuration for " << output;
198 if (!outputInfo.isEmpty() || globalOutputInfo.has_value()) {
199 // settings that are per output setup:
200 props->enabled = outputInfo["enabled"].toBool(true);
201 if (outputInfo["primary"].toBool()) {
202 outputOrder.push_back(std::make_pair(1, output));
203 if (!props->enabled) {
204 qCWarning(KWIN_CORE) << "KScreen config would disable the primary output!";
205 return std::nullopt;
206 }
207 } else if (int prio = outputInfo["priority"].toInt(); prio > 0) {
208 outputOrder.push_back(std::make_pair(prio, output));
209 if (!props->enabled) {
210 qCWarning(KWIN_CORE) << "KScreen config would disable an output with priority!";
211 return std::nullopt;
212 }
213 } else {
214 outputOrder.push_back(std::make_pair(0, output));
215 }
216 if (const QJsonObject pos = outputInfo["pos"].toObject(); !pos.isEmpty()) {
217 props->pos = QPoint(pos["x"].toInt(), pos["y"].toInt());
218 }
219
220 // settings that are independent of per output setups:
221 const auto &globalInfo = globalOutputInfo ? globalOutputInfo.value() : outputInfo;
222 if (const QJsonValue scale = globalInfo["scale"]; !scale.isUndefined()) {
223 props->scale = scale.toDouble(1.);
224 }
225 if (const QJsonValue rotation = globalInfo["rotation"]; !rotation.isUndefined()) {
226 props->transform = KScreenIntegration::toKWinTransform(rotation.toInt());
227 props->manualTransform = props->transform;
228 }
229 if (const QJsonValue overscan = globalInfo["overscan"]; !overscan.isUndefined()) {
230 props->overscan = globalInfo["overscan"].toInt();
231 }
232 if (const QJsonValue vrrpolicy = globalInfo["vrrpolicy"]; !vrrpolicy.isUndefined()) {
233 props->vrrPolicy = static_cast<VrrPolicy>(vrrpolicy.toInt());
234 }
235 if (const QJsonValue rgbrange = globalInfo["rgbrange"]; !rgbrange.isUndefined()) {
236 props->rgbRange = static_cast<Output::RgbRange>(rgbrange.toInt());
237 }

Callers 1

generateConfigMethod · 0.85

Calls 15

outputsConfigFunction · 0.85
globalOutputConfigFunction · 0.85
QPointClass · 0.85
toKWinTransformFunction · 0.85
parseModeFunction · 0.85
isPlaceholderMethod · 0.80
isNonDesktopMethod · 0.80
changeSetMethod · 0.80
panelOrientationMethod · 0.80
setXMethod · 0.80
beginMethod · 0.80
constChangeSetMethod · 0.80

Tested by

no test coverage detected