Changeset View
Changeset View
Standalone View
Standalone View
abstract_wayland_output.cpp
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | 103 | if (isEnabled()) { | |||
---|---|---|---|---|---|
108 | // or maybe even set this to 3 when we're scaling to 1.5 | 108 | // or maybe even set this to 3 when we're scaling to 1.5 | ||
109 | // don't treat this like it's chosen deliberately | 109 | // don't treat this like it's chosen deliberately | ||
110 | m_waylandOutput->setScale(std::ceil(scale)); | 110 | m_waylandOutput->setScale(std::ceil(scale)); | ||
111 | m_xdgOutput->setLogicalSize(pixelSize() / scale); | 111 | m_xdgOutput->setLogicalSize(pixelSize() / scale); | ||
112 | m_xdgOutput->done(); | 112 | m_xdgOutput->done(); | ||
113 | } | 113 | } | ||
114 | } | 114 | } | ||
115 | 115 | | |||
116 | using DeviceInterface = KWayland::Server::OutputDeviceInterface; | ||||
117 | | ||||
118 | KWayland::Server::OutputInterface::Transform toOutputTransform(DeviceInterface::Transform transform) | ||||
119 | { | ||||
120 | using Transform = DeviceInterface::Transform; | ||||
121 | using OutputTransform = KWayland::Server::OutputInterface::Transform; | ||||
122 | | ||||
123 | switch (transform) { | ||||
124 | case Transform::Rotated90: | ||||
125 | return OutputTransform::Rotated90; | ||||
126 | case Transform::Rotated180: | ||||
127 | return OutputTransform::Rotated180; | ||||
128 | case Transform::Rotated270: | ||||
129 | return OutputTransform::Rotated270; | ||||
130 | case Transform::Flipped: | ||||
131 | return OutputTransform::Flipped; | ||||
132 | case Transform::Flipped90: | ||||
133 | return OutputTransform::Flipped90; | ||||
134 | case Transform::Flipped180: | ||||
135 | return OutputTransform::Flipped180; | ||||
136 | case Transform::Flipped270: | ||||
137 | return OutputTransform::Flipped270; | ||||
138 | default: | ||||
139 | return OutputTransform::Normal; | ||||
140 | } | ||||
141 | } | ||||
142 | | ||||
143 | void AbstractWaylandOutput::setTransform(DeviceInterface::Transform transform) | ||||
144 | { | ||||
145 | m_waylandOutputDevice->setTransform(transform); | ||||
146 | | ||||
147 | if (isEnabled()) { | ||||
148 | m_waylandOutput->setTransform(toOutputTransform(transform)); | ||||
149 | m_xdgOutput->setLogicalSize(pixelSize() / scale()); | ||||
150 | m_xdgOutput->done(); | ||||
151 | } | ||||
152 | } | ||||
153 | | ||||
116 | void AbstractWaylandOutput::applyChanges(const KWayland::Server::OutputChangeSet *changeSet) | 154 | void AbstractWaylandOutput::applyChanges(const KWayland::Server::OutputChangeSet *changeSet) | ||
117 | { | 155 | { | ||
118 | qCDebug(KWIN_CORE) << "Apply changes to the Wayland output."; | 156 | qCDebug(KWIN_CORE) << "Apply changes to the Wayland output."; | ||
119 | bool emitModeChanged = false; | 157 | bool emitModeChanged = false; | ||
120 | 158 | | |||
121 | // Enablement changes are handled by platform. | 159 | // Enablement changes are handled by platform. | ||
122 | if (changeSet->modeChanged()) { | 160 | if (changeSet->modeChanged()) { | ||
123 | qCDebug(KWIN_CORE) << "Setting new mode:" << changeSet->mode(); | 161 | qCDebug(KWIN_CORE) << "Setting new mode:" << changeSet->mode(); | ||
124 | m_waylandOutputDevice->setCurrentMode(changeSet->mode()); | 162 | m_waylandOutputDevice->setCurrentMode(changeSet->mode()); | ||
125 | updateMode(changeSet->mode()); | 163 | updateMode(changeSet->mode()); | ||
126 | emitModeChanged = true; | 164 | emitModeChanged = true; | ||
127 | } | 165 | } | ||
128 | if (changeSet->transformChanged()) { | 166 | if (changeSet->transformChanged()) { | ||
129 | qCDebug(KWIN_CORE) << "Server setting transform: " << (int)(changeSet->transform()); | 167 | qCDebug(KWIN_CORE) << "Server setting transform: " << (int)(changeSet->transform()); | ||
130 | transform(changeSet->transform()); | 168 | transform(changeSet->transform()); | ||
169 | setTransform(changeSet->transform()); | ||||
131 | emitModeChanged = true; | 170 | emitModeChanged = true; | ||
132 | } | 171 | } | ||
133 | if (changeSet->positionChanged()) { | 172 | if (changeSet->positionChanged()) { | ||
134 | qCDebug(KWIN_CORE) << "Server setting position: " << changeSet->position(); | 173 | qCDebug(KWIN_CORE) << "Server setting position: " << changeSet->position(); | ||
135 | setGlobalPos(changeSet->position()); | 174 | setGlobalPos(changeSet->position()); | ||
136 | // may just work already! | 175 | // may just work already! | ||
137 | } | 176 | } | ||
138 | if (changeSet->scaleChanged()) { | 177 | if (changeSet->scaleChanged()) { | ||
139 | qCDebug(KWIN_CORE) << "Setting scale:" << changeSet->scale(); | 178 | qCDebug(KWIN_CORE) << "Setting scale:" << changeSet->scale(); | ||
140 | setScale(changeSet->scaleF()); | 179 | setScale(changeSet->scaleF()); | ||
141 | emitModeChanged = true; | 180 | emitModeChanged = true; | ||
142 | } | 181 | } | ||
143 | 182 | | |||
144 | if (emitModeChanged) { | 183 | if (emitModeChanged) { | ||
145 | emit modeChanged(); | 184 | emit modeChanged(); | ||
146 | } | 185 | } | ||
147 | } | 186 | } | ||
148 | 187 | | |||
149 | using DeviceInterface = KWayland::Server::OutputDeviceInterface; | | |||
150 | | ||||
151 | bool AbstractWaylandOutput::isEnabled() const | 188 | bool AbstractWaylandOutput::isEnabled() const | ||
152 | { | 189 | { | ||
153 | return m_waylandOutputDevice->enabled() == DeviceInterface::Enablement::Enabled; | 190 | return m_waylandOutputDevice->enabled() == DeviceInterface::Enablement::Enabled; | ||
154 | } | 191 | } | ||
155 | 192 | | |||
156 | void AbstractWaylandOutput::setEnabled(bool enable) | 193 | void AbstractWaylandOutput::setEnabled(bool enable) | ||
157 | { | 194 | { | ||
158 | if (enable == isEnabled()) { | 195 | if (enable == isEnabled()) { | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 276 | { | |||
257 | } | 294 | } | ||
258 | 295 | | |||
259 | m_waylandOutputDevice->create(); | 296 | m_waylandOutputDevice->create(); | ||
260 | createWaylandOutput(); | 297 | createWaylandOutput(); | ||
261 | } | 298 | } | ||
262 | 299 | | |||
263 | QSize AbstractWaylandOutput::orientateSize(const QSize &size) const | 300 | QSize AbstractWaylandOutput::orientateSize(const QSize &size) const | ||
264 | { | 301 | { | ||
265 | if (m_orientation == Qt::PortraitOrientation || m_orientation == Qt::InvertedPortraitOrientation) { | 302 | using Transform = DeviceInterface::Transform; | ||
303 | const Transform transform = m_waylandOutputDevice->transform(); | ||||
304 | if (transform == Transform::Rotated90 || transform == Transform::Rotated270 || | ||||
305 | transform == Transform::Flipped90 || transform == Transform::Flipped270) { | ||||
266 | return size.transposed(); | 306 | return size.transposed(); | ||
267 | } | 307 | } | ||
268 | return size; | 308 | return size; | ||
269 | } | 309 | } | ||
270 | 310 | | |||
271 | } | 311 | } |