diff --git a/src/popup_input_filter.cpp b/src/popup_input_filter.cpp index 1646e1b123..9d4336ffd8 100644 --- a/src/popup_input_filter.cpp +++ b/src/popup_input_filter.cpp @@ -95,6 +95,31 @@ bool PopupInputFilter::keyEvent(QKeyEvent *event) return true; } +bool PopupInputFilter::touchDown(qint32 id, const QPointF &pos, quint32 time) +{ + Q_UNUSED(id) + Q_UNUSED(time) + if (m_popupClients.isEmpty()) { + return false; + } + auto pointerFocus = qobject_cast(input()->findToplevel(pos.toPoint())); + if (!pointerFocus || !AbstractClient::belongToSameApplication(pointerFocus, qobject_cast(m_popupClients.constLast()))) { + // a touch on a window (or no window) not belonging to the popup window + cancelPopups(); + // filter out this touch + return true; + } + if (pointerFocus && pointerFocus->isDecorated()) { + // test whether it is on the decoration + const QRect clientRect = QRect(pointerFocus->clientPos(), pointerFocus->clientSize()).translated(pointerFocus->pos()); + if (!clientRect.contains(pos.toPoint())) { + cancelPopups(); + return true; + } + } + return false; +} + void PopupInputFilter::cancelPopups() { while (!m_popupClients.isEmpty()) { diff --git a/src/popup_input_filter.h b/src/popup_input_filter.h index a0a95446d2..7356ee595a 100644 --- a/src/popup_input_filter.h +++ b/src/popup_input_filter.h @@ -23,6 +23,7 @@ public: explicit PopupInputFilter(); bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override; bool keyEvent(QKeyEvent *event) override; + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override; private: void handleClientAdded(Toplevel *client); void handleClientRemoved(Toplevel *client);