@@ -48,7 +48,7 @@ Item {
48 property real distanceY
48 property real distanceY
49 property bool dragging
49 property bool dragging
51− readonly property int triggerArea: units.gu(3)
51+ readonly property int triggerArea: units.gu(8)
52 property bool nearLeftEdge: target.maximizedLeft
52 property bool nearLeftEdge: target.maximizedLeft
53 property bool nearTopEdge: target.maximized
53 property bool nearTopEdge: target.maximized
54 property bool nearRightEdge: target.maximizedRight
54 property bool nearRightEdge: target.maximizedRight
@@ -101,7 +101,7 @@ Item {
104− function handlePositionChanged(mouse) {
104+ function handlePositionChanged(mouse, sensingPoints) {
105 if (priv.dragging) {
105 if (priv.dragging) {
106 Mir.cursorName = "grabbing";
106 Mir.cursorName = "grabbing";
@@ -118,99 +118,91 @@ Item {
118 target.requestedX = Math.round(pos.x - priv.distanceX);
118 target.requestedX = Math.round(pos.x - priv.distanceX);
119 target.requestedY = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
119 target.requestedY = Math.round(Math.max(pos.y - priv.distanceY, PanelState.panelHeight));
121−// var globalPos = mapToItem(null, mouse.x, mouse.y);
121+ if (sensingPoints) {
122−// var globalX = globalPos.x;
122+ print("!!! Detecting edges/corners in touch mode")
123−// var globalY = globalPos.y;
124−// if (globalX < priv.triggerArea && globalY < PanelState.panelHeight) { // top left
123+ if (sensingPoints.topLeft.x < priv.triggerArea && sensingPoints.topLeft.y < PanelState.panelHeight
125−// if (target.canBeCornerMaximized) {
124+ && target.canBeCornerMaximized) { // top left
126−// priv.progress = priv.progressInCorner(0, PanelState.panelHeight, globalX, globalY);
125+ priv.progress = priv.progressInCorner(0, PanelState.panelHeight, sensingPoints.topLeft.x, sensingPoints.topLeft.y);
127−// priv.resetEdges();
126+ priv.resetEdges();
128−// priv.nearTopLeftCorner = true;
127+ priv.nearTopLeftCorner = true;
129−// root.fakeMaximizeTopLeftAnimationRequested(priv.progress);
128+ root.fakeMaximizeTopLeftAnimationRequested(priv.progress);
131−// } else if (globalX > stageWidth - priv.triggerArea && globalY < PanelState.panelHeight) { // top right
129+ } else if (sensingPoints.topRight.x > stageWidth - priv.triggerArea && sensingPoints.topRight.y < PanelState.panelHeight
132−// if (target.canBeCornerMaximized) {
130+ && target.canBeCornerMaximized) { // top right
133−// priv.progress = priv.progressInCorner(stageWidth, PanelState.panelHeight, globalX, globalY);
131+ priv.progress = priv.progressInCorner(stageWidth, PanelState.panelHeight, sensingPoints.topRight.x, sensingPoints.topRight.y);
134−// priv.resetEdges();
132+ priv.resetEdges();
135−// priv.nearTopRightCorner = true;
133+ priv.nearTopRightCorner = true;
136−// root.fakeMaximizeTopRightAnimationRequested(priv.progress);
134+ root.fakeMaximizeTopRightAnimationRequested(priv.progress);
138−// } else if (globalX < priv.triggerArea && globalY > stageHeight - priv.triggerArea) { // bottom left
135+ } else if (sensingPoints.bottomLeft.x < priv.triggerArea && sensingPoints.bottomLeft.y > stageHeight - priv.triggerArea
139−// if (target.canBeCornerMaximized) {
136+ && target.canBeCornerMaximized) { // bottom left
140−// priv.progress = priv.progressInCorner(0, stageHeight, globalX, globalY);
137+ priv.progress = priv.progressInCorner(0, stageHeight, sensingPoints.bottomLeft.x, sensingPoints.bottomLeft.y);
141−// priv.resetEdges();
138+ priv.resetEdges();
142−// priv.nearBottomLeftCorner = true;
139+ priv.nearBottomLeftCorner = true;
143−// root.fakeMaximizeBottomLeftAnimationRequested(priv.progress);
140+ root.fakeMaximizeBottomLeftAnimationRequested(priv.progress);
145−// } else if (globalX > stageWidth - priv.triggerArea && globalY > stageHeight - priv.triggerArea) { // bottom right
141+ } else if (sensingPoints.bottomRight.x > stageWidth - priv.triggerArea && sensingPoints.bottomRight.y > stageHeight - priv.triggerArea
146−// if (target.canBeCornerMaximized) {
142+ && target.canBeCornerMaximized) { // bottom right
147−// priv.progress = priv.progressInCorner(stageWidth, stageHeight, globalX, globalY);
143+ priv.progress = priv.progressInCorner(stageWidth, stageHeight, sensingPoints.bottomRight.x, sensingPoints.bottomRight.y);
148−// priv.resetEdges();
144+ priv.resetEdges();
149−// priv.nearBottomRightCorner = true;
145+ priv.nearBottomRightCorner = true;
150−// root.fakeMaximizeBottomRightAnimationRequested(priv.progress);
146+ root.fakeMaximizeBottomRightAnimationRequested(priv.progress);
152−// } else if (globalX < priv.triggerArea) { // left
153−// if (target.canBeMaximizedLeftRight) {
147+ } else if (sensingPoints.topLeft.x < priv.triggerArea && target.canBeMaximizedLeftRight) { // left
154−// priv.progress = MathUtils.clampAndProject(globalX, priv.triggerArea, 0, 0, 1);
148+ priv.progress = MathUtils.clampAndProject(sensingPoints.topLeft.x, priv.triggerArea, 0, 0, 1);
155−// priv.resetEdges();
149+ priv.resetEdges();
156−// priv.nearLeftEdge = true;
150+ priv.nearLeftEdge = true;
157−// root.fakeMaximizeLeftAnimationRequested(priv.progress);
151+ root.fakeMaximizeLeftAnimationRequested(priv.progress);
159−// } else if (globalX > stageWidth - priv.triggerArea) { // right
160−// if (target.canBeMaximizedLeftRight) {
152+ } else if (sensingPoints.topRight.x > stageWidth - priv.triggerArea && target.canBeMaximizedLeftRight) { // right
161−// priv.progress = MathUtils.clampAndProject(globalX, stageWidth - priv.triggerArea, stageWidth, 0, 1);
153+ priv.progress = MathUtils.clampAndProject(sensingPoints.topRight.x, stageWidth - priv.triggerArea, stageWidth, 0, 1);
162−// priv.resetEdges();
154+ priv.resetEdges();
163−// priv.nearRightEdge = true;
155+ priv.nearRightEdge = true;
164−// root.fakeMaximizeRightAnimationRequested(priv.progress);
156+ root.fakeMaximizeRightAnimationRequested(priv.progress);
166−// } else if (globalY < PanelState.panelHeight) { // top
157+ } else if (sensingPoints.topLeft.y < PanelState.panelHeight && target.canBeMaximized) { // top
167−// if (target.canBeMaximized) {
168−// priv.progress = MathUtils.clampAndProject(globalY, Math.max(PanelState.panelHeight, priv.triggerArea), 0, 0, 1);
158+ priv.progress = MathUtils.clampAndProject(sensingPoints.topLeft.y, Math.max(PanelState.panelHeight, priv.triggerArea), 0, 0, 1);
169−// priv.resetEdges();
159+ priv.resetEdges();
170−// priv.nearTopEdge = true;
160+ priv.nearTopEdge = true;
171−// root.fakeMaximizeAnimationRequested(priv.progress);
161+ root.fakeMaximizeAnimationRequested(priv.progress);
173−// } else if (priv.nearLeftEdge || priv.nearRightEdge || priv.nearTopEdge || priv.nearTopLeftCorner || priv.nearTopRightCorner ||
162+ } else if (priv.nearLeftEdge || priv.nearRightEdge || priv.nearTopEdge || priv.nearTopLeftCorner || priv.nearTopRightCorner ||
174−// priv.nearBottomLeftCorner || priv.nearBottomRightCorner) {
163+ priv.nearBottomLeftCorner || priv.nearBottomRightCorner) {
175−// print("!!! Exited")
164+ print("!!! Exited")
176−// priv.progress = 0;
165+ priv.progress = 0;
177−// priv.resetEdges();
166+ priv.resetEdges();
178−// root.stopFakeAnimation();
167+ root.stopFakeAnimation();
183− function handleReleased(mouse) {
173+ function handleReleased(touchMode) {
175+ if (priv.progress < 0.3) { // cancel the preview shape if under 30%
178+ root.stopFakeAnimation();
179+ } else if (priv.nearLeftEdge) {
180+ target.maximizeLeft();
182+ } else if (priv.nearTopEdge) {
185+ } else if (priv.nearRightEdge) {
186+ target.maximizeRight();
188+ } else if (priv.nearTopLeftCorner) {
189+ target.maximizeTopLeft();
191+ } else if (priv.nearTopRightCorner) {
192+ target.maximizeTopRight();
194+ } else if (priv.nearBottomLeftCorner) {
195+ target.maximizeBottomLeft();
197+ } else if (priv.nearBottomRightCorner) {
198+ target.maximizeBottomRight();
184− if (mouse.button == Qt.LeftButton && (target.state == "normal" || target.state == "restored") && priv.progress == 0) {
201+ } else if ((target.state == "normal" || target.state == "restored") && priv.progress == 0) {
185 // save the x/y to restore to
202 // save the x/y to restore to
186 print("!!! Saving restoredX/Y")
203 print("!!! Saving restoredX/Y")
187 target.restoredX = target.x;
204 target.restoredX = target.x;
188 target.restoredY = target.y;
205 target.restoredY = target.y;
189− } /*else if (priv.progress < 0.3) { // cancel the preview shape if under 30%
206+ }
192− root.stopFakeAnimation();
193− } else if (priv.nearLeftEdge) {
194− target.maximizeLeft();
196− } else if (priv.nearTopEdge) {
199− } else if (priv.nearRightEdge) {
200− target.maximizeRight();
202− } else if (priv.nearTopLeftCorner) {
203− target.maximizeTopLeft();
205− } else if (priv.nearTopRightCorner) {
206− target.maximizeTopRight();
208− } else if (priv.nearBottomLeftCorner) {
209− target.maximizeBottomLeft();
211− } else if (priv.nearBottomRightCorner) {
212− target.maximizeBottomRight();