fix: touch down to close popup window.
when a popup window is shown,use touch to operation window or touch to move client,the popup window not be closed and be showing state.
This commit is contained in:
parent
bd17ca0110
commit
44285de0e1
2 changed files with 26 additions and 0 deletions
|
@ -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<AbstractClient*>(input()->findToplevel(pos.toPoint()));
|
||||
if (!pointerFocus || !AbstractClient::belongToSameApplication(pointerFocus, qobject_cast<AbstractClient*>(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()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue