From 9cd16c5cda30a00fc7f7ff1b56a77d64951ae2a0 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 30 Dec 2016 16:51:44 +0200 Subject: [PATCH] fix #16, systemtray working ok --calculate freeedges even when screen=-1 is passed, such a case is on the creation of a containment --- app/nowdockcorona.cpp | 29 +++++++++++++++++++++++++---- app/nowdockcorona.h | 1 + 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/nowdockcorona.cpp b/app/nowdockcorona.cpp index 4326a871d..89a88c7ac 100644 --- a/app/nowdockcorona.cpp +++ b/app/nowdockcorona.cpp @@ -121,14 +121,35 @@ QRect NowDockCorona::availableScreenRect(int id) const return qGuiApp->primaryScreen()->availableGeometry(); } +int NowDockCorona::primaryScreenId() const +{ + const auto screens = qGuiApp->screens(); + + int id = -1; + + for (int i = 0; i < screens.size(); ++i) { + auto *scr = screens.at(i); + + if (scr == qGuiApp->primaryScreen()) { + id = i; + break; + } + } + + return id; +} + QList NowDockCorona::freeEdges(int screen) const { using Plasma::Types; QList edges{Types::BottomEdge, Types::LeftEdge, Types::TopEdge, Types::RightEdge}; - + + //when screen=-1 is passed then the primaryScreenid is used + int fixedScreen = (screen == -1) ? primaryScreenId() : screen; + for (const NowDockView *cont : m_containments) { - if (cont && cont->containment()->screen() == screen) + if (cont && cont->containment()->screen() == fixedScreen) edges.removeOne(cont->location()); } @@ -156,8 +177,8 @@ void NowDockCorona::addDock(Plasma::Containment *containment) // the system tray is a containment that behaves as an applet // so a dockview shouldnt be created for it KPluginMetaData metadata = containment->kPackage().metadata(); - - if (metadata.pluginId() == "org.kde.plasma.systemtray") { + + if (metadata.pluginId() == "org.kde.plasma.private.systemtray") { return; } diff --git a/app/nowdockcorona.h b/app/nowdockcorona.h index 2888f8b59..f9ad89c2c 100644 --- a/app/nowdockcorona.h +++ b/app/nowdockcorona.h @@ -61,6 +61,7 @@ signals: private: void qmlRegisterTypes() const; + int primaryScreenId() const; std::vector m_containments; };