diff --git a/shell/screenpool.cpp b/shell/screenpool.cpp index b41a2fd7f..7ed58f550 100644 --- a/shell/screenpool.cpp +++ b/shell/screenpool.cpp @@ -38,16 +38,18 @@ ScreenPool::ScreenPool(const KSharedConfig::Ptr &config, QObject *parent) void ScreenPool::load() { - m_primaryConnector = QString(); + m_primaryConnector.clear(); m_connectorForId.clear(); m_idForConnector.clear(); - QScreen *primary = qGuiApp->primaryScreen(); - if (primary) { - m_primaryConnector = primary->name(); - if (!m_primaryConnector.isEmpty()) { - m_connectorForId[0] = m_primaryConnector; - m_idForConnector[m_primaryConnector] = 0; + if (KWindowSystem::isPlatformX11()) { + QScreen *primary = qGuiApp->primaryScreen(); + if (primary) { + m_primaryConnector = primary->name(); + if (!m_primaryConnector.isEmpty()) { + m_connectorForId[0] = m_primaryConnector; + m_idForConnector[m_primaryConnector] = 0; + } } } @@ -86,6 +88,11 @@ QString ScreenPool::primaryConnector() const return m_primaryConnector; } +int ScreenPool::primaryScreenId() const +{ + return m_idForConnector.value(m_primaryConnector); +} + void ScreenPool::setPrimaryConnector(const QString &primary) { if (m_primaryConnector == primary) { diff --git a/shell/screenpool.h b/shell/screenpool.h index 278821cc4..135135389 100644 --- a/shell/screenpool.h +++ b/shell/screenpool.h @@ -24,6 +24,7 @@ public: void load(); ~ScreenPool() override; + int primaryScreenId() const; QString primaryConnector() const; void setPrimaryConnector(const QString &primary); diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index 5b33883f0..80df4bd67 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -662,11 +662,10 @@ void ShellCorona::load() // historically CustomContainments are treated as desktops } else if (containment->containmentType() == Plasma::Types::DesktopContainment || containment->containmentType() == Plasma::Types::CustomContainment) { - // FIXME ideally fix this, or at least document the crap out of it int screen = containment->lastScreen(); if (screen < 0) { - screen = 0; - qWarning() << "last screen is < 0 so putting containment on screen " << screen; + screen = m_screenPool->primaryScreenId(); + qWarning() << "last screen is unknown so putting containment on screen " << screen; } insertContainment(containment->activity(), screen, containment); } @@ -1292,7 +1291,7 @@ void ShellCorona::createWaitingPanels() // ignore non existing (yet?) screens int requestedScreen = cont->lastScreen(); if (requestedScreen < 0) { - requestedScreen = 0; + requestedScreen = m_desktopViewforId.cbegin().key(); } DesktopView *desktopView = m_desktopViewforId.value(requestedScreen);