Changeset View
Changeset View
Standalone View
Standalone View
kded/output.cpp
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | |||||
158 | 158 | | |||
159 | // TODO: move this into the Layouter class. | 159 | // TODO: move this into the Layouter class. | ||
160 | void Output::adjustPositions(KScreen::ConfigPtr config, const QVariantList &outputsInfo) | 160 | void Output::adjustPositions(KScreen::ConfigPtr config, const QVariantList &outputsInfo) | ||
161 | { | 161 | { | ||
162 | typedef QPair<int, QPoint> Out; | 162 | typedef QPair<int, QPoint> Out; | ||
163 | 163 | | |||
164 | KScreen::OutputList outputs = config->outputs(); | 164 | KScreen::OutputList outputs = config->outputs(); | ||
165 | QVector<Out> sortedOutputs; // <id, pos> | 165 | QVector<Out> sortedOutputs; // <id, pos> | ||
166 | for (const KScreen::OutputPtr output : outputs) { | 166 | for (const KScreen::OutputPtr &output : outputs) { | ||
167 | sortedOutputs.append(Out(output->id(), output->pos())); | 167 | sortedOutputs.append(Out(output->id(), output->pos())); | ||
168 | } | 168 | } | ||
169 | 169 | | |||
170 | // go from left to right, top to bottom | 170 | // go from left to right, top to bottom | ||
171 | std::sort(sortedOutputs.begin(), sortedOutputs.end(), [](const Out &o1, const Out &o2) { | 171 | std::sort(sortedOutputs.begin(), sortedOutputs.end(), [](const Out &o1, const Out &o2) { | ||
172 | const int x1 = o1.second.x(); | 172 | const int x1 = o1.second.x(); | ||
173 | const int x2 = o2.second.x(); | 173 | const int x2 = o2.second.x(); | ||
174 | return x1 < x2 || (x1 == x2 && o1.second.y() < o2.second.y()); | 174 | return x1 < x2 || (x1 == x2 && o1.second.y() < o2.second.y()); | ||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 256 | const bool yOverlap = prevInfoGeo.y() + prevInfoGeo.height() > curInfoGeo.y() && | |||
257 | prevInfoGeo.y() < curInfoGeo.y() + curInfoGeo.height(); | 257 | prevInfoGeo.y() < curInfoGeo.y() + curInfoGeo.height(); | ||
258 | 258 | | |||
259 | // these values determine which horizontal edge of previous output we align with | 259 | // these values determine which horizontal edge of previous output we align with | ||
260 | const int topToTopDiffAbs = qAbs(prevInfoGeo.y() - curInfoGeo.y()); | 260 | const int topToTopDiffAbs = qAbs(prevInfoGeo.y() - curInfoGeo.y()); | ||
261 | const int topToBottomDiffAbs = qAbs(prevInfoGeo.y() - curInfoGeo.y() - curInfoGeo.height()); | 261 | const int topToBottomDiffAbs = qAbs(prevInfoGeo.y() - curInfoGeo.y() - curInfoGeo.height()); | ||
262 | const int bottomToBottomDiffAbs = qAbs(prevInfoGeo.y() + prevInfoGeo.height() - curInfoGeo.y() - curInfoGeo.height()); | 262 | const int bottomToBottomDiffAbs = qAbs(prevInfoGeo.y() + prevInfoGeo.height() - curInfoGeo.y() - curInfoGeo.height()); | ||
263 | const int bottomToTopDiffAbs = qAbs(prevInfoGeo.y() + prevInfoGeo.height() - curInfoGeo.y()); | 263 | const int bottomToTopDiffAbs = qAbs(prevInfoGeo.y() + prevInfoGeo.height() - curInfoGeo.y()); | ||
264 | 264 | | |||
265 | const bool yTopAligned = topToTopDiffAbs < bottomToBottomDiffAbs && topToTopDiffAbs <= bottomToTopDiffAbs || | 265 | const bool yTopAligned = (topToTopDiffAbs < bottomToBottomDiffAbs && topToTopDiffAbs <= bottomToTopDiffAbs) || | ||
266 | topToBottomDiffAbs < bottomToBottomDiffAbs; | 266 | topToBottomDiffAbs < bottomToBottomDiffAbs; | ||
267 | 267 | | |||
268 | int yInfoDiff = curInfoGeo.y() - prevInfoGeo.y(); | 268 | int yInfoDiff = curInfoGeo.y() - prevInfoGeo.y(); | ||
269 | int yDiff = curGeo.y() - prevGeo.y(); | 269 | int yDiff = curGeo.y() - prevGeo.y(); | ||
270 | int yCorrected; | 270 | int yCorrected; | ||
271 | 271 | | |||
272 | if (yTopAligned) { | 272 | if (yTopAligned) { | ||
273 | // align to previous top | 273 | // align to previous top | ||
▲ Show 20 Lines • Show All 192 Lines • Show Last 20 Lines |