Changeset View
Changeset View
Standalone View
Standalone View
kded/output.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | 118 | { | |||
---|---|---|---|---|---|
125 | if (retention != Control::OutputRetention::Individual && readInGlobal(output)) { | 125 | if (retention != Control::OutputRetention::Individual && readInGlobal(output)) { | ||
126 | // output data read from global output file | 126 | // output data read from global output file | ||
127 | return; | 127 | return; | ||
128 | } | 128 | } | ||
129 | // output data read directly from info | 129 | // output data read directly from info | ||
130 | readInGlobalPartFromInfo(output, info); | 130 | readInGlobalPartFromInfo(output, info); | ||
131 | } | 131 | } | ||
132 | 132 | | |||
133 | void Output::readInOutputs(KScreen::OutputList outputs, const QVariantList &outputsInfo, const QMap<QString, Control::OutputRetention> &retentions) | 133 | void Output::readInOutputs(KScreen::ConfigPtr config, const QVariantList &outputsInfo) | ||
134 | { | 134 | { | ||
135 | KScreen::OutputList outputs = config->outputs(); | ||||
136 | ControlConfig control(config); | ||||
135 | // As global outputs are indexed by a hash of their edid, which is not unique, | 137 | // As global outputs are indexed by a hash of their edid, which is not unique, | ||
136 | // to be able to tell apart multiple identical outputs, these need special treatment | 138 | // to be able to tell apart multiple identical outputs, these need special treatment | ||
137 | QStringList duplicateIds; | 139 | QStringList duplicateIds; | ||
138 | { | 140 | { | ||
139 | QStringList allIds; | 141 | QStringList allIds; | ||
140 | allIds.reserve(outputs.count()); | 142 | allIds.reserve(outputs.count()); | ||
141 | for (const KScreen::OutputPtr &output : outputs) { | 143 | for (const KScreen::OutputPtr &output : outputs) { | ||
142 | const auto outputId = output->hash(); | 144 | const auto outputId = output->hash(); | ||
143 | if (allIds.contains(outputId) && !duplicateIds.contains(outputId)) { | 145 | if (allIds.contains(outputId) && !duplicateIds.contains(outputId)) { | ||
144 | duplicateIds << outputId; | 146 | duplicateIds << outputId; | ||
145 | } | 147 | } | ||
146 | allIds << outputId; | 148 | allIds << outputId; | ||
147 | } | 149 | } | ||
148 | allIds.clear(); | 150 | allIds.clear(); | ||
149 | } | 151 | } | ||
150 | 152 | | |||
151 | for (KScreen::OutputPtr output : outputs) { | 153 | for (KScreen::OutputPtr output : outputs) { | ||
152 | if (!output->isConnected()) { | 154 | if (!output->isConnected()) { | ||
153 | output->setEnabled(false); | 155 | output->setEnabled(false); | ||
154 | continue; | 156 | continue; | ||
155 | } | 157 | } | ||
156 | const auto outputId = output->hash(); | 158 | const auto outputId = output->hash(); | ||
157 | const auto retention = Control::getOutputRetention(outputId, retentions); | | |||
158 | bool infoFound = false; | 159 | bool infoFound = false; | ||
159 | for (const auto &variantInfo : outputsInfo) { | 160 | for (const auto &variantInfo : outputsInfo) { | ||
160 | const QVariantMap info = variantInfo.toMap(); | 161 | const QVariantMap info = variantInfo.toMap(); | ||
161 | if (outputId != info[QStringLiteral("id")].toString()) { | 162 | if (outputId != info[QStringLiteral("id")].toString()) { | ||
162 | continue; | 163 | continue; | ||
163 | } | 164 | } | ||
164 | if (!output->name().isEmpty() && duplicateIds.contains(outputId)) { | 165 | if (!output->name().isEmpty() && duplicateIds.contains(outputId)) { | ||
165 | // We may have identical outputs connected, these will have the same id in the config | 166 | // We may have identical outputs connected, these will have the same id in the config | ||
166 | // in order to find the right one, also check the output's name (usually the connector) | 167 | // in order to find the right one, also check the output's name (usually the connector) | ||
167 | const auto metadata = info[QStringLiteral("metadata")].toMap(); | 168 | const auto metadata = info[QStringLiteral("metadata")].toMap(); | ||
168 | const auto outputName = metadata[QStringLiteral("name")].toString(); | 169 | const auto outputName = metadata[QStringLiteral("name")].toString(); | ||
169 | if (output->name() != outputName) { | 170 | if (output->name() != outputName) { | ||
170 | // was a duplicate id, but info not for this output | 171 | // was a duplicate id, but info not for this output | ||
171 | continue; | 172 | continue; | ||
172 | } | 173 | } | ||
173 | } | 174 | } | ||
174 | | ||||
175 | infoFound = true; | 175 | infoFound = true; | ||
176 | readIn(output, info, retention); | 176 | readIn(output, info, control.getOutputRetention(output)); | ||
177 | break; | 177 | break; | ||
178 | } | 178 | } | ||
179 | if (!infoFound) { | 179 | if (!infoFound) { | ||
180 | // no info in info for this output, try reading in global output info atleast or set some default values | 180 | // no info in info for this output, try reading in global output info atleast or set some default values | ||
181 | 181 | | |||
182 | qCWarning(KSCREEN_KDED) << "\tFailed to find a matching output in the current info data - this means that our info is corrupted" | 182 | qCWarning(KSCREEN_KDED) << "\tFailed to find a matching output in the current info data - this means that our info is corrupted" | ||
183 | "or a different device with the same serial number has been connected (very unlikely)."; | 183 | "or a different device with the same serial number has been connected (very unlikely)."; | ||
184 | if (!readInGlobal(output)) { | 184 | if (!readInGlobal(output)) { | ||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |