summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp46
1 files changed, 32 insertions, 14 deletions
diff --git a/src/main.cpp b/src/main.cpp
index ece6b87..8eee16f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,6 +22,7 @@
#include "settings.h"
#include "mainwindow.h"
#include "x11util.h"
+#include "global.h"
static void messageHandler(QtMsgType type, const QMessageLogContext&, const QString& msg)
{
@@ -35,34 +36,49 @@ static inline int size(const QRect& r)
int main(int argc, char *argv[])
{
- //dup2(2, 1)
+ if (argc > 1 && QString(argv[1]) == QString("--test")) {
+ Global::enableTestMode();
+ }
+
+ QApplication a(argc, argv);
+
// I have no idea why, but Qt's stock qWarning() output never makes it
// to /var/log/lightdm/x-0-greeter.log, so we use std::cerr instead..
qInstallMessageHandler(messageHandler);
- QApplication a(argc, argv);
-
if (! Settings().iconThemeName().isEmpty()) {
QIcon::setThemeName(Settings().iconThemeName());
}
- // Build background for X server, in case we start a session that
- // doesn't set one on its own this will make sure it's not simply
- // black
- QImage entire;
- QSize desktopSize = QApplication::desktop()->size();
- qWarning() << "Desktop full size is " << desktopSize;
- entire = QImage(desktopSize, QImage::Format_RGB32);
- QPainter painter(&entire);
+ if (!Global::testMode() && !Settings().autoLoginCheckCmd().isEmpty()) {
+ QProcess p;
+ int ret = QProcess::execute(Settings().autoLoginCheckCmd());
+ if (ret == 0) {
+ if (Global::autoLoginGuest()) {
+ qWarning() << "Guest login ok";
+ return a.exec();
+ // TODO: Background?
+ } else {
+ qWarning() << "Guest login failed";
+ // TODO: Set error message, display somewhere
+ }
+ }
+ }
- const bool testMode = argc > 1 && QString(argv[1]) == QString("--test");
+ // Build background for X server, in case we start a session that
+ // doesn't set one on its own this will make sure it's not simply
+ // black
+ QImage entire;
// Get a list of non-overlapping screens, as this might lead to a broken
// greeter with main windows covering other login forms
QMap<int, QRect> screens;
- if (testMode) {
+ if (Global::testMode()) {
screens.insert(0, QRect(0, 0, 1024, 768));
} else {
+ QSize desktopSize = QApplication::desktop()->size();
+ qWarning() << "Desktop full size is " << desktopSize;
+ entire = QImage(desktopSize, QImage::Format_RGB32);
for (int i = 0; i < QApplication::desktop()->screenCount(); ++i) {
QRect r = QApplication::desktop()->screenGeometry(i);
QMutableMapIterator<int, QRect>it(screens);
@@ -83,6 +99,7 @@ int main(int argc, char *argv[])
skip_rect: ; // Do nothing
}
}
+
// Determine primary screen
int primary;
if (screens.contains(QApplication::desktop()->primaryScreen())) {
@@ -94,11 +111,12 @@ int main(int argc, char *argv[])
}
// Now set up all the screens
+ QPainter painter(&entire);
MainWindow *focusWindow = 0;
QMapIterator<int, QRect> it(screens);
while (it.hasNext()) {
it.next();
- MainWindow *w = new MainWindow(primary == it.key(), it.key(), it.value(), testMode);
+ MainWindow *w = new MainWindow(primary == it.key(), it.key(), it.value());
w->show();
if (w->showLoginForm()) {
focusWindow = w;