diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cf40d7652..da7328e980 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,7 +186,7 @@ int main() { mmap(nullptr, size, PROT_WRITE, MAP_SHARED, fd, 0); }" HAVE_MEMFD) -find_package(Wayland 1.21) +find_package(Wayland 1.22) set_package_properties(Wayland PROPERTIES TYPE REQUIRED PURPOSE "Required for building KWin with Wayland support" diff --git a/src/wayland/compositor_interface.cpp b/src/wayland/compositor_interface.cpp index 51ea909fdc..e6dc8cdac6 100644 --- a/src/wayland/compositor_interface.cpp +++ b/src/wayland/compositor_interface.cpp @@ -13,7 +13,7 @@ namespace KWaylandServer { -static const int s_version = 5; +static const int s_version = 6; class CompositorInterfacePrivate : public QtWaylandServer::wl_compositor { diff --git a/src/wayland/surface_interface.cpp b/src/wayland/surface_interface.cpp index 60988f6933..586257e11b 100644 --- a/src/wayland/surface_interface.cpp +++ b/src/wayland/surface_interface.cpp @@ -74,6 +74,7 @@ void SurfaceInterfacePrivate::addChild(SubSurfaceInterface *child) current.above.append(child); child->surface()->setOutputs(outputs); child->surface()->setPreferredBufferScale(preferredBufferScale); + child->surface()->setPreferredBufferTransform(preferredBufferTransform); Q_EMIT q->childSubSurfaceAdded(child); Q_EMIT q->childSubSurfacesChanged(); @@ -1119,6 +1120,10 @@ void SurfaceInterface::setPreferredBufferScale(qreal scale) if (d->fractionalScaleExtension) { d->fractionalScaleExtension->setPreferredScale(scale); } + if (d->resource()->version() >= WL_SURFACE_PREFERRED_BUFFER_SCALE_SINCE_VERSION) { + d->send_preferred_buffer_scale(std::ceil(scale)); + } + for (auto child : qAsConst(d->current.below)) { child->surface()->setPreferredBufferScale(scale); } @@ -1127,4 +1132,23 @@ void SurfaceInterface::setPreferredBufferScale(qreal scale) } } +void SurfaceInterface::setPreferredBufferTransform(KWin::Output::Transform transform) +{ + if (transform == d->preferredBufferTransform) { + return; + } + d->preferredBufferTransform = transform; + + if (d->resource()->version() >= WL_SURFACE_PREFERRED_BUFFER_TRANSFORM_SINCE_VERSION) { + d->send_preferred_buffer_transform(uint32_t(transform)); + } + + for (auto child : qAsConst(d->current.below)) { + child->surface()->setPreferredBufferTransform(transform); + } + for (auto child : qAsConst(d->current.above)) { + child->surface()->setPreferredBufferTransform(transform); + } +} + } // namespace KWaylandServer diff --git a/src/wayland/surface_interface.h b/src/wayland/surface_interface.h index 18ee3ce935..cb88806297 100644 --- a/src/wayland/surface_interface.h +++ b/src/wayland/surface_interface.h @@ -359,6 +359,14 @@ public: */ void setPreferredBufferScale(qreal scale); + /** + * Sets the preferred buffer transform for this surface. + * + * This indicates to the client the preferred buffer transform to use when + * attaching buffers to this surface. + */ + void setPreferredBufferTransform(KWin::Output::Transform transform); + Q_SIGNALS: /** * This signal is emitted when the underlying wl_surface resource is about to be freed. diff --git a/src/wayland/surface_interface_p.h b/src/wayland/surface_interface_p.h index d26f0927ce..079c9a3e27 100644 --- a/src/wayland/surface_interface_p.h +++ b/src/wayland/surface_interface_p.h @@ -133,6 +133,7 @@ public: QVector outputs; qreal preferredBufferScale = 1.0; + KWin::Output::Transform preferredBufferTransform = KWin::Output::Transform::Normal; LockedPointerV1Interface *lockedPointer = nullptr; ConfinedPointerV1Interface *confinedPointer = nullptr; diff --git a/src/waylandwindow.cpp b/src/waylandwindow.cpp index ec0c83b530..03a951c9af 100644 --- a/src/waylandwindow.cpp +++ b/src/waylandwindow.cpp @@ -161,6 +161,7 @@ void WaylandWindow::updateClientOutputs() surface()->setOutputs(waylandServer()->display()->outputsIntersecting(frameGeometry().toAlignedRect())); if (output()) { surface()->setPreferredBufferScale(output()->scale()); + surface()->setPreferredBufferTransform(output()->transform()); } }