Commit d54aaf5a authored by Xaver Hugl's avatar Xaver Hugl
Browse files

workspace: restore cursor position after output changes

parent a3286959
Pipeline #221577 failed with stage
in 34 minutes and 50 seconds
......@@ -2210,6 +2210,22 @@ void Workspace::desktopResized()
}
updateClientArea();
// restore cursor position
const auto oldCursorOutput = std::find_if(m_oldScreenGeometries.cbegin(), m_oldScreenGeometries.cend(), [](const auto &geometry) {
return geometry.contains(Cursors::self()->mouse()->pos());
});
if (oldCursorOutput != m_oldScreenGeometries.end()) {
const Output *cursorOutput = oldCursorOutput.key();
if (std::find(m_outputs.cbegin(), m_outputs.cend(), cursorOutput) != m_outputs.cend()) {
const QRect oldGeometry = oldCursorOutput.value();
const QRect newGeometry = cursorOutput->geometry();
const QPoint relativePosition = Cursors::self()->mouse()->pos() - oldGeometry.topLeft();
const QPoint newRelativePosition(newGeometry.width() * relativePosition.x() / float(oldGeometry.width()), newGeometry.height() * relativePosition.y() / float(oldGeometry.height()));
Cursors::self()->mouse()->setPos(newGeometry.topLeft() + newRelativePosition);
}
}
saveOldScreenSizes(); // after updateClientArea(), so that one still uses the previous one
// TODO: emit a signal instead and remove the deep function calls into edges and effects
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment