Blob Blame History Raw
diff --git a/plasma/desktop/shell/data/layouts/org.kde.plasma-desktop.defaultPanel/contents/layout.js b/plasma/desktop/shell/data/layouts/org.kde.plasma-desktop.defaultPanel/contents/layout.js
index 47f635c..9d857a2 100644
--- a/plasma/desktop/shell/data/layouts/org.kde.plasma-desktop.defaultPanel/contents/layout.js
+++ b/plasma/desktop/shell/data/layouts/org.kde.plasma-desktop.defaultPanel/contents/layout.js
@@ -1,7 +1,28 @@
 var panel = new Panel
-if (panelIds.length == 1) {
-    // we are the only panel, so set the location for the user
-    panel.location = 'bottom'
+var panelScreen = panel.screen
+var freeEdges = {"bottom": true, "top": true, "left": true, "right": true}
+
+for (i = 0; i < panelIds.length; ++i) {
+    var tmpPanel = panelById(panelIds[i])
+    if (tmpPanel.screen == panelScreen) {
+        // Ignore the new panel
+        if (tmpPanel.id != panel.id) {
+            freeEdges[tmpPanel.location] = false;
+        }
+    }
+}
+
+if (freeEdges["bottom"] == true) {
+    panel.location = "bottom";
+} else if (freeEdges["top"] == true) {
+    panel.location = "top";
+} else if (freeEdges["left"] == true) {
+    panel.location = "left";
+} else if (freeEdges["right"] == true) {
+    panel.location = "right";
+} else {
+    // There is no free edge, so leave the default value
+    panel.location = "top";
 }
 
 panel.height = screenGeometry(panel.screen).height > 1024 ? 35 : 27
diff --git a/plasma/desktop/shell/desktopcorona.cpp b/plasma/desktop/shell/desktopcorona.cpp
index 4c2483d..2f05dfc 100644
--- a/plasma/desktop/shell/desktopcorona.cpp
+++ b/plasma/desktop/shell/desktopcorona.cpp
@@ -534,10 +534,10 @@ void DesktopCorona::addPanel(const QString &plugin)
     QList<Plasma::Location> freeEdges = DesktopCorona::freeEdges(screen);
     //kDebug() << freeEdges;
     Plasma::Location destination;
-    if (freeEdges.contains(Plasma::TopEdge)) {
-        destination = Plasma::TopEdge;
-    } else if (freeEdges.contains(Plasma::BottomEdge)) {
+    if (freeEdges.contains(Plasma::BottomEdge)) {
         destination = Plasma::BottomEdge;
+    } else if (freeEdges.contains(Plasma::TopEdge)) {
+        destination = Plasma::TopEdge;
     } else if (freeEdges.contains(Plasma::LeftEdge)) {
         destination = Plasma::LeftEdge;
     } else if (freeEdges.contains(Plasma::RightEdge)) {