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