@@ -13,6 +13,7 @@ Item {
13 property var background // TODO: should be stored in the workspace data
13 property var background // TODO: should be stored in the workspace data
15 signal commitScreenSetup();
15 signal commitScreenSetup();
16+ signal closeSpread();
17 DropArea {
18 DropArea {
18 anchors.fill: root
19 anchors.fill: root
@@ -20,15 +21,14 @@ Item {
20 keys: ['workspace']
21 keys: ['workspace']
22 onEntered: {
23 onEntered: {
23− var index = listView.getDropIndex(drag);
24+ listView.updateDropProperties(drag);
24− drag.source.workspace.assign(workspaceModel, index)
25+ drag.source.workspace.assign(workspaceModel, listView.hoveredWorkspaceIndex)
25− listView.dropItemIndex = index;
26 drag.source.inDropArea = true;
26 drag.source.inDropArea = true;
29 onPositionChanged: {
29 onPositionChanged: {
30− var index = listView.getDropIndex(drag);
30+ listView.updateDropProperties(drag);
31− if (listView.dropItemIndex == index) return;
31+ if (listView.dropItemIndex == listView.hoveredWorkspaceIndex) return;
32 listView.model.move(listView.dropItemIndex, index, 1);
32 listView.model.move(listView.dropItemIndex, index, 1);
33 listView.dropItemIndex = index;
33 listView.dropItemIndex = index;
@@ -36,6 +36,7 @@ Item {
36 onExited: {
36 onExited: {
37 drag.source.workspace.unassign()
37 drag.source.workspace.unassign()
38 listView.dropItemIndex = -1;
38 listView.dropItemIndex = -1;
39+ listView.hoveredWorkspaceIndex = -1;
39 drag.source.inDropArea = false;
40 drag.source.inDropArea = false;
@@ -51,7 +52,7 @@ Item {
52 onPositionChanged: {
53 onPositionChanged: {
53 listView.progressiveScroll(drag.x)
54 listView.progressiveScroll(drag.x)
54− listView.hoveredWorkspaceIndex = listView.getDropIndex(drag)
55+ listView.updateDropProperties(drag)
56 onExited: {
57 onExited: {
57 listView.hoveredWorkspaceIndex = -1
58 listView.hoveredWorkspaceIndex = -1
@@ -62,6 +63,10 @@ Item {
62 var workspace = listView.model.get(listView.hoveredWorkspaceIndex);
63 var workspace = listView.model.get(listView.hoveredWorkspaceIndex);
63 WorkspaceManager.moveSurfaceToWorkspace(surface, workspace);
64 WorkspaceManager.moveSurfaceToWorkspace(surface, workspace);
64 drop.accept(Qt.MoveAction)
65 drop.accept(Qt.MoveAction)
66+ if (listView.hoveredHalf == "right") {
67+ workspace.activate();
65 listView.hoveredWorkspaceIndex = -1
70 listView.hoveredWorkspaceIndex = -1
@@ -84,6 +89,7 @@ Item {
84 property real realContentX: contentX - originX + leftMargin
89 property real realContentX: contentX - originX + leftMargin
85 property int dropItemIndex: -1
90 property int dropItemIndex: -1
86 property int hoveredWorkspaceIndex: -1
91 property int hoveredWorkspaceIndex: -1
92+ property string hoveredHalf: "" // left or right
88 function getDropIndex(drag) {
94 function getDropIndex(drag) {
89 var coords = mapToItem(listView.contentItem, drag.x, drag.y)
95 var coords = mapToItem(listView.contentItem, drag.x, drag.y)
@@ -94,6 +100,23 @@ Item {
94 return index;
100 return index;
103+ function updateDropProperties(drag) {
104+ var coords = mapToItem(listView.contentItem, drag.x, drag.y)
105+ var index = Math.floor(drag.x + listView.realContentX) / (listView.itemWidth + listView.spacing);
107+ listView.hoveredWorkspaceIndex = -1;
108+ listView.hoveredHalf = "";
112+ var upperLimit = dropItemIndex == -1 ? listView.count : listView.count - 1
113+ if (index > upperLimit) index = upperLimit;
114+ listView.hoveredWorkspaceIndex = index;
115+ print("updating drag:", (drag.x + listView.realContentX) % (listView.itemWidth + listView.spacing))
116+ var pixelsInTile = (drag.x + listView.realContentX) % (listView.itemWidth + listView.spacing);
117+ listView.hoveredHalf = (pixelsInTile / listView.itemWidth) < .5 ? "left" : "right";
97 function progressiveScroll(mouseX) {
120 function progressiveScroll(mouseX) {
98 var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.leftMargin * 2 - listView.foldingAreaWidth * 2)))
121 var progress = Math.max(0, Math.min(1, (mouseX - listView.foldingAreaWidth) / (width - listView.leftMargin * 2 - listView.foldingAreaWidth * 2)))
99 listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
122 listView.contentX = listView.originX + (listView.contentWidth - listView.width + listView.leftMargin + listView.rightMargin) * progress - listView.leftMargin
@@ -195,13 +218,18 @@ Item {
195 width: listView.itemWidth
218 width: listView.itemWidth
196 background: root.background
219 background: root.background
197 screenHeight: screen.availableModes[screen.currentModeIndex].size.height
220 screenHeight: screen.availableModes[screen.currentModeIndex].size.height
221+ containsDragLeft: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "left"
198− containsDrag: listView.hoveredWorkspaceIndex == index
222+ containsDragRight: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "right"
199 isActive: model.workspace.active
223 isActive: model.workspace.active
201 MouseArea {
225 MouseArea {
202 anchors.fill: parent
226 anchors.fill: parent
203 onClicked: {
227 onClicked: {
204− model.workspace.activate()
228+ model.workspace.activate();
231+ model.workspace.activate();