Changeset View
Changeset View
Standalone View
Standalone View
shell/shellcorona.cpp
Show First 20 Lines • Show All 1094 Lines • ▼ Show 20 Line(s) | 1091 | { | |||
---|---|---|---|---|---|
1095 | 1095 | | |||
1096 | m_reconsiderOutputsTimer.start(); | 1096 | m_reconsiderOutputsTimer.start(); | ||
1097 | m_redundantOutputs.remove(screen); | 1097 | m_redundantOutputs.remove(screen); | ||
1098 | } | 1098 | } | ||
1099 | 1099 | | |||
1100 | bool ShellCorona::isOutputRedundant(QScreen* screen) const | 1100 | bool ShellCorona::isOutputRedundant(QScreen* screen) const | ||
1101 | { | 1101 | { | ||
1102 | Q_ASSERT(screen); | 1102 | Q_ASSERT(screen); | ||
1103 | const QRect geometry = screen->geometry(); | 1103 | const QRect thisGeometry = screen->geometry(); | ||
1104 | | ||||
1105 | const int thisId = m_screenPool->id(screen->name()); | ||||
1104 | 1106 | | |||
1105 | //FIXME: QScreen doesn't have any idea of "this qscreen is clone of this other one | 1107 | //FIXME: QScreen doesn't have any idea of "this qscreen is clone of this other one | ||
1106 | //so this ultra inefficient heuristic has to stay until we have a slightly better api | 1108 | //so this ultra inefficient heuristic has to stay until we have a slightly better api | ||
1109 | //logic is: | ||||
1110 | //a screen is redundant if: | ||||
1111 | //* its geometry is contained in another one | ||||
1112 | //* if their resolutions are different, the "biggest" one wins | ||||
1113 | //* if they have the same geometry, the one with the lowest id wins (arbitrary, but gives reproducible behavior and makes the primary screen win) | ||||
1107 | foreach (QScreen* s, qGuiApp->screens()) { | 1114 | foreach (QScreen* s, qGuiApp->screens()) { | ||
1115 | //don't compare with itself | ||||
1108 | if (screen == s) { | 1116 | if (screen == s) { | ||
1109 | continue; | 1117 | continue; | ||
1110 | } | 1118 | } | ||
1111 | 1119 | | |||
1112 | const QRect sGeometry = s->geometry(); | 1120 | const QRect otherGeometry = s->geometry(); | ||
1113 | if (sGeometry.contains(geometry, false) && | 1121 | | ||
1114 | sGeometry.width() > geometry.width() && | 1122 | const int otherId = m_screenPool->id(s->name()); | ||
1115 | sGeometry.height() > geometry.height()) { | 1123 | | ||
1124 | if (otherGeometry.contains(thisGeometry, false) && | ||||
1125 | (//since at this point contains is true, if either | ||||
1126 | //measure of othergeometry is bigger, has a bigger area | ||||
1127 | otherGeometry.width() > thisGeometry.width() || | ||||
davidedmundson: there's a bug here, but I'm not sure what the right fix is.
If you have two screens A, B… | |||||
I don't think this can happenas at this point
other cases, contains would be false mart: I don't think this can happenas at this point
otherGeometry.contains(thisGeometry, false) is… | |||||
1128 | otherGeometry.height() > thisGeometry.height() || | ||||
1129 | //ids not -1 are considered in descending order of importance | ||||
1130 | (thisId == -1 && otherId != -1) || | ||||
1131 | (thisId > otherId && otherId != -1))) { | ||||
1132 | qWarning()<<"AAARIDONDANTE"<<screen->name()<<" TO "<<s->name(); | ||||
1116 | return true; | 1133 | return true; | ||
1117 | } | 1134 | } | ||
1118 | } | 1135 | } | ||
1119 | 1136 | | |||
1120 | return false; | 1137 | return false; | ||
1121 | } | 1138 | } | ||
1122 | 1139 | | |||
1123 | void ShellCorona::reconsiderOutputs() | 1140 | void ShellCorona::reconsiderOutputs() | ||
▲ Show 20 Lines • Show All 992 Lines • Show Last 20 Lines |
there's a bug here, but I'm not sure what the right fix is.
If you have two screens A, B
both are new (so have ID == -1)
A is wider than B but B is taller than A
you return true for both.