Commit 7626dbb1 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

inputmethod: Also open the inputm method panel with a pen

BUG: 449888


(cherry picked from commit ad0a3588)
parent bf85f6ea
Pipeline #137185 passed with stage
in 14 minutes and 46 seconds
......@@ -2301,6 +2301,16 @@ void InputRedirection::setupWorkspace()
}
}
QObject *InputRedirection::lastInputHandler() const
{
return m_lastInputDevice;
}
void InputRedirection::setLastInputHandler(QObject *device)
{
m_lastInputDevice = device;
}
class UserActivitySpy : public InputEventSpy
{
public:
......@@ -3005,11 +3015,6 @@ Decoration::DecoratedClientImpl *InputDeviceHandler::decoration() const
return m_focus.decoration;
}
uint32_t InputDeviceHandler::lastEventTime() const
{
return m_lastEventTime;
}
} // namespace
#include "input.moc"
......@@ -217,6 +217,12 @@ public:
return m_touch;
}
/**
* Specifies which was the device that triggered the last input event
*/
void setLastInputHandler(QObject *device);
QObject *lastInputHandler() const;
QList<InputDevice *> devices() const;
bool hasAlphaNumericKeyboard();
......@@ -297,6 +303,7 @@ private:
PointerInputRedirection *m_pointer;
TabletInputRedirection *m_tablet;
TouchInputRedirection *m_touch;
QObject *m_lastInputDevice = nullptr;
GlobalShortcutsManager *m_shortcuts;
......@@ -444,8 +451,6 @@ public:
void setFocus(Toplevel *toplevel);
void setDecoration(Decoration::DecoratedClientImpl *decoration);
uint32_t lastEventTime() const;
Q_SIGNALS:
void decorationChanged();
......@@ -475,8 +480,6 @@ protected:
m_inited = set;
}
uint32_t m_lastEventTime = 0;
private:
bool setHover(Toplevel *toplevel);
void updateFocus();
......
......@@ -19,7 +19,7 @@
#include "screenlockerwatcher.h"
#include "deleted.h"
#include "touch_input.h"
#include "pointer_input.h"
#include "tablet_input.h"
#include <KWaylandServer/display.h>
#include <KWaylandServer/keyboard_interface.h>
......@@ -134,9 +134,8 @@ void InputMethod::hide()
bool InputMethod::shouldShowOnActive() const
{
return input()->touch()
&& input()->touch()->lastEventTime() > input()->keyboard()->lastEventTime()
&& input()->touch()->lastEventTime() > input()->pointer()->lastEventTime();
return input()->touch() == input()->lastInputHandler()
|| input()->tablet() == input()->lastInputHandler();
}
void InputMethod::setActive(bool active)
......
......@@ -244,7 +244,7 @@ void KeyboardInputRedirection::processKey(uint32_t key, InputRedirection::Keyboa
if (!m_inited) {
return;
}
m_lastEventTime = time;
input()->setLastInputHandler(this);
m_input->processFilters(std::bind(&InputEventFilter::keyEvent, std::placeholders::_1, &event));
m_xkb->forwardModifiers();
......
......@@ -73,10 +73,6 @@ public:
return m_xkb->modifiersRelevantForGlobalShortcuts();
}
uint32_t lastEventTime() const {
return m_lastEventTime;
}
Q_SIGNALS:
void ledsChanged(KWin::LEDs);
......@@ -87,7 +83,6 @@ private:
QMetaObject::Connection m_activeClientSurfaceChangedConnection;
ModifiersChangedSpy *m_modifiersChangedSpy = nullptr;
KeyboardLayout *m_keyboardLayout = nullptr;
uint32_t m_lastEventTime = 0;
};
}
......
......@@ -257,7 +257,7 @@ void PointerInputRedirection::processMotion(const QSizeF &delta, const QSizeF &d
void PointerInputRedirection::processMotionInternal(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
if (!inited()) {
return;
}
......@@ -280,7 +280,7 @@ void PointerInputRedirection::processMotionInternal(const QPointF &pos, const QS
void PointerInputRedirection::processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time, InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
QEvent::Type type;
switch (state) {
case InputRedirection::PointerButtonReleased:
......@@ -318,7 +318,7 @@ void PointerInputRedirection::processButton(uint32_t button, InputRedirection::P
void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qreal delta, qint32 discreteDelta,
InputRedirection::PointerAxisSource source, uint32_t time, InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
update();
Q_EMIT input()->pointerAxisChanged(axis, delta);
......@@ -338,7 +338,7 @@ void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qr
void PointerInputRedirection::processSwipeGestureBegin(int fingerCount, quint32 time, KWin::InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
Q_UNUSED(device)
if (!inited()) {
return;
......@@ -350,7 +350,7 @@ void PointerInputRedirection::processSwipeGestureBegin(int fingerCount, quint32
void PointerInputRedirection::processSwipeGestureUpdate(const QSizeF &delta, quint32 time, KWin::InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
Q_UNUSED(device)
if (!inited()) {
return;
......@@ -363,7 +363,7 @@ void PointerInputRedirection::processSwipeGestureUpdate(const QSizeF &delta, qui
void PointerInputRedirection::processSwipeGestureEnd(quint32 time, KWin::InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
Q_UNUSED(device)
if (!inited()) {
return;
......@@ -376,7 +376,7 @@ void PointerInputRedirection::processSwipeGestureEnd(quint32 time, KWin::InputDe
void PointerInputRedirection::processSwipeGestureCancelled(quint32 time, KWin::InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
Q_UNUSED(device)
if (!inited()) {
return;
......@@ -389,7 +389,7 @@ void PointerInputRedirection::processSwipeGestureCancelled(quint32 time, KWin::I
void PointerInputRedirection::processPinchGestureBegin(int fingerCount, quint32 time, KWin::InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
Q_UNUSED(device)
if (!inited()) {
return;
......@@ -402,7 +402,7 @@ void PointerInputRedirection::processPinchGestureBegin(int fingerCount, quint32
void PointerInputRedirection::processPinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time, KWin::InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
Q_UNUSED(device)
if (!inited()) {
return;
......@@ -415,7 +415,7 @@ void PointerInputRedirection::processPinchGestureUpdate(qreal scale, qreal angle
void PointerInputRedirection::processPinchGestureEnd(quint32 time, KWin::InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
Q_UNUSED(device)
if (!inited()) {
return;
......@@ -428,7 +428,7 @@ void PointerInputRedirection::processPinchGestureEnd(quint32 time, KWin::InputDe
void PointerInputRedirection::processPinchGestureCancelled(quint32 time, KWin::InputDevice *device)
{
m_lastEventTime = time;
input()->setLastInputHandler(this);
Q_UNUSED(device)
if (!inited()) {
return;
......
......@@ -53,7 +53,7 @@ void TabletInputRedirection::tabletToolEvent(KWin::InputRedirection::TabletEvent
if (!inited()) {
return;
}
m_lastEventTime = time;
input()->setLastInputHandler(this);
m_lastPosition = pos;
QEvent::Type t;
......@@ -95,6 +95,7 @@ void KWin::TabletInputRedirection::tabletToolButtonEvent(uint button, bool isPre
std::placeholders::_1, button, isPressed, tabletToolId));
input()->processFilters(std::bind( &InputEventFilter::tabletToolButtonEvent,
std::placeholders::_1, button, isPressed, tabletToolId));
input()->setLastInputHandler(this);
}
void KWin::TabletInputRedirection::tabletPadButtonEvent(uint button, bool isPressed,
......@@ -104,6 +105,7 @@ void KWin::TabletInputRedirection::tabletPadButtonEvent(uint button, bool isPres
std::placeholders::_1, button, isPressed, tabletPadId));
input()->processFilters(std::bind( &InputEventFilter::tabletPadButtonEvent,
std::placeholders::_1, button, isPressed, tabletPadId));
input()->setLastInputHandler(this);
}
void KWin::TabletInputRedirection::tabletPadStripEvent(int number, int position, bool isFinger,
......@@ -113,6 +115,7 @@ void KWin::TabletInputRedirection::tabletPadStripEvent(int number, int position,
std::placeholders::_1, number, position, isFinger, tabletPadId));
input()->processFilters(std::bind( &InputEventFilter::tabletPadStripEvent,
std::placeholders::_1, number, position, isFinger, tabletPadId));
input()->setLastInputHandler(this);
}
void KWin::TabletInputRedirection::tabletPadRingEvent(int number, int position, bool isFinger,
......@@ -122,6 +125,7 @@ void KWin::TabletInputRedirection::tabletPadRingEvent(int number, int position,
std::placeholders::_1, number, position, isFinger, tabletPadId));
input()->processFilters(std::bind( &InputEventFilter::tabletPadRingEvent,
std::placeholders::_1, number, position, isFinger, tabletPadId));
input()->setLastInputHandler(this);
}
bool TabletInputRedirection::focusUpdatesBlocked()
......
......@@ -138,7 +138,7 @@ void TouchInputRedirection::processDown(qint32 id, const QPointF &pos, quint32 t
if (m_activeTouchPoints.count() == 1) {
update();
}
m_lastEventTime = time;
input()->setLastInputHandler(this);
input()->processSpies(std::bind(&InputEventSpy::touchDown, std::placeholders::_1, id, pos, time));
input()->processFilters(std::bind(&InputEventFilter::touchDown, std::placeholders::_1, id, pos, time));
m_windowUpdatedInCycle = false;
......@@ -153,7 +153,7 @@ void TouchInputRedirection::processUp(qint32 id, quint32 time, InputDevice *devi
if (!m_activeTouchPoints.remove(id)) {
return;
}
m_lastEventTime = time;
input()->setLastInputHandler(this);
m_windowUpdatedInCycle = false;
input()->processSpies(std::bind(&InputEventSpy::touchUp, std::placeholders::_1, id, time));
input()->processFilters(std::bind(&InputEventFilter::touchUp, std::placeholders::_1, id, time));
......@@ -172,7 +172,7 @@ void TouchInputRedirection::processMotion(qint32 id, const QPointF &pos, quint32
if (!m_activeTouchPoints.contains(id)) {
return;
}
m_lastEventTime = time;
input()->setLastInputHandler(this);
m_lastPosition = pos;
m_windowUpdatedInCycle = false;
input()->processSpies(std::bind(&InputEventSpy::touchMotion, std::placeholders::_1, id, pos, time));
......
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