on xenial help sign in
Simplify code
commit71861ef519e51ae17a7149e114ccde549ac995f4 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 31 Aug 2016, 16:11 (10 years ago) parent5953e33
6 files changed+13−53
qml/Components/PanelState/PanelState.qml−2 qml/Panel/Panel.qml+5−24 qml/Stages/DecoratedWindow.qml+2−5 qml/Stages/DesktopStage.qml+2−14 qml/Stages/MoveHandler.qml−3 qml/Stages/WindowControlsOverlay.qml+4−5
qml/Components/PanelState/PanelState.qml−2
@@ -26,10 +26,8 @@ QtObject {
2626 property bool closeButtonShown: true
2727 property bool dropShadow: false
2828 property int panelHeight: 0
29− property var maximizedAppDelegate: null
3029
3130 signal closeClicked()
3231 signal minimizeClicked()
3332 signal restoreClicked()
34− signal focusMaximizedApp()
3533}
qml/Panel/Panel.qml+5−24
@@ -100,31 +100,12 @@ Item {
100100 }
101101 height: indicators.minimizedPanelHeight
102102 hoverEnabled: true
103− onClicked: callHint.visible ? callHint.showLiveCall() : PanelState.focusMaximizedApp()
104− onDoubleClicked: PanelState.restoreClicked()
103+ onClicked: if (callHint.visible) { callHint.showLiveCall(); }
105104
106− property Item delegate: null // appDelegate that's used to drag-and-restore a maximized window
107−
108− onPressedChanged: {
109− if (!delegate && PanelState.maximizedAppDelegate && pressed) {
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;
105+ onPressed: {
106+ if (!callHint.visible) {
107+ // let it fall through to the window decoration of the maximized window behind, if any
108+ mouse.accepted = false;
128109 }
129110 }
130111
qml/Stages/DecoratedWindow.qml+2−5
@@ -54,7 +54,6 @@ FocusScope {
5454 property alias overlayShown: decoration.overlayShown
5555 property alias stageWidth: moveHandler.stageWidth
5656 property alias stageHeight: moveHandler.stageHeight
57− readonly property alias moveHandler: moveHandler
5857
5958 signal closeClicked()
6059 signal maximizeClicked()
@@ -62,8 +61,7 @@ FocusScope {
6261 signal maximizeVerticallyClicked()
6362 signal minimizeClicked()
6463 signal decorationPressed()
65−
66− signal shouldCommitSnapWindow()
64+ signal decorationReleased()
6765
6866 Rectangle {
6967 id: selectionHighlight
@@ -110,7 +108,7 @@ FocusScope {
110108 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
111109 onPositionChanged: moveHandler.handlePositionChanged(mouse)
112110 onReleased: {
113− root.shouldCommitSnapWindow();
111+ root.decorationReleased();
114112 moveHandler.handleReleased();
115113 }
116114 }
@@ -121,7 +119,6 @@ FocusScope {
121119 objectName: "moveHandler"
122120 target: root.parent
123121 buttonsWidth: decoration.buttonsWidth
124− onShouldCommitSnapWindow: root.shouldCommitSnapWindow()
125122 }
126123
127124 ApplicationWindow {
qml/Stages/DesktopStage.qml+2−14
@@ -167,11 +167,6 @@ AbstractStage {
167167 onCloseClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.close(); } }
168168 onMinimizeClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.minimize(); } }
169169 onRestoreClicked: { if (priv.focusedAppDelegate) { priv.focusedAppDelegate.restoreFromMaximized(); } }
170− onFocusMaximizedApp: {
171− if (priv.foregroundMaximizedAppDelegate) {
172− priv.foregroundMaximizedAppDelegate.focus = true;
173− }
174− }
175170 }
176171
177172 Binding {
@@ -208,12 +203,6 @@ AbstractStage {
208203 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !priv.focusedAppDelegate.isDash
209204 }
210205
211− Binding {
212− target: PanelState
213− property: "maximizedAppDelegate"
214− value: priv.foregroundMaximizedAppDelegate ? priv.foregroundMaximizedAppDelegate : null
215− }
216−
217206 Component.onDestruction: {
218207 PanelState.title = "";
219208 PanelState.buttonsVisible = false;
@@ -358,7 +347,6 @@ AbstractStage {
358347 readonly property var surface: model.surface
359348 readonly property alias resizeArea: resizeArea
360349 readonly property alias focusedSurface: decoratedWindow.focusedSurface
361− readonly property var moveHandler: touchControls.overlayShown ? touchControls.moveHandler : decoratedWindow.moveHandler
362350
363351 readonly property bool isDash: model.application.appId == "unity8-dash"
364352
@@ -747,7 +735,7 @@ AbstractStage {
747735 onMaximizeVerticallyClicked: appDelegate.maximizedVertically ? appDelegate.restoreFromMaximized() : appDelegate.maximizeVertically()
748736 onMinimizeClicked: appDelegate.minimize()
749737 onDecorationPressed: { appDelegate.focus = true; }
750− onShouldCommitSnapWindow: fakeRectangle.commit();
738+ onDecorationReleased: fakeRectangle.commit();
751739 }
752740
753741 WindowControlsOverlay {
@@ -764,7 +752,7 @@ AbstractStage {
764752 onFakeMaximizeBottomLeftAnimationRequested: if (!appDelegate.maximizedBottomLeft) fakeRectangle.maximizeBottomLeft(amount, true);
765753 onFakeMaximizeBottomRightAnimationRequested: if (!appDelegate.maximizedBottomRight) fakeRectangle.maximizeBottomRight(amount, true);
766754 onStopFakeAnimation: fakeRectangle.stop();
767− onShouldCommitSnapWindow: fakeRectangle.commit();
755+ onDragReleased: fakeRectangle.commit();
768756 }
769757
770758 WindowedFullscreenPolicy {
qml/Stages/MoveHandler.qml−3
@@ -40,8 +40,6 @@ Item {
4040 signal fakeMaximizeBottomRightAnimationRequested(real amount)
4141 signal stopFakeAnimation()
4242
43− signal shouldCommitSnapWindow()
44−
4543 QtObject {
4644 id: priv
4745 property real distanceX
@@ -170,7 +168,6 @@ Item {
170168
171169 function handleReleased(touchMode) {
172170 if (touchMode) {
173− root.shouldCommitSnapWindow();
174171 priv.progress = 0;
175172 priv.resetEdges();
176173 }
qml/Stages/WindowControlsOverlay.qml+4−5
@@ -32,7 +32,6 @@ Item {
3232
3333 // to be read from outside
3434 readonly property alias overlayShown: overlay.visible
35− readonly property alias moveHandler: moveHandler
3635
3736 signal fakeMaximizeAnimationRequested(real amount)
3837 signal fakeMaximizeLeftAnimationRequested(real amount)
@@ -42,7 +41,7 @@ Item {
4241 signal fakeMaximizeBottomLeftAnimationRequested(real amount)
4342 signal fakeMaximizeBottomRightAnimationRequested(real amount)
4443 signal stopFakeAnimation()
45− signal shouldCommitSnapWindow()
44+ signal dragReleased()
4645
4746 TouchGestureArea {
4847 id: gestureArea
@@ -68,7 +67,8 @@ Item {
6867 moveHandler.handlePressedChanged(true, Qt.LeftButton, tp.x, tp.y);
6968 } else if (!mouseArea.containsPress) { // prevent interfering with the central piece drag/move
7069 moveHandler.handlePressedChanged(false, Qt.LeftButton);
71− moveHandler.handleReleased(true);
70+ root.dragReleased();
71+ moveHandler.handleReleased();
7272 }
7373 }
7474
@@ -150,7 +150,7 @@ Item {
150150 onPressedChanged: moveHandler.handlePressedChanged(pressed, pressedButtons, mouseX, mouseY)
151151 onPositionChanged: moveHandler.handlePositionChanged(mouse)
152152 onReleased: {
153− root.shouldCommitSnapWindow();
153+ root.dragReleased();
154154 moveHandler.handleReleased();
155155 }
156156 }
@@ -169,7 +169,6 @@ Item {
169169 onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(amount)
170170 onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(amount)
171171 onStopFakeAnimation: root.stopFakeAnimation()
172− onShouldCommitSnapWindow: root.shouldCommitSnapWindow();
173172 }
174173
175174 // dismiss area