Commit ff806d16 authored by Martin Flöser's avatar Martin Flöser
Browse files

Move focused pointer surface API to SeatInterface

There can only be one focused surface per Seat, thus the information
should be hold in the seat.

This only adjusts the API, the actual data is still hold in the
PointerInterface. This still needs adjustment.
parent 41fbb0a6
......@@ -236,7 +236,7 @@ void TestDataDevice::testDrag()
QVERIFY(dragStartedSpy.isValid());
// first we need to fake the pointer enter
m_seatInterface->pointer()->setFocusedSurface(surfaceInterface);
m_seatInterface->setFocusedPointerSurface(surfaceInterface);
m_seatInterface->pointer()->buttonPressed(1);
QCoreApplication::processEvents();
......@@ -288,7 +288,7 @@ void TestDataDevice::testDragInternally()
QVERIFY(dragStartedSpy.isValid());
// first we need to fake the pointer enter
m_seatInterface->pointer()->setFocusedSurface(surfaceInterface);
m_seatInterface->setFocusedPointerSurface(surfaceInterface);
m_seatInterface->pointer()->buttonPressed(1);
QCoreApplication::processEvents();
......
......@@ -284,9 +284,9 @@ void TestWaylandSeat::testPointer()
PointerInterface *serverPointer = m_seatInterface->pointer();
serverPointer->setGlobalPos(QPoint(20, 18));
serverPointer->setFocusedSurface(serverSurface, QPoint(10, 15));
m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(10, 15));
// no pointer yet - won't be set
QVERIFY(!serverPointer->focusedSurface());
QVERIFY(!m_seatInterface->focusedPointerSurface());
Pointer *p = m_seat->createPointer(m_seat);
QVERIFY(p->isValid());
......@@ -308,8 +308,8 @@ void TestWaylandSeat::testPointer()
QSignalSpy buttonSpy(p, SIGNAL(buttonStateChanged(quint32,quint32,quint32,KWayland::Client::Pointer::ButtonState)));
QVERIFY(buttonSpy.isValid());
serverPointer->setFocusedSurface(serverSurface, QPoint(10, 15));
QCOMPARE(serverPointer->focusedSurface(), serverSurface);
m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(10, 15));
QCOMPARE(m_seatInterface->focusedPointerSurface(), serverSurface);
QVERIFY(enteredSpy.wait());
QCOMPARE(enteredSpy.first().first().value<quint32>(), m_display->serial());
QCOMPARE(enteredSpy.first().last().toPoint(), QPoint(10, 3));
......@@ -381,18 +381,18 @@ void TestWaylandSeat::testPointer()
QCOMPARE(buttonSpy.at(3).at(3).value<KWayland::Client::Pointer::ButtonState>(), KWayland::Client::Pointer::ButtonState::Released);
// leave the surface
serverPointer->setFocusedSurface(nullptr);
m_seatInterface->setFocusedPointerSurface(nullptr);
QVERIFY(leftSpy.wait());
QCOMPARE(leftSpy.first().first().value<quint32>(), m_display->serial());
// enter it again
serverPointer->setFocusedSurface(serverSurface, QPoint(0, 0));
m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(0, 0));
QVERIFY(enteredSpy.wait());
delete s;
wl_display_flush(m_connection->display());
QTest::qWait(100);
QVERIFY(!serverPointer->focusedSurface());
QVERIFY(!m_seatInterface->focusedPointerSurface());
}
Q_DECLARE_METATYPE(Qt::MouseButton)
......@@ -452,9 +452,9 @@ void TestWaylandSeat::testPointerButton()
PointerInterface *serverPointer = m_seatInterface->pointer();
serverPointer->setGlobalPos(QPoint(20, 18));
serverPointer->setFocusedSurface(serverSurface, QPoint(10, 15));
m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(10, 15));
// no pointer yet - won't be set
QVERIFY(serverPointer->focusedSurface());
QVERIFY(m_seatInterface->focusedPointerSurface());
QFETCH(Qt::MouseButton, qtButton);
QFETCH(quint32, waylandButton);
......
......@@ -84,7 +84,7 @@ void DataDeviceInterface::Private::startDragCallback(wl_client *client, wl_resou
void DataDeviceInterface::Private::startDrag(DataSourceInterface *dataSource, SurfaceInterface *origin, SurfaceInterface *i)
{
if (seat->pointer()->focusedSurface() != origin) {
if (seat->focusedPointerSurface() != origin) {
wl_resource_post_error(resource, 0, "Surface doesn't have pointer grab");
return;
}
......
......@@ -65,9 +65,7 @@ public:
quint32 buttonSerial(Qt::MouseButton button) const;
void axis(Qt::Orientation orientation, quint32 delta);
void setFocusedSurface(SurfaceInterface *surface, const QPoint &surfacePosition = QPoint());
void setFocusedSurfacePosition(const QPoint &surfacePosition);
SurfaceInterface *focusedSurface() const;
QPoint focusedSurfacePosition() const;
Q_SIGNALS:
......@@ -78,6 +76,8 @@ Q_SIGNALS:
void globalPosChanged(const QPointF &pos);
private:
void setFocusedSurface(SurfaceInterface *surface, const QPoint &surfacePosition = QPoint());
SurfaceInterface *focusedSurface() const;
friend class SeatInterface;
explicit PointerInterface(SeatInterface *parent);
class Private;
......
......@@ -303,5 +303,17 @@ void SeatInterface::setTimestamp(quint32 time)
emit timestampChanged(time);
}
SurfaceInterface *SeatInterface::focusedPointerSurface() const
{
Q_D();
return d->pointerInterface->focusedSurface();
}
void SeatInterface::setFocusedPointerSurface(SurfaceInterface *surface, const QPoint &surfacePosition)
{
Q_D();
d->pointerInterface->setFocusedSurface(surface, surfacePosition);
}
}
}
......@@ -69,6 +69,8 @@ public:
// pointer related methods
void setPointerPos(const QPointF &pos);
QPointF pointerPos() const;
void setFocusedPointerSurface(SurfaceInterface *surface, const QPoint &surfacePosition = QPoint());
SurfaceInterface *focusedPointerSurface() const;
static SeatInterface *get(wl_resource *native);
......
......@@ -134,9 +134,9 @@ void CompositorWindow::mouseMoveEvent(QMouseEvent *event)
{
QWidget::mouseMoveEvent(event);
const auto pointer = m_seat->pointer();
if (!pointer->focusedSurface()) {
if (!m_seat->focusedPointerSurface()) {
if (!m_stackingOrder.isEmpty()) {
pointer->setFocusedSurface(m_stackingOrder.last()->surface());
m_seat->setFocusedPointerSurface(m_stackingOrder.last()->surface());
}
}
m_seat->setTimestamp(event->timestamp());
......@@ -147,9 +147,9 @@ void CompositorWindow::mousePressEvent(QMouseEvent *event)
{
QWidget::mousePressEvent(event);
const auto pointer = m_seat->pointer();
if (!pointer->focusedSurface()) {
if (!m_seat->focusedPointerSurface()) {
if (!m_stackingOrder.isEmpty()) {
pointer->setFocusedSurface(m_stackingOrder.last()->surface());
m_seat->setFocusedPointerSurface(m_stackingOrder.last()->surface());
}
}
m_seat->setTimestamp(event->timestamp());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment