aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2015-10-30 16:25:56 -0400
committerKen Moore <moorekou@gmail.com>2015-10-30 16:25:56 -0400
commit7846ab98e9df6e171255543591e0f12c49b9391d (patch)
tree8039817b94e7f24e7e5484bba8b3beb2cc066284 /lumina-desktop
parentMake sure that lumina-open always watches files that are *not* in the XDG aut... (diff)
downloadlumina-7846ab98e9df6e171255543591e0f12c49b9391d.tar.gz
lumina-7846ab98e9df6e171255543591e0f12c49b9391d.tar.bz2
lumina-7846ab98e9df6e171255543591e0f12c49b9391d.zip
Cleanup how auto-start apps are launched a bit (start them via a single lumina-open call now, instead of a bunch of individual ones). Also fix up the tray app detection/failover methods a bit to catch/discard tray icons which were registered/destroyed almost simultaneously (or no destroy event was ever caught for the icon). This prevents the situation where a "blank" tray icon may be trying to repaint itself repeatedly (eating up CPU cycles).
NOTE: It seems like these "blank" tray apps are all GTK based, so it might be something in that toolkit which needs fixing to prevent registering a tray window which will never be used (or is instantly destroyed).
Diffstat (limited to 'lumina-desktop')
-rw-r--r--lumina-desktop/BootSplash.cpp8
-rw-r--r--lumina-desktop/LSession.cpp29
-rw-r--r--lumina-desktop/LSession.h3
-rw-r--r--lumina-desktop/lumina-desktop.pro2
-rw-r--r--lumina-desktop/panel-plugins/systemtray/LSysTray.cpp14
-rw-r--r--lumina-desktop/panel-plugins/systemtray/LSysTray.h17
-rw-r--r--lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp28
-rw-r--r--lumina-desktop/panel-plugins/systemtray/TrayIcon.h6
8 files changed, 51 insertions, 56 deletions
diff --git a/lumina-desktop/BootSplash.cpp b/lumina-desktop/BootSplash.cpp
index b535fff4..e75bca21 100644
--- a/lumina-desktop/BootSplash.cpp
+++ b/lumina-desktop/BootSplash.cpp
@@ -41,10 +41,14 @@ void BootSplash::showScreen(QString loading){ //update icon, text, and progress
}else if(loading=="final"){
txt = tr("Finalizing …"); per = 90;
icon = "pcbsd";
+ }else if(loading.startsWith("app::")){
+ txt = QString(tr("Starting App: %1")).arg(loading.section("::",1,50)); per = -1;
}
- ui->progressBar->setValue(per);
+ if(per>0){ ui->progressBar->setValue(per); }
+ else{ ui->progressBar->setRange(0,0); } //loading indicator
ui->label_text->setText(txt);
- ui->label_icon->setPixmap( LXDG::findIcon(icon, "Lumina-DE").pixmap(64,64) );
+ if(!icon.isEmpty()){ui->label_icon->setPixmap( LXDG::findIcon(icon, "Lumina-DE").pixmap(64,64) ); }
+ this->raise();
this->show();
this->update();
QApplication::processEvents();
diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp
index 61c01175..4934d42b 100644
--- a/lumina-desktop/LSession.cpp
+++ b/lumina-desktop/LSession.cpp
@@ -9,6 +9,7 @@
#include <QTime>
#include <QScreen>
+#include <QtConcurrent>
#include "LXcbEventFilter.h"
#include "BootSplash.h"
@@ -162,9 +163,11 @@ void LSession::setupSession(){
connect(this, SIGNAL(aboutToQuit()), this, SLOT(SessionEnding()) );
if(DEBUG){ qDebug() << " - Init Finished:" << timer->elapsed(); delete timer;}
//QTimer::singleShot(3000, this, SLOT(launchStartupApps()) ); //startup these processes in 3 seconds
- splash.close();
QApplication::processEvents();
- launchStartupApps();
+ //QtConcurrent::run(this, &LSession::launchStartupApps);
+ //launchStartupApps(&splash);
+ QTimer::singleShot(500, this, SLOT(launchStartupApps()) );
+ splash.close();
}
void LSession::CleanupSession(){
@@ -260,24 +263,20 @@ void LSession::launchStartupApps(){
LOS::setScreenBrightness( tmp );
qDebug() << " - - Screen Brightness:" << QString::number(tmp)+"%";
}
-
+ QProcess::startDetached("nice lumina-open -autostart-apps");
//Now get any XDG startup applications and launch them
- QList<XDGDesktop> xdgapps = LXDG::findAutoStartFiles();
+ /*QList<XDGDesktop> xdgapps = LXDG::findAutoStartFiles();
for(int i=0; i<xdgapps.length(); i++){
qDebug() << " - Auto-Starting File:" << xdgapps[i].filePath;
+ //splash->showScreen("app::"+xdgapps[i].name);
if(xdgapps[i].startupNotify){
- LSession::LaunchApplication("lumina-open \""+xdgapps[i].filePath+"\"");
+ LSession::LaunchApplication("nice lumina-open \""+xdgapps[i].filePath+"\"");
}else{
//Don't update the mouse cursor
- QProcess::startDetached("lumina-open \""+xdgapps[i].filePath+"\"");
- }
- //Put a tiny bit of space between app starts (don't overload the system)
- for(int j=0; j<5; j++){
- usleep(50000); //50ms = 50000 us --> 250ms total wait
- LSession::processEvents();
+ QProcess::startDetached("nice lumina-open \""+xdgapps[i].filePath+"\"");
}
-
- }
+ LSession::processEvents();
+ }*/
//Re-load the screen brightness and volume settings from the previous session
// Wait until after the XDG-autostart functions, since the audio system might be started that way
@@ -818,6 +817,10 @@ void LSession::unregisterVisualTray(WId visualTray){
QList<WId> LSession::currentTrayApps(WId visualTray){
if(visualTray==VisualTrayID){
+ //Check the validity of all the current tray apps (make sure nothing closed erratically)
+ for(int i=0; i<RunningTrayApps.length(); i++){
+ if(XCB->WindowClass(RunningTrayApps[i]).isEmpty()){ RunningTrayApps.removeAt(i); i--; }
+ }
return RunningTrayApps;
}else if( registerVisualTray(visualTray) ){
return RunningTrayApps;
diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h
index 247b7ecb..8147e411 100644
--- a/lumina-desktop/LSession.h
+++ b/lumina-desktop/LSession.h
@@ -28,6 +28,7 @@
#include "SystemWindow.h"
#include "LDesktop.h"
#include "WMProcess.h"
+//#include "BootSplash.h"
#include <LuminaX11.h>
@@ -130,7 +131,6 @@ private:
int VersionStringToNumber(QString version);
public slots:
- void launchStartupApps();
void StartLogout();
void StartShutdown();
void StartReboot();
@@ -138,6 +138,7 @@ public slots:
void reloadIconTheme();
private slots:
+ void launchStartupApps(); //used during initialization
void watcherChange(QString);
void screensChanged();
void screenResized(int);
diff --git a/lumina-desktop/lumina-desktop.pro b/lumina-desktop/lumina-desktop.pro
index 9f791fbc..8db2662e 100644
--- a/lumina-desktop/lumina-desktop.pro
+++ b/lumina-desktop/lumina-desktop.pro
@@ -1,6 +1,6 @@
QT += core gui network
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras multimedia quickwidgets
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras multimedia quickwidgets concurrent
TARGET = Lumina-DE
diff --git a/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp b/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp
index 3be31f43..a921d314 100644
--- a/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp
+++ b/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp
@@ -88,8 +88,9 @@ void LSysTray::checkAll(){
int index = wins.indexOf(trayIcons[i]->appID());
if(index < 0){
//Tray Icon no longer exists: remove it
- qDebug() << " - Visual System Tray: Remove Icon";
+ qDebug() << " - Visual System Tray: Remove Icon:" << trayIcons[i]->appID();
TrayIcon *cont = trayIcons.takeAt(i);
+ cont->cleanup();
LI->removeWidget(cont);
delete cont;
i--; //List size changed
@@ -108,9 +109,10 @@ void LSysTray::checkAll(){
}
//Now go through any remaining windows and add them
for(int i=0; i<wins.length() && TrayRunning; i++){
- qDebug() << " - Visual System Tray: Add Icon";
+ qDebug() << " - Visual System Tray: Add Icon:" << wins[i];
TrayIcon *cont = new TrayIcon(this);
- LSession::processEvents();
+ connect(cont, SIGNAL(BadIcon()), this, SLOT(checkAll()) );
+ //LSession::processEvents();
trayIcons << cont;
LI->addWidget(cont);
//qDebug() << " - Update tray layout";
@@ -121,12 +123,12 @@ void LSysTray::checkAll(){
cont->setSizeSquare(this->width()-2-2*frame->frameWidth()); //vertical tray
this->setMaximumSize(10000, trayIcons.length()*this->width());
}
- LSession::processEvents();
+ //LSession::processEvents();
//qDebug() << " - Attach tray app";
cont->attachApp(wins[i]);
if(cont->appID()==0){
//could not attach window - remove the widget
- //qDebug() << "Invalid Tray Container:";
+ qDebug() << " - Invalid Tray App: Could Not Embed:";
trayIcons.takeAt(trayIcons.length()-1); //Always at the end
LI->removeWidget(cont);
delete cont;
@@ -151,8 +153,6 @@ void LSysTray::UpdateTrayWindow(WId win){
if(trayIcons[i]->appID()==win){
//qDebug() << "System Tray: Update Window " << win;
trayIcons[i]->repaint(); //don't use update() because we need an instant repaint (not a cached version)
- //QTimer::singleShot(10, trayIcons[i], SLOT(repaint()) ); //re-paint in 10ms (give it a moment to settle)
- //QTimer::singleShot(1000, trayIcons[i], SLOT(update()) );
return; //finished now
}
}
diff --git a/lumina-desktop/panel-plugins/systemtray/LSysTray.h b/lumina-desktop/panel-plugins/systemtray/LSysTray.h
index e189b729..84cde5c9 100644
--- a/lumina-desktop/panel-plugins/systemtray/LSysTray.h
+++ b/lumina-desktop/panel-plugins/systemtray/LSysTray.h
@@ -38,22 +38,14 @@ private:
QList<TrayIcon*> trayIcons;
QFrame *frame;
QBoxLayout *LI; //layout items
- //WId TrayID;
QTimer *upTimer; //manual timer to force refresh of all items
private slots:
- //void checkXEvent(XEvent *event);
- //void closeAll();
void checkAll();
void UpdateTrayWindow(WId win);
- //void initialTrayIconDetect(); //initial scan for previously running tray apps
- //void addTrayIcon(WId win);
//void removeTrayIcon(WId win);
- /*void updateStatus();
- void trayAppClosed();*/
-
public slots:
void start();
void stop();
@@ -76,15 +68,6 @@ public slots:
}
}
-protected:
- /*void paintEvent(QPaintEvent *event){
- //Also repaint all the tray icons
- for(int i=0; i<trayIcons.length(); i++){
- trayIcons[i]->update();
- }
- //Now pass the event on to the normal routine
- LPPlugin::paintEvent(event);
- }*/
};
#endif
diff --git a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp
index 1b843e3e..9fdbce50 100644
--- a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp
+++ b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp
@@ -14,6 +14,7 @@ TrayIcon::TrayIcon(QWidget *parent) : QWidget(parent){
AID = 0; //nothing yet
IID = 0;
dmgID = 0;
+ badpaints = 0;
//this->setLayout(new QHBoxLayout);
//this->layout()->setContentsMargins(0,0,0,0);
}
@@ -21,6 +22,10 @@ TrayIcon::TrayIcon(QWidget *parent) : QWidget(parent){
TrayIcon::~TrayIcon(){
}
+void TrayIcon::cleanup(){
+ AID = IID = 0;
+}
+
WId TrayIcon::appID(){
return AID;
}
@@ -94,26 +99,21 @@ void TrayIcon::paintEvent(QPaintEvent *event){
//qDebug() << " - - " << event->rect().x() << event->rect().y() << event->rect().width() << event->rect().height();
//qDebug() << " - Get image:" << AID;
QPixmap pix = LSession::handle()->XCB->TrayImage(AID); //= WIN->icon().pixmap(this->size());
- //if(pix.isNull()){
- //qDebug() << "Null Image - use Qt grab Window";
- //Try to grab the window directly with Qt instead
- /*QList<QScreen*> scrnlist = QApplication::screens();
- for(int i=0; i<scrnlist.length(); i++){
- pix = scrnlist[i]->grabWindow(AID);
- break; //stop here
- }
- //}
- if(pix.isNull()){
- qDebug() << "Null Qt Pixmap - Use XCB grab image:";
- pix = LSession::handle()->XCB->TrayImage(AID);
- }*/
+
//qDebug() << " - Pix size:" << pix.size().width() << pix.size().height();
//qDebug() << " - Geom:" << this->geometry().x() << this->geometry().y() << this->geometry().width() << this->geometry().height();
if(!pix.isNull()){
if(this->size() != pix.size()){ QTimer::singleShot(10, this, SLOT(updateIcon())); }
painter.drawPixmap(0,0,this->width(), this->height(), pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) );
+ badpaints = 0; //good paint
}else{
- qWarning() << " - - No Tray Icon/Image found!" << "ID:" << AID;
+ badpaints++;
+ if(badpaints>5){
+ qWarning() << " - - No Tray Icon/Image found!" << "ID:" << AID;
+ AID = 0; //reset back to nothing
+ IID = 0;
+ emit BadIcon(); //removed/destroyed in some non-valid way?
+ }
}
//qDebug() << " - Done";
}
diff --git a/lumina-desktop/panel-plugins/systemtray/TrayIcon.h b/lumina-desktop/panel-plugins/systemtray/TrayIcon.h
index fef3b578..5d072cc1 100644
--- a/lumina-desktop/panel-plugins/systemtray/TrayIcon.h
+++ b/lumina-desktop/panel-plugins/systemtray/TrayIcon.h
@@ -30,6 +30,8 @@ public:
TrayIcon(QWidget* parent = 0);
~TrayIcon();
+ void cleanup(); //about to be removed after window was detroyed
+
WId appID(); //the ID for the attached application
void attachApp(WId id);
void setSizeSquare(int side);
@@ -40,12 +42,14 @@ public slots:
private:
WId IID, AID; //icon ID and app ID
- //QWindow *WIN;
+ int badpaints;
uint dmgID;
protected:
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
+signals:
+ void BadIcon();
};
#endif \ No newline at end of file
bgstack15