diff options
author | Simon Rettberg | 2022-09-08 16:39:06 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-09-08 16:39:06 +0200 |
commit | 1a4c4b6cbe887886382ce389bf14b97010b88d9e (patch) | |
tree | 3af79994a339d59b71a3efb2fe4f9199375ba383 | |
parent | Always return to welcome page if only web login is enabled (diff) | |
download | slxgreeter-1a4c4b6cbe887886382ce389bf14b97010b88d9e.tar.gz slxgreeter-1a4c4b6cbe887886382ce389bf14b97010b88d9e.tar.xz slxgreeter-1a4c4b6cbe887886382ce389bf14b97010b88d9e.zip |
Try to select an output with an unused index
-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) { |