aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core')
-rw-r--r--src-qt5/core/libLumina/RootWindow.cpp66
-rw-r--r--src-qt5/core/libLumina/RootWindow.h18
-rw-r--r--src-qt5/core/libLumina/RootWindow.pri1
-rw-r--r--src-qt5/core/lumina-desktop-unified/LSession.cpp25
-rw-r--r--src-qt5/core/lumina-desktop-unified/LSession.h2
-rw-r--r--src-qt5/core/lumina-desktop-unified/global-includes.h1
-rw-r--r--src-qt5/core/lumina-desktop-unified/global-objects.h5
-rw-r--r--src-qt5/core/lumina-desktop-unified/lumina-desktop.pro1
8 files changed, 76 insertions, 43 deletions
diff --git a/src-qt5/core/libLumina/RootWindow.cpp b/src-qt5/core/libLumina/RootWindow.cpp
index 49d3fcac..0121c3b2 100644
--- a/src-qt5/core/libLumina/RootWindow.cpp
+++ b/src-qt5/core/libLumina/RootWindow.cpp
@@ -6,9 +6,12 @@
//===========================================
#include "RootWindow.h"
+#include <QDesktopWidget>
+#include <QScreen>
+
// === PUBLIC ===
RootWindow::RootWindow(){
-
+ autoResizeTimer = 0;
}
RootWindow::~RootWindow(){
@@ -16,16 +19,24 @@ RootWindow::~RootWindow(){
}
void RootWindow::start(){
+ if(autoResizeTimer==0){
+ autoResizeTimer = new QTimer(this);
+ autoResizeTimer->setInterval(100); //1/10 second (collect all nearly-simultaneous signals and compress into a single update)
+ autoResizeTimer->setSingleShot(true);
+ connect(autoResizeTimer, SIGNAL(timeout()), this, SLOT(ResizeRoot()) );
+ connect(QApplication::desktop(), SIGNAL(resized(int)), autoResizeTimer, SLOT(start()) );
+ connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), autoResizeTimer, SLOT(start()) );
+ }
}
// === PRIVATE ===
-void RootWindow::updateScreenPixmap(ScreenInfo *info){
+void RootWindow::updateScreenPixmap(screeninfo *info){
QPixmap pix(info->area.size());
if(info->scale == RootWindow::SolidColor){
QColor color;
- if(info->file.startsWith("rgb("))){
- QStringList colors = bgFile.section(")",0,0).section("(",1,1).split(",");
+ if(info->file.startsWith("rgb(")){
+ QStringList colors = info->file.section(")",0,0).section("(",1,1).split(",");
color = QColor(colors[0].toInt(), colors[1].toInt(), colors[2].toInt());
}else{
color = QColor(info->file);
@@ -39,7 +50,7 @@ void RootWindow::updateScreenPixmap(ScreenInfo *info){
if(info->scale == RootWindow::Stretch ){ armode = Qt::IgnoreAspectRatio; }
else if(info->scale == RootWindow::Full ){ armode = Qt::KeepAspectRatioByExpanding; }
if(raw.height()!=info->area.height() && raw.width() !=info->area.width()){
- raw = raw.scaled(info->area, armode);
+ raw = raw.scaled(info->area.size(), armode);
}
}
//Now calculate offset and draw width/height
@@ -59,7 +70,7 @@ void RootWindow::updateScreenPixmap(ScreenInfo *info){
}else if(info->scale == RootWindow::BottomRight ){
drawRect.moveTo( (info->area.width() - raw.width()), (info->area.height() - raw.height()) );
}else if(info->scale == RootWindow::BottomCenter ){
- drawRect.moveTo( (info->area.width() - raw.width())/2, info->area.height() - raw.height()) );
+ drawRect.moveTo( (info->area.width() - raw.width())/2, info->area.height() - raw.height() );
}else if(info->scale == RootWindow::TopLeft ){
drawRect.moveTo( 0, 0 );
}else if(info->scale == RootWindow::TopRight ){
@@ -74,27 +85,27 @@ void RootWindow::updateScreenPixmap(ScreenInfo *info){
QPainter P(&pix);
P.setBrush(raw);
- P.setBrushOrigin(dx,dy);
- P.drawRect(dx,dy,
+ P.setBrushOrigin( drawRect.x(), drawRect.y() );
+ P.drawRect( drawRect );
} //end SolidColor Check
- info.wallpaper = pix;
+ info->wallpaper = pix;
}
// === PUBLIC SLOTS ===
void RootWindow::ResizeRoot(){
QList<QScreen*> scrns = QApplication::screens();
//Update all the screen locations and ID's in the WALLPAPERS list
- QRect fullScreen;
- QStringList validids;
+ QRect fullscreen;
+ QStringList valid;
//Update the size of the rootWindow itself
for(int i=0; i<scrns.length(); i++){
fullscreen = fullscreen.united(scrns[i]->geometry());
- validids << scrns[i]->name();
+ valid << scrns[i]->name();
for(int j=0; j<WALLPAPERS.length(); j++){
- if(WALLPAPERS[j].id == scrn[i]->name()){
+ if(WALLPAPERS[j].id == scrns[i]->name()){
QSize oldsize = WALLPAPERS[j].area.size();
- WALLPAPERS[j].area = scrn[i]->geometry();
+ WALLPAPERS[j].area = scrns[i]->geometry();
if(oldsize != WALLPAPERS[j].area.size()){ updateScreenPixmap(&WALLPAPERS[j]); }
break;
}
@@ -114,8 +125,8 @@ void RootWindow::ResizeRoot(){
//Trigger a repaint and send out any signals
this->update();
emit RootResized();
- if(!validids.isEmpty()){ emit NewScreens(valid); }
- if(!invalid.isEmpty()){ emit RemoveScreens(invalid); }
+ if(!valid.isEmpty()){ emit NewScreens(valid); }
+ if(!invalid.isEmpty()){ emit RemovedScreens(invalid); }
}
void RootWindow::ChangeWallpaper(QString id, RootWindow::ScaleType scale, QString file){
@@ -131,13 +142,13 @@ void RootWindow::ChangeWallpaper(QString id, RootWindow::ScaleType scale, QStrin
if(!found){
//Need to create a new screeninfo structure
QList<QScreen*> scrns = QApplication::screens();
- for(int i=0; i<srcns.length(); i++){
- if(scrns[i].name()==id){
+ for(int i=0; i<scrns.length(); i++){
+ if(scrns[i]->name()==id){
screeninfo info;
info.id = id;
info.file = file;
info.scale = scale;
- info.area = srcns[i]->geometry();
+ info.area = scrns[i]->geometry();
updateScreenPixmap(&info);
WALLPAPERS << info;
break;
@@ -151,12 +162,17 @@ void RootWindow::ChangeWallpaper(QString id, RootWindow::ScaleType scale, QStrin
// === PROTECTED ===
void RootWindow::paintEvent(QPaintEvent *ev){
-
- if(!wallpaper.isNull()){
- QPainter painter(this);
- painter.setBrush(wallpaper);
- painter.drawRect(ev->rect().adjusted(-1,-1,2,2));
- }else{
+ bool found = false;
+ QPainter painter(this);
+ for(int i=0; i<WALLPAPERS.length(); i++){
+ if(WALLPAPERS[i].area.intersects(ev->rect()) ){
+ found = true;
+ QRect intersect = WALLPAPERS[i].area.intersected(ev->rect());
+ painter.drawPixmap( intersect, WALLPAPERS[i].wallpaper, intersect.translated(-WALLPAPERS[i].area.x(), -WALLPAPERS[i].area.y()) );
+ }
+ }
+ painter.end();
+ if(!found){
QWidget::paintEvent(ev);
}
}
diff --git a/src-qt5/core/libLumina/RootWindow.h b/src-qt5/core/libLumina/RootWindow.h
index 4893b0c7..a60c4a1d 100644
--- a/src-qt5/core/libLumina/RootWindow.h
+++ b/src-qt5/core/libLumina/RootWindow.h
@@ -10,28 +10,38 @@
#ifndef _LUMINA_ROOT_WINDOW_H
#define _LUMINA_ROOT_WINDOW_H
-
+#include <QWidget>
+#include <QRect>
+#include <QString>
+#include <QPixmap>
+#include <QPainter>
+#include <QTimer>
+#include <QApplication>
+#include <QPaintEvent>
class RootWindow : public QWidget{
Q_OBJECT
public:
- enum ScaleType{ SingleColor, Stretch, Full, Fit, Center, Tile, BottomLeft, BottomRight, BottomCenter, \
+ enum ScaleType{ SolidColor, Stretch, Full, Fit, Center, Tile, BottomLeft, BottomRight, BottomCenter, \
TopLeft, TopRight, TopCenter, CenterLeft, CenterRight};
RootWindow();
~RootWindow();
+ void start();
+
private:
struct screeninfo{
QString id;
QRect area;
QString file;
ScaleType scale;
- QPixmap wallpaper;
+ QPixmap wallpaper; //Note: This pixmap will always be the same size as "area"
};
+ QTimer *autoResizeTimer;
QList<screeninfo> WALLPAPERS;
- void updateScreenPixmap(ScreenInfo *info); //used for recalculating the wallpaper pixmap based on file/area/scale as needed
+ void updateScreenPixmap(screeninfo *info); //used for recalculating the wallpaper pixmap based on file/area/scale as needed
public slots:
void ResizeRoot();
diff --git a/src-qt5/core/libLumina/RootWindow.pri b/src-qt5/core/libLumina/RootWindow.pri
index 7f2a144d..7ef3efb0 100644
--- a/src-qt5/core/libLumina/RootWindow.pri
+++ b/src-qt5/core/libLumina/RootWindow.pri
@@ -7,4 +7,3 @@ INCLUDEPATH *= ${PWD}
# include LUtils and LuminaX11
include(LUtils.pri)
-include(LuminaX11.pri)
diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp
index 82fb4a4b..63e86fdc 100644
--- a/src-qt5/core/lumina-desktop-unified/LSession.cpp
+++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp
@@ -12,15 +12,17 @@
#define DEBUG 0
#endif
+//Initialize all the global objects to null pointers
+EventFilter* Lumina::EFILTER = 0;
+LScreenSaver* Lumina::SS = 0;
+DesktopSettings* Lumina::SETTINGS = 0;
+//Lumina::WM = 0;
+QThread* Lumina::EVThread = 0;
+RootWindow* Lumina::ROOTWIN = 0;
+
LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lumina-desktop"){
//Initialize the global objects to null pointers
mediaObj = 0; //private object used for playing login/logout chimes
- Lumina::EFILTER = 0;
- Lumina::SS = 0;
- Lumina::SETTINGS = 0;
- //Lumina::WM = 0;
- Lumina::EVThread = 0;
-
if(this->isPrimaryProcess()){
//Setup the global registrations
this->setApplicationName("Lumina Desktop Environment");
@@ -43,6 +45,8 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu
Lumina::EVThread = new QThread();
Lumina::EFILTER->moveToThread(Lumina::EVThread);
Lumina::EVThread->start();
+ Lumina::ROOTWIN = new RootWindow();
+
} //end check for primary process
}
@@ -56,6 +60,7 @@ LSession::~LSession(){
Lumina::EVThread->deleteLater();
}
if(Lumina::SETTINGS!=0){ Lumina::SETTINGS->deleteLater(); }
+ if(Lumina::ROOTWIN!=0){ Lumina::ROOTWIN->deleteLater(); }
}
void LSession::setupSession(){
@@ -235,7 +240,7 @@ void LSession::launchStartupApps(){
//Enable Numlock
if(LUtils::isValidBinary("numlockx")){ //make sure numlockx is installed
- if(sessionsettings->value("EnableNumlock",false).toBool()){
+ if(Lumina::SETTINGS->value(DesktopSettings::System,"EnableNumlock",false).toBool()){
QProcess::startDetached("numlockx on");
}else{
QProcess::startDetached("numlockx off");
@@ -256,7 +261,7 @@ void LSession::launchStartupApps(){
qDebug() << " - - Audio Volume:" << QString::number(tmp)+"%";
//Now play the login music since we are finished
- if(sessionsettings->value("PlayStartupAudio",true).toBool()){
+ if(Lumina::SETTINGS->value(DesktopSettings::System,"PlayStartupAudio",true).toBool()){
//Make sure to re-set the system volume to the last-used value at outset
int vol = LOS::audioVolume();
if(vol>=0){ LOS::setAudioVolume(vol); }
@@ -268,11 +273,11 @@ void LSession::launchStartupApps(){
void LSession::checkUserFiles(){
//internal version conversion examples:
// [1.0.0 -> 1000000], [1.2.3 -> 1002003], [0.6.1 -> 6001]
- QString OVS = sessionsettings->value("DesktopVersion","0").toString(); //Old Version String
+ QString OVS = Lumina::SETTINGS->value(DesktopSettings::System,"DesktopVersion","0").toString(); //Old Version String
bool changed = LDesktopUtils::checkUserFiles(OVS);
if(changed){
//Save the current version of the session to the settings file (for next time)
- sessionsettings->setValue("DesktopVersion", this->applicationVersion());
+ Lumina::SETTINGS->setValue(DesktopSettings::System,"DesktopVersion", this->applicationVersion());
}
}
diff --git a/src-qt5/core/lumina-desktop-unified/LSession.h b/src-qt5/core/lumina-desktop-unified/LSession.h
index d9c652c6..ac156035 100644
--- a/src-qt5/core/lumina-desktop-unified/LSession.h
+++ b/src-qt5/core/lumina-desktop-unified/LSession.h
@@ -22,7 +22,7 @@ private:
void CleanupSession();
int VersionStringToNumber(QString version);
- QMediaObject *mediaObj;
+ QMediaPlayer *mediaObj;
void playAudioFile(QString filepath);
QTranslator *currTranslator;
diff --git a/src-qt5/core/lumina-desktop-unified/global-includes.h b/src-qt5/core/lumina-desktop-unified/global-includes.h
index c7433155..04c4c27c 100644
--- a/src-qt5/core/lumina-desktop-unified/global-includes.h
+++ b/src-qt5/core/lumina-desktop-unified/global-includes.h
@@ -55,6 +55,7 @@
#include <LDesktopUtils.h>
#include <LuminaSingleApplication.h>
#include <DesktopSettings.h>
+#include <RootWindow.h>
// Standard C includes
#include <unistd.h>
diff --git a/src-qt5/core/lumina-desktop-unified/global-objects.h b/src-qt5/core/lumina-desktop-unified/global-objects.h
index 579807c7..7d924378 100644
--- a/src-qt5/core/lumina-desktop-unified/global-objects.h
+++ b/src-qt5/core/lumina-desktop-unified/global-objects.h
@@ -35,11 +35,12 @@ namespace Lumina{
extern DesktopSettings *SETTINGS; //All Settings files
//ScreenSaver
extern LScreenSaver *SS;
+ //Root Window
+ extern RootWindow *ROOTWIN;
//Window Manager
//LWindowManager *WM;
- QThread *EVThread; //X Event thread
+ extern QThread *EVThread; //X Event thread
};
-
#endif
diff --git a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
index 3f228373..a583e9d7 100644
--- a/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
+++ b/src-qt5/core/lumina-desktop-unified/lumina-desktop.pro
@@ -16,6 +16,7 @@ include(../libLumina/LuminaX11.pri)
include(../libLumina/LuminaSingleApplication.pri)
include(../libLumina/LuminaThemes.pri)
include(../libLumina/DesktopSettings.pri)
+include(../libLumina/RootWindow.pri)
#include all the main individual source groups
include(src-screensaver/screensaver.pri)
bgstack15