screens pool: On Wayland the 0 screen id is not the primary

There is no primary on Wayland, we were trying to make one up and making
everything worse in turn.
Instead, have the screen to connector mapping be stable across
executions. Each screen will look as configured, which makes it all more
predictable and we do not run into cases where we swap displays
configurations because the other one happened to be the primary this
time around.
wilder-5.24
Aleix Pol 5 years ago committed by David Edmundson
parent fd0c984ae0
commit 71ee728bd7
  1. 21
      shell/screenpool.cpp
  2. 1
      shell/screenpool.h
  3. 7
      shell/shellcorona.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) {

@ -24,6 +24,7 @@ public:
void load();
~ScreenPool() override;
int primaryScreenId() const;
QString primaryConnector() const;
void setPrimaryConnector(const QString &primary);

@ -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);

Loading…
Cancel
Save