diff options
author | Johan Klokkhammer Helsing <johan.helsing@theqtcompany.com> | 2016-03-19 15:36:22 +0100 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2016-09-20 08:15:55 +0000 |
commit | b248defd1741cd443dd1e5050fe5143e8650a7c7 (patch) | |
tree | 1dc2b7a552ba2051cbf549b510fe6d0b6a5a3979 /examples | |
parent | c7e417e8d552f3a6a10ac12f96119d083f081fc0 (diff) |
Compositor API: Add closeAllPopups method to QWaylandWlShell
The WlShell implementation now matches xdg shell. Also adds a
convenience method to QWaylandWlShell to get all popups.
QWaylandWlShellIntegration and qwindow-compositor uses this new API.
Change-Id: Ibfe3323ad7f56d43379785582b9be6801905a485
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@hawaiios.org>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/wayland/qwindow-compositor/compositor.cpp | 27 | ||||
-rw-r--r-- | examples/wayland/qwindow-compositor/compositor.h | 3 |
2 files changed, 12 insertions, 18 deletions
diff --git a/examples/wayland/qwindow-compositor/compositor.cpp b/examples/wayland/qwindow-compositor/compositor.cpp index 9d608d404..eed270cd6 100644 --- a/examples/wayland/qwindow-compositor/compositor.cpp +++ b/examples/wayland/qwindow-compositor/compositor.cpp @@ -193,13 +193,6 @@ void Compositor::surfaceHasContentChanged() || surface->role() == QWaylandXdgPopupV5::role()) { defaultSeat()->setKeyboardFocus(surface); } - } else if (popupActive()) { - for (int i = 0; i < m_popupViews.count(); i++) { - if (m_popupViews.at(i)->surface() == surface) { - m_popupViews.removeAt(i); - break; - } - } } triggerRender(); } @@ -308,7 +301,6 @@ void Compositor::onSetPopup(QWaylandSeat *seat, QWaylandSurface *parent, const Q Q_UNUSED(seat); QWaylandWlShellSurface *surface = qobject_cast<QWaylandWlShellSurface*>(sender()); View *view = findView(surface->surface()); - m_popupViews << view; if (view) { raise(view); View *parentView = findView(parent); @@ -380,21 +372,18 @@ void Compositor::adjustCursorSurface(QWaylandSurface *surface, int hotspotX, int void Compositor::closePopups() { - Q_FOREACH (View *view, m_popupViews) { - if (view->m_wlShellSurface) - view->m_wlShellSurface->sendPopupDone(); - } - m_popupViews.clear(); - + m_wlShell->closeAllPopups(); m_xdgShell->closeAllPopups(); } void Compositor::handleMouseEvent(QWaylandView *target, QMouseEvent *me) { - if (target && popupActive() && me->type() == QEvent::MouseButtonPress - && target->surface()->client() != m_popupViews.first()->surface()->client()) { + auto popClient = popupClient(); + if (target && me->type() == QEvent::MouseButtonPress + && popClient && popClient != target->surface()->client()) { closePopups(); } + QWaylandSeat *input = defaultSeat(); QWaylandSurface *surface = target ? target->surface() : nullptr; switch (me->type()) { @@ -462,6 +451,12 @@ void Compositor::handleDrag(View *target, QMouseEvent *me) } } +QWaylandClient *Compositor::popupClient() const +{ + auto client = m_wlShell->popupClient(); + return client ? client : m_xdgShell->popupClient(); +} + // We only have a flat list of views, plus pointers from child to parent, // so maintaining a stacking order gets a bit complex. A better data // structure is left as an exercise for the reader. diff --git a/examples/wayland/qwindow-compositor/compositor.h b/examples/wayland/qwindow-compositor/compositor.h index cfeccffda..636def97e 100644 --- a/examples/wayland/qwindow-compositor/compositor.h +++ b/examples/wayland/qwindow-compositor/compositor.h @@ -107,7 +107,7 @@ public: void handleResize(View *target, const QSize &initialSize, const QPoint &delta, int edge); void handleDrag(View *target, QMouseEvent *me); - bool popupActive() const { return !m_popupViews.isEmpty(); } + QWaylandClient *popupClient() const; void closePopups(); protected: void adjustCursorSurface(QWaylandSurface *surface, int hotspotX, int hotspotY); @@ -146,7 +146,6 @@ private: View *findView(const QWaylandSurface *s) const; QWindow *m_window; QList<View*> m_views; - QList<View*> m_popupViews; QWaylandWlShell *m_wlShell; QWaylandXdgShellV5 *m_xdgShell; QWaylandView m_cursorView; |