summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2020-10-02 12:50:00 +0200
committerSimon Rettberg2020-10-02 12:50:00 +0200
commit3cb366e8c2c302a974de55773552ebe26aac9f61 (patch)
tree780799d5a9a91fed19d63ca547367ec824f130cd /src
parentMake MainWindow reusing code smarter wrt LoginForm (diff)
downloadslxgreeter-3cb366e8c2c302a974de55773552ebe26aac9f61.tar.gz
slxgreeter-3cb366e8c2c302a974de55773552ebe26aac9f61.tar.xz
slxgreeter-3cb366e8c2c302a974de55773552ebe26aac9f61.zip
Always disable all outputs and use --fb if VIRTUAL output is missing
Diffstat (limited to 'src')
-rw-r--r--src/loginrpc.cpp49
1 files changed, 20 insertions, 29 deletions
diff --git a/src/loginrpc.cpp b/src/loginrpc.cpp
index bbb1e1d..a4e61fc 100644
--- a/src/loginrpc.cpp
+++ b/src/loginrpc.cpp
@@ -74,38 +74,25 @@ void LoginRpc::handleCommandV1(const QString &command)
QString out = QString::fromLocal8Bit(p.readAll());
QRegularExpression re("^(\\S+)\\s.*?(\\w*connected)", QRegularExpression::MultilineOption);
QRegularExpressionMatchIterator it = re.globalMatch(out);
- QString disconnectedOut;
QString virtOut;
- QStringList disabledOutputs, allOutputs;
+ QStringList allOutputs;
while (it.hasNext()) {
QRegularExpressionMatch m = it.next();
QString output = m.captured(1);
- allOutputs << output;
if (virtOut.isEmpty() && (output == QLatin1String("VIRTUAL1") || output == QLatin1String("VIRTUAL-1")
|| output == QLatin1String("Virtual1") || output == QLatin1String("Virtual-1")
|| output == QLatin1String("default"))) {
virtOut = output;
- } else if (disconnectedOut.isEmpty() && m.captured(2) == "disconnected") {
- disconnectedOut = output;
} else {
- disabledOutputs << output;
+ allOutputs << output;
}
}
- if (virtOut.isEmpty() && !disconnectedOut.isEmpty()) {
- virtOut = disconnectedOut;
- disconnectedOut.clear();
- }
- if (!disconnectedOut.isEmpty()) {
- disabledOutputs << disconnectedOut;
- }
- if (virtOut.isEmpty() && !disabledOutputs.isEmpty()) {
- virtOut = disabledOutputs.takeFirst();
- }
- qDebug() << "Virtual output:" << virtOut << "unwanted additional outputs:" << disabledOutputs << "(First disconnected:" << disconnectedOut << ")";
+ qDebug() << "Virtual output:" << virtOut << "unwanted additional outputs:" << allOutputs;
p.kill();
+ int ret = -1;
if (!virtOut.isEmpty()) {
setMode << "--output" << virtOut << "--mode" << name;
- for (auto output : disabledOutputs) {
+ for (auto output : allOutputs) {
setMode << "--output" << output << "--off";
}
qDebug() << "Setting mode" << newmode;
@@ -121,20 +108,24 @@ void LoginRpc::handleCommandV1(const QString &command)
// Set all outputs
p.start("xrandr", setMode);
p.waitForFinished(2000);
- int ret = p.exitCode();
+ ret = p.exitCode();
p.kill();
if (ret != 0) {
- // Play it safe and disable all the outputs
- qDebug() << "Command failed, trying to disable all outputs";
- setMode.clear();
- setMode << "--verbose" << "--fb" << name;
- for (auto s : allOutputs) {
- setMode << "--output" << s << "--off";
- }
- p.start("xrandr", setMode);
- p.waitForFinished(2000);
- p.kill();
+ allOutputs << virtOut;
+ }
+ }
+ // Either -1 if we didn't have a virtual one, or != 0 if xrandr setting failed
+ if (ret != 0) {
+ // Play it safe and disable all the outputs
+ qDebug() << "Ret:" << ret << "- Trying to disable all outputs";
+ setMode.clear();
+ setMode << "--verbose" << "--fb" << name; // Explicit framebuffer size
+ for (auto s : allOutputs) {
+ setMode << "--output" << s << "--off";
}
+ p.start("xrandr", setMode);
+ p.waitForFinished(2000);
+ p.kill();
}
}
}