2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2019-12-01 17:51:15 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2019 Aleix Pol Gonzalez <aleixpol@kde.org>
|
2019-12-01 17:51:15 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2019-12-01 17:51:15 +00:00
|
|
|
#include "tablet_input.h"
|
|
|
|
#include "abstract_client.h"
|
|
|
|
#include "decorations/decoratedclient.h"
|
2020-03-17 14:21:35 +00:00
|
|
|
#include "input_event.h"
|
2019-12-01 17:51:15 +00:00
|
|
|
#include "input_event_spy.h"
|
|
|
|
#include "libinput/device.h"
|
|
|
|
#include "pointer_input.h"
|
|
|
|
#include "toplevel.h"
|
|
|
|
#include "wayland_server.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
// KDecoration
|
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
// KWayland
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/seat_interface.h>
|
2019-12-01 17:51:15 +00:00
|
|
|
// screenlocker
|
|
|
|
#include <KScreenLocker/KsldApp>
|
|
|
|
// Qt
|
|
|
|
#include <QHoverEvent>
|
|
|
|
#include <QWindow>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
TabletInputRedirection::TabletInputRedirection(InputRedirection *parent)
|
|
|
|
: InputDeviceHandler(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TabletInputRedirection::~TabletInputRedirection() = default;
|
|
|
|
|
|
|
|
void TabletInputRedirection::init()
|
|
|
|
{
|
|
|
|
Q_ASSERT(!inited());
|
|
|
|
setInited(true);
|
|
|
|
InputDeviceHandler::init();
|
|
|
|
|
|
|
|
connect(workspace(), &QObject::destroyed, this, [this] { setInited(false); });
|
|
|
|
connect(waylandServer(), &QObject::destroyed, this, [this] { setInited(false); });
|
|
|
|
}
|
|
|
|
|
2020-11-20 01:28:05 +00:00
|
|
|
void TabletInputRedirection::tabletToolEvent(KWin::InputRedirection::TabletEventType type, const QPointF &pos,
|
|
|
|
qreal pressure, int xTilt, int yTilt, qreal rotation, bool tipDown,
|
|
|
|
bool tipNear, const TabletToolId &tabletToolId,
|
|
|
|
quint32 time)
|
2019-12-01 17:51:15 +00:00
|
|
|
{
|
|
|
|
if (!inited()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_lastPosition = pos;
|
|
|
|
|
|
|
|
QEvent::Type t;
|
|
|
|
switch (type) {
|
|
|
|
case InputRedirection::Axis:
|
|
|
|
t = QEvent::TabletMove;
|
|
|
|
break;
|
|
|
|
case InputRedirection::Tip:
|
|
|
|
t = tipDown ? QEvent::TabletPress : QEvent::TabletRelease;
|
|
|
|
break;
|
|
|
|
case InputRedirection::Proximity:
|
|
|
|
t = tipNear ? QEvent::TabletEnterProximity : QEvent::TabletLeaveProximity;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto button = m_tipDown ? Qt::LeftButton : Qt::NoButton;
|
2020-03-17 14:21:35 +00:00
|
|
|
TabletEvent ev(t, pos, pos, QTabletEvent::Stylus, QTabletEvent::Pen, pressure,
|
2019-12-01 17:51:15 +00:00
|
|
|
xTilt, yTilt,
|
|
|
|
0, // tangentialPressure
|
|
|
|
rotation,
|
|
|
|
0, // z
|
2020-11-20 01:28:05 +00:00
|
|
|
Qt::NoModifier, tabletToolId.m_uniqueId, button, button, tabletToolId);
|
2019-12-01 17:51:15 +00:00
|
|
|
|
2020-03-17 14:21:35 +00:00
|
|
|
ev.setTimestamp(time);
|
2019-12-01 17:51:15 +00:00
|
|
|
input()->processSpies(std::bind(&InputEventSpy::tabletToolEvent, std::placeholders::_1, &ev));
|
|
|
|
input()->processFilters(
|
|
|
|
std::bind(&InputEventFilter::tabletToolEvent, std::placeholders::_1, &ev));
|
|
|
|
|
|
|
|
m_tipDown = tipDown;
|
|
|
|
m_tipNear = tipNear;
|
|
|
|
}
|
|
|
|
|
2020-11-20 01:28:05 +00:00
|
|
|
void KWin::TabletInputRedirection::tabletToolButtonEvent(uint button, bool isPressed,
|
|
|
|
const TabletToolId &tabletToolId)
|
2019-12-01 17:51:15 +00:00
|
|
|
{
|
|
|
|
input()->processSpies(std::bind(&InputEventSpy::tabletToolButtonEvent,
|
2020-11-20 01:28:05 +00:00
|
|
|
std::placeholders::_1, button, isPressed, tabletToolId));
|
2019-12-01 17:51:15 +00:00
|
|
|
input()->processFilters(std::bind( &InputEventFilter::tabletToolButtonEvent,
|
2020-11-20 01:28:05 +00:00
|
|
|
std::placeholders::_1, button, isPressed, tabletToolId));
|
2019-12-01 17:51:15 +00:00
|
|
|
}
|
|
|
|
|
2020-11-20 01:28:05 +00:00
|
|
|
void KWin::TabletInputRedirection::tabletPadButtonEvent(uint button, bool isPressed,
|
2020-12-22 16:34:10 +00:00
|
|
|
const TabletPadId &tabletPadId)
|
2019-12-01 17:51:15 +00:00
|
|
|
{
|
|
|
|
input()->processSpies(std::bind( &InputEventSpy::tabletPadButtonEvent,
|
2020-12-22 16:34:10 +00:00
|
|
|
std::placeholders::_1, button, isPressed, tabletPadId));
|
2019-12-01 17:51:15 +00:00
|
|
|
input()->processFilters(std::bind( &InputEventFilter::tabletPadButtonEvent,
|
2020-12-22 16:34:10 +00:00
|
|
|
std::placeholders::_1, button, isPressed, tabletPadId));
|
2019-12-01 17:51:15 +00:00
|
|
|
}
|
|
|
|
|
2020-11-20 01:28:05 +00:00
|
|
|
void KWin::TabletInputRedirection::tabletPadStripEvent(int number, int position, bool isFinger,
|
2020-12-22 16:34:10 +00:00
|
|
|
const TabletPadId &tabletPadId)
|
2019-12-01 17:51:15 +00:00
|
|
|
{
|
|
|
|
input()->processSpies(std::bind( &InputEventSpy::tabletPadStripEvent,
|
2020-12-22 16:34:10 +00:00
|
|
|
std::placeholders::_1, number, position, isFinger, tabletPadId));
|
2019-12-01 17:51:15 +00:00
|
|
|
input()->processFilters(std::bind( &InputEventFilter::tabletPadStripEvent,
|
2020-12-22 16:34:10 +00:00
|
|
|
std::placeholders::_1, number, position, isFinger, tabletPadId));
|
2019-12-01 17:51:15 +00:00
|
|
|
}
|
|
|
|
|
2020-11-20 01:28:05 +00:00
|
|
|
void KWin::TabletInputRedirection::tabletPadRingEvent(int number, int position, bool isFinger,
|
2020-12-22 16:34:10 +00:00
|
|
|
const TabletPadId &tabletPadId)
|
2019-12-01 17:51:15 +00:00
|
|
|
{
|
|
|
|
input()->processSpies(std::bind( &InputEventSpy::tabletPadRingEvent,
|
2020-12-22 16:34:10 +00:00
|
|
|
std::placeholders::_1, number, position, isFinger, tabletPadId));
|
2019-12-01 17:51:15 +00:00
|
|
|
input()->processFilters(std::bind( &InputEventFilter::tabletPadRingEvent,
|
2020-12-22 16:34:10 +00:00
|
|
|
std::placeholders::_1, number, position, isFinger, tabletPadId));
|
2019-12-01 17:51:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TabletInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl *old,
|
|
|
|
Decoration::DecoratedClientImpl *now)
|
|
|
|
{
|
|
|
|
Q_UNUSED(old)
|
|
|
|
Q_UNUSED(now)
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletInputRedirection::cleanupInternalWindow(QWindow *old, QWindow *now)
|
|
|
|
{
|
|
|
|
Q_UNUSED(old)
|
|
|
|
Q_UNUSED(now)
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletInputRedirection::focusUpdate(KWin::Toplevel *old, KWin::Toplevel *now)
|
|
|
|
{
|
|
|
|
Q_UNUSED(old)
|
|
|
|
Q_UNUSED(now)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|