File indexing completed on 2024-11-10 04:57:47
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2016 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "input_event.h" 0010 #include "core/inputdevice.h" 0011 0012 namespace KWin 0013 { 0014 0015 MouseEvent::MouseEvent(QEvent::Type type, const QPointF &pos, Qt::MouseButton button, 0016 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, std::chrono::microseconds timestamp, 0017 const QPointF &delta, const QPointF &deltaNonAccelerated, InputDevice *device) 0018 : QMouseEvent(type, pos, pos, button, buttons, modifiers) 0019 , m_delta(delta) 0020 , m_deltaUnccelerated(deltaNonAccelerated) 0021 , m_timestamp(timestamp) 0022 , m_device(device) 0023 { 0024 setTimestamp(std::chrono::duration_cast<std::chrono::milliseconds>(timestamp).count()); 0025 } 0026 0027 WheelEvent::WheelEvent(const QPointF &pos, qreal delta, qint32 deltaV120, Qt::Orientation orientation, 0028 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, InputRedirection::PointerAxisSource source, 0029 std::chrono::microseconds timestamp, InputDevice *device) 0030 : QWheelEvent(pos, pos, QPoint(), (orientation == Qt::Horizontal) ? QPoint(delta, 0) : QPoint(0, delta), buttons, modifiers, Qt::NoScrollPhase, device ? device->isNaturalScroll() : false) 0031 , m_device(device) 0032 , m_orientation(orientation) 0033 , m_delta(delta) 0034 , m_deltaV120(deltaV120) 0035 , m_source(source) 0036 , m_timestamp(timestamp) 0037 { 0038 setTimestamp(std::chrono::duration_cast<std::chrono::milliseconds>(timestamp).count()); 0039 } 0040 0041 std::chrono::microseconds WheelEvent::timestamp() const 0042 { 0043 return m_timestamp; 0044 } 0045 0046 KeyEvent::KeyEvent(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers, quint32 code, quint32 keysym, 0047 const QString &text, bool autorepeat, std::chrono::microseconds timestamp, InputDevice *device) 0048 : QKeyEvent(type, key, modifiers, code, keysym, 0, text, autorepeat) 0049 , m_device(device) 0050 , m_timestamp(timestamp) 0051 { 0052 setTimestamp(std::chrono::duration_cast<std::chrono::milliseconds>(timestamp).count()); 0053 } 0054 0055 std::chrono::microseconds KeyEvent::timestamp() const 0056 { 0057 return m_timestamp; 0058 } 0059 0060 SwitchEvent::SwitchEvent(State state, std::chrono::microseconds timestamp, InputDevice *device) 0061 : QEvent(QEvent::User) 0062 , m_state(state) 0063 , m_timestamp(timestamp) 0064 , m_device(device) 0065 { 0066 } 0067 0068 TabletEvent::TabletEvent(Type t, const QPointingDevice *dev, const QPointF &pos, const QPointF &globalPos, 0069 qreal pressure, float xTilt, float yTilt, 0070 float tangentialPressure, qreal rotation, float z, 0071 Qt::KeyboardModifiers keyState, Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId) 0072 : QTabletEvent(t, dev, pos, globalPos, pressure, xTilt, yTilt, tangentialPressure, rotation, z, keyState, button, buttons) 0073 , m_id(tabletId) 0074 { 0075 } 0076 0077 }