Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org> | 5 | Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org> | ||
6 | Copyright (C) 2018 Roman Gilg <subdiff@gmail.com> | 6 | Copyright (C) 2018 Roman Gilg <subdiff@gmail.com> | ||
7 | Copyright (C) 2019 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
7 | 8 | | |||
8 | This program is free software; you can redistribute it and/or modify | 9 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | 10 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | 11 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | 12 | (at your option) any later version. | ||
12 | 13 | | |||
13 | This program is distributed in the hope that it will be useful, | 14 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
▲ Show 20 Lines • Show All 1311 Lines • ▼ Show 20 Line(s) | 1309 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | |||
1326 | default: | 1327 | default: | ||
1327 | break; | 1328 | break; | ||
1328 | } | 1329 | } | ||
1329 | return true; | 1330 | return true; | ||
1330 | } | 1331 | } | ||
1331 | bool wheelEvent(QWheelEvent *event) override { | 1332 | bool wheelEvent(QWheelEvent *event) override { | ||
1332 | auto seat = waylandServer()->seat(); | 1333 | auto seat = waylandServer()->seat(); | ||
1333 | seat->setTimestamp(event->timestamp()); | 1334 | seat->setTimestamp(event->timestamp()); | ||
1334 | const Qt::Orientation orientation = event->angleDelta().x() == 0 ? Qt::Vertical : Qt::Horizontal; | 1335 | auto _event = static_cast<WheelEvent *>(event); | ||
1335 | seat->pointerAxis(orientation, orientation == Qt::Horizontal ? event->angleDelta().x() : event->angleDelta().y()); | 1336 | KWayland::Server::PointerAxisSource source; | ||
1337 | switch (_event->axisSource()) { | ||||
1338 | case KWin::InputRedirection::PointerAxisSourceWheel: | ||||
1339 | source = KWayland::Server::PointerAxisSource::Wheel; | ||||
1340 | break; | ||||
1341 | case KWin::InputRedirection::PointerAxisSourceFinger: | ||||
1342 | source = KWayland::Server::PointerAxisSource::Finger; | ||||
1343 | break; | ||||
1344 | case KWin::InputRedirection::PointerAxisSourceContinuous: | ||||
1345 | source = KWayland::Server::PointerAxisSource::Continuous; | ||||
1346 | break; | ||||
1347 | case KWin::InputRedirection::PointerAxisSourceWheelTilt: | ||||
1348 | source = KWayland::Server::PointerAxisSource::WheelTilt; | ||||
1349 | break; | ||||
1350 | case KWin::InputRedirection::PointerAxisSourceUnknown: | ||||
1351 | default: | ||||
1352 | source = KWayland::Server::PointerAxisSource::Unknown; | ||||
1353 | break; | ||||
1354 | } | ||||
1355 | seat->pointerAxisV5(_event->orientation(), _event->delta(), _event->discreteDelta(), source); | ||||
1336 | return true; | 1356 | return true; | ||
1337 | } | 1357 | } | ||
1338 | bool keyEvent(QKeyEvent *event) override { | 1358 | bool keyEvent(QKeyEvent *event) override { | ||
1339 | if (!workspace()) { | 1359 | if (!workspace()) { | ||
1340 | return false; | 1360 | return false; | ||
1341 | } | 1361 | } | ||
1342 | if (event->isAutoRepeat()) { | 1362 | if (event->isAutoRepeat()) { | ||
1343 | // handled by Wayland client | 1363 | // handled by Wayland client | ||
▲ Show 20 Lines • Show All 375 Lines • ▼ Show 20 Line(s) | 1732 | [this] (Qt::Orientation orientation, qreal delta) { | |||
1719 | case Qt::Vertical: | 1739 | case Qt::Vertical: | ||
1720 | axis = InputRedirection::PointerAxisVertical; | 1740 | axis = InputRedirection::PointerAxisVertical; | ||
1721 | break; | 1741 | break; | ||
1722 | default: | 1742 | default: | ||
1723 | Q_UNREACHABLE(); | 1743 | Q_UNREACHABLE(); | ||
1724 | break; | 1744 | break; | ||
1725 | } | 1745 | } | ||
1726 | // TODO: Fix time | 1746 | // TODO: Fix time | ||
1727 | m_pointer->processAxis(axis, delta, 0); | 1747 | m_pointer->processAxis(axis, delta, 0, InputRedirection::PointerAxisSourceUnknown, 0); | ||
1728 | waylandServer()->simulateUserActivity(); | 1748 | waylandServer()->simulateUserActivity(); | ||
1729 | } | 1749 | } | ||
1730 | ); | 1750 | ); | ||
1731 | connect(device, &FakeInputDevice::touchDownRequested, this, | 1751 | connect(device, &FakeInputDevice::touchDownRequested, this, | ||
1732 | [this] (quint32 id, const QPointF &pos) { | 1752 | [this] (quint32 id, const QPointF &pos) { | ||
1733 | // TODO: Fix time | 1753 | // TODO: Fix time | ||
1734 | m_touch->processDown(id, pos, 0); | 1754 | m_touch->processDown(id, pos, 0); | ||
1735 | waylandServer()->simulateUserActivity(); | 1755 | waylandServer()->simulateUserActivity(); | ||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Line(s) | 2032 | { | |||
2013 | m_pointer->processMotion(pos, time); | 2033 | m_pointer->processMotion(pos, time); | ||
2014 | } | 2034 | } | ||
2015 | 2035 | | |||
2016 | void InputRedirection::processPointerButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time) | 2036 | void InputRedirection::processPointerButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time) | ||
2017 | { | 2037 | { | ||
2018 | m_pointer->processButton(button, state, time); | 2038 | m_pointer->processButton(button, state, time); | ||
2019 | } | 2039 | } | ||
2020 | 2040 | | |||
2021 | void InputRedirection::processPointerAxis(InputRedirection::PointerAxis axis, qreal delta, uint32_t time) | 2041 | void InputRedirection::processPointerAxis(InputRedirection::PointerAxis axis, qreal delta, qint32 discreteDelta, PointerAxisSource source, uint32_t time) | ||
2022 | { | 2042 | { | ||
2023 | m_pointer->processAxis(axis, delta, time); | 2043 | m_pointer->processAxis(axis, delta, discreteDelta, source, time); | ||
2024 | } | 2044 | } | ||
2025 | 2045 | | |||
2026 | void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time) | 2046 | void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time) | ||
2027 | { | 2047 | { | ||
2028 | m_keyboard->processKey(key, state, time); | 2048 | m_keyboard->processKey(key, state, time); | ||
2029 | } | 2049 | } | ||
2030 | 2050 | | |||
2031 | void InputRedirection::processKeyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) | 2051 | void InputRedirection::processKeyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) | ||
▲ Show 20 Lines • Show All 358 Lines • Show Last 20 Lines |