@@ -22,6 +22,8 @@
23#include <QQuickWindow>
23#include <QQuickWindow>
24#include <QGuiApplication>
24#include <QGuiApplication>
25+#include <QQmlProperty>
26#include <qpa/qwindowsysteminterface.h>
28#include <qpa/qwindowsysteminterface.h>
@@ -48,23 +50,33 @@ void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, Qt::Mouse
48 QPointF appliedMovement(int(m_accumulatedMovement.x()), int(m_accumulatedMovement.y()));
50 QPointF appliedMovement(int(m_accumulatedMovement.x()), int(m_accumulatedMovement.y()));
49 m_accumulatedMovement -= appliedMovement;
51 m_accumulatedMovement -= appliedMovement;
51− qreal newX = x() + appliedMovement.x();
53+ const qreal newX = x() + appliedMovement.x();
52− if (newX < 0) {
54+ const qreal newY = y() + appliedMovement.y();
55+ const qreal sceneWidth = parentItem()->width();
56+ const qreal sceneHeight = parentItem()->height();
58+ if (newX < 0 && newY < m_panelHeight) { // top left corner
59+ const auto distance = qSqrt(qPow(newX, 2) + qPow(newY-m_panelHeight, 2));
60+ Q_EMIT pushedTopLeftCorner(qAbs(distance), buttons);
61+ } else if (newX >= sceneWidth && newY < m_panelHeight) { // top right corner
62+ const auto distance = qSqrt(qPow(newX-sceneWidth, 2) + qPow(newY-m_panelHeight, 2));
63+ Q_EMIT pushedTopRightCorner(qAbs(distance), buttons);
64+ } else if (newX < 0 && newY >= sceneHeight) { // bottom left corner
65+ const auto distance = qSqrt(qPow(newX, 2) + qPow(newY-sceneHeight, 2));
66+ Q_EMIT pushedBottomLeftCorner(qAbs(distance), buttons);
67+ } else if (newX >= sceneWidth && newY >= sceneHeight) { // bottom right corner
68+ const auto distance = qSqrt(qPow(newX-sceneWidth, 2) + qPow(newY-sceneHeight, 2));
69+ Q_EMIT pushedBottomRightCorner(qAbs(distance), buttons);
70+ } else if (newX < 0) { // left edge
53 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
71 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
54− newX = 0;
72+ } else if (newX >= sceneWidth) { // right edge
55− } else if (newX >= parentItem()->width()) {
56− Q_EMIT pushedRightBoundary(newX - (parentItem()->width() - 1), buttons);
73+ Q_EMIT pushedRightBoundary(newX - (sceneWidth - 1), buttons);
57− newX = parentItem()->width() - 1;
74+ } else if (newY < m_panelHeight) { // top edge
75+ Q_EMIT pushedTopBoundary(qAbs(newY), buttons);
61− qreal newY = y() + appliedMovement.y();
78+ setX(qBound(0.0, newX, sceneWidth - 1));
64− } else if (newY >= parentItem()->height()) {
65− newY = parentItem()->height() - 1;
67− setY(newY);
79+ setY(qBound(0.0, newY, sceneHeight - 1));
69 QPointF scenePosition = mapToItem(nullptr, QPointF(0, 0));
81 QPointF scenePosition = mapToItem(nullptr, QPointF(0, 0));
70 QWindowSystemInterface::handleMouseEvent(window(), timestamp, scenePosition /*local*/, scenePosition /*global*/,
82 QWindowSystemInterface::handleMouseEvent(window(), timestamp, scenePosition /*local*/, scenePosition /*global*/,
@@ -89,6 +101,12 @@ void MousePointer::itemChange(ItemChange change, const ItemChangeData &value)
104+void MousePointer::componentComplete()
106+ MirMousePointerInterface::componentComplete();
107+ m_panelHeight = QQmlProperty::read(this, "panelHeight").toInt();
92void MousePointer::registerWindow(QWindow *window)
110void MousePointer::registerWindow(QWindow *window)
94 if (window == m_registeredWindow) {
112 if (window == m_registeredWindow) {