2016-05-24 08:57:57 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#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;
|
|
|
|
};
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|