Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_seat.cpp
Show First 20 Lines • Show All 824 Lines • ▼ Show 20 Line(s) | 805 | { | |||
---|---|---|---|---|---|
825 | QScopedPointer<Surface> grandChild2Surface(m_compositor->createSurface()); | 825 | QScopedPointer<Surface> grandChild2Surface(m_compositor->createSurface()); | ||
826 | QScopedPointer<SubSurface> childSubSurface(m_subCompositor->createSubSurface(childSurface.data(), parentSurface.data())); | 826 | QScopedPointer<SubSurface> childSubSurface(m_subCompositor->createSubSurface(childSurface.data(), parentSurface.data())); | ||
827 | QScopedPointer<SubSurface> grandChild1SubSurface(m_subCompositor->createSubSurface(grandChild1Surface.data(), childSurface.data())); | 827 | QScopedPointer<SubSurface> grandChild1SubSurface(m_subCompositor->createSubSurface(grandChild1Surface.data(), childSurface.data())); | ||
828 | QScopedPointer<SubSurface> grandChild2SubSurface(m_subCompositor->createSubSurface(grandChild2Surface.data(), childSurface.data())); | 828 | QScopedPointer<SubSurface> grandChild2SubSurface(m_subCompositor->createSubSurface(grandChild2Surface.data(), childSurface.data())); | ||
829 | grandChild2SubSurface->setPosition(QPoint(0, 25)); | 829 | grandChild2SubSurface->setPosition(QPoint(0, 25)); | ||
830 | 830 | | |||
831 | // let's map the surfaces | 831 | // let's map the surfaces | ||
832 | auto render = [this] (Surface *s, const QSize &size) { | 832 | auto render = [this] (Surface *s, const QSize &size) { | ||
833 | QImage image(size, QImage::Format_ARGB32); | 833 | QImage image(size, QImage::Format_ARGB32_Premultiplied); | ||
834 | image.fill(Qt::black); | 834 | image.fill(Qt::black); | ||
835 | s->attachBuffer(m_shm->createBuffer(image)); | 835 | s->attachBuffer(m_shm->createBuffer(image)); | ||
836 | s->damage(QRect(QPoint(0, 0), size)); | 836 | s->damage(QRect(QPoint(0, 0), size)); | ||
837 | s->commit(Surface::CommitFlag::None); | 837 | s->commit(Surface::CommitFlag::None); | ||
838 | }; | 838 | }; | ||
839 | render(grandChild2Surface.data(), QSize(50, 50)); | 839 | render(grandChild2Surface.data(), QSize(50, 50)); | ||
840 | render(grandChild1Surface.data(), QSize(50, 50)); | 840 | render(grandChild1Surface.data(), QSize(50, 50)); | ||
841 | render(childSurface.data(), QSize(50, 100)); | 841 | render(childSurface.data(), QSize(50, 100)); | ||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Line(s) | 1139 | { | |||
1166 | QScopedPointer<Surface> grandChild2Surface(m_compositor->createSurface()); | 1166 | QScopedPointer<Surface> grandChild2Surface(m_compositor->createSurface()); | ||
1167 | QScopedPointer<SubSurface> childSubSurface(m_subCompositor->createSubSurface(childSurface.data(), parentSurface.data())); | 1167 | QScopedPointer<SubSurface> childSubSurface(m_subCompositor->createSubSurface(childSurface.data(), parentSurface.data())); | ||
1168 | QScopedPointer<SubSurface> grandChild1SubSurface(m_subCompositor->createSubSurface(grandChild1Surface.data(), childSurface.data())); | 1168 | QScopedPointer<SubSurface> grandChild1SubSurface(m_subCompositor->createSubSurface(grandChild1Surface.data(), childSurface.data())); | ||
1169 | QScopedPointer<SubSurface> grandChild2SubSurface(m_subCompositor->createSubSurface(grandChild2Surface.data(), childSurface.data())); | 1169 | QScopedPointer<SubSurface> grandChild2SubSurface(m_subCompositor->createSubSurface(grandChild2Surface.data(), childSurface.data())); | ||
1170 | grandChild2SubSurface->setPosition(QPoint(0, 25)); | 1170 | grandChild2SubSurface->setPosition(QPoint(0, 25)); | ||
1171 | 1171 | | |||
1172 | // let's map the surfaces | 1172 | // let's map the surfaces | ||
1173 | auto render = [this] (Surface *s, const QSize &size) { | 1173 | auto render = [this] (Surface *s, const QSize &size) { | ||
1174 | QImage image(size, QImage::Format_ARGB32); | 1174 | QImage image(size, QImage::Format_ARGB32_Premultiplied); | ||
1175 | image.fill(Qt::black); | 1175 | image.fill(Qt::black); | ||
1176 | s->attachBuffer(m_shm->createBuffer(image)); | 1176 | s->attachBuffer(m_shm->createBuffer(image)); | ||
1177 | s->damage(QRect(QPoint(0, 0), size)); | 1177 | s->damage(QRect(QPoint(0, 0), size)); | ||
1178 | s->commit(Surface::CommitFlag::None); | 1178 | s->commit(Surface::CommitFlag::None); | ||
1179 | }; | 1179 | }; | ||
1180 | render(grandChild2Surface.data(), QSize(50, 50)); | 1180 | render(grandChild2Surface.data(), QSize(50, 50)); | ||
1181 | render(grandChild1Surface.data(), QSize(50, 50)); | 1181 | render(grandChild1Surface.data(), QSize(50, 50)); | ||
1182 | render(childSurface.data(), QSize(50, 100)); | 1182 | render(childSurface.data(), QSize(50, 100)); | ||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 1241 | { | |||
1323 | cursorSurface->commit(Surface::CommitFlag::None); | 1323 | cursorSurface->commit(Surface::CommitFlag::None); | ||
1324 | QVERIFY(changedSpy.wait()); | 1324 | QVERIFY(changedSpy.wait()); | ||
1325 | QCOMPARE(changedSpy.count(), 3); | 1325 | QCOMPARE(changedSpy.count(), 3); | ||
1326 | QCOMPARE(cursorChangedSpy.count(), 4); | 1326 | QCOMPARE(cursorChangedSpy.count(), 4); | ||
1327 | QCOMPARE(surfaceChangedSpy.count(), 1); | 1327 | QCOMPARE(surfaceChangedSpy.count(), 1); | ||
1328 | QCOMPARE(cursor->surface()->buffer()->data(), img); | 1328 | QCOMPARE(cursor->surface()->buffer()->data(), img); | ||
1329 | 1329 | | |||
1330 | // and add another image to the surface | 1330 | // and add another image to the surface | ||
1331 | QImage blue(QSize(10, 20), QImage::Format_ARGB32); | 1331 | QImage blue(QSize(10, 20), QImage::Format_ARGB32_Premultiplied); | ||
1332 | blue.fill(Qt::blue); | 1332 | blue.fill(Qt::blue); | ||
1333 | cursorSurface->attachBuffer(m_shm->createBuffer(blue)); | 1333 | cursorSurface->attachBuffer(m_shm->createBuffer(blue)); | ||
1334 | cursorSurface->damage(QRect(0, 0, 10, 20)); | 1334 | cursorSurface->damage(QRect(0, 0, 10, 20)); | ||
1335 | cursorSurface->commit(Surface::CommitFlag::None); | 1335 | cursorSurface->commit(Surface::CommitFlag::None); | ||
1336 | QVERIFY(changedSpy.wait()); | 1336 | QVERIFY(changedSpy.wait()); | ||
1337 | QCOMPARE(changedSpy.count(), 4); | 1337 | QCOMPARE(changedSpy.count(), 4); | ||
1338 | QCOMPARE(cursorChangedSpy.count(), 5); | 1338 | QCOMPARE(cursorChangedSpy.count(), 5); | ||
1339 | QCOMPARE(cursor->surface()->buffer()->data(), blue); | 1339 | QCOMPARE(cursor->surface()->buffer()->data(), blue); | ||
Show All 37 Lines | 1350 | { | |||
1377 | // create a signal spy for the cursor changed signal | 1377 | // create a signal spy for the cursor changed signal | ||
1378 | auto pointer = m_seatInterface->focusedPointer(); | 1378 | auto pointer = m_seatInterface->focusedPointer(); | ||
1379 | QSignalSpy cursorChangedSpy(pointer, &PointerInterface::cursorChanged); | 1379 | QSignalSpy cursorChangedSpy(pointer, &PointerInterface::cursorChanged); | ||
1380 | QVERIFY(cursorChangedSpy.isValid()); | 1380 | QVERIFY(cursorChangedSpy.isValid()); | ||
1381 | 1381 | | |||
1382 | // now let's set the cursor | 1382 | // now let's set the cursor | ||
1383 | Surface *cursorSurface = m_compositor->createSurface(m_compositor); | 1383 | Surface *cursorSurface = m_compositor->createSurface(m_compositor); | ||
1384 | QVERIFY(cursorSurface); | 1384 | QVERIFY(cursorSurface); | ||
1385 | QImage red(QSize(10, 10), QImage::Format_ARGB32); | 1385 | QImage red(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); | ||
1386 | red.fill(Qt::red); | 1386 | red.fill(Qt::red); | ||
1387 | cursorSurface->attachBuffer(m_shm->createBuffer(red)); | 1387 | cursorSurface->attachBuffer(m_shm->createBuffer(red)); | ||
1388 | cursorSurface->damage(QRect(0, 0, 10, 10)); | 1388 | cursorSurface->damage(QRect(0, 0, 10, 10)); | ||
1389 | cursorSurface->commit(Surface::CommitFlag::None); | 1389 | cursorSurface->commit(Surface::CommitFlag::None); | ||
1390 | p->setCursor(cursorSurface, QPoint(0, 0)); | 1390 | p->setCursor(cursorSurface, QPoint(0, 0)); | ||
1391 | QVERIFY(cursorChangedSpy.wait()); | 1391 | QVERIFY(cursorChangedSpy.wait()); | ||
1392 | QCOMPARE(pointer->cursor()->surface()->buffer()->data(), red); | 1392 | QCOMPARE(pointer->cursor()->surface()->buffer()->data(), red); | ||
1393 | 1393 | | |||
1394 | // and damage the surface | 1394 | // and damage the surface | ||
1395 | QImage blue(QSize(10, 10), QImage::Format_ARGB32); | 1395 | QImage blue(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); | ||
1396 | blue.fill(Qt::blue); | 1396 | blue.fill(Qt::blue); | ||
1397 | cursorSurface->attachBuffer(m_shm->createBuffer(blue)); | 1397 | cursorSurface->attachBuffer(m_shm->createBuffer(blue)); | ||
1398 | cursorSurface->damage(QRect(0, 0, 10, 10)); | 1398 | cursorSurface->damage(QRect(0, 0, 10, 10)); | ||
1399 | cursorSurface->commit(Surface::CommitFlag::None); | 1399 | cursorSurface->commit(Surface::CommitFlag::None); | ||
1400 | QVERIFY(cursorChangedSpy.wait()); | 1400 | QVERIFY(cursorChangedSpy.wait()); | ||
1401 | QCOMPARE(pointer->cursor()->surface()->buffer()->data(), blue); | 1401 | QCOMPARE(pointer->cursor()->surface()->buffer()->data(), blue); | ||
1402 | } | 1402 | } | ||
1403 | 1403 | | |||
▲ Show 20 Lines • Show All 893 Lines • Show Last 20 Lines |