on xenial help sign in
Ensure mouse and window movement are pixel-aligned
60472f0Daniel d'Andrada
plugins/Cursor/MousePointer.cpp+8−3
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2015 Canonical, Ltd.
2+ * Copyright (C) 2015-2016 Canonical, Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it under
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -43,7 +43,12 @@ void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, Qt::Mouse
43 Q_EMIT mouseMoved();
43 Q_EMIT mouseMoved();
44 }
44 }
45
45
46+ m_accumulatedMovement += movement;
47+ // don't apply the fractional part
48+ QPointF appliedMovement(int(m_accumulatedMovement.x()), int(m_accumulatedMovement.y()));
49+ m_accumulatedMovement -= appliedMovement;
50+
46− qreal newX = x() + movement.x();
51+ qreal newX = x() + appliedMovement.x();
47 if (newX < 0) {
52 if (newX < 0) {
48 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
53 Q_EMIT pushedLeftBoundary(qAbs(newX), buttons);
49 newX = 0;
54 newX = 0;
@@ -53,7 +58,7 @@ void MousePointer::handleMouseEvent(ulong timestamp, QPointF movement, Qt::Mouse
53 }
58 }
54 setX(newX);
59 setX(newX);
55
60
56− qreal newY = y() + movement.y();
61+ qreal newY = y() + appliedMovement.y();
57 if (newY < 0) {
62 if (newY < 0) {
58 newY = 0;
63 newY = 0;
59 } else if (newY > parentItem()->height()) {
64 } else if (newY > parentItem()->height()) {
plugins/Cursor/MousePointer.h+4−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2015 Canonical, Ltd.
2+ * Copyright (C) 2015-2016 Canonical, Ltd.
3 *
3 *
4 * This program is free software: you can redistribute it and/or modify it under
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -56,6 +56,9 @@ private:
56 QPointer<QWindow> m_registeredWindow;
56 QPointer<QWindow> m_registeredWindow;
57 QString m_cursorName;
57 QString m_cursorName;
58 QString m_themeName;
58 QString m_themeName;
59+
60+ // Accumulated, unapplied, mouse movement.
61+ QPointF m_accumulatedMovement;
59};
62};
60
63
61#endif // MOUSEPOINTER_H
64#endif // MOUSEPOINTER_H
qml/Stages/WindowDecoration.qml+5−2
@@ -58,8 +58,11 @@ MouseArea {
58 if (priv.dragging) {
58 if (priv.dragging) {
59 Mir.cursorName = "grabbing";
59 Mir.cursorName = "grabbing";
60 var pos = mapToItem(root.target.parent, mouseX, mouseY);
60 var pos = mapToItem(root.target.parent, mouseX, mouseY);
61+ // Use integer coordinate values to ensure that target is left in a pixel-aligned
62+ // position. Mouse movement could have subpixel precision, yielding a fractional
63+ // mouse position.
61− root.target.x = pos.x - priv.distanceX;
64+ root.target.x = Math.round(pos.x - priv.distanceX);
62− root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
65+ root.target.y = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
63 }
66 }
64 }
67 }
65
68