diff --git a/src/canvas.cpp b/src/canvas.cpp index b6b31addcf490efb951d03b49f6d62ad1fe51b0d..f81f58bb0a293b69f62910d5ba29cefdbeb84c76 100644 --- a/src/canvas.cpp +++ b/src/canvas.cpp @@ -264,6 +264,33 @@ void Canvas::mouseMoveEvent(QMouseEvent *event) { cur_layout->scroll_smooth(event->x() - mx, event->y() - my); mx = event->x(); my = event->y(); + + // wrap mouse around when dragging at the border + if (mx <= 0) { + mx = width() - 2; + QCursor c = cursor(); + c.setPos(mapToGlobal(QPoint(mx, my))); + setCursor(c); + } + if (mx >= width() - 1) { + mx = 1; + QCursor c = cursor(); + c.setPos(mapToGlobal(QPoint(mx, my))); + setCursor(c); + } + + if (my <= 0) { + my = height() - 2; + QCursor c = cursor(); + c.setPos(mapToGlobal(QPoint(mx, my))); + setCursor(c); + } + if (my >= height() - 1) { + my = 1; + QCursor c = cursor(); + c.setPos(mapToGlobal(QPoint(mx, my))); + setCursor(c); + } } if (select_text_button != Qt::NoButton && event->buttons() & select_text_button) { cur_layout->select(event->x(), event->y(), Selection::End);