summaryrefslogtreecommitdiff
path: root/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp')
-rw-r--r--src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
index e227971b..e3dee445 100644
--- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
+++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp
@@ -174,12 +174,17 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi
| ((edges & Qt::RightEdge) ? resize_edge_right : 0));
}
-QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent,
+QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent,
QtWayland::xdg_positioner *positioner)
- : xdg_popup(xdgSurface->get_popup(parent ? parent->object() : nullptr, positioner->object()))
- , m_xdgSurface(xdgSurface)
+ : m_xdgSurface(xdgSurface)
+ , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface()))
, m_parent(parent)
{
+
+ init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, positioner->object()));
+ if (m_parent) {
+ m_parent->addChildPopup(m_xdgSurface->window());
+ }
}
QWaylandXdgSurface::Popup::~Popup()
@@ -187,10 +192,14 @@ QWaylandXdgSurface::Popup::~Popup()
if (isInitialized())
destroy();
+ if (m_parent) {
+ m_parent->removeChildPopup(m_xdgSurface->window());
+ }
+
if (m_grabbing) {
auto *shell = m_xdgSurface->m_shell;
Q_ASSERT(shell->m_topmostGrabbingPopup == this);
- shell->m_topmostGrabbingPopup = m_parent ? m_parent->m_popup : nullptr;
+ shell->m_topmostGrabbingPopup = m_parentXdgSurface ? m_parentXdgSurface->m_popup : nullptr;
m_grabbing = false;
// Synthesize Qt enter/leave events for popup
@@ -396,8 +405,6 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
{
Q_ASSERT(!m_toplevel && !m_popup);
- auto parentXdgSurface = qobject_cast<QWaylandXdgSurface *>(parent->shellSurface());
-
auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner());
// set_popup expects a position relative to the parent
QPoint transientPos = m_window->geometry().topLeft(); // this is absolute
@@ -414,8 +421,9 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent)
| QtWayland::xdg_positioner::constraint_adjustment_slide_y
| QtWayland::xdg_positioner::constraint_adjustment_flip_x
| QtWayland::xdg_positioner::constraint_adjustment_flip_y);
- m_popup = new Popup(this, parentXdgSurface, positioner);
+ m_popup = new Popup(this, parent, positioner);
positioner->destroy();
+
delete positioner;
}