Changeset View
Changeset View
Standalone View
Standalone View
backends/kwayland/waylandoutput.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | { | 51 | { | ||
52 | return s_rotationMap.key(rotation); | 52 | return s_rotationMap.key(rotation); | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | WaylandOutput::WaylandOutput(quint32 id, WaylandConfig *parent) | 55 | WaylandOutput::WaylandOutput(quint32 id, WaylandConfig *parent) | ||
56 | : QObject(parent) | 56 | : QObject(parent) | ||
57 | , m_id(id) | 57 | , m_id(id) | ||
58 | , m_device(nullptr) | 58 | , m_device(nullptr) | ||
59 | , m_config(parent) | ||||
59 | { | 60 | { | ||
60 | } | 61 | } | ||
61 | 62 | | |||
62 | quint32 WaylandOutput::id() const | 63 | quint32 WaylandOutput::id() const | ||
63 | { | 64 | { | ||
64 | Q_ASSERT(m_device); | 65 | Q_ASSERT(m_device); | ||
65 | return m_id; | 66 | return m_id; | ||
66 | } | 67 | } | ||
Show All 23 Lines | |||||
90 | OutputPtr WaylandOutput::toKScreenOutput() | 91 | OutputPtr WaylandOutput::toKScreenOutput() | ||
91 | { | 92 | { | ||
92 | OutputPtr output(new Output()); | 93 | OutputPtr output(new Output()); | ||
93 | output->setId(m_id); | 94 | output->setId(m_id); | ||
94 | updateKScreenOutput(output); | 95 | updateKScreenOutput(output); | ||
95 | return output; | 96 | return output; | ||
96 | } | 97 | } | ||
97 | 98 | | |||
99 | int WaylandOutput::getReplicationSource() const | ||||
100 | { | ||||
101 | const auto uuid = m_device->replicationSource(); | ||||
102 | if (!uuid.isEmpty()) { | ||||
nicolasfellaUnsubmitted Not Done nicolasfella: ```if (uuid.isEmpty())
return
``` | |||||
103 | for (auto waylandOutput : m_config->outputMap()) { | ||||
104 | if (uuid == waylandOutput->outputDevice()->uuid()) { | ||||
105 | return waylandOutput->id(); | ||||
106 | } | ||||
107 | } | ||||
108 | } | ||||
109 | return 0; | ||||
110 | } | ||||
111 | | ||||
98 | void WaylandOutput::updateKScreenOutput(OutputPtr &output) | 112 | void WaylandOutput::updateKScreenOutput(OutputPtr &output) | ||
99 | { | 113 | { | ||
100 | // Initialize primary output | 114 | // Initialize primary output | ||
101 | output->setId(m_id); | 115 | output->setId(m_id); | ||
102 | output->setEnabled(m_device->enabled() == Wl::OutputDevice::Enablement::Enabled); | 116 | output->setEnabled(m_device->enabled() == Wl::OutputDevice::Enablement::Enabled); | ||
103 | output->setConnected(true); | 117 | output->setConnected(true); | ||
104 | output->setPrimary(true); // FIXME: wayland doesn't have the concept of a primary display | 118 | output->setPrimary(true); // FIXME: wayland doesn't have the concept of a primary display | ||
105 | output->setName(name()); | 119 | output->setName(name()); | ||
106 | output->setSizeMm(m_device->physicalSize()); | 120 | output->setSizeMm(m_device->physicalSize()); | ||
107 | output->setPos(m_device->globalPosition()); | 121 | output->setPos(m_device->globalPosition()); | ||
108 | output->setRotation(s_rotationMap[m_device->transform()]); | 122 | output->setRotation(s_rotationMap[m_device->transform()]); | ||
123 | output->setReplicationSource(getReplicationSource()); | ||||
109 | 124 | | |||
110 | ModeList modeList; | 125 | ModeList modeList; | ||
111 | QStringList preferredModeIds; | 126 | QStringList preferredModeIds; | ||
112 | m_modeIdMap.clear(); | 127 | m_modeIdMap.clear(); | ||
113 | QString currentModeId = QStringLiteral("-1"); | 128 | QString currentModeId = QStringLiteral("-1"); | ||
114 | 129 | | |||
115 | for (const Wl::OutputDevice::Mode &wlMode : m_device->modes()) { | 130 | for (const Wl::OutputDevice::Mode &wlMode : m_device->modes()) { | ||
116 | ModePtr mode(new Mode()); | 131 | ModePtr mode(new Mode()); | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 177 | { | |||
184 | } | 199 | } | ||
185 | 200 | | |||
186 | // rotation | 201 | // rotation | ||
187 | if (toKScreenRotation(m_device->transform()) != output->rotation()) { | 202 | if (toKScreenRotation(m_device->transform()) != output->rotation()) { | ||
188 | changed = true; | 203 | changed = true; | ||
189 | wlConfig->setTransform(m_device, toKWaylandTransform(output->rotation())); | 204 | wlConfig->setTransform(m_device, toKWaylandTransform(output->rotation())); | ||
190 | } | 205 | } | ||
191 | 206 | | |||
207 | // replication | ||||
208 | const QByteArray oldSourceUuid = m_device->replicationSource(); | ||||
209 | if (output->replicationSource() != 0) { | ||||
210 | auto *newSource = m_config->outputMap()[output->replicationSource()]->outputDevice(); | ||||
211 | if (oldSourceUuid != newSource->uuid()) { | ||||
212 | changed = true; | ||||
213 | wlConfig->setReplicationSource(m_device, newSource); | ||||
214 | } | ||||
215 | } else if (!oldSourceUuid.isEmpty()) { | ||||
216 | changed = true; | ||||
217 | wlConfig->setReplicationSource(m_device, nullptr); | ||||
218 | } | ||||
219 | | ||||
192 | // mode | 220 | // mode | ||
193 | if (m_modeIdMap.contains(output->currentModeId())) { | 221 | if (m_modeIdMap.contains(output->currentModeId())) { | ||
194 | const int newModeId = m_modeIdMap.value(output->currentModeId(), -1); | 222 | const int newModeId = m_modeIdMap.value(output->currentModeId(), -1); | ||
195 | if (newModeId != m_device->currentMode().id) { | 223 | if (newModeId != m_device->currentMode().id) { | ||
196 | changed = true; | 224 | changed = true; | ||
197 | wlConfig->setMode(m_device, newModeId); | 225 | wlConfig->setMode(m_device, newModeId); | ||
198 | } | 226 | } | ||
199 | } else { | 227 | } else { | ||
Show All 26 Lines |