on xenial help sign in
Implement moving windows by Alt + left mouse button

Approved by: Daniel d'Andrada

commit452372c82255628fa6147c757b7adec18b014c6b authorLukáš Tinkl <lukas.tinkl@canonical.com> dateFri 9 Sep 2016, 14:51 (10 years ago) parentfc5ef5e27a857c
1 file changed+30
qml/Stages/DecoratedWindow.qml+30
qml/Stages/DecoratedWindow.qml+30
@@ -154,4 +154,34 @@ FocusScope {
154154 angle: rotationAngle
155155 }
156156 }
157+
158+ MouseArea {
159+ anchors.fill: applicationWindow
160+ acceptedButtons: Qt.LeftButton
161+ hoverEnabled: true
162+ property bool dragging: false
163+ onPressed: {
164+ if (mouse.button == Qt.LeftButton && mouse.modifiers == Qt.AltModifier) {
165+ root.decorationPressed(); // to raise it
166+ moveHandler.handlePressedChanged(true, Qt.LeftButton, mouse.x, mouse.y);
167+ dragging = true;
168+ mouse.accepted = true;
169+ } else {
170+ mouse.accepted = false;
171+ }
172+ }
173+ onPositionChanged: {
174+ if (dragging) {
175+ moveHandler.handlePositionChanged(mouse);
176+ }
177+ }
178+ onReleased: {
179+ if (dragging) {
180+ moveHandler.handlePressedChanged(false, Qt.LeftButton);
181+ root.decorationReleased(); // commits the fake preview max rectangle
182+ moveHandler.handleReleased();
183+ dragging = false;
184+ }
185+ }
186+ }
157187}