wayland: Remove absolute position from processMotion() that handles relative moves
API-wise it's odd to require absolute position with relative pointer moves. This cleans up some of InputRedirection code by making it simply forward pointer input events from input devices to the pointer input device handler, which knows better what to do with the delta value. The pointer input device handler will compute the absolute position based on the specified delta value, but it could also do something else, e.g. not move the pointer at all if it's locked, etc.
This commit is contained in:
parent
8adfd2f244
commit
dda0c24187
3 changed files with 26 additions and 27 deletions
|
@ -1832,7 +1832,7 @@ public:
|
|||
switch (event->type()) {
|
||||
case QEvent::TabletMove:
|
||||
case QEvent::TabletEnterProximity:
|
||||
input()->pointer()->processMotion(event->globalPosF(), event->timestamp());
|
||||
input()->pointer()->processMotionAbsolute(event->globalPosF(), event->timestamp());
|
||||
break;
|
||||
case QEvent::TabletPress:
|
||||
input()->pointer()->processButton(KWin::qtMouseButtonToButton(Qt::LeftButton),
|
||||
|
@ -2197,14 +2197,14 @@ void InputRedirection::setupWorkspace()
|
|||
connect(device, &FakeInputDevice::pointerMotionRequested, this,
|
||||
[this] (const QSizeF &delta) {
|
||||
// TODO: Fix time
|
||||
m_pointer->processMotion(globalPointer() + QPointF(delta.width(), delta.height()), 0);
|
||||
m_pointer->processMotionAbsolute(globalPointer() + QPointF(delta.width(), delta.height()), 0);
|
||||
waylandServer()->simulateUserActivity();
|
||||
}
|
||||
);
|
||||
connect(device, &FakeInputDevice::pointerMotionAbsoluteRequested, this,
|
||||
[this] (const QPointF &pos) {
|
||||
// TODO: Fix time
|
||||
m_pointer->processMotion(pos, 0);
|
||||
m_pointer->processMotionAbsolute(pos, 0);
|
||||
waylandServer()->simulateUserActivity();
|
||||
}
|
||||
);
|
||||
|
@ -2414,16 +2414,8 @@ void InputRedirection::setupLibInput()
|
|||
connect(conn, &LibInput::Connection::swipeGestureEnd, m_pointer, &PointerInputRedirection::processSwipeGestureEnd);
|
||||
connect(conn, &LibInput::Connection::swipeGestureCancelled, m_pointer, &PointerInputRedirection::processSwipeGestureCancelled);
|
||||
connect(conn, &LibInput::Connection::keyChanged, m_keyboard, &KeyboardInputRedirection::processKey);
|
||||
connect(conn, &LibInput::Connection::pointerMotion, this,
|
||||
[this] (const QSizeF &delta, const QSizeF &deltaNonAccel, uint32_t time, quint64 timeMicroseconds, LibInput::Device *device) {
|
||||
m_pointer->processMotion(m_pointer->pos() + QPointF(delta.width(), delta.height()), delta, deltaNonAccel, time, timeMicroseconds, device);
|
||||
}
|
||||
);
|
||||
connect(conn, &LibInput::Connection::pointerMotionAbsolute, this,
|
||||
[this] (const QPointF &position, uint32_t time, LibInput::Device *device) {
|
||||
m_pointer->processMotion(position, time, device);
|
||||
}
|
||||
);
|
||||
connect(conn, &LibInput::Connection::pointerMotion, m_pointer, &PointerInputRedirection::processMotion);
|
||||
connect(conn, &LibInput::Connection::pointerMotionAbsolute, m_pointer, &PointerInputRedirection::processMotionAbsolute);
|
||||
connect(conn, &LibInput::Connection::touchDown, m_touch, &TouchInputRedirection::processDown);
|
||||
connect(conn, &LibInput::Connection::touchUp, m_touch, &TouchInputRedirection::processUp);
|
||||
connect(conn, &LibInput::Connection::touchMotion, m_touch, &TouchInputRedirection::processMotion);
|
||||
|
@ -2576,7 +2568,7 @@ void InputRedirection::setupLibInputWithScreens()
|
|||
|
||||
void InputRedirection::processPointerMotion(const QPointF &pos, uint32_t time)
|
||||
{
|
||||
m_pointer->processMotion(pos, time);
|
||||
m_pointer->processMotionAbsolute(pos, time);
|
||||
}
|
||||
|
||||
void InputRedirection::processPointerButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time)
|
||||
|
|
|
@ -199,11 +199,6 @@ void PointerInputRedirection::updateToReset()
|
|||
waylandServer()->seat()->setFocusedPointerSurface(nullptr);
|
||||
}
|
||||
|
||||
void PointerInputRedirection::processMotion(const QPointF &pos, uint32_t time, LibInput::Device *device)
|
||||
{
|
||||
processMotion(pos, QSizeF(), QSizeF(), time, 0, device);
|
||||
}
|
||||
|
||||
class PositionUpdateBlocker
|
||||
{
|
||||
public:
|
||||
|
@ -217,7 +212,7 @@ public:
|
|||
if (s_counter == 0) {
|
||||
if (!s_scheduledPositions.isEmpty()) {
|
||||
const auto pos = s_scheduledPositions.takeFirst();
|
||||
m_pointer->processMotion(pos.pos, pos.delta, pos.deltaNonAccelerated, pos.time, pos.timeUsec, nullptr);
|
||||
m_pointer->processMotionInternal(pos.pos, pos.delta, pos.deltaNonAccelerated, pos.time, pos.timeUsec, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +242,17 @@ private:
|
|||
int PositionUpdateBlocker::s_counter = 0;
|
||||
QVector<PositionUpdateBlocker::ScheduledPosition> PositionUpdateBlocker::s_scheduledPositions;
|
||||
|
||||
void PointerInputRedirection::processMotion(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, LibInput::Device *device)
|
||||
void PointerInputRedirection::processMotionAbsolute(const QPointF &pos, uint32_t time, LibInput::Device *device)
|
||||
{
|
||||
processMotionInternal(pos, QSizeF(), QSizeF(), time, 0, device);
|
||||
}
|
||||
|
||||
void PointerInputRedirection::processMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, LibInput::Device *device)
|
||||
{
|
||||
processMotionInternal(m_pos + QPointF(delta.width(), delta.height()), delta, deltaNonAccelerated, time, timeUsec, device);
|
||||
}
|
||||
|
||||
void PointerInputRedirection::processMotionInternal(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, LibInput::Device *device)
|
||||
{
|
||||
m_lastEventTime = time;
|
||||
if (!inited()) {
|
||||
|
@ -717,7 +722,7 @@ void PointerInputRedirection::updatePointerConstraints()
|
|||
m_locked = false;
|
||||
disconnectLockedPointerAboutToBeUnboundConnection();
|
||||
if (! (hint.x() < 0 || hint.y() < 0) && focus()) {
|
||||
processMotion(focus()->mapFromLocal(hint), waylandServer()->seat()->timestamp());
|
||||
processMotionAbsolute(focus()->mapFromLocal(hint), waylandServer()->seat()->timestamp());
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -740,7 +745,7 @@ void PointerInputRedirection::updatePointerConstraints()
|
|||
// When the resource finally goes away, reposition the cursor according to the hint
|
||||
connect(lock, &KWaylandServer::LockedPointerV1Interface::destroyed, this,
|
||||
[this, globalHint]() {
|
||||
processMotion(globalHint, waylandServer()->seat()->timestamp());
|
||||
processMotionAbsolute(globalHint, waylandServer()->seat()->timestamp());
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -890,7 +895,7 @@ void PointerInputRedirection::warp(const QPointF &pos)
|
|||
{
|
||||
if (supportsWarping()) {
|
||||
kwinApp()->platform()->warpPointer(pos);
|
||||
processMotion(pos, waylandServer()->seat()->timestamp());
|
||||
processMotionAbsolute(pos, waylandServer()->seat()->timestamp());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -920,7 +925,7 @@ void PointerInputRedirection::updateAfterScreenChange()
|
|||
// pointer no longer on a screen, reposition to closes screen
|
||||
const AbstractOutput *output = kwinApp()->platform()->outputAt(m_pos.toPoint());
|
||||
// TODO: better way to get timestamps
|
||||
processMotion(output->geometry().center(), waylandServer()->seat()->timestamp());
|
||||
processMotionAbsolute(output->geometry().center(), waylandServer()->seat()->timestamp());
|
||||
}
|
||||
|
||||
QPointF PointerInputRedirection::position() const
|
||||
|
|
|
@ -86,11 +86,11 @@ public:
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
void processMotion(const QPointF &pos, uint32_t time, LibInput::Device *device = nullptr);
|
||||
void processMotionAbsolute(const QPointF &pos, uint32_t time, LibInput::Device *device = nullptr);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
void processMotion(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, LibInput::Device *device);
|
||||
void processMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, LibInput::Device *device);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
@ -133,6 +133,7 @@ public:
|
|||
void processPinchGestureCancelled(quint32 time, KWin::LibInput::Device *device = nullptr);
|
||||
|
||||
private:
|
||||
void processMotionInternal(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, LibInput::Device *device);
|
||||
void cleanupInternalWindow(QWindow *old, QWindow *now) override;
|
||||
void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) override;
|
||||
|
||||
|
@ -165,6 +166,7 @@ private:
|
|||
bool m_confined = false;
|
||||
bool m_locked = false;
|
||||
bool m_enableConstraints = true;
|
||||
friend class PositionUpdateBlocker;
|
||||
};
|
||||
|
||||
class WaylandCursorImage : public QObject
|
||||
|
|
Loading…
Reference in a new issue