diff options
Diffstat (limited to 'lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp')
-rw-r--r-- | lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp index 37970051..64c7c77d 100644 --- a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp +++ b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp @@ -13,7 +13,7 @@ static Damage dmgID = 0; TrayIcon::TrayIcon(QWidget *parent) : QWidget(parent){ - AID = 0; //nothing attached yet + AID = 0; //nothing yet IID = 0; } @@ -31,9 +31,21 @@ void TrayIcon::attachApp(WId id){ if(id==0){ return; } //nothing to attach else if(AID!=0){ qWarning() << "Tray Icon is already attached to a window!"; return; } AID = id; - //qDebug() << "Container:" << this->winId(); - //qDebug() << " - Tray:" << AID; - QTimer::singleShot(0,this,SLOT(slotAttach()) ); + IID = this->winId(); //embed directly into this widget + //IID = LX11::CreateWindow( this->winId(), this->rect() ); //Create an intermediate window to be the parent + if( LX11::EmbedWindow(AID, IID) ){ + LX11::RestoreWindow(AID); //make it visible + //XSelectInput(QX11Info::display(), AID, StructureNotifyMask); + dmgID = XDamageCreate( QX11Info::display(), AID, XDamageReportRawRectangles ); + updateIcon(); + qDebug() << "New System Tray App:" << AID; + QTimer::singleShot(500, this, SLOT(updateIcon()) ); + }else{ + qWarning() << "Could not Embed Tray Application:" << AID; + //LX11::DestroyWindow(IID); + IID = 0; + AID = 0; + } } void TrayIcon::setSizeSquare(int side){ @@ -58,13 +70,12 @@ void TrayIcon::detachApp(){ qDebug() << " - finished app:" << tmp; //if(IID!=this->winId()){ LX11::DestroyWindow(IID); } IID = 0; - emit AppClosed(); } // ============== // PRIVATE SLOTS // ============== -void TrayIcon::slotAttach(){ +/*void TrayIcon::slotAttach(){ IID = this->winId(); //embed directly into this widget //IID = LX11::CreateWindow( this->winId(), this->rect() ); //Create an intermediate window to be the parent if( LX11::EmbedWindow(AID, IID) ){ @@ -73,16 +84,14 @@ void TrayIcon::slotAttach(){ dmgID = XDamageCreate( QX11Info::display(), AID, XDamageReportRawRectangles ); updateIcon(); qDebug() << "New System Tray App:" << AID; - emit AppAttached(); QTimer::singleShot(500, this, SLOT(updateIcon()) ); }else{ qWarning() << "Could not Embed Tray Application:" << AID; //LX11::DestroyWindow(IID); IID = 0; AID = 0; - emit AppClosed(); } -} +}*/ void TrayIcon::updateIcon(){ if(AID==0){ return; } @@ -102,16 +111,18 @@ void TrayIcon::paintEvent(QPaintEvent *event){ //Now paint the tray app on top of the background //qDebug() << " - Draw tray:" << AID << IID << this->winId(); //qDebug() << " - - " << event->rect().x() << event->rect().y() << event->rect().width() << event->rect().height(); - //qDebug() << " - Get image"; + //qDebug() << " - Get image:" << AID; QPixmap pix = LX11::WindowImage(AID, false); if(pix.isNull()){ //Try to grab the window directly with Qt - //qDebug() << " - Grab window directly"; + //qDebug() << " - - Grab window directly"; pix = QPixmap::grabWindow(AID); } //qDebug() << " - Pix size:" << pix.size().width() << pix.size().height(); //qDebug() << " - Geom:" << this->geometry().x() << this->geometry().y() << this->geometry().width() << this->geometry().height(); - painter.drawPixmap(0,0,this->width(), this->height(), pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) ); + if(!pix.isNull()){ + painter.drawPixmap(0,0,this->width(), this->height(), pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) ); + } //qDebug() << " - Done"; } } |