on xenial help sign in
Drag child windows with Alt+LeftMouseButton (LP: #1664947)
60493b4Daniel d'Andrada
qml/Stage/ChildWindow.qml+34−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2016 Canonical, Ltd.
2+ * Copyright (C) 2016-2017 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
5 * it under the terms of the GNU General Public License as published by
@@ -143,6 +143,39 @@ Item {
143 consumesInput: true
143 consumesInput: true
144 }
144 }
145
145
146+ Loader {
147+ active: d.moveable
148+ anchors.fill: parent
149+ sourceComponent: Component {
150+ MouseArea {
151+ acceptedButtons: Qt.LeftButton
152+ property bool dragging: false
153+ cursorShape: undefined // don't interfere with the cursor shape set by the underlying MirSurfaceItem
154+ onPressed: {
155+ if (mouse.button == Qt.LeftButton && mouse.modifiers == Qt.AltModifier) {
156+ d.moveHandler.handlePressedChanged(true, Qt.LeftButton, mouse.x, mouse.y);
157+ dragging = true;
158+ mouse.accepted = true;
159+ } else {
160+ mouse.accepted = false;
161+ }
162+ }
163+ onPositionChanged: {
164+ if (dragging) {
165+ d.moveHandler.handlePositionChanged(mouse);
166+ }
167+ }
168+ onReleased: {
169+ if (dragging) {
170+ d.moveHandler.handlePressedChanged(false, Qt.LeftButton);
171+ d.moveHandler.handleReleased();
172+ dragging = false;
173+ }
174+ }
175+ }
176+ }
177+ }
178+
146 Loader {
179 Loader {
147 id: touchOverlayLoader
180 id: touchOverlayLoader
148 active: d.resizeable || d.moveable
181 active: d.resizeable || d.moveable