diff --git a/src/workspace.cpp b/src/workspace.cpp index 85ce1d7bca..6712b72c2b 100644 --- a/src/workspace.cpp +++ b/src/workspace.cpp @@ -1390,7 +1390,8 @@ void Workspace::updateCurrentActivity(const QString &new_activity) Output *Workspace::outputAt(const QPointF &pos) const { Output *bestOutput = nullptr; - int minDistance = INT_MAX; + qreal minDistance; + for (Output *output : std::as_const(m_outputs)) { const QRect &geo = output->geometry(); if (geo.contains(pos.toPoint())) { @@ -1400,7 +1401,7 @@ Output *Workspace::outputAt(const QPointF &pos) const distance = std::min(distance, QPointF(geo.topRight() - pos).manhattanLength()); distance = std::min(distance, QPointF(geo.bottomRight() - pos).manhattanLength()); distance = std::min(distance, QPointF(geo.bottomLeft() - pos).manhattanLength()); - if (distance < minDistance) { + if (!bestOutput || distance < minDistance) { minDistance = distance; bestOutput = output; }