diff options
Diffstat (limited to 'src/compositor')
15 files changed, 48 insertions, 32 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 530cf8ed..36c995c3 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -200,8 +200,8 @@ void QWaylandCompositorPrivate::init() buffer_manager = new QtWayland::BufferManager(q); wl_display_init_shm(display); - QVector<wl_shm_format> formats = QWaylandSharedMemoryFormatHelper::supportedWaylandFormats(); - foreach (wl_shm_format format, formats) + const QVector<wl_shm_format> formats = QWaylandSharedMemoryFormatHelper::supportedWaylandFormats(); + for (wl_shm_format format : formats) wl_display_add_shm_format(display, format); if (!socket_name.isEmpty()) { @@ -706,7 +706,7 @@ QList<QWaylandSurface *> QWaylandCompositor::surfacesForClient(QWaylandClient* c { Q_D(const QWaylandCompositor); QList<QWaylandSurface *> surfs; - foreach (QWaylandSurface *surface, d->all_surfaces) { + for (QWaylandSurface *surface : d->all_surfaces) { if (surface->client() == client) surfs.append(surface); } @@ -728,7 +728,7 @@ QList<QWaylandSurface *> QWaylandCompositor::surfaces() const QWaylandOutput *QWaylandCompositor::outputFor(QWindow *window) const { Q_D(const QWaylandCompositor); - foreach (QWaylandOutput *output, d->outputs) { + for (QWaylandOutput *output : d->outputs) { if (output->window() == window) return output; } diff --git a/src/compositor/compositor_api/qwaylandkeyboard.cpp b/src/compositor/compositor_api/qwaylandkeyboard.cpp index 2302c0b6..452be436 100644 --- a/src/compositor/compositor_api/qwaylandkeyboard.cpp +++ b/src/compositor/compositor_api/qwaylandkeyboard.cpp @@ -256,7 +256,8 @@ void QWaylandKeyboardPrivate::maybeUpdateKeymap() return; createXKBKeymap(); - foreach (Resource *res, resourceMap()) { + const auto resMap = resourceMap(); + for (Resource *res : resMap) { send_keymap(res->handle, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymap_fd, keymap_size); } @@ -386,7 +387,8 @@ void QWaylandKeyboardPrivate::createXKBKeymap() void QWaylandKeyboardPrivate::sendRepeatInfo() { - Q_FOREACH (Resource *resource, resourceMap()) { + const auto resMap = resourceMap(); + for (Resource *resource : resMap) { if (resource->version() >= WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) send_repeat_info(resource->handle, repeatRate, repeatDelay); } diff --git a/src/compositor/compositor_api/qwaylandoutput.cpp b/src/compositor/compositor_api/qwaylandoutput.cpp index 006edbe6..7a02d4ca 100644 --- a/src/compositor/compositor_api/qwaylandoutput.cpp +++ b/src/compositor/compositor_api/qwaylandoutput.cpp @@ -831,7 +831,8 @@ void QWaylandOutput::setScaleFactor(int scale) d->scaleFactor = scale; - Q_FOREACH (QWaylandOutputPrivate::Resource *resource, d->resourceMap().values()) { + const auto resMap = d->resourceMap(); + for (QWaylandOutputPrivate::Resource *resource : resMap) { if (resource->version() >= 2) { d->send_scale(resource->handle, scale); d->send_done(resource->handle); diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index c79787e6..add4020d 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -136,9 +136,9 @@ QWaylandSurfacePrivate::~QWaylandSurfacePrivate() bufferRef = QWaylandBufferRef(); - foreach (QtWayland::FrameCallback *c, pendingFrameCallbacks) + for (QtWayland::FrameCallback *c : qAsConst(pendingFrameCallbacks)) c->destroy(); - foreach (QtWayland::FrameCallback *c, frameCallbacks) + for (QtWayland::FrameCallback *c : qAsConst(frameCallbacks)) c->destroy(); } @@ -151,7 +151,7 @@ void QWaylandSurfacePrivate::removeFrameCallback(QtWayland::FrameCallback *callb void QWaylandSurfacePrivate::notifyViewsAboutDestruction() { Q_Q(QWaylandSurface); - foreach (QWaylandView *view, views) { + for (QWaylandView *view : qAsConst(views)) { QWaylandViewPrivate::get(view)->markSurfaceAsDestroyed(q); } if (hasContent) { @@ -673,7 +673,7 @@ QWaylandCompositor *QWaylandSurface::compositor() const void QWaylandSurface::frameStarted() { Q_D(QWaylandSurface); - foreach (QtWayland::FrameCallback *c, d->frameCallbacks) + for (QtWayland::FrameCallback *c : qAsConst(d->frameCallbacks)) c->canSend = true; } diff --git a/src/compositor/compositor_api/qwaylandview.cpp b/src/compositor/compositor_api/qwaylandview.cpp index 1a6bf1a6..12889bdf 100644 --- a/src/compositor/compositor_api/qwaylandview.cpp +++ b/src/compositor/compositor_api/qwaylandview.cpp @@ -246,7 +246,8 @@ bool QWaylandView::advance() return false; if (d->surface && d->surface->primaryView() == this) { - Q_FOREACH (QWaylandView *view, d->surface->views()) { + const auto views = d->surface->views(); + for (QWaylandView *view : views) { if (view != this && view->allowDiscardFrontBuffer() && view->d_func()->currentBuffer == d->currentBuffer) view->discardCurrentBuffer(); } diff --git a/src/compositor/extensions/qwaylandqtwindowmanager.cpp b/src/compositor/extensions/qwaylandqtwindowmanager.cpp index 86678b2e..c3cf3488 100644 --- a/src/compositor/extensions/qwaylandqtwindowmanager.cpp +++ b/src/compositor/extensions/qwaylandqtwindowmanager.cpp @@ -109,7 +109,8 @@ void QWaylandQtWindowManager::setShowIsFullScreen(bool value) return; d->showIsFullScreen = value; - Q_FOREACH (QWaylandQtWindowManagerPrivate::Resource *resource, d->resourceMap().values()) { + const auto resMap = d->resourceMap(); + for (QWaylandQtWindowManagerPrivate::Resource *resource : resMap) { d->send_hints(resource->handle, static_cast<int32_t>(d->showIsFullScreen)); } Q_EMIT showIsFullScreenChanged(); diff --git a/src/compositor/extensions/qwaylandtextinput.cpp b/src/compositor/extensions/qwaylandtextinput.cpp index f60a32a1..b46caa64 100644 --- a/src/compositor/extensions/qwaylandtextinput.cpp +++ b/src/compositor/extensions/qwaylandtextinput.cpp @@ -162,7 +162,7 @@ void QWaylandTextInputPrivate::sendInputMethodEvent(QInputMethodEvent *event) afterCommit.cursorPosition += event->commitString().length(); afterCommit.anchorPosition = afterCommit.cursorPosition; - foreach (const QInputMethodEvent::Attribute &attribute, event->attributes()) { + for (const QInputMethodEvent::Attribute &attribute : event->attributes()) { if (attribute.type == QInputMethodEvent::Selection) { afterCommit.cursorPosition = attribute.start; afterCommit.anchorPosition = attribute.length; @@ -174,7 +174,7 @@ void QWaylandTextInputPrivate::sendInputMethodEvent(QInputMethodEvent *event) } } send_commit_string(focusResource->handle, event->commitString()); - foreach (const QInputMethodEvent::Attribute &attribute, event->attributes()) { + for (const QInputMethodEvent::Attribute &attribute : event->attributes()) { if (attribute.type == QInputMethodEvent::Cursor) { int index = QWaylandInputMethodEventBuilder::indexToWayland(event->preeditString(), attribute.start); send_preedit_cursor(focusResource->handle, index); diff --git a/src/compositor/extensions/qwaylandwlshell.cpp b/src/compositor/extensions/qwaylandwlshell.cpp index 9871a8a5..8cd2c731 100644 --- a/src/compositor/extensions/qwaylandwlshell.cpp +++ b/src/compositor/extensions/qwaylandwlshell.cpp @@ -332,7 +332,7 @@ QList<QWaylandWlShellSurface *> QWaylandWlShell::shellSurfacesForClient(QWayland { Q_D(const QWaylandWlShell); QList<QWaylandWlShellSurface *> surfsForClient; - Q_FOREACH (QWaylandWlShellSurface *shellSurface, d->m_shellSurfaces) { + for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) { if (shellSurface->surface() && shellSurface->surface()->client() == client) surfsForClient.append(shellSurface); } @@ -343,7 +343,7 @@ QList<QWaylandWlShellSurface *> QWaylandWlShell::mappedPopups() const { Q_D(const QWaylandWlShell); QList<QWaylandWlShellSurface *> popupSurfaces; - Q_FOREACH (QWaylandWlShellSurface *shellSurface, d->m_shellSurfaces) { + for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) { if (shellSurface->windowType() == Qt::WindowType::Popup && shellSurface->surface() && shellSurface->surface()->hasContent()) { popupSurfaces.append(shellSurface); @@ -355,7 +355,7 @@ QList<QWaylandWlShellSurface *> QWaylandWlShell::mappedPopups() const QWaylandClient *QWaylandWlShell::popupClient() const { Q_D(const QWaylandWlShell); - Q_FOREACH (QWaylandWlShellSurface *shellSurface, d->m_shellSurfaces) { + for (QWaylandWlShellSurface *shellSurface : d->m_shellSurfaces) { if (shellSurface->windowType() == Qt::WindowType::Popup && shellSurface->surface() && shellSurface->surface()->hasContent()) { return shellSurface->surface()->client(); @@ -366,7 +366,8 @@ QWaylandClient *QWaylandWlShell::popupClient() const void QWaylandWlShell::closeAllPopups() { - Q_FOREACH (QWaylandWlShellSurface* shellSurface, mappedPopups()) + const auto mapped = mappedPopups(); + for (QWaylandWlShellSurface *shellSurface : mapped) shellSurface->sendPopupDone(); } diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index 99a2e765..b732069c 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -198,7 +198,8 @@ void WlShellIntegration::handleSetPopup(QWaylandSeat *seat, QWaylandSurface *par // Find the parent item on the same output QWaylandQuickShellSurfaceItem *parentItem = nullptr; - Q_FOREACH (QWaylandView *view, parent->views()) { + const auto views = parent->views(); + for (QWaylandView *view : views) { if (view->output() == m_item->view()->output()) { QWaylandQuickShellSurfaceItem *item = qobject_cast<QWaylandQuickShellSurfaceItem*>(view->renderObject()); if (item) { diff --git a/src/compositor/extensions/qwaylandxdgshell.cpp b/src/compositor/extensions/qwaylandxdgshell.cpp index f06fd793..eece3f3d 100644 --- a/src/compositor/extensions/qwaylandxdgshell.cpp +++ b/src/compositor/extensions/qwaylandxdgshell.cpp @@ -1279,7 +1279,9 @@ QWaylandXdgToplevel *QWaylandXdgToplevel::fromResource(wl_resource *resource) QList<int> QWaylandXdgToplevel::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; diff --git a/src/compositor/extensions/qwaylandxdgshellv5.cpp b/src/compositor/extensions/qwaylandxdgshellv5.cpp index a85efbc5..eebfab6d 100644 --- a/src/compositor/extensions/qwaylandxdgshellv5.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv5.cpp @@ -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(); } @@ -987,7 +987,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 +1240,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); diff --git a/src/compositor/extensions/qwaylandxdgshellv6.cpp b/src/compositor/extensions/qwaylandxdgshellv6.cpp index d1ee45da..96d6f550 100644 --- a/src/compositor/extensions/qwaylandxdgshellv6.cpp +++ b/src/compositor/extensions/qwaylandxdgshellv6.cpp @@ -1214,7 +1214,9 @@ QWaylandSurfaceRole *QWaylandXdgToplevelV6::role() QList<int> QWaylandXdgToplevelV6::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; diff --git a/src/compositor/global/qwaylandcompositorextension.cpp b/src/compositor/global/qwaylandcompositorextension.cpp index 91298539..36daebce 100644 --- a/src/compositor/global/qwaylandcompositorextension.cpp +++ b/src/compositor/global/qwaylandcompositorextension.cpp @@ -146,7 +146,7 @@ QWaylandObject::QWaylandObject(QObjectPrivate &d, QObject *parent) QWaylandObject::~QWaylandObject() { - foreach (QWaylandCompositorExtension *extension, extension_vector) + for (QWaylandCompositorExtension *extension : qAsConst(extension_vector)) QWaylandCompositorExtensionPrivate::get(extension)->extension_container = nullptr; } diff --git a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp index e30bc84f..624a24b0 100644 --- a/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp +++ b/src/compositor/wayland_wrapper/qwldatadevicemanager.cpp @@ -186,12 +186,12 @@ struct wl_display *DataDeviceManager::display() const void DataDeviceManager::overrideSelection(const QMimeData &mimeData) { - QStringList formats = mimeData.formats(); + const QStringList formats = mimeData.formats(); if (formats.isEmpty()) return; m_retainedData.clear(); - foreach (const QString &format, formats) + for (const QString &format : formats) m_retainedData.setData(format, mimeData.data(format)); QWaylandCompositorPrivate::get(m_compositor)->feedRetainedSelectionData(&m_retainedData); @@ -217,7 +217,8 @@ bool DataDeviceManager::offerFromCompositorToClient(wl_resource *clientDataDevic wl_resource_create(client, &wl_data_offer_interface, -1, 0); wl_resource_set_implementation(selectionOffer, &compositor_offer_interface, this, nullptr); wl_data_device_send_data_offer(clientDataDeviceResource, selectionOffer); - foreach (const QString &format, m_retainedData.formats()) { + const auto formats = m_retainedData.formats(); + for (const QString &format : formats) { QByteArray ba = format.toLatin1(); wl_data_offer_send_offer(selectionOffer, ba.constData()); } diff --git a/src/compositor/wayland_wrapper/qwldataoffer.cpp b/src/compositor/wayland_wrapper/qwldataoffer.cpp index 9fea664a..ddc5545e 100644 --- a/src/compositor/wayland_wrapper/qwldataoffer.cpp +++ b/src/compositor/wayland_wrapper/qwldataoffer.cpp @@ -55,7 +55,8 @@ DataOffer::DataOffer(DataSource *dataSource, QtWaylandServer::wl_data_device::Re { // FIXME: connect to dataSource and reset m_dataSource on destroy target->data_device_object->send_data_offer(target->handle, resource()->handle); - Q_FOREACH (const QString &mimeType, dataSource->mimeTypes()) { + const auto mimeTypes = dataSource->mimeTypes(); + for (const QString &mimeType : mimeTypes) { send_offer(mimeType); } } |