2016-05-24 08:57:57 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
2020-08-02 22:10:35 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2016-05-24 08:57:57 +00:00
|
|
|
|
2020-08-02 22:10:35 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
2016-05-24 08:57:57 +00:00
|
|
|
*********************************************************************/
|
|
|
|
#ifndef KWIN_INPUT_EVENT_H
|
|
|
|
#define KWIN_INPUT_EVENT_H
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
|
|
|
|
#include "input.h"
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
#include <QInputEvent>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace LibInput
|
|
|
|
{
|
|
|
|
class Device;
|
|
|
|
}
|
|
|
|
|
|
|
|
class MouseEvent : public QMouseEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit MouseEvent(QEvent::Type type, const QPointF &pos, Qt::MouseButton button, Qt::MouseButtons buttons,
|
2016-10-07 12:47:25 +00:00
|
|
|
Qt::KeyboardModifiers modifiers, quint32 timestamp,
|
|
|
|
const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 timestampMicroseconds,
|
|
|
|
LibInput::Device *device);
|
|
|
|
|
|
|
|
QSizeF delta() const {
|
|
|
|
return m_delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
QSizeF deltaUnaccelerated() const {
|
|
|
|
return m_deltaUnccelerated;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint64 timestampMicroseconds() const {
|
|
|
|
return m_timestampMicroseconds;
|
|
|
|
}
|
2016-05-24 08:57:57 +00:00
|
|
|
|
|
|
|
LibInput::Device *device() const {
|
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
|
2016-12-26 13:19:56 +00:00
|
|
|
Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const {
|
|
|
|
return m_modifiersRelevantForShortcuts;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) {
|
|
|
|
m_modifiersRelevantForShortcuts = mods;
|
|
|
|
}
|
|
|
|
|
2016-12-30 18:07:45 +00:00
|
|
|
quint32 nativeButton() const {
|
|
|
|
return m_nativeButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setNativeButton(quint32 button) {
|
|
|
|
m_nativeButton = button;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
private:
|
2016-10-07 12:47:25 +00:00
|
|
|
QSizeF m_delta;
|
|
|
|
QSizeF m_deltaUnccelerated;
|
|
|
|
quint64 m_timestampMicroseconds;
|
2016-05-24 08:57:57 +00:00
|
|
|
LibInput::Device *m_device;
|
2016-12-26 13:19:56 +00:00
|
|
|
Qt::KeyboardModifiers m_modifiersRelevantForShortcuts = Qt::KeyboardModifiers();
|
2016-12-30 18:07:45 +00:00
|
|
|
quint32 m_nativeButton = 0;
|
2016-05-24 08:57:57 +00:00
|
|
|
};
|
|
|
|
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
// TODO: Don't derive from QWheelEvent, this event is quite domain specific.
|
2016-05-24 08:57:57 +00:00
|
|
|
class WheelEvent : public QWheelEvent
|
|
|
|
{
|
|
|
|
public:
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
explicit WheelEvent(const QPointF &pos, qreal delta, qint32 discreteDelta, Qt::Orientation orientation,
|
|
|
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, InputRedirection::PointerAxisSource source,
|
|
|
|
quint32 timestamp, LibInput::Device *device);
|
|
|
|
|
|
|
|
Qt::Orientation orientation() const {
|
|
|
|
return m_orientation;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal delta() const {
|
|
|
|
return m_delta;
|
|
|
|
}
|
|
|
|
|
|
|
|
qint32 discreteDelta() const {
|
|
|
|
return m_discreteDelta;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputRedirection::PointerAxisSource axisSource() const {
|
|
|
|
return m_source;
|
|
|
|
}
|
2016-05-24 08:57:57 +00:00
|
|
|
|
|
|
|
LibInput::Device *device() const {
|
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
|
2016-12-26 13:19:56 +00:00
|
|
|
Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const {
|
|
|
|
return m_modifiersRelevantForShortcuts;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) {
|
|
|
|
m_modifiersRelevantForShortcuts = mods;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
private:
|
|
|
|
LibInput::Device *m_device;
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
Qt::Orientation m_orientation;
|
|
|
|
qreal m_delta;
|
|
|
|
qint32 m_discreteDelta;
|
|
|
|
InputRedirection::PointerAxisSource m_source;
|
2016-12-26 13:19:56 +00:00
|
|
|
Qt::KeyboardModifiers m_modifiersRelevantForShortcuts = Qt::KeyboardModifiers();
|
2016-05-24 08:57:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class KeyEvent : public QKeyEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit KeyEvent(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers, quint32 code, quint32 keysym,
|
|
|
|
const QString &text, bool autorepeat, quint32 timestamp, LibInput::Device *device);
|
|
|
|
|
|
|
|
LibInput::Device *device() const {
|
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
|
2016-12-26 13:19:56 +00:00
|
|
|
Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const {
|
|
|
|
return m_modifiersRelevantForShortcuts;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) {
|
|
|
|
m_modifiersRelevantForShortcuts = mods;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
private:
|
|
|
|
LibInput::Device *m_device;
|
2016-12-26 13:19:56 +00:00
|
|
|
Qt::KeyboardModifiers m_modifiersRelevantForShortcuts = Qt::KeyboardModifiers();
|
2016-05-24 08:57:57 +00:00
|
|
|
};
|
|
|
|
|
2017-12-27 19:25:36 +00:00
|
|
|
class SwitchEvent : public QInputEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class State {
|
|
|
|
Off,
|
|
|
|
On
|
|
|
|
};
|
|
|
|
explicit SwitchEvent(State state, quint32 timestamp, quint64 timestampMicroseconds, LibInput::Device *device);
|
|
|
|
|
|
|
|
State state() const {
|
|
|
|
return m_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint64 timestampMicroseconds() const {
|
|
|
|
return m_timestampMicroseconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
LibInput::Device *device() const {
|
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
State m_state;
|
|
|
|
quint64 m_timestampMicroseconds;
|
|
|
|
LibInput::Device *m_device;
|
|
|
|
};
|
|
|
|
|
2020-03-17 14:21:35 +00:00
|
|
|
class TabletEvent : public QTabletEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TabletEvent(Type t, const QPointF &pos, const QPointF &globalPos,
|
|
|
|
int device, int pointerType, qreal pressure, int xTilt, int yTilt,
|
|
|
|
qreal tangentialPressure, qreal rotation, int z,
|
|
|
|
Qt::KeyboardModifiers keyState, qint64 uniqueID,
|
|
|
|
Qt::MouseButton button, Qt::MouseButtons buttons, InputRedirection::TabletToolType toolType,
|
|
|
|
const QVector<InputRedirection::Capability> &capabilities,
|
|
|
|
quint64 serialId, const QString &tabletSysname);
|
|
|
|
|
|
|
|
InputRedirection::TabletToolType toolType() const { return m_toolType; }
|
|
|
|
QVector<InputRedirection::Capability> capabilities() const { return m_capabilities; }
|
|
|
|
quint64 serialId() const { return m_serialId; }
|
|
|
|
QString tabletSysName() { return m_tabletSysName; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const InputRedirection::TabletToolType m_toolType;
|
|
|
|
const QVector<InputRedirection::Capability> m_capabilities;
|
|
|
|
const quint64 m_serialId;
|
|
|
|
const QString m_tabletSysName;
|
|
|
|
};
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|