2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2016-05-24 08:57:57 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2016-05-24 08:57:57 +00:00
|
|
|
|
2020-08-02 22:22:19 +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
|
|
|
|
{
|
|
|
|
|
2021-10-02 08:26:51 +00:00
|
|
|
class InputDevice;
|
2016-05-24 08:57:57 +00:00
|
|
|
|
|
|
|
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,
|
2022-10-25 08:18:45 +00:00
|
|
|
const QPointF &delta, const QPointF &deltaNonAccelerated, quint64 timestampMicroseconds,
|
2021-10-02 08:26:51 +00:00
|
|
|
InputDevice *device);
|
2016-10-07 12:47:25 +00:00
|
|
|
|
2022-10-25 08:18:45 +00:00
|
|
|
QPointF delta() const
|
2022-03-23 10:13:38 +00:00
|
|
|
{
|
2016-10-07 12:47:25 +00:00
|
|
|
return m_delta;
|
|
|
|
}
|
|
|
|
|
2022-10-25 08:18:45 +00:00
|
|
|
QPointF deltaUnaccelerated() const
|
2022-03-23 10:13:38 +00:00
|
|
|
{
|
2016-10-07 12:47:25 +00:00
|
|
|
return m_deltaUnccelerated;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
quint64 timestampMicroseconds() const
|
|
|
|
{
|
2016-10-07 12:47:25 +00:00
|
|
|
return m_timestampMicroseconds;
|
|
|
|
}
|
2016-05-24 08:57:57 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
InputDevice *device() const
|
|
|
|
{
|
2016-05-24 08:57:57 +00:00
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const
|
|
|
|
{
|
2016-12-26 13:19:56 +00:00
|
|
|
return m_modifiersRelevantForShortcuts;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods)
|
|
|
|
{
|
2016-12-26 13:19:56 +00:00
|
|
|
m_modifiersRelevantForShortcuts = mods;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
quint32 nativeButton() const
|
|
|
|
{
|
2016-12-30 18:07:45 +00:00
|
|
|
return m_nativeButton;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void setNativeButton(quint32 button)
|
|
|
|
{
|
2016-12-30 18:07:45 +00:00
|
|
|
m_nativeButton = button;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
private:
|
2022-10-25 08:18:45 +00:00
|
|
|
QPointF m_delta;
|
|
|
|
QPointF m_deltaUnccelerated;
|
2016-10-07 12:47:25 +00:00
|
|
|
quint64 m_timestampMicroseconds;
|
2021-10-02 08:26:51 +00:00
|
|
|
InputDevice *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:
|
2022-10-11 10:33:04 +00:00
|
|
|
explicit WheelEvent(const QPointF &pos, qreal delta, qint32 deltaV120, Qt::Orientation orientation,
|
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::MouseButtons buttons, Qt::KeyboardModifiers modifiers, InputRedirection::PointerAxisSource source,
|
2021-10-02 08:26:51 +00:00
|
|
|
quint32 timestamp, InputDevice *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
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
Qt::Orientation orientation() const
|
|
|
|
{
|
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
|
|
|
return m_orientation;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
qreal delta() const
|
|
|
|
{
|
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
|
|
|
return m_delta;
|
|
|
|
}
|
|
|
|
|
2022-10-11 10:33:04 +00:00
|
|
|
qint32 deltaV120() const
|
2022-03-23 10:13:38 +00:00
|
|
|
{
|
2022-10-11 10:33:04 +00:00
|
|
|
return m_deltaV120;
|
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
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
InputRedirection::PointerAxisSource axisSource() const
|
|
|
|
{
|
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
|
|
|
return m_source;
|
|
|
|
}
|
2016-05-24 08:57:57 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
InputDevice *device() const
|
|
|
|
{
|
2016-05-24 08:57:57 +00:00
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const
|
|
|
|
{
|
2016-12-26 13:19:56 +00:00
|
|
|
return m_modifiersRelevantForShortcuts;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods)
|
|
|
|
{
|
2016-12-26 13:19:56 +00:00
|
|
|
m_modifiersRelevantForShortcuts = mods;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
private:
|
2021-10-02 08:26:51 +00:00
|
|
|
InputDevice *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;
|
2022-10-11 10:33:04 +00:00
|
|
|
qint32 m_deltaV120;
|
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
|
|
|
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,
|
2021-10-02 08:26:51 +00:00
|
|
|
const QString &text, bool autorepeat, quint32 timestamp, InputDevice *device);
|
2016-05-24 08:57:57 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
InputDevice *device() const
|
|
|
|
{
|
2016-05-24 08:57:57 +00:00
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const
|
|
|
|
{
|
2016-12-26 13:19:56 +00:00
|
|
|
return m_modifiersRelevantForShortcuts;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods)
|
|
|
|
{
|
2016-12-26 13:19:56 +00:00
|
|
|
m_modifiersRelevantForShortcuts = mods;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
private:
|
2021-10-02 08:26:51 +00:00
|
|
|
InputDevice *m_device;
|
2016-12-26 13:19:56 +00:00
|
|
|
Qt::KeyboardModifiers m_modifiersRelevantForShortcuts = Qt::KeyboardModifiers();
|
2016-05-24 08:57:57 +00:00
|
|
|
};
|
|
|
|
|
2022-10-10 14:49:47 +00:00
|
|
|
class SwitchEvent : public QEvent
|
2017-12-27 19:25:36 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum class State {
|
|
|
|
Off,
|
|
|
|
On
|
|
|
|
};
|
2021-10-02 08:26:51 +00:00
|
|
|
explicit SwitchEvent(State state, quint32 timestamp, quint64 timestampMicroseconds, InputDevice *device);
|
2017-12-27 19:25:36 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
State state() const
|
|
|
|
{
|
2017-12-27 19:25:36 +00:00
|
|
|
return m_state;
|
|
|
|
}
|
|
|
|
|
2022-10-10 14:49:47 +00:00
|
|
|
quint64 timestamp() const
|
|
|
|
{
|
|
|
|
return m_timestamp;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
quint64 timestampMicroseconds() const
|
|
|
|
{
|
2017-12-27 19:25:36 +00:00
|
|
|
return m_timestampMicroseconds;
|
|
|
|
}
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
InputDevice *device() const
|
|
|
|
{
|
2017-12-27 19:25:36 +00:00
|
|
|
return m_device;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
State m_state;
|
|
|
|
quint64 m_timestampMicroseconds;
|
2022-10-10 14:49:47 +00:00
|
|
|
quint64 m_timestamp;
|
2021-10-02 08:26:51 +00:00
|
|
|
InputDevice *m_device;
|
2017-12-27 19:25:36 +00:00
|
|
|
};
|
|
|
|
|
2020-11-20 01:28:05 +00:00
|
|
|
class TabletToolId
|
|
|
|
{
|
|
|
|
public:
|
2022-10-26 00:38:27 +00:00
|
|
|
InputRedirection::TabletToolType m_toolType;
|
|
|
|
QVector<InputRedirection::Capability> m_capabilities;
|
|
|
|
quint64 m_serialId;
|
|
|
|
quint64 m_uniqueId;
|
|
|
|
void *m_deviceGroupData;
|
|
|
|
QString m_name;
|
2020-12-22 16:34:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TabletPadId
|
|
|
|
{
|
|
|
|
public:
|
2022-08-30 18:13:28 +00:00
|
|
|
const QString name;
|
2020-12-22 16:34:10 +00:00
|
|
|
void *data;
|
2020-11-20 01:28:05 +00:00
|
|
|
};
|
|
|
|
|
2020-03-17 14:21:35 +00:00
|
|
|
class TabletEvent : public QTabletEvent
|
|
|
|
{
|
|
|
|
public:
|
2022-10-10 15:38:54 +00:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
TabletEvent(Type t, const QPointingDevice *dev, const QPointF &pos, const QPointF &globalPos,
|
|
|
|
qreal pressure, float xTilt, float yTilt,
|
|
|
|
float tangentialPressure, qreal rotation, float z,
|
|
|
|
Qt::KeyboardModifiers keyState, Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId);
|
|
|
|
#else
|
2020-03-17 14:21:35 +00:00
|
|
|
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,
|
2020-11-20 01:28:05 +00:00
|
|
|
Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId);
|
2022-10-10 15:38:54 +00:00
|
|
|
#endif
|
2020-03-17 14:21:35 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const TabletToolId &tabletId() const
|
|
|
|
{
|
2020-11-20 01:28:05 +00:00
|
|
|
return m_id;
|
|
|
|
}
|
2020-03-17 14:21:35 +00:00
|
|
|
|
|
|
|
private:
|
2020-11-20 01:28:05 +00:00
|
|
|
const TabletToolId m_id;
|
2020-03-17 14:21:35 +00:00
|
|
|
};
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|