on xenial help sign in
add support for dragging apps out of the spread
792e2c9Michael Zanetti
qml/Stage/Spread/ScreensAndWorkspaces.qml+19
@@ -33,6 +33,25 @@ Item {
33 backgroundColor: "white"
33 backgroundColor: "white"
34 z: 1
34 z: 1
35
35
36+ DropArea {
37+ anchors.fill: parent
38+ keys: ["workspace"]
39+
40+ onEntered: {
41+ workspaces.workspaceModel.insert(workspaces.workspaceModel.count, {text: drag.source.text})
42+ drag.source.inDropArea = true;
43+ }
44+
45+ onExited: {
46+ workspaces.workspaceModel.remove(workspaces.workspaceModel.count - 1, 1)
47+ drag.source.inDropArea = false;
48+ }
49+
50+ onDropped: {
51+ drag.source.inDropArea = false;
52+ }
53+ }
54+
36 Column {
55 Column {
37 anchors.fill: parent
56 anchors.fill: parent
38 anchors.margins: units.gu(1)
57 anchors.margins: units.gu(1)
qml/Stage/Spread/SpreadDelegateInputArea.qml+24−11
@@ -85,15 +85,15 @@ Item {
85 }
85 }
86
86
87 // Event eater
87 // Event eater
88− MouseArea {
88+// MouseArea {
89− anchors.fill: parent
89+// anchors.fill: parent
90− onClicked: root.clicked()
90+// onClicked: root.clicked()
91− onWheel: wheel.accepted = true
91+// onWheel: wheel.accepted = true
92− }
92+// }
93
93
94 MultiPointTouchArea {
94 MultiPointTouchArea {
95 anchors.fill: parent
95 anchors.fill: parent
96− mouseEnabled: false
96+// mouseEnabled: false
97 maximumTouchPoints: 1
97 maximumTouchPoints: 1
98 property int offset: 0
98 property int offset: 0
99
99
@@ -109,7 +109,7 @@ Item {
109 }
109 }
110
110
111 onTouchUpdated: {
111 onTouchUpdated: {
112− if (!d.moving) {
112+ if (!d.moving || !tp.pressed) {
113 if (Math.abs(tp.startY - tp.y) > d.threshold) {
113 if (Math.abs(tp.startY - tp.y) > d.threshold) {
114 d.moving = true;
114 d.moving = true;
115 d.dragEvents = []
115 d.dragEvents = []
@@ -119,17 +119,30 @@ Item {
119 }
119 }
120 }
120 }
121
121
122− if (root.closeable) {
122+
123− d.distance = tp.y - tp.startY - offset
123+ var value = tp.y - tp.startY - offset;
124+ if (value < 0) {
125+ var coords = mapToItem(shell, tp.x, tp.y);
126+ fakeDragItem.x = coords.x
127+ fakeDragItem.y = coords.y
128+ fakeDragItem.Drag.active = true;
129+ fakeDragItem.surface = model.window.surface;
130+
124 } else {
131 } else {
125− var value = tp.y - tp.startY - offset;
132+ if (root.closeable) {
133+ d.distance = value
134+ } else {
126− d.distance = Math.sqrt(Math.abs(value)) * (value < 0 ? -1 : 1) * 3
135+ d.distance = Math.sqrt(Math.abs(value)) * (value < 0 ? -1 : 1) * 3
136+ }
127 }
137 }
128
138
129 d.pushDragEvent(tp);
139 d.pushDragEvent(tp);
130 }
140 }
131
141
132 onReleased: {
142 onReleased: {
143+ print("released!")
144+ fakeDragItem.surface = null;
145+
133 if (!d.moving) {
146 if (!d.moving) {
134 root.clicked()
147 root.clicked()
135 }
148 }
qml/Stage/Spread/WorkspacePreview.qml+10−1
@@ -14,9 +14,18 @@ Item {
14
14
15 property real previewScale: previewSpace.height / previewSpace.screenHeight
15 property real previewScale: previewSpace.height / previewSpace.screenHeight
16
16
17− Wallpaper {
17+ DropArea {
18+ anchors.fill: parent
19+ keys: ["application"]
20+
21+ onEntered: print("yehaaaa")
22+ }
23+
24+ Image {
18 source: previewSpace.background
25 source: previewSpace.background
19 anchors.fill: parent
26 anchors.fill: parent
27+ sourceSize.width: width
28+ sourceSize.height: height
20
29
21 Repeater {
30 Repeater {
22 id: topLevelSurfaceRepeater
31 id: topLevelSurfaceRepeater
qml/Stage/Spread/Workspaces.qml+17−6
@@ -48,7 +48,7 @@ Item {
48 anchors.fill: parent
48 anchors.fill: parent
49 anchors.leftMargin: -itemWidth
49 anchors.leftMargin: -itemWidth
50 anchors.rightMargin: -itemWidth
50 anchors.rightMargin: -itemWidth
51− interactive: false
51+// interactive: false
52
52
53 orientation: ListView.Horizontal
53 orientation: ListView.Horizontal
54 spacing: units.gu(1)
54 spacing: units.gu(1)
@@ -178,17 +178,25 @@ Item {
178 id: mouseArea
178 id: mouseArea
179 anchors.fill: parent
179 anchors.fill: parent
180 hoverEnabled: true
180 hoverEnabled: true
181− preventStealing: true
181+ propagateComposedEvents: true
182 anchors.leftMargin: listView.leftMargin
182 anchors.leftMargin: listView.leftMargin
183 anchors.rightMargin: listView.rightMargin
183 anchors.rightMargin: listView.rightMargin
184
184
185 property int draggedIndex: -1
185 property int draggedIndex: -1
186
186
187+ property int startX: 0
188+ property int startY: 0
189+
187 onMouseXChanged: {
190 onMouseXChanged: {
191+ if (!pressed || dragging) {
188− var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.foldingAreaWidth * 2)))
192+ var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.foldingAreaWidth * 2)))
189−// var progress = mouseX / width
190− print("p:", progress)
191− listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
193+ listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
194+ }
195+ }
196+ onMouseYChanged: {
197+ if (Math.abs(mouseY - startY) > units.gu(3)) {
198+ drag.axis = Drag.XAndYAxis;
199+ }
192 }
200 }
193
201
194 onReleased: {
202 onReleased: {
@@ -205,6 +213,8 @@ Item {
205 }
213 }
206
214
207 onPressed: {
215 onPressed: {
216+ startX = mouseX;
217+ startY = mouseY;
208 if (listView.model.count < 2) return;
218 if (listView.model.count < 2) return;
209
219
210 var coords = mapToItem(listView.contentItem, mouseX, mouseY)
220 var coords = mapToItem(listView.contentItem, mouseX, mouseY)
@@ -220,6 +230,7 @@ Item {
220 fakeDragItem.Drag.hotSpot.x = mouseCoordsInItem.x
230 fakeDragItem.Drag.hotSpot.x = mouseCoordsInItem.x
221 fakeDragItem.Drag.hotSpot.y = mouseCoordsInItem.y
231 fakeDragItem.Drag.hotSpot.y = mouseCoordsInItem.y
222
232
233+ drag.axis = Drag.YAxis;
223 drag.target = fakeDragItem;
234 drag.target = fakeDragItem;
224 }
235 }
225
236
qml/Stage/Stage.qml+24−2
@@ -620,6 +620,8 @@ FocusScope {
620 property int scrollAreaWidth: width / 3
620 property int scrollAreaWidth: width / 3
621 property bool progressiveScrollingEnabled: false
621 property bool progressiveScrollingEnabled: false
622
622
623+ onPressed: mouse.accepted = false
624+
623 onMouseXChanged: {
625 onMouseXChanged: {
624 mouse.accepted = false
626 mouse.accepted = false
625
627
@@ -658,8 +660,6 @@ FocusScope {
658 }
660 }
659 }
661 }
660 }
662 }
661−
662− onPressed: mouse.accepted = false
663 }
663 }
664 }
664 }
665
665
@@ -755,6 +755,25 @@ FocusScope {
755 }
755 }
756 }
756 }
757
757
758+ MirSurfaceItem {
759+ id: fakeDragItem
760+ property real previewScale: .5
761+ width: implicitWidth * previewScale
762+ height: implicitHeight * previewScale
763+ surfaceWidth: -1
764+ surfaceHeight: -1
765+// surface: model.window.surface
766+ onSurfaceChanged: print("surface changed", surface)
767+ opacity: surface != null ? 1 : 0
768+ Behavior on opacity { UbuntuNumberAnimation {} }
769+ visible: opacity > 0
770+
771+ Drag.active: surface != null
772+ Drag.keys: ["application"]
773+
774+ z: 1000
775+ }
776+
758 Item {
777 Item {
759 id: boundariesForWindowPlacement
778 id: boundariesForWindowPlacement
760 anchors.fill: parent
779 anchors.fill: parent
@@ -790,6 +809,9 @@ FocusScope {
790 }
809 }
791 z: normalZ
810 z: normalZ
792
811
812+ opacity: fakeDragItem.surface == model.window.surface && fakeDragItem.Drag.active ? 0 : 1
813+ Behavior on opacity { UbuntuNumberAnimation {} }
814+
793 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
815 // Normally we want x/y where the surface thinks it is. Width/height of our delegate will
794 // match what the actual surface size is.
816 // match what the actual surface size is.
795 // Don't write to those, they will be set by states
817 // Don't write to those, they will be set by states