on xenial help sign in
prevent windows to be moved under the panel

If they happen to have a saved state which is under the panel (might happen on alt+drag later), they will be moved below the panel on close and reopen. This is how unity7 behaves in this regard.

commita21de656b8164082caa770eba1683034e5bb02b4 authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 30 Oct 2015, 16:20 (11 years ago) parentae797aa
5 files changed+47−6
qml/Components/PanelState/PanelState.qml+2 qml/Panel/Panel.qml+6 qml/Stages/WindowDecoration.qml+2−1 qml/Stages/WindowResizeArea.qml+2−1 tests/qmltests/tst_Shell.qml+35−4
qml/Components/PanelState/PanelState.qml+2
@@ -23,6 +23,8 @@ QtObject {
2323 property string title: ""
2424 property bool buttonsVisible: false
2525
26+ property int panelHeight: 0
27+
2628 signal close()
2729 signal minimize()
2830 signal maximize()
qml/Panel/Panel.qml+6
@@ -32,6 +32,12 @@ Item {
3232
3333 opacity: fullscreenMode && indicators.fullyClosed ? 0.0 : 1.0
3434
35+ Binding {
36+ target: PanelState
37+ property: "panelHeight"
38+ value: root.panelHeight
39+ }
40+
3541 Rectangle {
3642 id: darkenedArea
3743 property real darkenedOpacity: 0.6
qml/Stages/WindowDecoration.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.3
1818import Unity.Application 0.1 // For Mir singleton
1919import Ubuntu.Components 1.1
2020import "../Components"
21+import "../Components/PanelState"
2122
2223MouseArea {
2324 id: root
@@ -56,7 +57,7 @@ MouseArea {
5657 Mir.cursorName = "grabbing";
5758 var pos = mapToItem(root.target.parent, mouseX, mouseY);
5859 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);
6061 }
6162 }
6263
qml/Stages/WindowResizeArea.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.3
1818import Ubuntu.Components 1.1
1919import Utils 0.1
2020import Unity.Application 0.1 // for Mir.cursorName
21+import "../Components/PanelState"
2122
2223MouseArea {
2324 id: root
@@ -66,7 +67,7 @@ MouseArea {
6667 var windowGeometry = windowStateStorage.getGeometry(root.windowId, Qt.rect(target.x, target.y, target.width, target.height))
6768 if (windowGeometry !== undefined) {
6869 target.x = windowGeometry.x
69− target.y = windowGeometry.y
70+ target.y = Math.max(windowGeometry.y, PanelState.panelHeight)
7071 target.width = windowGeometry.width
7172 target.height = windowGeometry.height
7273 }
tests/qmltests/tst_Shell.qml+35−4
@@ -332,9 +332,9 @@ Rectangle {
332332 var app2 = ApplicationManager.startApplication("webbrowser-app")
333333 var app3 = ApplicationManager.startApplication("camera-app")
334334 var app4 = ApplicationManager.startApplication("facebook-webapp")
335− var app5 = ApplicationManager.startApplication("calendar-app")
336− var app6 = ApplicationManager.startApplication("gallery-app")
337335 var app7 = ApplicationManager.startApplication("camera-app")
336+ var app6 = ApplicationManager.startApplication("gallery-app")
337+ var app5 = ApplicationManager.startApplication("calendar-app")
338338 waitUntilAppWindowIsFullyLoaded(app7);
339339 }
340340
@@ -1696,11 +1696,11 @@ Rectangle {
16961696 keyPress(Qt.Key_Control)
16971697 keyClick(Qt.Key_Tab);
16981698
1699−
17001699 tryCompare(desktopSpread, "state", "altTab")
17011700
1702− mouseMove(shell, 0, 0);
1701+ mouseMove(shell, 0, shell.height / 2);
17031702 tryCompare(launcher, "state", "visibleTemporary")
1703+ waitForRendering(shell)
17041704
17051705 mouseClick(bfb, bfb.width / 2, bfb.height / 2)
17061706 tryCompare(launcher, "state", "")
@@ -1780,5 +1780,36 @@ Rectangle {
17801780 waitForRendering(shell);
17811781 tryCompare(panelButtons, "visible", true);
17821782 }
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+ }
17831814 }
17841815}