aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/panel-plugins/systemtray
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/panel-plugins/systemtray
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/panel-plugins/systemtray')
-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
4 files changed, 26 insertions, 39 deletions
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