diff --git a/abstract_backend.cpp b/abstract_backend.cpp
index 7b062fbe83..55e7c583b9 100644
--- a/abstract_backend.cpp
+++ b/abstract_backend.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see .
#include
#include "composite.h"
#include "cursor.h"
+#include "input.h"
#include "wayland_server.h"
#if HAVE_WAYLAND_CURSOR
#include "wayland_backend.h"
@@ -179,4 +180,116 @@ void AbstractBackend::markCursorAsRendered()
m_cursor.lastRenderedPosition = Cursor::pos();
}
+void AbstractBackend::keyboardKeyPressed(quint32 key, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processKeyboardKey(key, InputRedirection::KeyboardKeyPressed, time);
+}
+
+void AbstractBackend::keyboardKeyReleased(quint32 key, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processKeyboardKey(key, InputRedirection::KeyboardKeyReleased, time);
+}
+
+void AbstractBackend::keyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processKeyboardModifiers(modsDepressed, modsLatched, modsLocked, group);
+}
+
+void AbstractBackend::keymapChange(int fd, uint32_t size)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processKeymapChange(fd, size);
+}
+
+void AbstractBackend::pointerAxisHorizontal(qreal delta, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processPointerAxis(InputRedirection::PointerAxisHorizontal, delta, time);
+}
+
+void AbstractBackend::pointerAxisVertical(qreal delta, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processPointerAxis(InputRedirection::PointerAxisVertical, delta, time);
+}
+
+void AbstractBackend::pointerButtonPressed(quint32 button, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processPointerButton(button, InputRedirection::PointerButtonPressed, time);
+}
+
+void AbstractBackend::pointerButtonReleased(quint32 button, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processPointerButton(button, InputRedirection::PointerButtonReleased, time);
+}
+
+void AbstractBackend::pointerMotion(const QPointF &position, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processPointerMotion(position, time);
+}
+
+void AbstractBackend::touchCancel()
+{
+ if (!input()) {
+ return;
+ }
+ input()->cancelTouch();
+}
+
+void AbstractBackend::touchDown(qint32 id, const QPointF &pos, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processTouchDown(id, pos, time);
+}
+
+void AbstractBackend::touchFrame()
+{
+ if (!input()) {
+ return;
+ }
+ input()->touchFrame();
+}
+
+void AbstractBackend::touchMotion(qint32 id, const QPointF &pos, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processTouchMotion(id, pos, time);
+}
+
+void AbstractBackend::touchUp(qint32 id, quint32 time)
+{
+ if (!input()) {
+ return;
+ }
+ input()->processTouchUp(id, time);
+}
+
}
diff --git a/abstract_backend.h b/abstract_backend.h
index 8ab841e774..6819f3dbac 100644
--- a/abstract_backend.h
+++ b/abstract_backend.h
@@ -62,6 +62,21 @@ public:
return m_handlesOutputs;
}
+ void pointerMotion(const QPointF &position, quint32 time);
+ void pointerButtonPressed(quint32 button, quint32 time);
+ void pointerButtonReleased(quint32 button, quint32 time);
+ void pointerAxisHorizontal(qreal delta, quint32 time);
+ void pointerAxisVertical(qreal delta, quint32 time);
+ void keyboardKeyPressed(quint32 key, quint32 time);
+ void keyboardKeyReleased(quint32 key, quint32 time);
+ void keyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
+ void keymapChange(int fd, uint32_t size);
+ void touchDown(qint32 id, const QPointF &pos, quint32 time);
+ void touchUp(qint32 id, quint32 time);
+ void touchMotion(qint32 id, const QPointF &pos, quint32 time);
+ void touchCancel();
+ void touchFrame();
+
Q_SIGNALS:
void cursorChanged();
diff --git a/wayland_backend.cpp b/wayland_backend.cpp
index 1dbd096e2b..64b4800d1b 100644
--- a/wayland_backend.cpp
+++ b/wayland_backend.cpp
@@ -21,7 +21,6 @@ along with this program. If not, see .
#include "wayland_backend.h"
// KWin
#include "cursor.h"
-#include "input.h"
#include "main.h"
#include "scene_qpainter.h"
#include "screens_wayland.h"
@@ -87,26 +86,26 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
m_keyboard = m_seat->createKeyboard(this);
connect(m_keyboard, &Keyboard::keyChanged, this,
[this](quint32 key, Keyboard::KeyState state, quint32 time) {
- auto toState = [state] {
- switch (state) {
- case Keyboard::KeyState::Pressed:
- return InputRedirection::KeyboardKeyPressed;
- case Keyboard::KeyState::Released:
- return InputRedirection::KeyboardKeyReleased;
- }
- abort();
- };
- input()->processKeyboardKey(key, toState(), time);
+ switch (state) {
+ case Keyboard::KeyState::Pressed:
+ m_backend->keyboardKeyPressed(key, time);
+ break;
+ case Keyboard::KeyState::Released:
+ m_backend->keyboardKeyReleased(key, time);
+ break;
+ default:
+ Q_UNREACHABLE();
+ }
}
);
connect(m_keyboard, &Keyboard::modifiersChanged, this,
[this](quint32 depressed, quint32 latched, quint32 locked, quint32 group) {
- input()->processKeyboardModifiers(depressed, latched, locked, group);
+ m_backend->keyboardModifiers(depressed, latched, locked, group);
}
);
connect(m_keyboard, &Keyboard::keymapChanged, this,
[this](int fd, quint32 size) {
- input()->processKeymapChange(fd, size);
+ m_backend->keymapChange(fd, size);
}
);
} else {
@@ -129,36 +128,36 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
);
connect(m_pointer, &Pointer::motion, this,
[this](const QPointF &relativeToSurface, quint32 time) {
- input()->processPointerMotion(relativeToSurface.toPoint(), time);
+ m_backend->pointerMotion(relativeToSurface, time);
}
);
connect(m_pointer, &Pointer::buttonStateChanged, this,
[this](quint32 serial, quint32 time, quint32 button, Pointer::ButtonState state) {
Q_UNUSED(serial)
- auto toState = [state] {
- switch (state) {
- case Pointer::ButtonState::Pressed:
- return InputRedirection::PointerButtonPressed;
- case Pointer::ButtonState::Released:
- return InputRedirection::PointerButtonReleased;
- }
- abort();
- };
- input()->processPointerButton(button, toState(), time);
+ switch (state) {
+ case Pointer::ButtonState::Pressed:
+ m_backend->pointerButtonPressed(button, time);
+ break;
+ case Pointer::ButtonState::Released:
+ m_backend->pointerButtonReleased(button, time);
+ break;
+ default:
+ Q_UNREACHABLE();
+ }
}
);
connect(m_pointer, &Pointer::axisChanged, this,
[this](quint32 time, Pointer::Axis axis, qreal delta) {
- auto toAxis = [axis] {
- switch (axis) {
- case Pointer::Axis::Horizontal:
- return InputRedirection::PointerAxisHorizontal;
- case Pointer::Axis::Vertical:
- return InputRedirection::PointerAxisVertical;
- }
- abort();
- };
- input()->processPointerAxis(toAxis(), delta, time);
+ switch (axis) {
+ case Pointer::Axis::Horizontal:
+ m_backend->pointerAxisHorizontal(delta, time);
+ break;
+ case Pointer::Axis::Vertical:
+ m_backend->pointerAxisVertical(delta, time);
+ break;
+ default:
+ Q_UNREACHABLE();
+ }
}
);
} else {
@@ -170,26 +169,26 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
[this] (bool hasTouch) {
if (hasTouch && !m_touch) {
m_touch = m_seat->createTouch(this);
- connect(m_touch, &Touch::sequenceCanceled, input(), &InputRedirection::cancelTouch);
- connect(m_touch, &Touch::frameEnded, input(), &InputRedirection::touchFrame);
+ connect(m_touch, &Touch::sequenceCanceled, m_backend, &AbstractBackend::touchCancel);
+ connect(m_touch, &Touch::frameEnded, m_backend, &AbstractBackend::touchFrame);
connect(m_touch, &Touch::sequenceStarted, this,
- [] (TouchPoint *tp) {
- input()->processTouchDown(tp->id(), tp->position(), tp->time());
+ [this] (TouchPoint *tp) {
+ m_backend->touchDown(tp->id(), tp->position(), tp->time());
}
);
connect(m_touch, &Touch::pointAdded, this,
- [] (TouchPoint *tp) {
- input()->processTouchDown(tp->id(), tp->position(), tp->time());
+ [this] (TouchPoint *tp) {
+ m_backend->touchDown(tp->id(), tp->position(), tp->time());
}
);
connect(m_touch, &Touch::pointRemoved, this,
- [] (TouchPoint *tp) {
- input()->processTouchUp(tp->id(), tp->time());
+ [this] (TouchPoint *tp) {
+ m_backend->touchUp(tp->id(), tp->time());
}
);
connect(m_touch, &Touch::pointMoved, this,
- [] (TouchPoint *tp) {
- input()->processTouchMotion(tp->id(), tp->position(), tp->time());
+ [this] (TouchPoint *tp) {
+ m_backend->touchMotion(tp->id(), tp->position(), tp->time());
}
);
} else {
diff --git a/x11windowed_backend.cpp b/x11windowed_backend.cpp
index 197fa36251..4fbe39e3da 100644
--- a/x11windowed_backend.cpp
+++ b/x11windowed_backend.cpp
@@ -19,7 +19,6 @@ along with this program. If not, see .
*********************************************************************/
#include "x11windowed_backend.h"
#include "composite.h"
-#include "input.h"
#include "scene_qpainter.h"
#include "screens_x11windowed.h"
#include "utils.h"
@@ -150,26 +149,27 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e)
case XCB_BUTTON_RELEASE:
handleButtonPress(reinterpret_cast(e));
break;
- case XCB_MOTION_NOTIFY:
- if (input()) {
+ case XCB_MOTION_NOTIFY: {
auto event = reinterpret_cast(e);
- input()->processPointerMotion(QPointF(event->event_x, event->event_y), event->time);
+ pointerMotion(QPointF(event->event_x, event->event_y), event->time);
}
break;
case XCB_KEY_PRESS:
- case XCB_KEY_RELEASE:
- if (input()) {
+ case XCB_KEY_RELEASE: {
auto event = reinterpret_cast(e);
- input()->processKeyboardKey(event->detail - 8, eventType == XCB_KEY_PRESS ? InputRedirection::KeyboardKeyPressed : InputRedirection::KeyboardKeyReleased, event->time);
+ if (eventType == XCB_KEY_PRESS) {
+ keyboardKeyPressed(event->detail - 8, event->time);
+ } else {
+ keyboardKeyReleased(event->detail - 8, event->time);
+ }
}
break;
case XCB_CONFIGURE_NOTIFY:
updateSize(reinterpret_cast(e));
break;
- case XCB_ENTER_NOTIFY:
- if (input()) {
+ case XCB_ENTER_NOTIFY: {
auto event = reinterpret_cast(e);
- input()->processPointerMotion(QPointF(event->event_x, event->event_y), event->time);
+ pointerMotion(QPointF(event->event_x, event->event_y), event->time);
}
break;
case XCB_CLIENT_MESSAGE:
@@ -208,9 +208,12 @@ void X11WindowedBackend::handleButtonPress(xcb_button_press_event_t *event)
return;
}
const int delta = (event->detail == XCB_BUTTON_INDEX_4 || event->detail == 6) ? -1 : 1;
- InputRedirection::PointerAxis axis = (event->detail > 5) ? InputRedirection::PointerAxisHorizontal : InputRedirection::PointerAxisVertical;
static const qreal s_defaultAxisStepDistance = 10.0;
- input()->processPointerAxis(axis, delta * s_defaultAxisStepDistance, event->time);
+ if (event->detail > 5) {
+ pointerAxisHorizontal(delta * s_defaultAxisStepDistance, event->time);
+ } else {
+ pointerAxisVertical(delta * s_defaultAxisStepDistance, event->time);
+ }
return;
}
uint32_t button = 0;
@@ -228,8 +231,12 @@ void X11WindowedBackend::handleButtonPress(xcb_button_press_event_t *event)
button = event->detail + BTN_LEFT - 1;
return;
}
- input()->processPointerMotion(QPointF(event->event_x, event->event_y), event->time);
- input()->processPointerButton(button, pressed ? InputRedirection::PointerButtonPressed : InputRedirection::PointerButtonReleased, event->time);
+ pointerMotion(QPointF(event->event_x, event->event_y), event->time);
+ if (pressed) {
+ pointerButtonPressed(button, event->time);
+ } else {
+ pointerButtonReleased(button, event->time);
+ }
}
void X11WindowedBackend::handleExpose(xcb_expose_event_t *event)