on xenial help sign in
properly restore a maximized window from the panel
3adcd5eLukáš Tinkl
qml/Panel/Panel.qml+19−11
@@ -102,22 +102,30 @@ Item {
102 hoverEnabled: true
102 hoverEnabled: true
103 onClicked: callHint.visible ? callHint.showLiveCall() : PanelState.focusMaximizedApp()
103 onClicked: callHint.visible ? callHint.showLiveCall() : PanelState.focusMaximizedApp()
104 onDoubleClicked: PanelState.restoreClicked()
104 onDoubleClicked: PanelState.restoreClicked()
105− drag.target: PanelState.maximizedAppDelegate
105+
106− drag.axis: Drag.XAndYAxis
106+ property Item delegate: null // appDelegate that's used to drag-and-restore a maximized window
107− drag.minimumX: 0
107+
108− drag.minimumY: panelHeight
108+ onPressedChanged: {
109− drag.maximumX: PanelState.maximizedAppDelegate ? PanelState.maximizedAppDelegate.moveHandler.stageWidth : 0
109+ if (!delegate && PanelState.maximizedAppDelegate && pressed) {
110− drag.maximumY: PanelState.maximizedAppDelegate ? PanelState.maximizedAppDelegate.moveHandler.stageHeight : 0
111− drag.threshold: PanelState.panelHeight
112− drag.filterChildren: true
113− onReleased: {
114− if (drag.active) {
115− var delegate = PanelState.maximizedAppDelegate;
110+ delegate = PanelState.maximizedAppDelegate;
111+ delegate.moveHandler.handlePressedChanged(true, pressedButtons, mouseX, mouseY);
112+ }
113+ }
114+ onPositionChanged: {
115+ if (delegate && delegate.moveHandler.dragging) {
116 delegate.restoredX = Math.round(mouse.x - delegate.moveHandler.buttonsWidth);
116 delegate.restoredX = Math.round(mouse.x - delegate.moveHandler.buttonsWidth);
117 delegate.restoredY = Math.round(Math.max(mouse.y, PanelState.panelHeight));
117 delegate.restoredY = Math.round(Math.max(mouse.y, PanelState.panelHeight));
118 delegate.restoreFromMaximized(false);
118 delegate.restoreFromMaximized(false);
119 }
119 }
120 }
120 }
121+ onReleased: {
122+ if (delegate) {
123+ delegate.moveHandler.handlePressedChanged(false, pressedButtons, mouseX, mouseY);
124+ delegate.moveHandler.handleReleased(mouse);
125+ delegate.moveHandler.shouldCommitSnapWindow();
126+ delegate = null;
127+ }
128+ }
121
129
122 // WindowControlButtons inside the mouse area, otherwise QML doesn't grok nested hover events :/
130 // WindowControlButtons inside the mouse area, otherwise QML doesn't grok nested hover events :/
123 // cf. https://bugreports.qt.io/browse/QTBUG-32909
131 // cf. https://bugreports.qt.io/browse/QTBUG-32909
qml/Stages/DecoratedWindow.qml+1
@@ -140,6 +140,7 @@ FocusScope {
140 onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(progress)
140 onFakeMaximizeBottomLeftAnimationRequested: root.fakeMaximizeBottomLeftAnimationRequested(progress)
141 onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(progress)
141 onFakeMaximizeBottomRightAnimationRequested: root.fakeMaximizeBottomRightAnimationRequested(progress)
142 onStopFakeAnimation: root.stopFakeAnimation()
142 onStopFakeAnimation: root.stopFakeAnimation()
143+ onShouldCommitSnapWindow: root.shouldCommitSnapWindow()
143 }
144 }
144
145
145 ApplicationWindow {
146 ApplicationWindow {
qml/Stages/MoveHandler.qml+2
@@ -40,6 +40,8 @@ Item {
40 signal fakeMaximizeBottomRightAnimationRequested(real progress)
40 signal fakeMaximizeBottomRightAnimationRequested(real progress)
41 signal stopFakeAnimation()
41 signal stopFakeAnimation()
42
42
43+ signal shouldCommitSnapWindow()
44+
43 QtObject {
45 QtObject {
44 id: priv
46 id: priv
45 property real distanceX
47 property real distanceX