wayland: Implement wl_surface.preferred_buffer_scale and wl_surface.preferred_buffer_transform
The new events provide a way to tell the client what buffer scale and buffer transform to use as they may lack the context to make a proper decision.
This commit is contained in:
parent
cad72753f0
commit
d2b0ed0c5a
6 changed files with 36 additions and 2 deletions
|
@ -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"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace KWaylandServer
|
||||
{
|
||||
static const int s_version = 5;
|
||||
static const int s_version = 6;
|
||||
|
||||
class CompositorInterfacePrivate : public QtWaylandServer::wl_compositor
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -133,6 +133,7 @@ public:
|
|||
|
||||
QVector<OutputInterface *> outputs;
|
||||
qreal preferredBufferScale = 1.0;
|
||||
KWin::Output::Transform preferredBufferTransform = KWin::Output::Transform::Normal;
|
||||
|
||||
LockedPointerV1Interface *lockedPointer = nullptr;
|
||||
ConfinedPointerV1Interface *confinedPointer = nullptr;
|
||||
|
|
|
@ -161,6 +161,7 @@ void WaylandWindow::updateClientOutputs()
|
|||
surface()->setOutputs(waylandServer()->display()->outputsIntersecting(frameGeometry().toAlignedRect()));
|
||||
if (output()) {
|
||||
surface()->setPreferredBufferScale(output()->scale());
|
||||
surface()->setPreferredBufferTransform(output()->transform());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue