@@ -245,20 +245,26 @@ Item {
245 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
245 anchors { top: parent.top; right: parent.right; bottom: parent.bottom }
246 width: root.dragAreaWidth
246 width: root.dragAreaWidth
248+ // Sitting at the right edge of the screen, this EdgeDragArea directly controls the spreadView when
249+ // attachedToView is true. When the finger movement passes positionMarker3 we detach it from the
250+ // spreadView and make the spreadView snap to positionMarker4.
248 property bool attachedToView: true
251 property bool attachedToView: true
250 property var gesturePoints: new Array()
253 property var gesturePoints: new Array()
252 onTouchXChanged: {
255 onTouchXChanged: {
253 if (!dragging && !priv.waitingForScreenshot) {
256 if (!dragging && !priv.waitingForScreenshot) {
257+ // Initial touch. Let's update the screenshot and reset the spreadView to the starting position.
254 priv.requestNewScreenshot();
258 priv.requestNewScreenshot();
255 spreadView.stage = 0;
259 spreadView.stage = 0;
256 spreadView.contentX = -spreadView.shift;
260 spreadView.contentX = -spreadView.shift;
258 if (dragging && attachedToView) {
262 if (dragging && attachedToView) {
263+ // Gesture recognized. Let's move the spreadView with the finger
259 spreadView.contentX = -touchX - spreadView.shift;
264 spreadView.contentX = -touchX - spreadView.shift;
261 if (attachedToView && spreadView.shiftedContentX >= spreadView.width * spreadView.positionMarker3) {
266 if (attachedToView && spreadView.shiftedContentX >= spreadView.width * spreadView.positionMarker3) {
267+ // We passed positionMarker3. Detach from spreadView and snap it.
262 attachedToView = false;
268 attachedToView = false;
263 spreadView.snap();
269 spreadView.snap();
@@ -272,6 +278,11 @@ Item {
274 onDraggingChanged: {
280 onDraggingChanged: {
285+ // Ok. The user released. Find out if it was a one-way movement.
275 var oneWayFlick = true;
286 var oneWayFlick = true;
276 var smallestX = spreadDragArea.width;
287 var smallestX = spreadDragArea.width;
277 for (var i = 0; i < gesturePoints.length; i++) {
288 for (var i = 0; i < gesturePoints.length; i++) {
@@ -283,9 +294,14 @@ Item {
284 gesturePoints = [];
295 gesturePoints = [];
297+ if (oneWayFlick && spreadView.shiftedContentX > units.gu(2) &&
286− if (oneWayFlick && spreadView.shiftedContentX > units.gu(2) && spreadView.shiftedContentX < spreadView.positionMarker1 * spreadView.width) {
298+ spreadView.shiftedContentX < spreadView.positionMarker1 * spreadView.width) {
299+ // If it was a short one-way movement, do the Alt+Tab switch
300+ // no matter if we didn't cross positionMarker1 yet.
287 spreadView.snapTo(1);
301 spreadView.snapTo(1);
288 } else if (!dragging && attachedToView) {
302 } else if (!dragging && attachedToView) {
303+ // otherwise snap to the closest snap position we can find
304+ // (might be back to start, to app 1 or to spread)
289 spreadView.snap();
305 spreadView.snap();
@@ -321,10 +337,15 @@ Item {
322 property int tileDistance: width / 4
338 property int tileDistance: width / 4
340+ // Those markers mark the various positions in the spread (ratio to screen width from right to left):
341+ // 0 - 1: following finger, snap back to the beginning on release
324 property real positionMarker1: 0.3
342 property real positionMarker1: 0.3
343+ // 1 - 2: curved snapping movement, snap to app 1 on release
325 property real positionMarker2: 0.45
344 property real positionMarker2: 0.45
345+ // 2 - 3: movement follows finger, snaps back to app 1 on release
326 property real positionMarker3: 0.6
346 property real positionMarker3: 0.6
347+ // passing 3, we detach movement from the finger and snap to 4
327− property real positionMarker4: .9
348+ property real positionMarker4: 0.9
329 // This is where the first app snaps to when bringing it in from the right edge.
350 // This is where the first app snaps to when bringing it in from the right edge.
330 property real snapPosition: 0.75
351 property real snapPosition: 0.75