aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop/LDesktop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/lumina-desktop/LDesktop.cpp')
-rw-r--r--src-qt5/core/lumina-desktop/LDesktop.cpp79
1 files changed, 47 insertions, 32 deletions
diff --git a/src-qt5/core/lumina-desktop/LDesktop.cpp b/src-qt5/core/lumina-desktop/LDesktop.cpp
index e3d946d4..5031fb96 100644
--- a/src-qt5/core/lumina-desktop/LDesktop.cpp
+++ b/src-qt5/core/lumina-desktop/LDesktop.cpp
@@ -12,11 +12,13 @@
#include "LWinInfo.h"
#include "JsonMenu.h"
+#include <QScreen>
+
#define DEBUG 0
LDesktop::LDesktop(int deskNum, bool setdefault) : QObject(){
-
- DPREFIX = "desktop-"+QString::number(deskNum)+"/";
+ QString screenID = QApplication::screens().at(deskNum)->name();
+ DPREFIX = "desktop-"+screenID+"/";
desktopnumber = deskNum;
desktop = QApplication::desktop();
defaultdesktop = setdefault; //(desktop->screenGeometry(desktopnumber).x()==0);
@@ -28,7 +30,7 @@ LDesktop::LDesktop(int deskNum, bool setdefault) : QObject(){
settings = new QSettings(QSettings::UserScope, "lumina-desktop","desktopsettings", this);
//qDebug() << " - Desktop Settings File:" << settings->fileName();
if(!QFile::exists(settings->fileName())){ settings->setValue(DPREFIX+"background/filelist",QStringList()<<"default"); settings->sync(); }
- bgWindow = 0;
+ //bgWindow = 0;
bgDesktop = 0;
QTimer::singleShot(1,this, SLOT(InitDesktop()) );
@@ -37,7 +39,7 @@ LDesktop::LDesktop(int deskNum, bool setdefault) : QObject(){
LDesktop::~LDesktop(){
delete deskMenu;
delete winMenu;
- delete bgWindow;
+ //delete bgWindow;
delete workspacelabel;
delete wkspaceact;
}
@@ -47,13 +49,13 @@ int LDesktop::Screen(){
}
void LDesktop::show(){
- if(bgWindow!=0){ bgWindow->show(); }
+ //if(bgWindow!=0){ bgWindow->show(); }
if(bgDesktop!=0){ bgDesktop->show(); }
for(int i=0; i<PANELS.length(); i++){ PANELS[i]->show(); }
}
void LDesktop::hide(){
- if(bgWindow!=0){ bgWindow->hide(); }
+ //if(bgWindow!=0){ bgWindow->hide(); }
if(bgDesktop!=0){ bgDesktop->hide(); }
for(int i=0; i<PANELS.length(); i++){ PANELS[i]->hide(); }
}
@@ -69,7 +71,7 @@ void LDesktop::prepareToClose(){
}
WId LDesktop::backgroundID(){
- if(bgWindow!=0){ return bgWindow->winId(); }
+ if(bgDesktop!=0){ return bgDesktop->winId(); }
else{ return QX11Info::appRootWindow(); }
}
@@ -88,13 +90,17 @@ void LDesktop::UpdateGeometry(){
//Now update the screen
// NOTE: This functionality is highly event-driven based on X changes - so we need to keep things in order (no signals/slots)
//qDebug() << "Changing Desktop Geom:" << desktopnumber;
- bgWindow->setGeometry(desktop->screenGeometry(desktopnumber));
+ //bgWindow->setGeometry(desktop->screenGeometry(desktopnumber));
//qDebug() << " - Update Desktop Plugin Area";
UpdateDesktopPluginArea();
//qDebug() << " - Done With Desktop Geom Updates";
QTimer::singleShot(0, this, SLOT(UpdatePanels()));
}
-
+
+void LDesktop::SystemLock(){
+ QProcess::startDetached("xscreensaver-command -lock");
+}
+
void LDesktop::SystemLogout(){
LSession::handle()->systemWindow();
}
@@ -209,26 +215,31 @@ void LDesktop::InitDesktop(){
connect(QApplication::instance(), SIGNAL(DesktopConfigChanged()), this, SLOT(SettingsChanged()) );
connect(QApplication::instance(), SIGNAL(DesktopFilesChanged()), this, SLOT(UpdateDesktop()) );
connect(QApplication::instance(), SIGNAL(LocaleChanged()), this, SLOT(LocaleChanged()) );
+ connect(QApplication::instance(), SIGNAL(WorkspaceChanged()), this, SLOT(UpdateBackground()) );
- if(DEBUG){ qDebug() << "Create bgWindow"; }
- bgWindow = new LDesktopBackground();
+ //if(DEBUG){ qDebug() << "Create bgWindow"; }
+ /*bgWindow = new QWidget(); //LDesktopBackground();
bgWindow->setObjectName("bgWindow");
bgWindow->setContextMenuPolicy(Qt::CustomContextMenu);
bgWindow->setFocusPolicy(Qt::StrongFocus);
bgWindow->setWindowFlags(Qt::WindowStaysOnBottomHint | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
LSession::handle()->XCB->SetAsDesktop(bgWindow->winId());
bgWindow->setGeometry(LSession::handle()->screenGeom(desktopnumber));
- connect(bgWindow, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowMenu()) );
+ bgWindow->setWindowOpacity(0.0);
+ connect(bgWindow, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowMenu()) );*/
if(DEBUG){ qDebug() << "Create bgDesktop"; }
- bgDesktop = new LDesktopPluginSpace(bgWindow); //new QMdiArea(bgWindow);
+ bgDesktop = new LDesktopPluginSpace();
int grid = settings->value(DPREFIX+"GridSize",-1).toInt();
- if(grid<0 && bgWindow->height() > 2000){ grid = 200; }
+ if(grid<0 &&desktop->screenGeometry(desktopnumber).height() > 2000){ grid = 200; }
else if(grid<0){ grid = 100; }
bgDesktop->SetIconSize( grid );
+ bgDesktop->setContextMenuPolicy(Qt::CustomContextMenu);
+ //LSession::handle()->XCB->SetAsDesktop(bgDesktop->winId());
connect(bgDesktop, SIGNAL(PluginRemovedByUser(QString)), this, SLOT(RemoveDeskPlugin(QString)) );
connect(bgDesktop, SIGNAL(IncreaseIcons()), this, SLOT(IncreaseDesktopPluginIcons()) );
connect(bgDesktop, SIGNAL(DecreaseIcons()), this, SLOT(DecreaseDesktopPluginIcons()) );
connect(bgDesktop, SIGNAL(HideDesktopMenu()), deskMenu, SLOT(hide()));
+ connect(bgDesktop, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(ShowMenu()) );
if(DEBUG){ qDebug() << " - Desktop Init Done:" << desktopnumber; }
//Start the update processes
QTimer::singleShot(10,this, SLOT(UpdateMenu()) );
@@ -272,6 +283,7 @@ void LDesktop::UpdateMenu(bool fast){
usewinmenu=false;
for(int i=0; i<items.length(); i++){
if(items[i]=="terminal"){ deskMenu->addAction(LXDG::findIcon("utilities-terminal",""), tr("Terminal"), this, SLOT(SystemTerminal()) ); }
+ else if(items[i]=="lockdesktop"){ deskMenu->addAction(LXDG::findIcon("system-lock-screen",""), tr("Lock Session"), this, SLOT(SystemLock()) ); }
else if(items[i]=="filemanager"){ deskMenu->addAction( LXDG::findIcon("user-home",""), tr("Browse Files"), this, SLOT(SystemFileManager()) ); }
else if(items[i]=="applications"){ deskMenu->addMenu( LSession::handle()->applicationMenu() ); }
else if(items[i]=="line"){ deskMenu->addSeparator(); }
@@ -280,9 +292,8 @@ void LDesktop::UpdateMenu(bool fast){
else if(items[i].startsWith("app::::") && items[i].endsWith(".desktop")){
//Custom *.desktop application
QString file = items[i].section("::::",1,1).simplified();
- bool ok = false;
- XDGDesktop xdgf = LXDG::loadDesktopFile(file, ok);
- if(ok){
+ XDGDesktop xdgf(file);// = LXDG::loadDesktopFile(file, ok);
+ if(xdgf.type!=XDGDesktop::BAD){
deskMenu->addAction( LXDG::findIcon(xdgf.icon,""), xdgf.name)->setWhatsThis(file);
}else{
qDebug() << "Could not load application file:" << file;
@@ -374,7 +385,7 @@ void LDesktop::RemoveDeskPlugin(QString ID){
void LDesktop::IncreaseDesktopPluginIcons(){
int cur = settings->value(DPREFIX+"GridSize",-1).toInt();
- if(cur<0 && bgWindow->height() > 2000){ cur = 200; }
+ if(cur<0 && desktop->screenGeometry(desktopnumber).height() > 2000){ cur = 200; }
else if(cur<0){ cur = 100; }
cur+=16;
issyncing=true; //don't let the change cause a refresh
@@ -386,7 +397,7 @@ void LDesktop::IncreaseDesktopPluginIcons(){
void LDesktop::DecreaseDesktopPluginIcons(){
int cur = settings->value(DPREFIX+"GridSize",-1).toInt();
- if(cur<0 && bgWindow->height() > 2000){ cur = 200; }
+ if(cur<0 && desktop->screenGeometry(desktopnumber).height() > 2000){ cur = 200; }
else if(cur<0){ cur = 100; }
if(cur<32){ return; } //cannot get smaller than 16x16
cur-=16;
@@ -424,7 +435,7 @@ void LDesktop::UpdatePanels(){
if(!found){
if(DEBUG){ qDebug() << " -- Create panel "<< i; }
//New panel
- LPanel *pan = new LPanel(settings, desktopnumber, i, bgWindow);
+ LPanel *pan = new LPanel(settings, desktopnumber, i, bgDesktop);
PANELS << pan;
pan->show();
}
@@ -434,7 +445,7 @@ void LDesktop::UpdatePanels(){
}
void LDesktop::UpdateDesktopPluginArea(){
- QRegion visReg( bgWindow->geometry() ); //visible region (not hidden behind a panel)
+ QRegion visReg( desktop->screenGeometry(desktopnumber) ); //visible region (not hidden behind a panel)
QRect rawRect = visReg.boundingRect(); //initial value (screen size)
//qDebug() << "Update Desktop Plugin Area:" << bgWindow->geometry();
for(int i=0; i<PANELS.length(); i++){
@@ -465,21 +476,25 @@ void LDesktop::UpdateDesktopPluginArea(){
rec.moveTopLeft( QPoint( rec.x()-desktop->screenGeometry(desktopnumber).x() , rec.y()-desktop->screenGeometry(desktopnumber).y() ) );
//qDebug() << "DPlug Area:" << rec << bgDesktop->geometry() << LSession::handle()->desktop()->availableGeometry(bgDesktop);
if(rec.size().isNull() || rec == bgDesktop->geometry()){return; } //nothing changed
- bgDesktop->setGeometry( rec );
+ bgDesktop->setGeometry(desktop->screenGeometry(desktopnumber));
+ bgDesktop->setDesktopArea( rec );
bgDesktop->UpdateGeom(); //just in case the plugin space itself needs to do anything
+ QTimer::singleShot(10, this, SLOT(UpdateBackground()) );
//Re-paint the panels (just in case a plugin was underneath it and the panel is transparent)
- for(int i=0; i<PANELS.length(); i++){ PANELS[i]->update(); }
+ //for(int i=0; i<PANELS.length(); i++){ PANELS[i]->update(); }
//Make sure to re-disable any WM control flags
- LSession::handle()->XCB->SetDisableWMActions(bgWindow->winId());
+ LSession::handle()->XCB->SetDisableWMActions(bgDesktop->winId());
}
void LDesktop::UpdateBackground(){
//Get the current Background
- if(bgupdating || bgWindow==0){ return; } //prevent multiple calls to this at the same time
+ if(bgupdating || bgDesktop==0){ return; } //prevent multiple calls to this at the same time
bgupdating = true;
if(DEBUG){ qDebug() << " - Update Desktop Background for screen:" << desktopnumber; }
//Get the list of background(s) to show
- QStringList bgL = settings->value(DPREFIX+"background/filelist", QStringList()).toStringList();
+ QStringList bgL = settings->value(DPREFIX+"background/filelist-workspace-"+QString::number( LSession::handle()->XCB->CurrentWorkspace()), QStringList()).toStringList();
+ if(bgL.isEmpty()){ bgL = settings->value(DPREFIX+"background/filelist", QStringList()).toStringList(); }
+
//qDebug() << " - List:" << bgL << CBG;
//Remove any invalid files
for(int i=0; i<bgL.length(); i++){
@@ -490,17 +505,15 @@ void LDesktop::UpdateBackground(){
//qDebug() << "BG List:" << bgL << oldBGL << CBG << bgtimer->isActive();
if(bgL==oldBGL && !CBG.isEmpty() && bgtimer->isActive()){
//No background change scheduled - just update the widget
- bgWindow->update();
+ bgDesktop->update();
bgupdating=false;
return;
}
oldBGL = bgL; //save this for later
//Determine which background to use next
- int index;
- if(CBG.isEmpty()){ index = ( qrand() % bgL.length() ); } //random first wallpaper
- else{
+ int index ( qrand() % bgL.length() );
+ if(index== bgL.indexOf(CBG)){ //if the current wallpaper was selected by the randomization again
//Go to the next in the list
- index = bgL.indexOf(CBG);
if(index < 0 || index >= bgL.length()-1){ index = 0; } //if invalid or last item in the list - go to first
else{ index++; } //go to next
}
@@ -511,7 +524,9 @@ void LDesktop::UpdateBackground(){
if( (bgFile.toLower()=="default")){ bgFile = LOS::LuminaShare()+"desktop-background.jpg"; }
//Now set this file as the current background
QString format = settings->value(DPREFIX+"background/format","stretch").toString();
- bgWindow->setBackground(bgFile, format);
+ //bgWindow->setBackground(bgFile, format);
+ QPixmap backPix = LDesktopBackground::setBackground(bgFile, format, LSession::handle()->screenGeom(desktopnumber));
+ bgDesktop->setBackground(backPix);
//Now reset the timer for the next change (if appropriate)
if(bgtimer->isActive()){ bgtimer->stop(); }
if(bgL.length() > 1){
bgstack15