diff options
authorMarco Martin <>2017-04-06 16:57:45 (GMT)
committerMarco Martin <>2017-04-07 10:12:05 (GMT)
commitef12ad389ee48208e7a7c8520dc3a05864d2fe87 (patch)
parent628593db4c65560ace95759ffca5ce0920de621e (diff)
Correctly handle when a new primary screen displaces the old
Summary: this is for the following setup: the primary screen is at position 0,0 and gets disconnected. the other screen will be moved at 0,0 and becomes primary the screen is reconnected, the events arrive in the followin order: 1) a new screen gets added, at 0,0 position (not primary yet, it may be markedredundant) 2) the screen becomes primary, both screens still at 0,0 3) the old screen gets moved out of the way in the end result none of the two need to be redundant. adding the old one in the redundant list, will cause reconsideroutputs to consider it and create a view for it. Test Plan: added and removed sevaral times a primary screen at 0,0 Reviewers: #plasma, broulik, sebas Subscribers: plasma-devel Tags: #plasma Differential Revision:
1 files changed, 15 insertions, 6 deletions
diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp
index 6c98931..e40da45 100644
--- a/shell/shellcorona.cpp
+++ b/shell/shellcorona.cpp
@@ -710,10 +710,9 @@ void ShellCorona::primaryOutputChanged()
- //Since the primary screen is considered more important
- //then the others, having the primary changed may have changed what outputs are redundant and what are not
- //TODO: for a particular corner case, in which in the same moment the primary screen changes *and* geometries change to make former redundant screens to not be anymore, instead of doinf reconsiderOutputs() here, it may be better to instead put here the adding of new outputs and after the switch dance has been done, at the bottom of this function remove the eventual redundant ones
- reconsiderOutputs();
+ //when the appearance of a new primary screen *moves*
+ //the position of the now secondary, the two screens will appear overlapped for an instant, and a spurious output redundant would happen here if checked immediately
+ m_reconsiderOutputsTimer.start();
QScreen *oldPrimary = m_desktopViewforId.value(0)->screen();
QScreen *newPrimary = qGuiApp->primaryScreen();
@@ -733,6 +732,15 @@ void ShellCorona::primaryOutputChanged()
+ //corner case: the new primary screen was added into redundant outputs when appeared, *and* !m_desktopViewforId.contains(oldIdOfPrimary)
+ //meaning that we had only one screen, connected a new oone that
+ //a) is now primary and
+ //b) is at 0,0 position, moving the current screen out of the way
+ // and this will always happen in two events
+ } else if (m_desktopViewforId.contains(0) && m_redundantOutputs.contains(newPrimary)) {
+ m_desktopViewforId[0]->setScreenToFollow(newPrimary);
+ m_redundantOutputs.remove(newPrimary);
+ m_redundantOutputs.insert(oldPrimary);
foreach (PanelView *panel, m_panelViews) {
@@ -743,7 +751,8 @@ void ShellCorona::primaryOutputChanged()
+ //can't do the screen invariant here as reconsideroutputs wasn't executed yet
#ifndef NDEBUG
@@ -1143,7 +1152,7 @@ void ShellCorona::reconsiderOutputs()
foreach (QScreen* screen, qGuiApp->screens()) {
if (m_redundantOutputs.contains(screen)) {
if (!isOutputRedundant(screen)) {
-// qDebug() << "not redundant anymore" << out;
+ //qDebug() << "not redundant anymore" << screen;
} else if (isOutputRedundant(screen)) {