Changeset View
Changeset View
Standalone View
Standalone View
input.cpp
Show All 12 Lines | |||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "input.h" | 20 | #include "input.h" | ||
21 | #include "input_event.h" | ||||
21 | #include "keyboard_input.h" | 22 | #include "keyboard_input.h" | ||
22 | #include "pointer_input.h" | 23 | #include "pointer_input.h" | ||
23 | #include "touch_input.h" | 24 | #include "touch_input.h" | ||
24 | #include "client.h" | 25 | #include "client.h" | ||
25 | #include "effects.h" | 26 | #include "effects.h" | ||
26 | #include "globalshortcuts.h" | 27 | #include "globalshortcuts.h" | ||
27 | #include "logind.h" | 28 | #include "logind.h" | ||
28 | #include "main.h" | 29 | #include "main.h" | ||
Show All 9 Lines | |||||
38 | #include "libinput/device.h" | 39 | #include "libinput/device.h" | ||
39 | #endif | 40 | #endif | ||
40 | #include "platform.h" | 41 | #include "platform.h" | ||
41 | #include "shell_client.h" | 42 | #include "shell_client.h" | ||
42 | #include "wayland_server.h" | 43 | #include "wayland_server.h" | ||
43 | #include <KWayland/Server/display.h> | 44 | #include <KWayland/Server/display.h> | ||
44 | #include <KWayland/Server/fakeinput_interface.h> | 45 | #include <KWayland/Server/fakeinput_interface.h> | ||
45 | #include <KWayland/Server/seat_interface.h> | 46 | #include <KWayland/Server/seat_interface.h> | ||
47 | #include <KWayland/Server/relativepointer_interface.h> | ||||
46 | #include <decorations/decoratedclient.h> | 48 | #include <decorations/decoratedclient.h> | ||
47 | #include <KDecoration2/Decoration> | 49 | #include <KDecoration2/Decoration> | ||
48 | //screenlocker | 50 | //screenlocker | ||
49 | #include <KScreenLocker/KsldApp> | 51 | #include <KScreenLocker/KsldApp> | ||
50 | // Qt | 52 | // Qt | ||
51 | #include <QKeyEvent> | 53 | #include <QKeyEvent> | ||
52 | 54 | | |||
53 | #include <xkbcommon/xkbcommon.h> | 55 | #include <xkbcommon/xkbcommon.h> | ||
▲ Show 20 Lines • Show All 833 Lines • ▼ Show 20 Line(s) | |||||
887 | **/ | 889 | **/ | ||
888 | class ForwardInputFilter : public InputEventFilter | 890 | class ForwardInputFilter : public InputEventFilter | ||
889 | { | 891 | { | ||
890 | public: | 892 | public: | ||
891 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | 893 | bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { | ||
892 | auto seat = waylandServer()->seat(); | 894 | auto seat = waylandServer()->seat(); | ||
893 | seat->setTimestamp(event->timestamp()); | 895 | seat->setTimestamp(event->timestamp()); | ||
894 | switch (event->type()) { | 896 | switch (event->type()) { | ||
895 | case QEvent::MouseMove: | 897 | case QEvent::MouseMove: { | ||
896 | if (event->buttons() == Qt::NoButton) { | 898 | if (event->buttons() == Qt::NoButton) { | ||
897 | // update pointer window only if no button is pressed | 899 | // update pointer window only if no button is pressed | ||
898 | input()->pointer()->update(); | 900 | input()->pointer()->update(); | ||
899 | } | 901 | } | ||
900 | seat->setPointerPos(event->globalPos()); | 902 | seat->setPointerPos(event->globalPos()); | ||
903 | MouseEvent *e = static_cast<MouseEvent*>(event); | ||||
904 | if (e->delta() != QSizeF()) { | ||||
905 | seat->relativePointerMotion(e->delta(), e->deltaUnaccelerated(), e->timestampMicroseconds()); | ||||
906 | } | ||||
901 | break; | 907 | break; | ||
908 | } | ||||
902 | case QEvent::MouseButtonPress: | 909 | case QEvent::MouseButtonPress: | ||
903 | seat->pointerButtonPressed(nativeButton); | 910 | seat->pointerButtonPressed(nativeButton); | ||
904 | break; | 911 | break; | ||
905 | case QEvent::MouseButtonRelease: | 912 | case QEvent::MouseButtonRelease: | ||
906 | seat->pointerButtonReleased(nativeButton); | 913 | seat->pointerButtonReleased(nativeButton); | ||
907 | if (event->buttons() == Qt::NoButton) { | 914 | if (event->buttons() == Qt::NoButton) { | ||
908 | input()->pointer()->update(); | 915 | input()->pointer()->update(); | ||
909 | } | 916 | } | ||
▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Line(s) | 1233 | if (!Application::usesLibinput()) { | |||
1227 | return; | 1234 | return; | ||
1228 | } | 1235 | } | ||
1229 | if (m_libInput) { | 1236 | if (m_libInput) { | ||
1230 | return; | 1237 | return; | ||
1231 | } | 1238 | } | ||
1232 | LibInput::Connection *conn = LibInput::Connection::create(this); | 1239 | LibInput::Connection *conn = LibInput::Connection::create(this); | ||
1233 | m_libInput = conn; | 1240 | m_libInput = conn; | ||
1234 | if (conn) { | 1241 | if (conn) { | ||
1242 | | ||||
1243 | if (waylandServer()) { | ||||
1244 | // create relative pointer manager | ||||
1245 | waylandServer()->display()->createRelativePointerManager(KWayland::Server::RelativePointerInterfaceVersion::UnstableV1, waylandServer()->display())->create(); | ||||
1246 | } | ||||
1247 | | ||||
1235 | conn->setInputConfig(m_inputConfig); | 1248 | conn->setInputConfig(m_inputConfig); | ||
1236 | conn->setup(); | 1249 | conn->setup(); | ||
1237 | connect(conn, &LibInput::Connection::eventsRead, this, | 1250 | connect(conn, &LibInput::Connection::eventsRead, this, | ||
1238 | [this] { | 1251 | [this] { | ||
1239 | m_libInput->processEvents(); | 1252 | m_libInput->processEvents(); | ||
1240 | }, Qt::QueuedConnection | 1253 | }, Qt::QueuedConnection | ||
1241 | ); | 1254 | ); | ||
1242 | connect(conn, &LibInput::Connection::pointerButtonChanged, m_pointer, &PointerInputRedirection::processButton); | 1255 | connect(conn, &LibInput::Connection::pointerButtonChanged, m_pointer, &PointerInputRedirection::processButton); | ||
1243 | connect(conn, &LibInput::Connection::pointerAxisChanged, m_pointer, &PointerInputRedirection::processAxis); | 1256 | connect(conn, &LibInput::Connection::pointerAxisChanged, m_pointer, &PointerInputRedirection::processAxis); | ||
1244 | connect(conn, &LibInput::Connection::pinchGestureBegin, m_pointer, &PointerInputRedirection::processPinchGestureBegin); | 1257 | connect(conn, &LibInput::Connection::pinchGestureBegin, m_pointer, &PointerInputRedirection::processPinchGestureBegin); | ||
1245 | connect(conn, &LibInput::Connection::pinchGestureUpdate, m_pointer, &PointerInputRedirection::processPinchGestureUpdate); | 1258 | connect(conn, &LibInput::Connection::pinchGestureUpdate, m_pointer, &PointerInputRedirection::processPinchGestureUpdate); | ||
1246 | connect(conn, &LibInput::Connection::pinchGestureEnd, m_pointer, &PointerInputRedirection::processPinchGestureEnd); | 1259 | connect(conn, &LibInput::Connection::pinchGestureEnd, m_pointer, &PointerInputRedirection::processPinchGestureEnd); | ||
1247 | connect(conn, &LibInput::Connection::pinchGestureCancelled, m_pointer, &PointerInputRedirection::processPinchGestureCancelled); | 1260 | connect(conn, &LibInput::Connection::pinchGestureCancelled, m_pointer, &PointerInputRedirection::processPinchGestureCancelled); | ||
1248 | connect(conn, &LibInput::Connection::swipeGestureBegin, m_pointer, &PointerInputRedirection::processSwipeGestureBegin); | 1261 | connect(conn, &LibInput::Connection::swipeGestureBegin, m_pointer, &PointerInputRedirection::processSwipeGestureBegin); | ||
1249 | connect(conn, &LibInput::Connection::swipeGestureUpdate, m_pointer, &PointerInputRedirection::processSwipeGestureUpdate); | 1262 | connect(conn, &LibInput::Connection::swipeGestureUpdate, m_pointer, &PointerInputRedirection::processSwipeGestureUpdate); | ||
1250 | connect(conn, &LibInput::Connection::swipeGestureEnd, m_pointer, &PointerInputRedirection::processSwipeGestureEnd); | 1263 | connect(conn, &LibInput::Connection::swipeGestureEnd, m_pointer, &PointerInputRedirection::processSwipeGestureEnd); | ||
1251 | connect(conn, &LibInput::Connection::swipeGestureCancelled, m_pointer, &PointerInputRedirection::processSwipeGestureCancelled); | 1264 | connect(conn, &LibInput::Connection::swipeGestureCancelled, m_pointer, &PointerInputRedirection::processSwipeGestureCancelled); | ||
1252 | connect(conn, &LibInput::Connection::keyChanged, m_keyboard, &KeyboardInputRedirection::processKey); | 1265 | connect(conn, &LibInput::Connection::keyChanged, m_keyboard, &KeyboardInputRedirection::processKey); | ||
1253 | connect(conn, &LibInput::Connection::pointerMotion, this, | 1266 | connect(conn, &LibInput::Connection::pointerMotion, this, | ||
1254 | [this] (QPointF delta, uint32_t time, LibInput::Device *device) { | 1267 | [this] (const QSizeF &delta, const QSizeF &deltaNonAccel, uint32_t time, quint64 timeMicroseconds, LibInput::Device *device) { | ||
1255 | m_pointer->processMotion(m_pointer->pos() + delta, time, device); | 1268 | m_pointer->processMotion(m_pointer->pos() + QPointF(delta.width(), delta.height()), delta, deltaNonAccel, time, timeMicroseconds, device); | ||
1256 | } | 1269 | } | ||
1257 | ); | 1270 | ); | ||
1258 | connect(conn, &LibInput::Connection::pointerMotionAbsolute, this, | 1271 | connect(conn, &LibInput::Connection::pointerMotionAbsolute, this, | ||
1259 | [this] (QPointF orig, QPointF screen, uint32_t time, LibInput::Device *device) { | 1272 | [this] (QPointF orig, QPointF screen, uint32_t time, LibInput::Device *device) { | ||
1260 | Q_UNUSED(orig) | 1273 | Q_UNUSED(orig) | ||
1261 | m_pointer->processMotion(screen, time, device); | 1274 | m_pointer->processMotion(screen, time, device); | ||
1262 | } | 1275 | } | ||
1263 | ); | 1276 | ); | ||
▲ Show 20 Lines • Show All 362 Lines • Show Last 20 Lines |