Client tests: Add convenience for getting cursor surface
Let's simplify all those pointer()->surfaceCursor() calls. Change-Id: I83c51f460fa2313a0b84c8c64509d48027156443 Reviewed-by: Giulio Camuffo <giulio.camuffo@kdab.com>
This commit is contained in:
parent
446a9753ab
commit
ecd0d448fa
@ -133,7 +133,7 @@ void tst_seatv4::setsCursorOnEnter()
|
|||||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||||
|
|
||||||
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_seatv4::usesEnterSerial()
|
void tst_seatv4::usesEnterSerial()
|
||||||
@ -339,20 +339,20 @@ void tst_seatv4::scaledCursor()
|
|||||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||||
|
|
||||||
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface());
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
|
||||||
QCOMPOSITOR_TRY_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 1);
|
QCOMPOSITOR_TRY_COMPARE(cursorSurface()->m_committed.bufferScale, 1);
|
||||||
QSize unscaledPixelSize = exec([=] {
|
QSize unscaledPixelSize = exec([=] {
|
||||||
return pointer()->cursorSurface()->m_committed.buffer->size();
|
return cursorSurface()->m_committed.buffer->size();
|
||||||
});
|
});
|
||||||
|
|
||||||
exec([=] {
|
exec([=] {
|
||||||
auto *surface = pointer()->cursorSurface();
|
auto *surface = cursorSurface();
|
||||||
surface->sendEnter(getAll<Output>()[1]);
|
surface->sendEnter(getAll<Output>()[1]);
|
||||||
surface->sendLeave(getAll<Output>()[0]);
|
surface->sendLeave(getAll<Output>()[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
QCOMPOSITOR_TRY_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), unscaledPixelSize * 2);
|
QCOMPOSITOR_TRY_COMPARE(cursorSurface()->m_committed.buffer->size(), unscaledPixelSize * 2);
|
||||||
|
|
||||||
// Remove the extra output to clean up for the next test
|
// Remove the extra output to clean up for the next test
|
||||||
exec([&] { remove(output(1)); });
|
exec([&] { remove(output(1)); });
|
||||||
@ -380,11 +380,11 @@ void tst_seatv4::unscaledFallbackCursor()
|
|||||||
window.show();
|
window.show();
|
||||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||||
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface());
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
|
||||||
QCOMPOSITOR_TRY_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 1);
|
QCOMPOSITOR_TRY_COMPARE(cursorSurface()->m_committed.bufferScale, 1);
|
||||||
QSize unscaledPixelSize = exec([=] {
|
QSize unscaledPixelSize = exec([=] {
|
||||||
return pointer()->cursorSurface()->m_committed.buffer->size();
|
return cursorSurface()->m_committed.buffer->size();
|
||||||
});
|
});
|
||||||
|
|
||||||
QCOMPARE(unscaledPixelSize.width(), int(defaultSize));
|
QCOMPARE(unscaledPixelSize.width(), int(defaultSize));
|
||||||
@ -392,7 +392,7 @@ void tst_seatv4::unscaledFallbackCursor()
|
|||||||
|
|
||||||
for (int i = 1; i < screens; ++i) {
|
for (int i = 1; i < screens; ++i) {
|
||||||
exec([=] {
|
exec([=] {
|
||||||
auto *surface = pointer()->cursorSurface();
|
auto *surface = cursorSurface();
|
||||||
surface->sendEnter(getAll<Output>()[i]);
|
surface->sendEnter(getAll<Output>()[i]);
|
||||||
surface->sendLeave(getAll<Output>()[i-1]);
|
surface->sendLeave(getAll<Output>()[i-1]);
|
||||||
});
|
});
|
||||||
@ -400,7 +400,7 @@ void tst_seatv4::unscaledFallbackCursor()
|
|||||||
xdgPingAndWaitForPong(); // Give the client a chance to mess up
|
xdgPingAndWaitForPong(); // Give the client a chance to mess up
|
||||||
|
|
||||||
// Surface size (buffer size / scale) should stay constant
|
// Surface size (buffer size / scale) should stay constant
|
||||||
QCOMPOSITOR_TRY_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size() / pointer()->cursorSurface()->m_committed.bufferScale, unscaledPixelSize);
|
QCOMPOSITOR_TRY_COMPARE(cursorSurface()->m_committed.buffer->size() / cursorSurface()->m_committed.bufferScale, unscaledPixelSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the extra outputs to clean up for the next test
|
// Remove the extra outputs to clean up for the next test
|
||||||
@ -430,14 +430,14 @@ void tst_seatv4::bitmapCursor()
|
|||||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||||
|
|
||||||
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface());
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(24, 24));
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(24, 24));
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 1);
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 1);
|
||||||
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
|
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
|
||||||
|
|
||||||
exec([=] {
|
exec([=] {
|
||||||
auto *surface = pointer()->cursorSurface();
|
auto *surface = cursorSurface();
|
||||||
surface->sendEnter(getAll<Output>()[1]);
|
surface->sendEnter(getAll<Output>()[1]);
|
||||||
surface->sendLeave(getAll<Output>()[0]);
|
surface->sendLeave(getAll<Output>()[0]);
|
||||||
});
|
});
|
||||||
@ -445,8 +445,8 @@ void tst_seatv4::bitmapCursor()
|
|||||||
xdgPingAndWaitForPong();
|
xdgPingAndWaitForPong();
|
||||||
|
|
||||||
// Everything should remain the same, the cursor still has dpr 1
|
// Everything should remain the same, the cursor still has dpr 1
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 1);
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 1);
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(24, 24));
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(24, 24));
|
||||||
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
|
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
|
||||||
|
|
||||||
// Remove the extra output to clean up for the next test
|
// Remove the extra output to clean up for the next test
|
||||||
@ -476,22 +476,22 @@ void tst_seatv4::hidpiBitmapCursor()
|
|||||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||||
|
|
||||||
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface());
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(48, 48));
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(48, 48));
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 2);
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 2);
|
||||||
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
|
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
|
||||||
|
|
||||||
exec([=] {
|
exec([=] {
|
||||||
auto *surface = pointer()->cursorSurface();
|
auto *surface = cursorSurface();
|
||||||
surface->sendEnter(getAll<Output>()[1]);
|
surface->sendEnter(getAll<Output>()[1]);
|
||||||
surface->sendLeave(getAll<Output>()[0]);
|
surface->sendLeave(getAll<Output>()[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
xdgPingAndWaitForPong();
|
xdgPingAndWaitForPong();
|
||||||
|
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 2);
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 2);
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(48, 48));
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(48, 48));
|
||||||
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
|
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(12, 12));
|
||||||
|
|
||||||
// Remove the extra output to clean up for the next test
|
// Remove the extra output to clean up for the next test
|
||||||
@ -513,10 +513,10 @@ void tst_seatv4::hidpiBitmapCursorNonInt()
|
|||||||
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
QCOMPOSITOR_TRY_VERIFY(xdgSurface() && xdgSurface()->m_committedConfigureSerial);
|
||||||
|
|
||||||
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
exec([=] { pointer()->sendEnter(xdgSurface()->m_surface, {32, 32}); });
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface());
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface());
|
||||||
QCOMPOSITOR_TRY_VERIFY(pointer()->cursorSurface()->m_committed.buffer);
|
QCOMPOSITOR_TRY_VERIFY(cursorSurface()->m_committed.buffer);
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.buffer->size(), QSize(100, 100));
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.buffer->size(), QSize(100, 100));
|
||||||
QCOMPOSITOR_COMPARE(pointer()->cursorSurface()->m_committed.bufferScale, 2);
|
QCOMPOSITOR_COMPARE(cursorSurface()->m_committed.bufferScale, 2);
|
||||||
// Verify that the hotspot was scaled correctly
|
// Verify that the hotspot was scaled correctly
|
||||||
// Surface size is now 100 / 2 = 50, so the middle should be at 25 in surface coordinates
|
// Surface size is now 100 / 2 = 50, so the middle should be at 25 in surface coordinates
|
||||||
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(25, 25));
|
QCOMPOSITOR_COMPARE(pointer()->m_hotspot, QPoint(25, 25));
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
XdgToplevel *xdgToplevel(int i = 0) { return get<XdgWmBase>()->toplevel(i); }
|
XdgToplevel *xdgToplevel(int i = 0) { return get<XdgWmBase>()->toplevel(i); }
|
||||||
XdgPopup *xdgPopup(int i = 0) { return get<XdgWmBase>()->popup(i); }
|
XdgPopup *xdgPopup(int i = 0) { return get<XdgWmBase>()->popup(i); }
|
||||||
Pointer *pointer() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_pointer; }
|
Pointer *pointer() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_pointer; }
|
||||||
|
Surface *cursorSurface() { auto *p = pointer(); return p ? p->cursorSurface() : nullptr; }
|
||||||
Keyboard *keyboard() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_keyboard; }
|
Keyboard *keyboard() { auto *seat = get<Seat>(); Q_ASSERT(seat); return seat->m_keyboard; }
|
||||||
uint sendXdgShellPing();
|
uint sendXdgShellPing();
|
||||||
void xdgPingAndWaitForPong();
|
void xdgPingAndWaitForPong();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user