From 33f3a13a1a8c42d57063f49e410e21ae80cb0729 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 29 Nov 2021 15:49:38 +0100 Subject: [PATCH] wayland: show cursor if stylus is in proximity While a stylus is in proximity we want to show its cursor. In this commit it only gets shown on move because for a still unknown reason the position is out of date before the first move event. BUG: 443921 --- src/CMakeLists.txt | 2 +- ...ide_cursor_spy.cpp => hide_cursor_spy.cpp} | 22 ++++++++++++++----- ...ch_hide_cursor_spy.h => hide_cursor_spy.h} | 3 ++- src/input.cpp | 4 ++-- 4 files changed, 21 insertions(+), 10 deletions(-) rename src/{touch_hide_cursor_spy.cpp => hide_cursor_spy.cpp} (57%) rename src/{touch_hide_cursor_spy.h => hide_cursor_spy.h} (84%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 473a68e662..5c19f8eda7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,7 +123,7 @@ set(kwin_SRCS syncalarmx11filter.cpp tablet_input.cpp toplevel.cpp - touch_hide_cursor_spy.cpp + hide_cursor_spy.cpp touch_input.cpp udev.cpp unmanaged.cpp diff --git a/src/touch_hide_cursor_spy.cpp b/src/hide_cursor_spy.cpp similarity index 57% rename from src/touch_hide_cursor_spy.cpp rename to src/hide_cursor_spy.cpp index 0fbe62aafc..c735352966 100644 --- a/src/touch_hide_cursor_spy.cpp +++ b/src/hide_cursor_spy.cpp @@ -6,26 +6,27 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "touch_hide_cursor_spy.h" +#include "hide_cursor_spy.h" #include "main.h" #include "platform.h" +#include "input_event.h" namespace KWin { -void TouchHideCursorSpy::pointerEvent(MouseEvent *event) +void HideCursorSpy::pointerEvent(MouseEvent *event) { Q_UNUSED(event) showCursor(); } -void TouchHideCursorSpy::wheelEvent(KWin::WheelEvent *event) +void HideCursorSpy::wheelEvent(KWin::WheelEvent *event) { Q_UNUSED(event) showCursor(); } -void TouchHideCursorSpy::touchDown(qint32 id, const QPointF &pos, quint32 time) +void HideCursorSpy::touchDown(qint32 id, const QPointF &pos, quint32 time) { Q_UNUSED(id) Q_UNUSED(pos) @@ -33,7 +34,16 @@ void TouchHideCursorSpy::touchDown(qint32 id, const QPointF &pos, quint32 time) hideCursor(); } -void TouchHideCursorSpy::showCursor() +void HideCursorSpy::tabletToolEvent(TabletEvent *event) +{ + if (event->type() == QEvent::Type::TabletLeaveProximity) { + hideCursor(); + } else { + showCursor(); + } +} + +void HideCursorSpy::showCursor() { if (!m_cursorHidden) { return; @@ -42,7 +52,7 @@ void TouchHideCursorSpy::showCursor() kwinApp()->platform()->showCursor(); } -void TouchHideCursorSpy::hideCursor() +void HideCursorSpy::hideCursor() { if (m_cursorHidden) { return; diff --git a/src/touch_hide_cursor_spy.h b/src/hide_cursor_spy.h similarity index 84% rename from src/touch_hide_cursor_spy.h rename to src/hide_cursor_spy.h index 2aa4a87975..72a706ba45 100644 --- a/src/touch_hide_cursor_spy.h +++ b/src/hide_cursor_spy.h @@ -12,12 +12,13 @@ namespace KWin { -class TouchHideCursorSpy : public InputEventSpy +class HideCursorSpy : public InputEventSpy { public: void pointerEvent(KWin::MouseEvent *event) override; void wheelEvent(KWin::WheelEvent *event) override; void touchDown(qint32 id, const QPointF &pos, quint32 time) override; + void tabletToolEvent(TabletEvent *event) override; private: void showCursor(); diff --git a/src/input.cpp b/src/input.cpp index 85c632afd6..651580d63a 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -23,7 +23,7 @@ #include "pointer_input.h" #include "session.h" #include "tablet_input.h" -#include "touch_hide_cursor_spy.h" +#include "hide_cursor_spy.h" #include "touch_input.h" #include "x11client.h" #ifdef KWIN_BUILD_TABBOX @@ -2455,7 +2455,7 @@ void InputRedirection::setupInputFilters() installInputEventFilter(new VirtualTerminalFilter); } if (waylandServer()) { - installInputEventSpy(new TouchHideCursorSpy); + installInputEventSpy(new HideCursorSpy); installInputEventSpy(new UserActivitySpy); if (hasGlobalShortcutSupport) { installInputEventFilter(new TerminateServerFilter);