Prefer constant iterators when we don't change the container
This commit is contained in:
parent
7b99a28050
commit
a7ecaa55e3
1 changed files with 8 additions and 9 deletions
|
@ -340,10 +340,10 @@ WaylandSeat::WaylandSeat(wl_seat *seat, WaylandBackend *backend)
|
||||||
|
|
||||||
void WaylandBackend::pointerMotionRelativeToOutput(const QPointF &position, quint32 time)
|
void WaylandBackend::pointerMotionRelativeToOutput(const QPointF &position, quint32 time)
|
||||||
{
|
{
|
||||||
auto outputIt = std::find_if(m_outputs.begin(), m_outputs.end(), [this](WaylandOutput *wo) {
|
auto outputIt = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), [this](WaylandOutput *wo) {
|
||||||
return wo->surface() == m_seat->pointer()->enteredSurface();
|
return wo->surface() == m_seat->pointer()->enteredSurface();
|
||||||
});
|
});
|
||||||
Q_ASSERT(outputIt != m_outputs.end());
|
Q_ASSERT(outputIt != m_outputs.constEnd());
|
||||||
const QPointF outputPosition = (*outputIt)->geometry().topLeft() + position;
|
const QPointF outputPosition = (*outputIt)->geometry().topLeft() + position;
|
||||||
Platform::pointerMotion(outputPosition, time);
|
Platform::pointerMotion(outputPosition, time);
|
||||||
}
|
}
|
||||||
|
@ -640,10 +640,10 @@ void WaylandBackend::initConnection()
|
||||||
|
|
||||||
void WaylandBackend::updateScreenSize(WaylandOutput *output)
|
void WaylandBackend::updateScreenSize(WaylandOutput *output)
|
||||||
{
|
{
|
||||||
auto it = std::find(m_outputs.begin(), m_outputs.end(), output);
|
auto it = std::find(m_outputs.constBegin(), m_outputs.constEnd(), output);
|
||||||
|
|
||||||
int nextLogicalPosition = output->geometry().topRight().x();
|
int nextLogicalPosition = output->geometry().topRight().x();
|
||||||
while (++it != m_outputs.end()) {
|
while (++it != m_outputs.constEnd()) {
|
||||||
const QRect geo = (*it)->geometry();
|
const QRect geo = (*it)->geometry();
|
||||||
(*it)->setGeometry(QPoint(nextLogicalPosition, 0), geo.size());
|
(*it)->setGeometry(QPoint(nextLogicalPosition, 0), geo.size());
|
||||||
nextLogicalPosition = geo.topRight().x();
|
nextLogicalPosition = geo.topRight().x();
|
||||||
|
@ -737,7 +737,7 @@ QPainterBackend *WaylandBackend::createQPainterBackend()
|
||||||
|
|
||||||
void WaylandBackend::checkBufferSwap()
|
void WaylandBackend::checkBufferSwap()
|
||||||
{
|
{
|
||||||
const bool allRendered = std::all_of(m_outputs.begin(), m_outputs.end(), [](WaylandOutput *o) {
|
const bool allRendered = std::all_of(m_outputs.constBegin(), m_outputs.constEnd(), [](WaylandOutput *o) {
|
||||||
return o->rendered();
|
return o->rendered();
|
||||||
});
|
});
|
||||||
if (!allRendered) {
|
if (!allRendered) {
|
||||||
|
@ -750,10 +750,9 @@ void WaylandBackend::checkBufferSwap()
|
||||||
if (!output->rendered()) {
|
if (!output->rendered()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Compositor::self()->bufferSwapComplete();
|
Compositor::self()->bufferSwapComplete();
|
||||||
|
|
||||||
for (auto *output : m_outputs) {
|
for (auto *output : qAsConst(m_outputs)) {
|
||||||
output->resetRendered();
|
output->resetRendered();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -771,8 +770,8 @@ WaylandOutput* WaylandBackend::getOutputAt(const QPointF globalPosition)
|
||||||
auto checkPosition = [pos](WaylandOutput *output) {
|
auto checkPosition = [pos](WaylandOutput *output) {
|
||||||
return output->geometry().contains(pos);
|
return output->geometry().contains(pos);
|
||||||
};
|
};
|
||||||
auto it = std::find_if(m_outputs.begin(), m_outputs.end(), checkPosition);
|
auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), checkPosition);
|
||||||
return it == m_outputs.end() ? nullptr : *it;
|
return it == m_outputs.constEnd() ? nullptr : *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaylandBackend::supportsPointerLock()
|
bool WaylandBackend::supportsPointerLock()
|
||||||
|
|
Loading…
Reference in a new issue