Return SurfaceInterface::size in global compositor space
REVIEW: 129358
This commit is contained in:
parent
bfbc8b9c54
commit
8b3ecf8436
3 changed files with 55 additions and 3 deletions
|
@ -671,6 +671,10 @@ void TestWaylandSurface::testScale()
|
||||||
|
|
||||||
// let's change the scale factor
|
// let's change the scale factor
|
||||||
QSignalSpy scaleChangedSpy(serverSurface, &SurfaceInterface::scaleChanged);
|
QSignalSpy scaleChangedSpy(serverSurface, &SurfaceInterface::scaleChanged);
|
||||||
|
|
||||||
|
//changing the scale implicitly changes the size
|
||||||
|
QSignalSpy sizeChangedSpy(serverSurface, &SurfaceInterface::sizeChanged);
|
||||||
|
|
||||||
QVERIFY(scaleChangedSpy.isValid());
|
QVERIFY(scaleChangedSpy.isValid());
|
||||||
s->setScale(2);
|
s->setScale(2);
|
||||||
QCOMPARE(s->scale(), 2);
|
QCOMPARE(s->scale(), 2);
|
||||||
|
@ -682,6 +686,11 @@ void TestWaylandSurface::testScale()
|
||||||
QCOMPARE(scaleChangedSpy.first().first().toInt(), 2);
|
QCOMPARE(scaleChangedSpy.first().first().toInt(), 2);
|
||||||
QCOMPARE(serverSurface->scale(), 2);
|
QCOMPARE(serverSurface->scale(), 2);
|
||||||
|
|
||||||
|
//even though we've changed the scale, if we don't have a buffer we
|
||||||
|
//don't have a size. If we don't have a size it can't have changed
|
||||||
|
QCOMPARE(sizeChangedSpy.count(), 0);
|
||||||
|
QVERIFY(!serverSurface->size().isValid());
|
||||||
|
|
||||||
// let's try changing to same factor, should not emit changed on server
|
// let's try changing to same factor, should not emit changed on server
|
||||||
s->setScale(2);
|
s->setScale(2);
|
||||||
s->commit(Surface::CommitFlag::None);
|
s->commit(Surface::CommitFlag::None);
|
||||||
|
@ -695,6 +704,44 @@ void TestWaylandSurface::testScale()
|
||||||
QCOMPARE(scaleChangedSpy.first().first().toInt(), 2);
|
QCOMPARE(scaleChangedSpy.first().first().toInt(), 2);
|
||||||
QCOMPARE(scaleChangedSpy.last().first().toInt(), 4);
|
QCOMPARE(scaleChangedSpy.last().first().toInt(), 4);
|
||||||
QCOMPARE(serverSurface->scale(), 4);
|
QCOMPARE(serverSurface->scale(), 4);
|
||||||
|
scaleChangedSpy.clear();
|
||||||
|
|
||||||
|
//attach a buffer of 100x100, our scale is 4, so this should be a size of 25x25
|
||||||
|
QImage red(100, 100, QImage::Format_ARGB32);
|
||||||
|
red.fill(QColor(255, 0, 0, 128));
|
||||||
|
auto redBuffer = m_shm->createBuffer(red);
|
||||||
|
s->attachBuffer(redBuffer.data());
|
||||||
|
s->damage(QRect(0,0, 25,25));
|
||||||
|
s->commit(Surface::CommitFlag::None);
|
||||||
|
QVERIFY(sizeChangedSpy.wait());
|
||||||
|
QCOMPARE(sizeChangedSpy.count(), 1);
|
||||||
|
QCOMPARE(serverSurface->size(), QSize(25,25));
|
||||||
|
sizeChangedSpy.clear();
|
||||||
|
scaleChangedSpy.clear();
|
||||||
|
|
||||||
|
//set the scale to 1, buffer is still 100x100 so size should change to 100x100
|
||||||
|
s->setScale(1);
|
||||||
|
s->commit(Surface::CommitFlag::None);
|
||||||
|
QVERIFY(sizeChangedSpy.wait());
|
||||||
|
QCOMPARE(sizeChangedSpy.count(), 1);
|
||||||
|
QCOMPARE(scaleChangedSpy.count(), 1);
|
||||||
|
QCOMPARE(serverSurface->scale(), 1);
|
||||||
|
QCOMPARE(serverSurface->size(), QSize(100,100));
|
||||||
|
sizeChangedSpy.clear();
|
||||||
|
scaleChangedSpy.clear();
|
||||||
|
|
||||||
|
//set scale and size in one commit, buffer is 50x50 at scale 2 so size should be 25x25
|
||||||
|
QImage blue(50, 50, QImage::Format_ARGB32);
|
||||||
|
red.fill(QColor(255, 0, 0, 128));
|
||||||
|
auto blueBuffer = m_shm->createBuffer(blue);
|
||||||
|
s->attachBuffer(blueBuffer.data());
|
||||||
|
s->setScale(2);
|
||||||
|
s->commit(Surface::CommitFlag::None);
|
||||||
|
QVERIFY(sizeChangedSpy.wait());
|
||||||
|
QCOMPARE(sizeChangedSpy.count(), 1);
|
||||||
|
QCOMPARE(scaleChangedSpy.count(), 1);
|
||||||
|
QCOMPARE(serverSurface->scale(), 2);
|
||||||
|
QCOMPARE(serverSurface->size(), QSize(25,25));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestWaylandSurface::testDestroy()
|
void TestWaylandSurface::testDestroy()
|
||||||
|
|
|
@ -335,6 +335,9 @@ void SurfaceInterface::Private::swapStates(State *source, State *target, bool em
|
||||||
}
|
}
|
||||||
if (scaleFactorChanged) {
|
if (scaleFactorChanged) {
|
||||||
emit q->scaleChanged(target->scale);
|
emit q->scaleChanged(target->scale);
|
||||||
|
if (buffer && !sizeChanged) {
|
||||||
|
emit q->sizeChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (transformChanged) {
|
if (transformChanged) {
|
||||||
emit q->transformChanged(target->transform);
|
emit q->transformChanged(target->transform);
|
||||||
|
@ -634,9 +637,9 @@ QPointer< SubSurfaceInterface > SurfaceInterface::subSurface() const
|
||||||
QSize SurfaceInterface::size() const
|
QSize SurfaceInterface::size() const
|
||||||
{
|
{
|
||||||
Q_D();
|
Q_D();
|
||||||
// TODO: apply transform and scale to the buffer size
|
// TODO: apply transform to the buffer size
|
||||||
if (d->current.buffer) {
|
if (d->current.buffer) {
|
||||||
return d->current.buffer->size();
|
return d->current.buffer->size() / scale();
|
||||||
}
|
}
|
||||||
return QSize();
|
return QSize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,9 @@ public:
|
||||||
BufferInterface *buffer();
|
BufferInterface *buffer();
|
||||||
QPoint offset() const;
|
QPoint offset() const;
|
||||||
/**
|
/**
|
||||||
* The size of the Surface.
|
* The size of the Surface in global compositor space.
|
||||||
|
* @see For buffer size use BufferInterface::size
|
||||||
|
* from SurfaceInterface::buffer
|
||||||
* @since 5.3
|
* @since 5.3
|
||||||
**/
|
**/
|
||||||
QSize size() const;
|
QSize size() const;
|
||||||
|
|
Loading…
Reference in a new issue