Changeset View
Changeset View
Standalone View
Standalone View
backends/kwayland/waylandconfig.cpp
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | 137 | { | |||
---|---|---|---|---|---|
162 | m_registry->setEventQueue(m_queue); | 162 | m_registry->setEventQueue(m_queue); | ||
163 | m_registry->setup(); | 163 | m_registry->setup(); | ||
164 | } | 164 | } | ||
165 | 165 | | |||
166 | int s_outputId = 0; | 166 | int s_outputId = 0; | ||
167 | 167 | | |||
168 | void WaylandConfig::addOutput(quint32 name, quint32 version) | 168 | void WaylandConfig::addOutput(quint32 name, quint32 version) | ||
169 | { | 169 | { | ||
170 | // KWayland should only add this output once before removing again | | |||
171 | Q_ASSERT(!m_initializingOutputs.contains(name)); | | |||
172 | m_initializingOutputs << name; | | |||
173 | | ||||
174 | WaylandOutput *waylandoutput = new WaylandOutput(++s_outputId, name, this); | 170 | WaylandOutput *waylandoutput = new WaylandOutput(++s_outputId, name, this); | ||
171 | m_initializingOutputs << waylandoutput; | ||||
172 | | ||||
175 | connect(waylandoutput, &WaylandOutput::deviceRemoved, this, [this, waylandoutput]() { | 173 | connect(waylandoutput, &WaylandOutput::deviceRemoved, this, [this, waylandoutput]() { | ||
176 | removeOutput(waylandoutput); | 174 | removeOutput(waylandoutput); | ||
177 | }); | 175 | }); | ||
178 | waylandoutput->createOutputDevice(m_registry, version); | 176 | waylandoutput->createOutputDevice(m_registry, version); | ||
179 | 177 | | |||
180 | // finalize: when the output is done, we put it in the known outputs map, | 178 | // finalize: when the output is done, we put it in the known outputs map, | ||
181 | // remove if from the list of initializing outputs, and emit configChanged() | 179 | // remove if from the list of initializing outputs, and emit configChanged() | ||
182 | connect(waylandoutput, &WaylandOutput::complete, this, [this, waylandoutput, name]{ | 180 | connect(waylandoutput, &WaylandOutput::complete, this, [this, waylandoutput, name]{ | ||
183 | m_outputMap.insert(waylandoutput->id(), waylandoutput); | 181 | m_outputMap.insert(waylandoutput->id(), waylandoutput); | ||
184 | m_initializingOutputs.removeAll(name); | 182 | m_initializingOutputs.removeOne(waylandoutput); | ||
185 | checkInitialized(); | 183 | checkInitialized(); | ||
186 | 184 | | |||
187 | if (!m_blockSignals && m_initializingOutputs.empty()) { | 185 | if (!m_blockSignals && m_initializingOutputs.empty()) { | ||
188 | m_screen->setOutputs(m_outputMap.values()); | 186 | m_screen->setOutputs(m_outputMap.values()); | ||
189 | Q_EMIT configChanged(); | 187 | Q_EMIT configChanged(); | ||
190 | } | 188 | } | ||
191 | 189 | | |||
192 | connect(waylandoutput, &WaylandOutput::changed, this, [this]() { | 190 | connect(waylandoutput, &WaylandOutput::changed, this, [this]() { | ||
193 | if (!m_blockSignals) { | 191 | if (!m_blockSignals) { | ||
194 | Q_EMIT configChanged(); | 192 | Q_EMIT configChanged(); | ||
195 | } | 193 | } | ||
196 | }); | 194 | }); | ||
197 | }); | 195 | }); | ||
198 | } | 196 | } | ||
199 | 197 | | |||
200 | void WaylandConfig::removeOutput(WaylandOutput *output) | 198 | void WaylandConfig::removeOutput(WaylandOutput *output) | ||
201 | { | 199 | { | ||
202 | if (m_initializingOutputs.removeOne(output->wlName())) { | 200 | if (m_initializingOutputs.removeOne(output)) { | ||
203 | // output was not yet fully initialized, just remove here and return | 201 | // output was not yet fully initialized, just remove here and return | ||
204 | delete output; | 202 | delete output; | ||
205 | return; | 203 | return; | ||
206 | } | 204 | } | ||
207 | 205 | | |||
208 | // remove the output from output mapping | 206 | // remove the output from output mapping | ||
209 | Q_ASSERT(m_outputMap.take(output->id()) == output); | 207 | Q_ASSERT(m_outputMap.take(output->id()) == output); | ||
210 | m_screen->setOutputs(m_outputMap.values()); | 208 | m_screen->setOutputs(m_outputMap.values()); | ||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |