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
|
|
|
#include "input_event.h"
|
2023-01-18 16:35:34 +00:00
|
|
|
#include "core/inputdevice.h"
|
2016-05-24 08:57:57 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
MouseEvent::MouseEvent(QEvent::Type type, const QPointF &pos, Qt::MouseButton button,
|
2022-12-21 00:55:20 +00:00
|
|
|
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, std::chrono::microseconds timestamp,
|
|
|
|
const QPointF &delta, const QPointF &deltaNonAccelerated, InputDevice *device)
|
2022-03-23 10:13:38 +00:00
|
|
|
: QMouseEvent(type, pos, pos, button, buttons, modifiers)
|
|
|
|
, m_delta(delta)
|
|
|
|
, m_deltaUnccelerated(deltaNonAccelerated)
|
2022-12-21 00:55:20 +00:00
|
|
|
, m_timestamp(timestamp)
|
2022-03-23 10:13:38 +00:00
|
|
|
, m_device(device)
|
2016-05-24 08:57:57 +00:00
|
|
|
{
|
2022-12-21 00:55:20 +00:00
|
|
|
setTimestamp(std::chrono::duration_cast<std::chrono::milliseconds>(timestamp).count());
|
2016-05-24 08:57:57 +00:00
|
|
|
}
|
|
|
|
|
2022-10-11 10:33:04 +00:00
|
|
|
WheelEvent::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,
|
2022-12-21 00:55:20 +00:00
|
|
|
std::chrono::microseconds timestamp, InputDevice *device)
|
2023-01-18 16:35:34 +00:00
|
|
|
: QWheelEvent(pos, pos, QPoint(), (orientation == Qt::Horizontal) ? QPoint(delta, 0) : QPoint(0, delta), buttons, modifiers, Qt::NoScrollPhase, device->isNaturalScroll())
|
2022-03-23 10:13:38 +00:00
|
|
|
, m_device(device)
|
|
|
|
, m_orientation(orientation)
|
|
|
|
, m_delta(delta)
|
2022-10-11 10:33:04 +00:00
|
|
|
, m_deltaV120(deltaV120)
|
2022-03-23 10:13:38 +00:00
|
|
|
, m_source(source)
|
2022-12-21 00:55:20 +00:00
|
|
|
, m_timestamp(timestamp)
|
|
|
|
{
|
|
|
|
setTimestamp(std::chrono::duration_cast<std::chrono::milliseconds>(timestamp).count());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::chrono::microseconds WheelEvent::timestamp() const
|
2016-05-24 08:57:57 +00:00
|
|
|
{
|
2022-12-21 00:55:20 +00:00
|
|
|
return m_timestamp;
|
2016-05-24 08:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KeyEvent::KeyEvent(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers, quint32 code, quint32 keysym,
|
2022-12-21 00:55:20 +00:00
|
|
|
const QString &text, bool autorepeat, std::chrono::microseconds timestamp, InputDevice *device)
|
2022-03-23 10:13:38 +00:00
|
|
|
: QKeyEvent(type, key, modifiers, code, keysym, 0, text, autorepeat)
|
|
|
|
, m_device(device)
|
2022-12-21 00:55:20 +00:00
|
|
|
, m_timestamp(timestamp)
|
|
|
|
{
|
|
|
|
setTimestamp(std::chrono::duration_cast<std::chrono::milliseconds>(timestamp).count());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::chrono::microseconds KeyEvent::timestamp() const
|
2016-05-24 08:57:57 +00:00
|
|
|
{
|
2022-12-21 00:55:20 +00:00
|
|
|
return m_timestamp;
|
2016-05-24 08:57:57 +00:00
|
|
|
}
|
|
|
|
|
2022-12-21 00:55:20 +00:00
|
|
|
SwitchEvent::SwitchEvent(State state, std::chrono::microseconds timestamp, InputDevice *device)
|
2022-10-10 14:49:47 +00:00
|
|
|
: QEvent(QEvent::User)
|
2017-12-27 19:25:36 +00:00
|
|
|
, m_state(state)
|
2022-10-10 14:49:47 +00:00
|
|
|
, m_timestamp(timestamp)
|
2017-12-27 19:25:36 +00:00
|
|
|
, m_device(device)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-10-10 15:38:54 +00:00
|
|
|
TabletEvent::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)
|
|
|
|
: QTabletEvent(t, dev, pos, globalPos, pressure, xTilt, yTilt, tangentialPressure, rotation, z, keyState, button, buttons)
|
|
|
|
, m_id(tabletId)
|
|
|
|
{
|
|
|
|
}
|
2020-03-17 14:21:35 +00:00
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
}
|