summaryrefslogtreecommitdiff
path: root/src/client/qwaylandwindow.cpp
diff options
context:
space:
mode:
authorWeng Xuetian <wengxt@gmail.com>2022-07-20 15:57:40 -0700
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-07-24 06:03:11 +0000
commit608579a2853ecfa4ef892aa202767788519254f5 (patch)
tree7e0a1b668cb35ae1ed548b6ab4268be2607ada6d /src/client/qwaylandwindow.cpp
parent1a07779a2578e254bdbc1e4e76ffb4904e53b0aa (diff)
downloadqtwayland-608579a2853ecfa4ef892aa202767788519254f5.tar.gz
Only close popup in the the hierchary
Imagine following event sequences: 1. a tooltip is shown. activePopups = {tooltip} 2. user click menu bar to show the menu, QMenu::setVisible is called. now activePopups(tooltip, menu} 3. tooltip visibility changed to false. 4. closePopups() close both tooltip and menu. This is a common pattern under wayland that menu is shown as a invisible state. This patch tries to memorize the surface hierchary used to create the popup role. And only close those popups whose ancesotor is hidden. Change-Id: I78aa0b4e32a5812603e003e756d8bcd202e94af4 Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit f8e3257e9b1e22d52e9c221c62b8d9b6dd1151a3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r--src/client/qwaylandwindow.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index d669e839..27572185 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -215,6 +215,7 @@ void QWaylandWindow::endFrame()
void QWaylandWindow::reset()
{
+ closeChildPopups();
delete mShellSurface;
mShellSurface = nullptr;
delete mSubSurfaceWindow;
@@ -429,20 +430,6 @@ void QWaylandWindow::sendExposeEvent(const QRect &rect)
mLastExposeGeometry = rect;
}
-static QList<QPointer<QWaylandWindow>> activePopups;
-
-void QWaylandWindow::closePopups(QWaylandWindow *parent)
-{
- while (!activePopups.isEmpty()) {
- auto popup = activePopups.takeLast();
- if (popup.isNull())
- continue;
- if (popup.data() == parent)
- return;
- popup->reset();
- }
-}
-
QPlatformScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const
{
QReadLocker lock(&mSurfaceLock);
@@ -462,8 +449,6 @@ void QWaylandWindow::setVisible(bool visible)
lastVisible = visible;
if (visible) {
- if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
- activePopups << this;
initWindow();
setGeometry(windowGeometry());
@@ -472,7 +457,6 @@ void QWaylandWindow::setVisible(bool visible)
// QWaylandShmBackingStore::beginPaint().
} else {
sendExposeEvent(QRect());
- closePopups(this);
reset();
}
}
@@ -1520,6 +1504,21 @@ void QWaylandWindow::setXdgActivationToken(const QString &token)
{
mShellSurface->setXdgActivationToken(token);
}
+
+void QWaylandWindow::addChildPopup(QWaylandWindow *surface) {
+ mChildPopups.append(surface);
+}
+
+void QWaylandWindow::removeChildPopup(QWaylandWindow *surface) {
+ mChildPopups.removeAll(surface);
+}
+
+void QWaylandWindow::closeChildPopups() {
+ while (!mChildPopups.isEmpty()) {
+ auto popup = mChildPopups.takeLast();
+ popup->reset();
+ }
+}
}
QT_END_NAMESPACE