on xenial help sign in
use DND for restoring from panel
commit8bfb5eb82422cb7ed87440f421885311547b7070 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 24 Aug 2016, 12:38 (10 years ago) parent24430f3
3 files changed+23−7
qml/Components/PanelState/PanelState.qml+1 qml/Panel/Panel.qml+15−7 qml/Stages/DesktopStage.qml+7
qml/Components/PanelState/PanelState.qml+1
@@ -26,6 +26,7 @@ QtObject {
2626 property bool closeButtonShown: true
2727 property bool dropShadow: false
2828 property int panelHeight: 0
29+ property var maximizedAppDelegate: null
2930
3031 signal closeClicked()
3132 signal minimizeClicked()
qml/Panel/Panel.qml+15−7
@@ -102,13 +102,21 @@ Item {
102102 hoverEnabled: true
103103 onClicked: callHint.visible ? callHint.showLiveCall() : PanelState.focusMaximizedApp()
104104 onDoubleClicked: PanelState.restoreClicked()
105−
106− property bool mouseWasPressed: false
107− onPressed: mouseWasPressed = containsPress
108− onMouseYChanged: {
109− if (mouseWasPressed && mouseY > panelHeight) {
110− PanelState.restoreClicked(); // restore the window when "dragging" the panel down
111− mouseWasPressed = false;
105+ drag.target: PanelState.maximizedAppDelegate
106+ drag.axis: Drag.XAndYAxis
107+ drag.minimumX: 0
108+ drag.minimumY: panelHeight
109+ drag.maximumX: PanelState.maximizedAppDelegate ? PanelState.maximizedAppDelegate.moveHandler.stageWidth : 0
110+ drag.maximumY: PanelState.maximizedAppDelegate ? PanelState.maximizedAppDelegate.moveHandler.stageHeight : 0
111+ drag.threshold: panelHeight
112+ drag.filterChildren: true
113+ onReleased: {
114+ if (drag.active) {
115+ var delegate = PanelState.maximizedAppDelegate;
116+ print("!!! Released drag at", mouse.x, mouse.y, drag.active)
117+ delegate.restoredX = Math.round(mouse.x - delegate.moveHandler.buttonsWidth);
118+ delegate.restoredY = Math.round(Math.max(mouse.y, panelHeight));
119+ delegate.restoreFromMaximized(false);
112120 }
113121 }
114122
qml/Stages/DesktopStage.qml+7
@@ -205,6 +205,12 @@ AbstractStage {
205205 value: priv.focusedAppDelegate && priv.focusedAppDelegate.maximized && !priv.focusedAppDelegate.isDash
206206 }
207207
208+ Binding {
209+ target: PanelState
210+ property: "maximizedAppDelegate"
211+ value: priv.foregroundMaximizedAppDelegate ? priv.foregroundMaximizedAppDelegate : null
212+ }
213+
208214 Component.onDestruction: {
209215 PanelState.title = "";
210216 PanelState.buttonsVisible = false;
@@ -349,6 +355,7 @@ AbstractStage {
349355 readonly property var surface: model.surface
350356 readonly property alias resizeArea: resizeArea
351357 readonly property alias focusedSurface: decoratedWindow.focusedSurface
358+ readonly property alias moveHandler: decoratedWindow.moveHandler
352359
353360 readonly property bool isDash: model.application.appId == "unity8-dash"
354361