diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/loginrpc.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/loginrpc.cpp b/src/loginrpc.cpp index 1d36103..86bfe07 100644 --- a/src/loginrpc.cpp +++ b/src/loginrpc.cpp @@ -130,9 +130,33 @@ void LoginRpc::handleCommandV1(const QString &command) } // Either -1 if we didn't have a virtual one, or != 0 if xrandr setting failed // Now as fallback, try enabling a disconnected output only - if (ret != 0) { + if (ret != 0 && !disconnectedOutputs.isEmpty()) { qDebug() << "Ret:" << ret << "- Trying to enable one disconnected output"; - QString dis = disconnectedOutputs.first(); + QRegularExpression re("\\d+$"); + QString dis; + int used[10] = {}; + for (QString c : connectedOutputs) { + auto m = re.match(c); + if (m.hasMatch()) { + int i = m.captured().toInt(); + if (i >= 0 && i < 10) { + used[i]++; + } + } + } + for (QString c : disconnectedOutputs) { + auto m = re.match(c); + if (m.hasMatch()) { + int i = m.captured().toInt(); + if (i >= 0 && i < 10 && used[i] == 0) { + dis = c; + break; + } + } + } + if (dis.isEmpty()) { + dis = disconnectedOutputs.first(); + } setMode.clear(); setMode << "--verbose" << "--output" << dis << "--mode" << name; for (auto s : allOutputs) { |