@@ -22,6 +22,8 @@
2222
2323#include <QQuickWindow>
2424#include <QGuiApplication>
25+#include <QQmlProperty>
26+#include <QtMath>
2527
2628#include <qpa/qwindowsysteminterface.h>
2729
@@ -48,23 +50,33 @@ void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, Qt::Mouse
4850 QPointF appliedMovement(int(m_accumulatedMovement.x()), int(m_accumulatedMovement.y()));
4951 m_accumulatedMovement -= appliedMovement;
5052
51− qreal newX = x() + appliedMovement.x();
52− if (newX < 0) {
53+ const qreal newX = x() + appliedMovement.x();
54+ const qreal newY = y() + appliedMovement.y();
55+ const qreal sceneWidth = parentItem()->width();
56+ const qreal sceneHeight = parentItem()->height();
57+
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
5371 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
54− newX = 0;
55− } else if (newX >= parentItem()->width()) {
56− Q_EMIT pushedRightBoundary(newX - (parentItem()->width() - 1), buttons);
57− newX = parentItem()->width() - 1;
72+ } else if (newX >= sceneWidth) { // right edge
73+ Q_EMIT pushedRightBoundary(newX - (sceneWidth - 1), buttons);
74+ } else if (newY < m_panelHeight) { // top edge
75+ Q_EMIT pushedTopBoundary(qAbs(newY), buttons);
5876 }
59− setX(newX);
6077
61− qreal newY = y() + appliedMovement.y();
62− if (newY < 0) {
63− newY = 0;
64− } else if (newY >= parentItem()->height()) {
65− newY = parentItem()->height() - 1;
66− }
67− setY(newY);
78+ setX(qBound(0.0, newX, sceneWidth - 1));
79+ setY(qBound(0.0, newY, sceneHeight - 1));
6880
6981 QPointF scenePosition = mapToItem(nullptr, QPointF(0, 0));
7082 QWindowSystemInterface::handleMouseEvent(window(), timestamp, scenePosition /*local*/, scenePosition /*global*/,
@@ -89,6 +101,12 @@ void MousePointer::itemChange(ItemChange change, const ItemChangeData &value)
89101 }
90102}
91103
104+void MousePointer::componentComplete()
105+{
106+ MirMousePointerInterface::componentComplete();
107+ m_panelHeight = QQmlProperty::read(this, "panelHeight").toInt();
108+}
109+
92110void MousePointer::registerWindow(QWindow *window)
93111{
94112 if (window == m_registeredWindow) {