on xenial help sign in
Simplify code
71861efDaniel d'Andrada
qml/Components/PanelState/PanelState.qml−2
@@ -26,10 +26,8 @@ QtObject {
26 property bool closeButtonShown: true
26 property bool closeButtonShown: true
27 property bool dropShadow: false
27 property bool dropShadow: false
28 property int panelHeight: 0
28 property int panelHeight: 0
29− property var maximizedAppDelegate: null
30
29
31 signal closeClicked()
30 signal closeClicked()
32 signal minimizeClicked()
31 signal minimizeClicked()
33 signal restoreClicked()
32 signal restoreClicked()
34− signal focusMaximizedApp()
35}
33}
qml/Panel/Panel.qml+5−24
@@ -100,31 +100,12 @@ Item {
100 }
100 }
101 height: indicators.minimizedPanelHeight
101 height: indicators.minimizedPanelHeight
102 hoverEnabled: true
102 hoverEnabled: true
103− onClicked: callHint.visible ? callHint.showLiveCall() : PanelState.focusMaximizedApp()
103+ onClicked: if (callHint.visible) { callHint.showLiveCall(); }
104− onDoubleClicked: PanelState.restoreClicked()
105
104
106− property Item delegate: null // appDelegate that's used to drag-and-restore a maximized window
105+ onPressed: {
107−
106+ if (!callHint.visible) {
108− onPressedChanged: {
107+ // let it fall through to the window decoration of the maximized window behind, if any
109− if (!delegate && PanelState.maximizedAppDelegate && pressed) {
108+ mouse.accepted = false;
110− delegate = PanelState.maximizedAppDelegate;
111− delegate.moveHandler.handlePressedChanged(true, pressedButtons, mouseX, mouseY);
112− }
113− }
114− onPositionChanged: {
115− if (delegate && delegate.moveHandler.dragging) {
116− delegate.focus = true;
117− delegate.restoredX = Math.round(mouse.x - delegate.moveHandler.buttonsWidth);
118− delegate.restoredY = Math.round(Math.max(mouse.y, PanelState.panelHeight));
119− delegate.restoreFromMaximized(false);
120− }
121− }
122− onReleased: {
123− if (delegate) {
124− delegate.moveHandler.handlePressedChanged(false, pressedButtons);
125− delegate.moveHandler.handleReleased();
126− delegate.moveHandler.shouldCommitSnapWindow();
127− delegate = null;
128 }
109 }
129 }
110 }
130
111
qml/Stages/DecoratedWindow.qml+2−5
@@ -54,7 +54,6 @@ FocusScope {
54 property alias overlayShown: decoration.overlayShown
54 property alias overlayShown: decoration.overlayShown
55 property alias stageWidth: moveHandler.stageWidth
55 property alias stageWidth: moveHandler.stageWidth
56 property alias stageHeight: moveHandler.stageHeight
56 property alias stageHeight: moveHandler.stageHeight
57− readonly property alias moveHandler: moveHandler
58
57
59 signal closeClicked()
58 signal closeClicked()
60 signal maximizeClicked()
59 signal maximizeClicked()
@@ -62,8 +61,7 @@ FocusScope {
62 signal maximizeVerticallyClicked()
61 signal maximizeVerticallyClicked()
63 signal minimizeClicked()
62 signal minimizeClicked()
64 signal decorationPressed()
63 signal decorationPressed()
65−
64+ signal decorationReleased()
66− signal shouldCommitSnapWindow()
67
65
68 Rectangle {
66 Rectangle {
69 id: selectionHighlight
67 id: selectionHighlight
@@ -110,7 +108,7 @@ FocusScope {
110 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
108 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
111 onPositionChanged: moveHandler.handlePositionChanged(mouse)
109 onPositionChanged: moveHandler.handlePositionChanged(mouse)
112 onReleased: {
110 onReleased: {
113− root.shouldCommitSnapWindow();
111+ root.decorationReleased();
114 moveHandler.handleReleased();
112 moveHandler.handleReleased();
115 }
113 }
116 }
114 }
@@ -121,7 +119,6 @@ FocusScope {
121 objectName: "moveHandler"
119 objectName: "moveHandler"
122 target: root.parent
120 target: root.parent
123 buttonsWidth: decoration.buttonsWidth
121 buttonsWidth: decoration.buttonsWidth
124− onShouldCommitSnapWindow: root.shouldCommitSnapWindow()
125 }
122 }
126
123
127 ApplicationWindow {
124 ApplicationWindow {
qml/Stages/DesktopStage.qml+2−14
@@ -167,11 +167,6 @@ AbstractStage {
167 onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
167 onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
168 onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
168 onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
169 onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
169 onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
170− onFocusMaximizedApp: {
171− if (priv.foregroundMaximizedAppDelegate) {
172− priv.foregroundMaximizedAppDelegate.focus = true;
173− }
174− }
175 }
170 }
176
171
177 Binding {
172 Binding {
@@ -208,12 +203,6 @@ AbstractStage {
208 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !priv.focusedAppDelegate.isDash
203 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !priv.focusedAppDelegate.isDash
209 }
204 }
210
205
211− Binding {
212− target: PanelState
213− property: "maximizedAppDelegate"
214− value: priv.foregroundMaximizedAppDelegate ? priv.foregroundMaximizedAppDelegate : null
215− }
216−
217 Component.onDestruction: {
206 Component.onDestruction: {
218 PanelState.title = "";
207 PanelState.title = "";
219 PanelState.buttonsVisible = false;
208 PanelState.buttonsVisible = false;
@@ -358,7 +347,6 @@ AbstractStage {
358 readonly property var surface: model.surface
347 readonly property var surface: model.surface
359 readonly property alias resizeArea: resizeArea
348 readonly property alias resizeArea: resizeArea
360 readonly property alias focusedSurface: decoratedWindow.focusedSurface
349 readonly property alias focusedSurface: decoratedWindow.focusedSurface
361− readonly property var moveHandler: touchControls.overlayShown ? touchControls.moveHandler : decoratedWindow.moveHandler
362
350
363 readonly property bool isDash: model.application.appId == "unity8-dash"
351 readonly property bool isDash: model.application.appId == "unity8-dash"
364
352
@@ -747,7 +735,7 @@ AbstractStage {
747 onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
735 onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
748 onMinimizeClicked: appDelegate.minimize()
736 onMinimizeClicked: appDelegate.minimize()
749 onDecorationPressed: { appDelegate.focus = true; }
737 onDecorationPressed: { appDelegate.focus = true; }
750− onShouldCommitSnapWindow: fakeRectangle.commit();
738+ onDecorationReleased: fakeRectangle.commit();
751 }
739 }
752
740
753 WindowControlsOverlay {
741 WindowControlsOverlay {
@@ -764,7 +752,7 @@ AbstractStage {
764 onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount, true);
752 onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount, true);
765 onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount, true);
753 onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount, true);
766 onStopFakeAnimation: fakeRectangle.stop();
754 onStopFakeAnimation: fakeRectangle.stop();
767− onShouldCommitSnapWindow: fakeRectangle.commit();
755+ onDragReleased: fakeRectangle.commit();
768 }
756 }
769
757
770 WindowedFullscreenPolicy {
758 WindowedFullscreenPolicy {
qml/Stages/MoveHandler.qml−3
@@ -40,8 +40,6 @@ Item {
40 signal fakeMaximizeBottomRightAnimationRequested(real amount)
40 signal fakeMaximizeBottomRightAnimationRequested(real amount)
41 signal stopFakeAnimation()
41 signal stopFakeAnimation()
42
42
43− signal shouldCommitSnapWindow()
44−
45 QtObject {
43 QtObject {
46 id: priv
44 id: priv
47 property real distanceX
45 property real distanceX
@@ -170,7 +168,6 @@ Item {
170
168
171 function handleReleased(touchMode) {
169 function handleReleased(touchMode) {
172 if (touchMode) {
170 if (touchMode) {
173− root.shouldCommitSnapWindow();
174 priv.progress = 0;
171 priv.progress = 0;
175 priv.resetEdges();
172 priv.resetEdges();
176 }
173 }
qml/Stages/WindowControlsOverlay.qml+4−5
@@ -32,7 +32,6 @@ Item {
32
32
33 // to be read from outside
33 // to be read from outside
34 readonly property alias overlayShown: overlay.visible
34 readonly property alias overlayShown: overlay.visible
35− readonly property alias moveHandler: moveHandler
36
35
37 signal fakeMaximizeAnimationRequested(real amount)
36 signal fakeMaximizeAnimationRequested(real amount)
38 signal fakeMaximizeLeftAnimationRequested(real amount)
37 signal fakeMaximizeLeftAnimationRequested(real amount)
@@ -42,7 +41,7 @@ Item {
42 signal fakeMaximizeBottomLeftAnimationRequested(real amount)
41 signal fakeMaximizeBottomLeftAnimationRequested(real amount)
43 signal fakeMaximizeBottomRightAnimationRequested(real amount)
42 signal fakeMaximizeBottomRightAnimationRequested(real amount)
44 signal stopFakeAnimation()
43 signal stopFakeAnimation()
45− signal shouldCommitSnapWindow()
44+ signal dragReleased()
46
45
47 TouchGestureArea {
46 TouchGestureArea {
48 id: gestureArea
47 id: gestureArea
@@ -68,7 +67,8 @@ Item {
68 moveHandler.handlePressedChanged(true, Qt.LeftButton, tp.x, tp.y);
67 moveHandler.handlePressedChanged(true, Qt.LeftButton, tp.x, tp.y);
69 } else if (!mouseArea.containsPress) { // prevent interfering with the central piece drag/move
68 } else if (!mouseArea.containsPress) { // prevent interfering with the central piece drag/move
70 moveHandler.handlePressedChanged(false, Qt.LeftButton);
69 moveHandler.handlePressedChanged(false, Qt.LeftButton);
70+ root.dragReleased();
71− moveHandler.handleReleased(true);
71+ moveHandler.handleReleased();
72 }
72 }
73 }
73 }
74
74
@@ -150,7 +150,7 @@ Item {
150 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
150 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
151 onPositionChanged: moveHandler.handlePositionChanged(mouse)
151 onPositionChanged: moveHandler.handlePositionChanged(mouse)
152 onReleased: {
152 onReleased: {
153− root.shouldCommitSnapWindow();
153+ root.dragReleased();
154 moveHandler.handleReleased();
154 moveHandler.handleReleased();
155 }
155 }
156 }
156 }
@@ -169,7 +169,6 @@ Item {
169 onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(amount)
169 onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(amount)
170 onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(amount)
170 onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(amount)
171 onStopFakeAnimation: root.stopFakeAnimation()
171 onStopFakeAnimation: root.stopFakeAnimation()
172− onShouldCommitSnapWindow: root.shouldCommitSnapWindow();
173 }
172 }
174
173
175 // dismiss area
174 // dismiss area