From f4f15d598f7fb43b46759eafd609780c9dc9d759 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 3 Sep 2024 14:08:18 +0300 Subject: [PATCH] Make popup input filter process tablet tool events --- src/popup_input_filter.cpp | 24 ++++++++++++++++++++++++ src/popup_input_filter.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/popup_input_filter.cpp b/src/popup_input_filter.cpp index 5b288b61bb..2de4052d2c 100644 --- a/src/popup_input_filter.cpp +++ b/src/popup_input_filter.cpp @@ -112,6 +112,30 @@ bool PopupInputFilter::touchDown(qint32 id, const QPointF &pos, std::chrono::mic return false; } +bool PopupInputFilter::tabletToolEvent(TabletEvent *event) +{ + if (m_popupWindows.isEmpty()) { + return false; + } + if (event->type() == QEvent::TabletPress) { + auto tabletFocus = input()->findToplevel(event->globalPosition()); + if (!tabletFocus || !Window::belongToSameApplication(tabletFocus, m_popupWindows.constLast())) { + // a touch on a window (or no window) not belonging to the popup window + cancelPopups(); + // filter out this touch + return true; + } + if (tabletFocus && tabletFocus->isDecorated()) { + // test whether it is on the decoration + if (!exclusiveContains(tabletFocus->clientGeometry(), event->globalPosition())) { + cancelPopups(); + return true; + } + } + } + return false; +} + void PopupInputFilter::cancelPopups() { while (!m_popupWindows.isEmpty()) { diff --git a/src/popup_input_filter.h b/src/popup_input_filter.h index 38515c1565..82cc89ea67 100644 --- a/src/popup_input_filter.h +++ b/src/popup_input_filter.h @@ -23,6 +23,7 @@ public: bool pointerEvent(MouseEvent *event, quint32 nativeButton) override; bool keyEvent(KeyEvent *event) override; bool touchDown(qint32 id, const QPointF &pos, std::chrono::microseconds time) override; + bool tabletToolEvent(TabletEvent *event) override; private: void handleWindowAdded(Window *client);