Changeset View
Changeset View
Standalone View
Standalone View
pointer_input.cpp
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | 107 | { | |||
---|---|---|---|---|---|
108 | for (int i = 0; i < screens()->count(); ++i) { | 108 | for (int i = 0; i < screens()->count(); ++i) { | ||
109 | if (screens()->geometry(i).contains(pos.toPoint())) { | 109 | if (screens()->geometry(i).contains(pos.toPoint())) { | ||
110 | return true; | 110 | return true; | ||
111 | } | 111 | } | ||
112 | } | 112 | } | ||
113 | return false; | 113 | return false; | ||
114 | } | 114 | } | ||
115 | 115 | | |||
116 | static QPointF confineToBoundingBox(const QPointF &pos, const QRectF &boundingBox) | ||||
117 | { | ||||
118 | return QPointF( | ||||
119 | qBound(boundingBox.left(), pos.x(), boundingBox.right() - 1.0), | ||||
120 | qBound(boundingBox.top(), pos.y(), boundingBox.bottom() - 1.0) | ||||
121 | ); | ||||
122 | } | ||||
123 | | ||||
116 | PointerInputRedirection::PointerInputRedirection(InputRedirection* parent) | 124 | PointerInputRedirection::PointerInputRedirection(InputRedirection* parent) | ||
117 | : InputDeviceHandler(parent) | 125 | : InputDeviceHandler(parent) | ||
118 | , m_cursor(nullptr) | 126 | , m_cursor(nullptr) | ||
119 | , m_supportsWarping(Application::usesLibinput()) | 127 | , m_supportsWarping(Application::usesLibinput()) | ||
120 | { | 128 | { | ||
121 | } | 129 | } | ||
122 | 130 | | |||
123 | PointerInputRedirection::~PointerInputRedirection() = default; | 131 | PointerInputRedirection::~PointerInputRedirection() = default; | ||
▲ Show 20 Lines • Show All 616 Lines • ▼ Show 20 Line(s) | |||||
740 | { | 748 | { | ||
741 | if (m_locked) { | 749 | if (m_locked) { | ||
742 | // locked pointer should not move | 750 | // locked pointer should not move | ||
743 | return; | 751 | return; | ||
744 | } | 752 | } | ||
745 | // verify that at least one screen contains the pointer position | 753 | // verify that at least one screen contains the pointer position | ||
746 | QPointF p = pos; | 754 | QPointF p = pos; | ||
747 | if (!screenContainsPos(p)) { | 755 | if (!screenContainsPos(p)) { | ||
748 | // allow either x or y to pass | 756 | const QRectF unitedScreensGeometry = screens()->geometry(); | ||
749 | p = QPointF(m_pos.x(), pos.y()); | 757 | p = confineToBoundingBox(p, unitedScreensGeometry); | ||
750 | if (!screenContainsPos(p)) { | | |||
751 | p = QPointF(pos.x(), m_pos.y()); | | |||
752 | if (!screenContainsPos(p)) { | 758 | if (!screenContainsPos(p)) { | ||
753 | return; | 759 | const QRectF currentScreenGeometry = screens()->geometry(screens()->number(m_pos.toPoint())); | ||
754 | } | 760 | p = confineToBoundingBox(p, currentScreenGeometry); | ||
755 | } | 761 | } | ||
756 | } | 762 | } | ||
757 | p = applyPointerConfinement(p); | 763 | p = applyPointerConfinement(p); | ||
758 | if (p == m_pos) { | 764 | if (p == m_pos) { | ||
759 | // didn't change due to confinement | 765 | // didn't change due to confinement | ||
760 | return; | 766 | return; | ||
761 | } | 767 | } | ||
762 | // verify screen confinement | 768 | // verify screen confinement | ||
▲ Show 20 Lines • Show All 551 Lines • Show Last 20 Lines |