on xenial help sign in
prevent windows to be moved under the panel
a21de65Michael Zanetti
qml/Components/PanelState/PanelState.qml+2
@@ -23,6 +23,8 @@ QtObject {
23 property string title: ""
23 property string title: ""
24 property bool buttonsVisible: false
24 property bool buttonsVisible: false
25
25
26+ property int panelHeight: 0
27+
26 signal close()
28 signal close()
27 signal minimize()
29 signal minimize()
28 signal maximize()
30 signal maximize()
qml/Panel/Panel.qml+6
@@ -32,6 +32,12 @@ Item {
32
32
33 opacity: fullscreenMode && indicators.fullyClosed ? 0.0 : 1.0
33 opacity: fullscreenMode && indicators.fullyClosed ? 0.0 : 1.0
34
34
35+ Binding {
36+ target: PanelState
37+ property: "panelHeight"
38+ value: root.panelHeight
39+ }
40+
35 Rectangle {
41 Rectangle {
36 id: darkenedArea
42 id: darkenedArea
37 property real darkenedOpacity: 0.6
43 property real darkenedOpacity: 0.6
qml/Stages/WindowDecoration.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.3
18import Unity.Application 0.1 // For Mir singleton
18import Unity.Application 0.1 // For Mir singleton
19import Ubuntu.Components 1.1
19import Ubuntu.Components 1.1
20import "../Components"
20import "../Components"
21+import "../Components/PanelState"
21
22
22MouseArea {
23MouseArea {
23 id: root
24 id: root
@@ -56,7 +57,7 @@ MouseArea {
56 Mir.cursorName = "grabbing";
57 Mir.cursorName = "grabbing";
57 var pos = mapToItem(root.target.parent, mouseX, mouseY);
58 var pos = mapToItem(root.target.parent, mouseX, mouseY);
58 root.target.x = pos.x - priv.distanceX;
59 root.target.x = pos.x - priv.distanceX;
59− root.target.y = pos.y - priv.distanceY;
60+ root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
60 }
61 }
61 }
62 }
62
63
qml/Stages/WindowResizeArea.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.3
18import Ubuntu.Components 1.1
18import Ubuntu.Components 1.1
19import Utils 0.1
19import Utils 0.1
20import Unity.Application 0.1 // for Mir.cursorName
20import Unity.Application 0.1 // for Mir.cursorName
21+import "../Components/PanelState"
21
22
22MouseArea {
23MouseArea {
23 id: root
24 id: root
@@ -66,7 +67,7 @@ MouseArea {
66 var windowGeometry = windowStateStorage.getGeometry(root.windowId, Qt.rect(target.x, target.y, target.width, target.height))
67 var windowGeometry = windowStateStorage.getGeometry(root.windowId, Qt.rect(target.x, target.y, target.width, target.height))
67 if (windowGeometry !== undefined) {
68 if (windowGeometry !== undefined) {
68 target.x = windowGeometry.x
69 target.x = windowGeometry.x
69− target.y = windowGeometry.y
70+ target.y = Math.max(windowGeometry.y, PanelState.panelHeight)
70 target.width = windowGeometry.width
71 target.width = windowGeometry.width
71 target.height = windowGeometry.height
72 target.height = windowGeometry.height
72 }
73 }
tests/qmltests/tst_Shell.qml+35−4
@@ -332,9 +332,9 @@ Rectangle {
332 var app2 = ApplicationManager.startApplication("webbrowser-app")
332 var app2 = ApplicationManager.startApplication("webbrowser-app")
333 var app3 = ApplicationManager.startApplication("camera-app")
333 var app3 = ApplicationManager.startApplication("camera-app")
334 var app4 = ApplicationManager.startApplication("facebook-webapp")
334 var app4 = ApplicationManager.startApplication("facebook-webapp")
335− var app5 = ApplicationManager.startApplication("calendar-app")
336− var app6 = ApplicationManager.startApplication("gallery-app")
337 var app7 = ApplicationManager.startApplication("camera-app")
335 var app7 = ApplicationManager.startApplication("camera-app")
336+ var app6 = ApplicationManager.startApplication("gallery-app")
337+ var app5 = ApplicationManager.startApplication("calendar-app")
338 waitUntilAppWindowIsFullyLoaded(app7);
338 waitUntilAppWindowIsFullyLoaded(app7);
339 }
339 }
340
340
@@ -1696,11 +1696,11 @@ Rectangle {
1696 keyPress(Qt.Key_Control)
1696 keyPress(Qt.Key_Control)
1697 keyClick(Qt.Key_Tab);
1697 keyClick(Qt.Key_Tab);
1698
1698
1699−
1700 tryCompare(desktopSpread, "state", "altTab")
1699 tryCompare(desktopSpread, "state", "altTab")
1701
1700
1702− mouseMove(shell, 0, 0);
1701+ mouseMove(shell, 0, shell.height / 2);
1703 tryCompare(launcher, "state", "visibleTemporary")
1702 tryCompare(launcher, "state", "visibleTemporary")
1703+ waitForRendering(shell)
1704
1704
1705 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1705 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
1706 tryCompare(launcher, "state", "")
1706 tryCompare(launcher, "state", "")
@@ -1780,5 +1780,36 @@ Rectangle {
1780 waitForRendering(shell);
1780 waitForRendering(shell);
1781 tryCompare(panelButtons, "visible", true);
1781 tryCompare(panelButtons, "visible", true);
1782 }
1782 }
1783+
1784+ function test_cantMoveWindowUnderPanel() {
1785+ loadDesktopShellWithApps();
1786+ var appRepeater = findChild(shell, "appRepeater")
1787+ var appDelegate = appRepeater.itemAt(0);
1788+
1789+ mousePress(appDelegate, appDelegate.width / 2, units.gu(1))
1790+ mouseMove(appDelegate, appDelegate.width / 2, -units.gu(100))
1791+
1792+ compare(appDelegate.y >= PanelState.panelHeight, true);
1793+ }
1794+
1795+ function test_restoreWindowStateFixesIfUnderPanel() {
1796+ loadDesktopShellWithApps();
1797+ var appRepeater = findChild(shell, "appRepeater")
1798+ var appId = ApplicationManager.get(0).appId;
1799+ var appDelegate = appRepeater.itemAt(0);
1800+
1801+ // Move it under the panel programmatically (might happen later with an alt+drag)
1802+ appDelegate.y = -units.gu(10)
1803+
1804+ ApplicationManager.stopApplication(appId)
1805+ ApplicationManager.startApplication(appId)
1806+ waitForRendering(shell)
1807+
1808+ // Make sure the newly started one is at index 0 again
1809+ tryCompare(ApplicationManager.get(0), "appId", appId);
1810+
1811+ appDelegate = appRepeater.itemAt(0);
1812+ compare(appDelegate.y >= PanelState.panelHeight, true);
1813+ }
1783 }
1814 }
1784}
1815}