Simplify input event flow
Currently, input events can flow directly to input device handlers and sometimes they go through the InputRedirection, which simply forwards them to the corresponding input device handler.
This commit is contained in:
parent
bbe879988d
commit
e83da51844
3 changed files with 20 additions and 119 deletions
|
@ -743,14 +743,14 @@ public:
|
||||||
m_active = true;
|
m_active = true;
|
||||||
m_callback = callback;
|
m_callback = callback;
|
||||||
input()->keyboard()->update();
|
input()->keyboard()->update();
|
||||||
input()->cancelTouch();
|
input()->touch()->cancel();
|
||||||
}
|
}
|
||||||
void start(std::function<void(const QPoint &)> callback) {
|
void start(std::function<void(const QPoint &)> callback) {
|
||||||
Q_ASSERT(!m_active);
|
Q_ASSERT(!m_active);
|
||||||
m_active = true;
|
m_active = true;
|
||||||
m_pointSelectionFallback = callback;
|
m_pointSelectionFallback = callback;
|
||||||
input()->keyboard()->update();
|
input()->keyboard()->update();
|
||||||
input()->cancelTouch();
|
input()->touch()->cancel();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void deactivate() {
|
void deactivate() {
|
||||||
|
@ -2723,71 +2723,6 @@ void InputRedirection::setupLibInputWithScreens()
|
||||||
connect(screens(), &Screens::changed, m_libInput, &LibInput::Connection::updateScreens);
|
connect(screens(), &Screens::changed, m_libInput, &LibInput::Connection::updateScreens);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputRedirection::processPointerMotion(const QPointF &pos, uint32_t time)
|
|
||||||
{
|
|
||||||
m_pointer->processMotionAbsolute(pos, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::processPointerButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time)
|
|
||||||
{
|
|
||||||
m_pointer->processButton(button, state, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::processPointerAxis(InputRedirection::PointerAxis axis, qreal delta, qint32 discreteDelta, PointerAxisSource source, uint32_t time)
|
|
||||||
{
|
|
||||||
m_pointer->processAxis(axis, delta, discreteDelta, source, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time)
|
|
||||||
{
|
|
||||||
m_keyboard->processKey(key, state, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::processKeyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
|
|
||||||
{
|
|
||||||
m_keyboard->processModifiers(modsDepressed, modsLatched, modsLocked, group);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::processKeymapChange(int fd, uint32_t size)
|
|
||||||
{
|
|
||||||
m_keyboard->processKeymapChange(fd, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::processTouchDown(qint32 id, const QPointF &pos, quint32 time)
|
|
||||||
{
|
|
||||||
m_touch->processDown(id, pos, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::processTouchUp(qint32 id, quint32 time)
|
|
||||||
{
|
|
||||||
m_touch->processUp(id, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::processTouchMotion(qint32 id, const QPointF &pos, quint32 time)
|
|
||||||
{
|
|
||||||
m_touch->processMotion(id, pos, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::cancelTouchSequence()
|
|
||||||
{
|
|
||||||
m_touch->cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::cancelTouch()
|
|
||||||
{
|
|
||||||
m_touch->cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputRedirection::touchFrame()
|
|
||||||
{
|
|
||||||
m_touch->frame();
|
|
||||||
}
|
|
||||||
|
|
||||||
int InputRedirection::touchPointCount()
|
|
||||||
{
|
|
||||||
return m_touch->touchPointCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::MouseButtons InputRedirection::qtButtonStates() const
|
Qt::MouseButtons InputRedirection::qtButtonStates() const
|
||||||
{
|
{
|
||||||
return m_pointer->buttons();
|
return m_pointer->buttons();
|
||||||
|
|
36
src/input.h
36
src/input.h
|
@ -142,42 +142,6 @@ public:
|
||||||
void registerRealtimeTouchpadSwipeShortcut(SwipeDirection direction, QAction *onUp, std::function<void(qreal)> progressCallback);
|
void registerRealtimeTouchpadSwipeShortcut(SwipeDirection direction, QAction *onUp, std::function<void(qreal)> progressCallback);
|
||||||
void registerGlobalAccel(KGlobalAccelInterface *interface);
|
void registerGlobalAccel(KGlobalAccelInterface *interface);
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
void processPointerMotion(const QPointF &pos, uint32_t time);
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
void processPointerButton(uint32_t button, PointerButtonState state, uint32_t time);
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
void processPointerAxis(PointerAxis axis, qreal delta, qint32 discreteDelta, PointerAxisSource source, uint32_t time);
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
void processKeyboardKey(uint32_t key, KeyboardKeyState state, uint32_t time);
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
void processKeyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
void processKeymapChange(int fd, uint32_t size);
|
|
||||||
void processTouchDown(qint32 id, const QPointF &pos, quint32 time);
|
|
||||||
void processTouchUp(qint32 id, quint32 time);
|
|
||||||
void processTouchMotion(qint32 id, const QPointF &pos, quint32 time);
|
|
||||||
/**
|
|
||||||
* triggers the same code path as LIBINPUT_TOUCH_CANCEL_EVENT.
|
|
||||||
* Only intended for autotests
|
|
||||||
*/
|
|
||||||
void cancelTouchSequence();
|
|
||||||
void cancelTouch();
|
|
||||||
void touchFrame();
|
|
||||||
int touchPointCount();
|
|
||||||
|
|
||||||
bool supportsPointerWarping() const;
|
bool supportsPointerWarping() const;
|
||||||
void warpPointer(const QPointF &pos);
|
void warpPointer(const QPointF &pos);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "composite.h"
|
#include "composite.h"
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
#include "effects.h"
|
#include "effects.h"
|
||||||
|
#include "keyboard_input.h"
|
||||||
#include <KCoreAddons>
|
#include <KCoreAddons>
|
||||||
#include "overlaywindow.h"
|
#include "overlaywindow.h"
|
||||||
#include "outline.h"
|
#include "outline.h"
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#include "screenedge.h"
|
#include "screenedge.h"
|
||||||
|
#include "touch_input.h"
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
|
|
||||||
#include <KWaylandServer/outputconfiguration_v2_interface.h>
|
#include <KWaylandServer/outputconfiguration_v2_interface.h>
|
||||||
|
@ -259,7 +261,7 @@ void Platform::keyboardKeyPressed(quint32 key, quint32 time)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processKeyboardKey(key, InputRedirection::KeyboardKeyPressed, time);
|
input()->keyboard()->processKey(key, InputRedirection::KeyboardKeyPressed, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::keyboardKeyReleased(quint32 key, quint32 time)
|
void Platform::keyboardKeyReleased(quint32 key, quint32 time)
|
||||||
|
@ -267,7 +269,7 @@ void Platform::keyboardKeyReleased(quint32 key, quint32 time)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processKeyboardKey(key, InputRedirection::KeyboardKeyReleased, time);
|
input()->keyboard()->processKey(key, InputRedirection::KeyboardKeyReleased, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::keyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
|
void Platform::keyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
|
||||||
|
@ -275,7 +277,7 @@ void Platform::keyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, u
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processKeyboardModifiers(modsDepressed, modsLatched, modsLocked, group);
|
input()->keyboard()->processModifiers(modsDepressed, modsLatched, modsLocked, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::keymapChange(int fd, uint32_t size)
|
void Platform::keymapChange(int fd, uint32_t size)
|
||||||
|
@ -283,7 +285,7 @@ void Platform::keymapChange(int fd, uint32_t size)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processKeymapChange(fd, size);
|
input()->keyboard()->processKeymapChange(fd, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::pointerAxisHorizontal(qreal delta, quint32 time, qint32 discreteDelta, InputRedirection::PointerAxisSource source)
|
void Platform::pointerAxisHorizontal(qreal delta, quint32 time, qint32 discreteDelta, InputRedirection::PointerAxisSource source)
|
||||||
|
@ -291,7 +293,7 @@ void Platform::pointerAxisHorizontal(qreal delta, quint32 time, qint32 discreteD
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processPointerAxis(InputRedirection::PointerAxisHorizontal, delta, discreteDelta, source, time);
|
input()->pointer()->processAxis(InputRedirection::PointerAxisHorizontal, delta, discreteDelta, source, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::pointerAxisVertical(qreal delta, quint32 time, qint32 discreteDelta, InputRedirection::PointerAxisSource source)
|
void Platform::pointerAxisVertical(qreal delta, quint32 time, qint32 discreteDelta, InputRedirection::PointerAxisSource source)
|
||||||
|
@ -299,7 +301,7 @@ void Platform::pointerAxisVertical(qreal delta, quint32 time, qint32 discreteDel
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processPointerAxis(InputRedirection::PointerAxisVertical, delta, discreteDelta, source, time);
|
input()->pointer()->processAxis(InputRedirection::PointerAxisVertical, delta, discreteDelta, source, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::pointerButtonPressed(quint32 button, quint32 time)
|
void Platform::pointerButtonPressed(quint32 button, quint32 time)
|
||||||
|
@ -307,7 +309,7 @@ void Platform::pointerButtonPressed(quint32 button, quint32 time)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processPointerButton(button, InputRedirection::PointerButtonPressed, time);
|
input()->pointer()->processButton(button, InputRedirection::PointerButtonPressed, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::pointerButtonReleased(quint32 button, quint32 time)
|
void Platform::pointerButtonReleased(quint32 button, quint32 time)
|
||||||
|
@ -315,7 +317,7 @@ void Platform::pointerButtonReleased(quint32 button, quint32 time)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processPointerButton(button, InputRedirection::PointerButtonReleased, time);
|
input()->pointer()->processButton(button, InputRedirection::PointerButtonReleased, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Platform::touchPointCount()
|
int Platform::touchPointCount()
|
||||||
|
@ -323,7 +325,7 @@ int Platform::touchPointCount()
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return input()->touchPointCount();
|
return input()->touch()->touchPointCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::pointerMotion(const QPointF &position, quint32 time)
|
void Platform::pointerMotion(const QPointF &position, quint32 time)
|
||||||
|
@ -331,7 +333,7 @@ void Platform::pointerMotion(const QPointF &position, quint32 time)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processPointerMotion(position, time);
|
input()->pointer()->processMotionAbsolute(position, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::cancelTouchSequence()
|
void Platform::cancelTouchSequence()
|
||||||
|
@ -339,7 +341,7 @@ void Platform::cancelTouchSequence()
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->cancelTouchSequence();
|
input()->touch()->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::touchCancel()
|
void Platform::touchCancel()
|
||||||
|
@ -347,7 +349,7 @@ void Platform::touchCancel()
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->cancelTouch();
|
input()->touch()->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::touchDown(qint32 id, const QPointF &pos, quint32 time)
|
void Platform::touchDown(qint32 id, const QPointF &pos, quint32 time)
|
||||||
|
@ -355,7 +357,7 @@ void Platform::touchDown(qint32 id, const QPointF &pos, quint32 time)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processTouchDown(id, pos, time);
|
input()->touch()->processDown(id, pos, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::touchFrame()
|
void Platform::touchFrame()
|
||||||
|
@ -363,7 +365,7 @@ void Platform::touchFrame()
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->touchFrame();
|
input()->touch()->frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::touchMotion(qint32 id, const QPointF &pos, quint32 time)
|
void Platform::touchMotion(qint32 id, const QPointF &pos, quint32 time)
|
||||||
|
@ -371,7 +373,7 @@ void Platform::touchMotion(qint32 id, const QPointF &pos, quint32 time)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processTouchMotion(id, pos, time);
|
input()->touch()->processMotion(id, pos, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::touchUp(qint32 id, quint32 time)
|
void Platform::touchUp(qint32 id, quint32 time)
|
||||||
|
@ -379,7 +381,7 @@ void Platform::touchUp(qint32 id, quint32 time)
|
||||||
if (!input()) {
|
if (!input()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
input()->processTouchUp(id, time);
|
input()->touch()->processUp(id, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform::processSwipeGestureBegin(int fingerCount, quint32 time)
|
void Platform::processSwipeGestureBegin(int fingerCount, quint32 time)
|
||||||
|
|
Loading…
Reference in a new issue