|
|
|
@ -50,8 +50,10 @@ void ScreenPool::load()
|
|
|
|
|
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;
|
|
|
|
@ -62,6 +64,7 @@ void ScreenPool::load()
|
|
|
|
|
foreach (const QString &key, m_configGroup.keyList()) {
|
|
|
|
|
QString connector = m_configGroup.readEntry(key, QString());
|
|
|
|
|
qDebug() << "connector :" << connector << " - " << key;
|
|
|
|
|
|
|
|
|
|
if (!key.isEmpty() && !connector.isEmpty() &&
|
|
|
|
|
!m_connectorForId.contains(key.toInt()) &&
|
|
|
|
|
!m_idForConnector.contains(connector)) {
|
|
|
|
@ -104,6 +107,7 @@ void ScreenPool::setPrimaryConnector(const QString &primary)
|
|
|
|
|
if ((m_primaryConnector == primary) || primary.startsWith(":")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_ASSERT(m_idForConnector.contains(primary));
|
|
|
|
|
|
|
|
|
|
/* int oldIdForPrimary = m_idForConnector.value(primary);
|
|
|
|
@ -120,9 +124,11 @@ void ScreenPool::setPrimaryConnector(const QString &primary)
|
|
|
|
|
void ScreenPool::save()
|
|
|
|
|
{
|
|
|
|
|
QMap<int, QString>::const_iterator i;
|
|
|
|
|
|
|
|
|
|
for (i = m_connectorForId.constBegin(); i != m_connectorForId.constEnd(); ++i) {
|
|
|
|
|
m_configGroup.writeEntry(QString::number(i.key()), i.value());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//write to disck every 30 seconds at most
|
|
|
|
|
m_configSaveTimer.start(30000);
|
|
|
|
|
}
|
|
|
|
@ -173,12 +179,14 @@ int ScreenPool::firstAvailableId() const
|
|
|
|
|
//be used for special cases.
|
|
|
|
|
//e.g primaryScreen, id=0
|
|
|
|
|
int i = 10;
|
|
|
|
|
|
|
|
|
|
//find the first integer not stored in m_connectorForId
|
|
|
|
|
//m_connectorForId is the only map, so the ids are sorted
|
|
|
|
|
foreach (int existingId, m_connectorForId.keys()) {
|
|
|
|
|
if (i != existingId) {
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -194,6 +202,7 @@ bool ScreenPool::nativeEventFilter(const QByteArray& eventType, void* message, l
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(result);
|
|
|
|
|
#if HAVE_X11
|
|
|
|
|
|
|
|
|
|
// a particular edge case: when we switch the only enabled screen
|
|
|
|
|
// we don't have any signal about it, the primary screen changes but we have the same old QScreen* getting recycled
|
|
|
|
|
// see https://bugs.kde.org/show_bug.cgi?id=373880
|
|
|
|
@ -214,12 +223,14 @@ bool ScreenPool::nativeEventFilter(const QByteArray& eventType, void* message, l
|
|
|
|
|
if (id(qGuiApp->primaryScreen()->name()) < 0) {
|
|
|
|
|
insertScreenMapping(firstAvailableId(), qGuiApp->primaryScreen()->name());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//switch the primary screen in the pool
|
|
|
|
|
setPrimaryConnector(qGuiApp->primaryScreen()->name());
|
|
|
|
|
|
|
|
|
|
emit primaryPoolChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|