diff options
Diffstat (limited to 'src/compositor/extensions/qwaylandxdgshellv5.cpp')
-rw-r--r-- | src/compositor/extensions/qwaylandxdgshellv5.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp index ffd1ef90d..e38e68eb0 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv5.cpp @@ -115,9 +115,9 @@ QWaylandXdgPopupV5 *QWaylandXdgShellV5Private::topmostPopupForClient(wl_client * return clientPopups.empty() ? nullptr : clientPopups.last(); } -QWaylandXdgSurfaceV5 *QWaylandXdgShellV5Private::xdgSurfaceFromSurface(QWaylandSurface *surface) +QWaylandXdgSurfaceV5 *QWaylandXdgShellV5Private::xdgSurfaceFromSurface(QWaylandSurface *surface) const { - Q_FOREACH (QWaylandXdgSurfaceV5 *xdgSurface, m_xdgSurfaces) { + for (QWaylandXdgSurfaceV5 *xdgSurface : m_xdgSurfaces) { if (surface == xdgSurface->surface()) return xdgSurface; } @@ -414,7 +414,7 @@ void QWaylandXdgSurfaceV5Private::xdg_surface_ack_configure(Resource *resource, break; } - QVector<uint> changedStates; + std::vector<uint> changedStates; std::set_symmetric_difference( m_lastAckedConfigure.states.begin(), m_lastAckedConfigure.states.end(), config.states.begin(), config.states.end(), @@ -423,7 +423,7 @@ void QWaylandXdgSurfaceV5Private::xdg_surface_ack_configure(Resource *resource, m_lastAckedConfigure = config; if (!changedStates.empty()) { - Q_FOREACH (uint state, changedStates) { + for (uint state : changedStates) { switch (state) { case QWaylandXdgSurfaceV5::State::MaximizedState: emit q->maximizedChanged(); @@ -580,7 +580,7 @@ void QWaylandXdgShellV5::initialize() QWaylandClient *QWaylandXdgShellV5::popupClient() const { Q_D(const QWaylandXdgShellV5); - Q_FOREACH (QWaylandXdgPopupV5 *popup, d->m_xdgPopups) { + for (QWaylandXdgPopupV5 *popup : d->m_xdgPopups) { if (popup->surface()->hasContent()) return popup->surface()->client(); } @@ -627,15 +627,19 @@ uint QWaylandXdgShellV5::ping(QWaylandClient *client) return serial; } +// ### remove once QMap has rbegin()/rend() +template <typename Iterator> +std::reverse_iterator<Iterator> make_reverse(Iterator it) +{ + return std::reverse_iterator<Iterator>(std::move(it)); +} + void QWaylandXdgShellV5::closeAllPopups() { Q_D(QWaylandXdgShellV5); - Q_FOREACH (struct wl_client *client, d->m_xdgPopups.keys()) { - QList<QWaylandXdgPopupV5 *> popups = d->m_xdgPopups.values(client); - std::reverse(popups.begin(), popups.end()); - Q_FOREACH (QWaylandXdgPopupV5 *currentTopmostPopup, popups) { - currentTopmostPopup->sendPopupDone(); - } + // Close pop-ups from top-most to bottom-most, lest we get protocol errors: + for (auto rit = make_reverse(d->m_xdgPopups.end()), rend = make_reverse(d->m_xdgPopups.begin()); rit != rend; ++rit) { + (*rit)->sendPopupDone(); } } @@ -987,7 +991,9 @@ void QWaylandXdgSurfaceV5::initialize() QList<int> QWaylandXdgSurfaceV5::statesAsInts() const { QList<int> list; - Q_FOREACH (uint state, states()) { + const auto s = states(); + list.reserve(s.size()); + for (auto state : s) { list << static_cast<int>(state); } return list; @@ -1238,7 +1244,8 @@ uint QWaylandXdgSurfaceV5::sendConfigure(const QSize &size, const QVector<uint> uint QWaylandXdgSurfaceV5::sendConfigure(const QSize &size, const QVector<QWaylandXdgSurfaceV5::State> &states) { QVector<uint> asUints; - Q_FOREACH (QWaylandXdgSurfaceV5::State state, states) { + asUints.reserve(states.size()); + for (QWaylandXdgSurfaceV5::State state : states) { asUints << state; } return sendConfigure(size, asUints); |