summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-06-16 18:02:47 +0200
committerSimon Rettberg2020-06-16 18:02:47 +0200
commitbb18e7680f426ff51e435afe78950082da42b643 (patch)
tree9fb51f78d26ed24131b428d90b882ab85e2cbab9
parentRestore accidentally deleted line (diff)
downloadslxgreeter-bb18e7680f426ff51e435afe78950082da42b643.tar.gz
slxgreeter-bb18e7680f426ff51e435afe78950082da42b643.tar.xz
slxgreeter-bb18e7680f426ff51e435afe78950082da42b643.zip
Support setting resolution received via loginrpc
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/loginrpc.cpp35
2 files changed, 36 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd7606f..28d953f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
-file(GLOB SRCS src/*.cpp)
+file(GLOB SRCS src/*.cpp src/*.c)
file(GLOB UIS src/*.ui)
FIND_PACKAGE(Qt5 COMPONENTS Widgets X11Extras Svg Network REQUIRED)
diff --git a/src/loginrpc.cpp b/src/loginrpc.cpp
index 4ced53e..dfb1757 100644
--- a/src/loginrpc.cpp
+++ b/src/loginrpc.cpp
@@ -1,8 +1,10 @@
#include "loginrpc.h"
+#include "cvt.h"
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
#include <QDebug>
+#include <QProcess>
LoginRpc::LoginRpc(int port, QObject *parent)
: QObject(parent)
@@ -41,5 +43,38 @@ void LoginRpc::handleCommandV1(const QString &command)
while (lines.count() < 3) {
lines.append(QString());
}
+ QString res = lines[2];
+ QStringList parts = res.split("x");
+ if (parts.size() == 2) {
+ int x = parts[0].toInt();
+ int y = parts[1].toInt();
+ if (x > 0 && y > 0) {
+ x = (x / 8) * 8;
+ y = (y / 8) * 8;
+ // TODO: Configurable min max sizes
+ if (x < 1024) x = 1024;
+ if (y < 720) y = 720;
+ if (x > 1920) x = 1920;
+ if (y > 1080) y = 1080;
+ QString name = QString("%1x%2").arg(x).arg(y);
+ mode *mode = vert_refresh(x, y, 60, 0, 0, 0);
+ QProcess p;
+ QStringList newmode = QStringList() << "--verbose" << "--newmode" << name << QString::asprintf("%.2f", mode->pclk)
+ << QString::number(mode->hr) << QString::number(mode->hss) << QString::number(mode->hse) << QString::number(mode->hfl)
+ << QString::number(mode->vr) << QString::number(mode->vss) << QString::number(mode->vse) << QString::number(mode->vfl)
+ << "-hsync" << "+vsync";
+ qDebug() << "Setting mode" << newmode;
+ p.setProcessChannelMode(QProcess::ForwardedChannels);
+ p.start("xrandr", newmode);
+ p.waitForFinished(2000);
+ p.kill();
+ p.start("xrandr", QStringList() << "--verbose" << "--addmode" << "VIRTUAL1" << name);
+ p.waitForFinished(2000);
+ p.kill();
+ p.start("xrandr", QStringList() << "--verbose" << "--output" << "VIRTUAL1" << "--mode" << name);
+ p.waitForFinished(2000);
+ p.kill();
+ }
+ }
emit loginRequest(lines[0], lines[1], lines[2]);
}