Changeset View
Changeset View
Standalone View
Standalone View
backends/kwayland/waylandoutput.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 122 | { | |||
---|---|---|---|---|---|
126 | output->setConnected(true); | 126 | output->setConnected(true); | ||
127 | output->setPrimary(true); // FIXME: wayland doesn't have the concept of a primary display | 127 | output->setPrimary(true); // FIXME: wayland doesn't have the concept of a primary display | ||
128 | output->setName(m_output->model()); | 128 | output->setName(m_output->model()); | ||
129 | // Physical size | 129 | // Physical size | ||
130 | output->setSizeMm(m_output->physicalSize()); | 130 | output->setSizeMm(m_output->physicalSize()); | ||
131 | output->setPos(m_output->globalPosition()); | 131 | output->setPos(m_output->globalPosition()); | ||
132 | output->setRotation(m_rotationMap[m_output->transform()]); | 132 | output->setRotation(m_rotationMap[m_output->transform()]); | ||
133 | KScreen::ModeList modeList; | 133 | KScreen::ModeList modeList; | ||
134 | QStringList preferredModeIds; | ||||
134 | m_modeIdMap.clear(); | 135 | m_modeIdMap.clear(); | ||
135 | QString currentModeId = QStringLiteral("-1"); | 136 | QString currentModeId = QStringLiteral("-1"); | ||
136 | Q_FOREACH (const KWayland::Client::OutputDevice::Mode &m, m_output->modes()) { | 137 | Q_FOREACH (const KWayland::Client::OutputDevice::Mode &m, m_output->modes()) { | ||
137 | KScreen::ModePtr mode(new KScreen::Mode()); | 138 | KScreen::ModePtr mode(new KScreen::Mode()); | ||
138 | const QString modename = modeName(m); | 139 | const QString modename = modeName(m); | ||
139 | QString modeid = QString::number(m.id); | 140 | QString modeid = QString::number(m.id); | ||
140 | if (modeid.isEmpty()) { | 141 | if (modeid.isEmpty()) { | ||
141 | qCDebug(KSCREEN_WAYLAND) << "Could not create mode id from" << m.id << ", using" << modename << "instead."; | 142 | qCDebug(KSCREEN_WAYLAND) << "Could not create mode id from" << m.id << ", using" << modename << "instead."; | ||
142 | modeid = modename; | 143 | modeid = modename; | ||
143 | } | 144 | } | ||
144 | if (m_modeIdMap.keys().contains(modeid)) { | 145 | if (m_modeIdMap.keys().contains(modeid)) { | ||
145 | qCWarning(KSCREEN_WAYLAND) << "Mode id already in use:" << modeid; | 146 | qCWarning(KSCREEN_WAYLAND) << "Mode id already in use:" << modeid; | ||
146 | } | 147 | } | ||
147 | 148 | | |||
148 | mode->setId(modeid); | 149 | mode->setId(modeid); | ||
149 | mode->setRefreshRate(m.refreshRate); | 150 | mode->setRefreshRate(m.refreshRate); | ||
150 | mode->setSize(m.size); | 151 | mode->setSize(m.size); | ||
151 | mode->setName(modename); | 152 | mode->setName(modename); | ||
152 | if (m.flags.testFlag(KWayland::Client::OutputDevice::Mode::Flag::Current)) { | 153 | if (m.flags.testFlag(KWayland::Client::OutputDevice::Mode::Flag::Current)) { | ||
153 | currentModeId = modeid; | 154 | currentModeId = modeid; | ||
154 | } | 155 | } | ||
156 | if (m.flags.testFlag(KWayland::Client::OutputDevice::Mode::Flag::Preferred)) { | ||||
157 | preferredModeIds << modeid; | ||||
158 | } | ||||
155 | // Update the kscreen => kwayland mode id translation map | 159 | // Update the kscreen => kwayland mode id translation map | ||
156 | m_modeIdMap.insert(modeid, m.id); | 160 | m_modeIdMap.insert(modeid, m.id); | ||
157 | // Add to the modelist which gets set on the output | 161 | // Add to the modelist which gets set on the output | ||
158 | modeList[modeid] = mode; | 162 | modeList[modeid] = mode; | ||
159 | } | 163 | } | ||
160 | if (currentModeId == QLatin1String("-1")) { | 164 | if (currentModeId == QLatin1String("-1")) { | ||
161 | qCWarning(KSCREEN_WAYLAND) << "Could not find the current mode id" << modeList; | 165 | qCWarning(KSCREEN_WAYLAND) << "Could not find the current mode id" << modeList; | ||
162 | } | 166 | } | ||
163 | output->setCurrentModeId(currentModeId); | 167 | output->setCurrentModeId(currentModeId); | ||
164 | 168 | | |||
169 | output->setPreferredModes(preferredModeIds); | ||||
165 | output->setModes(modeList); | 170 | output->setModes(modeList); | ||
166 | output->setScale(m_output->scale()); | 171 | output->setScale(m_output->scale()); | ||
167 | } | 172 | } | ||
168 | 173 | | |||
169 | QString WaylandOutput::modeName(const KWayland::Client::OutputDevice::Mode &m) const | 174 | QString WaylandOutput::modeName(const KWayland::Client::OutputDevice::Mode &m) const | ||
170 | { | 175 | { | ||
171 | return QString::number(m.size.width()) + QLatin1Char('x') + | 176 | return QString::number(m.size.width()) + QLatin1Char('x') + | ||
172 | QString::number(m.size.height()) + QLatin1Char('@') + | 177 | QString::number(m.size.height()) + QLatin1Char('@') + | ||
Show All 16 Lines |