summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-05-07 15:52:09 +0200
committerSimon Rettberg2020-05-07 15:52:09 +0200
commit589b0d4bc81232768b54c8c11bd0a44a72352d7d (patch)
tree6d57d2ad399cfcf6afe4e0050dd65d2bb1793eaa
parentReact to changed screen setup, update layout (diff)
downloadslxgreeter-589b0d4bc81232768b54c8c11bd0a44a72352d7d.tar.gz
slxgreeter-589b0d4bc81232768b54c8c11bd0a44a72352d7d.tar.xz
slxgreeter-589b0d4bc81232768b54c8c11bd0a44a72352d7d.zip
Reintroduce X background generation
-rw-r--r--src/loginform.cpp3
-rw-r--r--src/main.cpp23
-rw-r--r--src/mainwindow.h2
3 files changed, 22 insertions, 6 deletions
diff --git a/src/loginform.cpp b/src/loginform.cpp
index a17401d..a52aa3d 100644
--- a/src/loginform.cpp
+++ b/src/loginform.cpp
@@ -30,6 +30,8 @@
#include <QX11Info>
#include <iostream>
+void createSimpleBackground();
+
LoginForm::LoginForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::LoginForm),
@@ -258,6 +260,7 @@ void LoginForm::onAuthenticationComplete()
std::cerr << "Auth complete, start session" << std::endl;
showMessage(tr("Starting session..."), false);
if (Global::startSession()) {
+ createSimpleBackground();
cancelLoginTimer.stop();
} else {
showMessage(tr("Cannot open session"), true);
diff --git a/src/main.cpp b/src/main.cpp
index 17d07bc..50816ec 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,7 +37,7 @@ static QMap<int, MainWindow*> currentWindows;
static QTimer setupDelay;
-static void createSimpleBackground();
+void createSimpleBackground();
static void watch(const QScreen *scrn);
@@ -124,12 +124,23 @@ static void watch(const QScreen *scrn)
});
}
-static void createSimpleBackground()
+void createSimpleBackground()
{
- QImage img = Global::getConfigGradient();
- if (img.isNull())
- return;
- img = img.scaled(QApplication::desktop()->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ QImage img;
+ if (currentWindows.isEmpty()) {
+ img = Global::getConfigGradient();
+ if (img.isNull()) {
+ img = QImage(QApplication::desktop()->size(), QImage::Format::Format_RGB32);
+ } else {
+ img = img.scaled(QApplication::desktop()->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ }
+ } else {
+ img = QImage(QApplication::desktop()->size(), QImage::Format::Format_RGB32);
+ QPainter p(&img);
+ for (auto *w : currentWindows) {
+ p.drawImage(w->geometry(), w->background(), QRect(QPoint(0, 0), w->geometry().size()));
+ }
+ }
AddPixmapToBackground(img.constBits(), img.width(), img.height(),
24, img.bytesPerLine(), img.byteCount());
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index fc0249b..f6b1072 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -40,6 +40,8 @@ public:
LoginForm* stealLoginForm() { LoginForm *p = m_LoginForm; m_LoginForm = nullptr; return p; }
+ const QImage& background() { return m_background; }
+
protected:
virtual void paintEvent(QPaintEvent *event) override;