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