From df4689bb9c47e4959e5894f847c53119b8b2c2a1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 2 Oct 2020 12:38:41 +0200 Subject: --dump: Fall back to screen size if list is empty --- src/main.cpp | 8 ++++++++ src/widget.cpp | 6 +++++- src/xprivate.cpp | 10 ++++++++++ src/xx.cpp | 4 ++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d2def2c..54bf745 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace { bool _testMode, _autoSetup, _showGui, _backgroundMode, _wakeup, _center, _dumpScreens; @@ -199,6 +200,13 @@ static void dumpScreens() qSort(list.begin(), list.end(), [](const QRect &one, const QRect &other) -> bool { return one.y() < other.y() || (one.y() == other.y() && one.x() < other.x()); }); + if (list.empty()) { + // Fallback to desktop size + QRect s = qApp->desktop()->screenGeometry(); + if (s.width() > 0 && s.height() > 0) { + list.append(s); + } + } int nextX = 0; int lastY = 0; qStdOut() << "# x y width height" << endl; diff --git a/src/widget.cpp b/src/widget.cpp index 6b231fa..ec0c4b3 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -345,7 +345,11 @@ void Widget::initControls(bool jumpToTab) break; } } - fillCombo(_ui->cboCloneResolution, modes, screenList[0].currentResolution, preferredClone); + if (screenList.empty()) { + fillCombo(_ui->cboCloneResolution, modes, QSize(), preferredClone); + } else { + fillCombo(_ui->cboCloneResolution, modes, screenList[0].currentResolution, preferredClone); + } // Dual _ui->dualContainer->takeAt(0); _ui->dualContainer->takeAt(1); diff --git a/src/xprivate.cpp b/src/xprivate.cpp index 15447b7..ba5b805 100644 --- a/src/xprivate.cpp +++ b/src/xprivate.cpp @@ -181,9 +181,19 @@ void XPrivate::updateScreenResources() _allOutputs.append(outputName); tempMap.insert(_screenResources->outputs[i], outputName); if (info->connection == RR_Disconnected) { + bool ign = !_crtcMap.contains(info->crtc); + if (!ign) { + ign = !_modeMap.contains(_crtcMap[info->crtc]->mode); + } + if (!ign) { + auto mode = _modeMap[_crtcMap[info->crtc]->mode]; + ign = (mode->width == 0 || mode->height == 0); + } + if (ign) { qDebug() << "Ignoring disconnected output" << outputName; XRRFreeOutputInfo(info); continue; + } } bool disconnected = false; if (info->crtc == None && info->connection == RR_Connected) { diff --git a/src/xx.cpp b/src/xx.cpp index 8aab4ac..3ee2a2d 100644 --- a/src/xx.cpp +++ b/src/xx.cpp @@ -241,6 +241,10 @@ QMap ScreenSetup::getScreenPositions() const { QMap ret; for (auto oi : a->_outputMap) { + if (oi->mode == nullptr) + continue; + if (oi->mode->width == 0 || oi->mode->height == 0) + continue; ret.insert(oi->outputName, initScreenInfo(oi)); } return ret; -- cgit v1.2.3-55-g7522