[server] Add a size property to SurfaceInterface
Basically just wraps the size of the attached buffer. Convenience to not have to go down to the Buffer to read the size. TODO: apply buffer scale and transform.
This commit is contained in:
parent
846a4e1d79
commit
33a37f99b7
2 changed files with 30 additions and 0 deletions
|
@ -182,13 +182,20 @@ void SurfaceInterface::Private::commit()
|
|||
const bool inputRegionChanged = pending.inputIsSet;
|
||||
const bool scaleFactorChanged = current.scale != pending.scale;
|
||||
const bool transformFactorChanged = current.transform != pending.transform;
|
||||
bool sizeChanged = false;
|
||||
auto buffer = current.buffer;
|
||||
if (bufferChanged) {
|
||||
QSize oldSize;
|
||||
if (current.buffer) {
|
||||
oldSize = current.buffer->size();
|
||||
current.buffer->unref();
|
||||
QObject::disconnect(current.buffer, &BufferInterface::sizeChanged, q, &SurfaceInterface::sizeChanged);
|
||||
}
|
||||
if (pending.buffer) {
|
||||
pending.buffer->ref();
|
||||
QObject::connect(pending.buffer, &BufferInterface::sizeChanged, q, &SurfaceInterface::sizeChanged);
|
||||
const QSize newSize = pending.buffer->size();
|
||||
sizeChanged = newSize.isValid() && newSize != oldSize;
|
||||
}
|
||||
buffer = pending.buffer;
|
||||
}
|
||||
|
@ -226,6 +233,9 @@ void SurfaceInterface::Private::commit()
|
|||
emit q->unmapped();
|
||||
}
|
||||
}
|
||||
if (sizeChanged) {
|
||||
emit q->sizeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceInterface::Private::damage(const QRect &rect)
|
||||
|
@ -436,6 +446,16 @@ QPointer< SubSurfaceInterface > SurfaceInterface::subSurface() const
|
|||
return d->subSurface;
|
||||
}
|
||||
|
||||
QSize SurfaceInterface::size() const
|
||||
{
|
||||
Q_D();
|
||||
// TODO: apply transform and scale to the buffer size
|
||||
if (d->current.buffer) {
|
||||
return d->current.buffer->size();
|
||||
}
|
||||
return QSize();
|
||||
}
|
||||
|
||||
SurfaceInterface::Private *SurfaceInterface::d_func() const
|
||||
{
|
||||
return reinterpret_cast<Private*>(d.data());
|
||||
|
|
|
@ -45,6 +45,7 @@ class KWAYLANDSERVER_EXPORT SurfaceInterface : public Resource
|
|||
Q_PROPERTY(QRegion input READ input NOTIFY inputChanged)
|
||||
Q_PROPERTY(qint32 scale READ scale NOTIFY scaleChanged)
|
||||
Q_PROPERTY(KWayland::Server::OutputInterface::Transform transform READ transform NOTIFY transformChanged)
|
||||
Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
|
||||
public:
|
||||
virtual ~SurfaceInterface();
|
||||
|
||||
|
@ -58,6 +59,11 @@ public:
|
|||
OutputInterface::Transform transform() const;
|
||||
BufferInterface *buffer();
|
||||
QPoint offset() const;
|
||||
/**
|
||||
* The size of the Surface.
|
||||
* @since 5.3
|
||||
**/
|
||||
QSize size() const;
|
||||
|
||||
/**
|
||||
* @returns The SubSurface for this Surface in case there is one.
|
||||
|
@ -85,6 +91,10 @@ Q_SIGNALS:
|
|||
* Emitted when the Surface removes its content
|
||||
**/
|
||||
void unmapped();
|
||||
/**
|
||||
* @since 5.3
|
||||
**/
|
||||
void sizeChanged();
|
||||
|
||||
private:
|
||||
friend class CompositorInterface;
|
||||
|
|
Loading…
Reference in a new issue