Changeset View
Changeset View
Standalone View
Standalone View
abstract_wayland_output.cpp
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | 144 | { | |||
---|---|---|---|---|---|
146 | 146 | | |||
147 | if (isEnabled()) { | 147 | if (isEnabled()) { | ||
148 | m_waylandOutput->setTransform(toOutputTransform(transform)); | 148 | m_waylandOutput->setTransform(toOutputTransform(transform)); | ||
149 | m_xdgOutput->setLogicalSize(pixelSize() / scale()); | 149 | m_xdgOutput->setLogicalSize(pixelSize() / scale()); | ||
150 | m_xdgOutput->done(); | 150 | m_xdgOutput->done(); | ||
151 | } | 151 | } | ||
152 | } | 152 | } | ||
153 | 153 | | |||
154 | inline | ||||
zzag: Make these two helpers `static`. | |||||
Forgot to add it. Does it really make a difference in C++ though? To my knowledge it doesn't. romangg: Forgot to add it. Does it really make a difference in C++ though? To my knowledge it doesn't. | |||||
Yes, it does make a difference. Using static will result in symbols local to the translation unit. Using inline will result in weak symbols. The second thing is that inline just gives a hint to inline the function. The compiler may ignore that hint, but it can also inline functions that are not marked with the inline keyword. So, making functions inline in this case is kind of pointless. zzag: Yes, it does make a difference. Using `static` will result in symbols local to the translation… | |||||
155 | AbstractWaylandOutput::Transform toTransform(DeviceInterface::Transform deviceTransform) | ||||
156 | { | ||||
157 | return static_cast<AbstractWaylandOutput::Transform>(deviceTransform); | ||||
158 | } | ||||
159 | | ||||
160 | inline | ||||
161 | DeviceInterface::Transform toDeviceTransform(AbstractWaylandOutput::Transform transform) | ||||
162 | { | ||||
163 | return static_cast<DeviceInterface::Transform>(transform); | ||||
164 | } | ||||
165 | | ||||
154 | void AbstractWaylandOutput::applyChanges(const KWayland::Server::OutputChangeSet *changeSet) | 166 | void AbstractWaylandOutput::applyChanges(const KWayland::Server::OutputChangeSet *changeSet) | ||
155 | { | 167 | { | ||
156 | qCDebug(KWIN_CORE) << "Apply changes to the Wayland output."; | 168 | qCDebug(KWIN_CORE) << "Apply changes to the Wayland output."; | ||
157 | bool emitModeChanged = false; | 169 | bool emitModeChanged = false; | ||
158 | 170 | | |||
159 | // Enablement changes are handled by platform. | 171 | // Enablement changes are handled by platform. | ||
160 | if (changeSet->modeChanged()) { | 172 | if (changeSet->modeChanged()) { | ||
161 | qCDebug(KWIN_CORE) << "Setting new mode:" << changeSet->mode(); | 173 | qCDebug(KWIN_CORE) << "Setting new mode:" << changeSet->mode(); | ||
162 | m_waylandOutputDevice->setCurrentMode(changeSet->mode()); | 174 | m_waylandOutputDevice->setCurrentMode(changeSet->mode()); | ||
163 | updateMode(changeSet->mode()); | 175 | updateMode(changeSet->mode()); | ||
164 | emitModeChanged = true; | 176 | emitModeChanged = true; | ||
165 | } | 177 | } | ||
166 | if (changeSet->transformChanged()) { | 178 | if (changeSet->transformChanged()) { | ||
167 | qCDebug(KWIN_CORE) << "Server setting transform: " << (int)(changeSet->transform()); | 179 | qCDebug(KWIN_CORE) << "Server setting transform: " << (int)(changeSet->transform()); | ||
168 | transform(changeSet->transform()); | 180 | updateTransform(toTransform(changeSet->transform())); | ||
169 | setTransform(changeSet->transform()); | 181 | setTransform(changeSet->transform()); | ||
170 | emitModeChanged = true; | 182 | emitModeChanged = true; | ||
171 | } | 183 | } | ||
172 | if (changeSet->positionChanged()) { | 184 | if (changeSet->positionChanged()) { | ||
173 | qCDebug(KWIN_CORE) << "Server setting position: " << changeSet->position(); | 185 | qCDebug(KWIN_CORE) << "Server setting position: " << changeSet->position(); | ||
174 | setGlobalPos(changeSet->position()); | 186 | setGlobalPos(changeSet->position()); | ||
175 | // may just work already! | 187 | // may just work already! | ||
176 | } | 188 | } | ||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 313 | { | |||
303 | const Transform transform = m_waylandOutputDevice->transform(); | 315 | const Transform transform = m_waylandOutputDevice->transform(); | ||
304 | if (transform == Transform::Rotated90 || transform == Transform::Rotated270 || | 316 | if (transform == Transform::Rotated90 || transform == Transform::Rotated270 || | ||
305 | transform == Transform::Flipped90 || transform == Transform::Flipped270) { | 317 | transform == Transform::Flipped90 || transform == Transform::Flipped270) { | ||
306 | return size.transposed(); | 318 | return size.transposed(); | ||
307 | } | 319 | } | ||
308 | return size; | 320 | return size; | ||
309 | } | 321 | } | ||
310 | 322 | | |||
311 | DeviceInterface::Transform toTransform(Qt::ScreenOrientations orientation) | 323 | void AbstractWaylandOutput::setTransform(Transform transform) | ||
312 | { | | |||
313 | if (orientation | Qt::LandscapeOrientation) { | | |||
314 | if (orientation | Qt::InvertedPortraitOrientation) { | | |||
315 | return DeviceInterface::Transform::Flipped; | | |||
316 | } | | |||
317 | return DeviceInterface::Transform::Normal; | | |||
318 | } | | |||
319 | | ||||
320 | if (orientation | Qt::PortraitOrientation) { | | |||
321 | if (orientation | Qt::InvertedLandscapeOrientation) { | | |||
322 | if (orientation | Qt::InvertedPortraitOrientation) { | | |||
323 | return DeviceInterface::Transform::Flipped270; | | |||
324 | } | | |||
325 | return DeviceInterface::Transform::Flipped90; | | |||
326 | } | | |||
327 | return DeviceInterface::Transform::Rotated90; | | |||
328 | } | | |||
329 | | ||||
330 | if (orientation | Qt::InvertedLandscapeOrientation) { | | |||
331 | return DeviceInterface::Transform::Rotated180; | | |||
332 | } | | |||
333 | | ||||
334 | if (orientation | Qt::InvertedPortraitOrientation) { | | |||
335 | return DeviceInterface::Transform::Rotated270; | | |||
336 | } | | |||
337 | | ||||
338 | Q_ASSERT(orientation == Qt::PrimaryOrientation); | | |||
339 | return DeviceInterface::Transform::Normal; | | |||
340 | } | | |||
341 | | ||||
342 | void AbstractWaylandOutput::setOrientation(Qt::ScreenOrientations orientation) | | |||
343 | { | 324 | { | ||
344 | const auto transform = toTransform(orientation); | 325 | const auto deviceTransform = toDeviceTransform(transform); | ||
345 | if (transform == m_waylandOutputDevice->transform()) { | 326 | if (deviceTransform == m_waylandOutputDevice->transform()) { | ||
346 | return; | 327 | return; | ||
347 | } | 328 | } | ||
348 | setTransform(transform); | 329 | setTransform(deviceTransform); | ||
349 | emit modeChanged(); | 330 | emit modeChanged(); | ||
350 | } | 331 | } | ||
351 | 332 | | |||
352 | Qt::ScreenOrientations AbstractWaylandOutput::orientation() const | 333 | AbstractWaylandOutput::Transform AbstractWaylandOutput::transform() const | ||
353 | { | 334 | { | ||
354 | const DeviceInterface::Transform transform = m_waylandOutputDevice->transform(); | 335 | return static_cast<Transform>(m_waylandOutputDevice->transform()); | ||
355 | | ||||
356 | switch (transform) { | | |||
357 | case DeviceInterface::Transform::Rotated90: | | |||
358 | return Qt::PortraitOrientation; | | |||
359 | case DeviceInterface::Transform::Rotated180: | | |||
360 | return Qt::InvertedLandscapeOrientation; | | |||
361 | case DeviceInterface::Transform::Rotated270: | | |||
362 | return Qt::InvertedPortraitOrientation; | | |||
363 | case DeviceInterface::Transform::Flipped: | | |||
364 | return Qt::LandscapeOrientation | Qt::InvertedPortraitOrientation; | | |||
365 | case DeviceInterface::Transform::Flipped90: | | |||
366 | return Qt::PortraitOrientation | Qt::InvertedLandscapeOrientation; | | |||
367 | case DeviceInterface::Transform::Flipped180: | | |||
368 | return Qt::InvertedLandscapeOrientation | Qt::InvertedPortraitOrientation; | | |||
369 | case DeviceInterface::Transform::Flipped270: | | |||
370 | return Qt::PortraitOrientation | Qt::InvertedLandscapeOrientation | | | |||
371 | Qt::InvertedPortraitOrientation; | | |||
372 | default: | | |||
373 | return Qt::LandscapeOrientation; | | |||
374 | } | | |||
375 | } | 336 | } | ||
376 | 337 | | |||
377 | } | 338 | } |
Make these two helpers static.