diff options
-rw-r--r-- | libLumina/LuminaX11.cpp | 39 | ||||
-rw-r--r-- | libLumina/LuminaX11.h | 1 | ||||
-rw-r--r-- | libLumina/libLumina.pro | 2 | ||||
-rw-r--r-- | lumina-desktop/LWinInfo.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp | 5 |
5 files changed, 44 insertions, 5 deletions
diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index f56b6448..fcfe0f39 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -25,6 +25,7 @@ #include <xcb/xproto.h> #include <xcb/xcb_ewmh.h> #include <xcb/xcb_icccm.h> +#include <xcb/xcb_image.h> //===== WindowList() ======== @@ -1088,11 +1089,11 @@ QIcon LXCB::WindowIcon(WId win){ bool done =false; while(!done){ //Now convert the current data into a Qt image - // - first 2 elements are width and height + // - first 2 elements are width and height (removed via XCB functions) // - data in rows from left to right and top to bottom QImage image(iter.width, iter.height, QImage::Format_ARGB32); //initial setup uint* dat = iter.data; - dat+=2; //remember the first 2 element offset + //dat+=2; //remember the first 2 element offset for(int i=0; i<image.byteCount()/4; ++i, ++dat){ ((uint*)image.bits())[i] = *dat; } @@ -1106,6 +1107,40 @@ QIcon LXCB::WindowIcon(WId win){ return icon; } +// === WindowImage() === +QPixmap LXCB::WindowImage(WId win, bool useleader){ + QPixmap pix; + //Display *disp = QX11Info::display(); + /*WId leader = LX11::leaderWindow(win); //check for an alternate window that contains the image + if(leader!=0 && useleader){ win = leader; } //use the leader window instead + //First get the size of the window image (embedded in the window attributes) + XWindowAttributes att; + if( 0 == XGetWindowAttributes(disp, win, &att) ){ return pix; } //invalid window attributes + //Now extract the image + XImage *xim = XGetImage(disp, win, 0,0, att.width, att.height, AllPlanes, ZPixmap); + if(xim!=0){ + //Convert the X image to a Qt Image + pix.convertFromImage( QImage( (const uchar*) xim->data, xim->width, xim->height, xim->bytes_per_line, QImage::Format_ARGB32_Premultiplied) ); + XDestroyImage(xim); //clean up + }*/ + //First get the size of the window + + //xcb_get_window_attributes_reply_t reply; + xcb_get_geometry_cookie_t cookie = xcb_get_geometry_unchecked(QX11Info::connection(), win); + xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(QX11Info::connection(), cookie, NULL); + if(reply == 0){ return pix; } //could not determine window geometry + //Now get the image + xcb_image_t *img = xcb_image_get(QX11Info::connection(), win, 0, 0, reply->width, reply->height, (uint32_t) AllPlanes, XCB_IMAGE_FORMAT_Z_PIXMAP); + if(img!=0){ + //Now convert the image into a QPixmap + pix.convertFromImage( QImage( (const uchar*) img->data, img->width, img->height, img->stride, QImage::Format_ARGB32_Premultiplied) ); + //Clean up the xcb_image structure + xcb_image_destroy(img); + } + //Return the pixmap + return pix; +} + // === SetAsSticky() === void LXCB::SetAsSticky(WId win){ //Need to send a client message event for the window so the WM picks it up diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h index 3cb15d89..c2e27dcd 100644 --- a/libLumina/LuminaX11.h +++ b/libLumina/LuminaX11.h @@ -139,6 +139,7 @@ public: QString WindowName(WId win); //_WM_NAME bool WindowIsMaximized(WId win); QIcon WindowIcon(WId win); //_NET_WM_ICON + QPixmap WindowImage(WId win, bool useleader=true); //Pull the image directly from the window //Window Modification void SetAsSticky(WId); //Stick to all workspaces diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro index 7606210b..e0963fc6 100644 --- a/libLumina/libLumina.pro +++ b/libLumina/libLumina.pro @@ -42,7 +42,7 @@ SOURCES += LuminaXDG.cpp \ INCLUDEPATH += $$PREFIX/include -LIBS += -lX11 -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm +LIBS += -lX11 -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image include.path=$$PREFIX/include/ include.files=LuminaXDG.h \ diff --git a/lumina-desktop/LWinInfo.cpp b/lumina-desktop/LWinInfo.cpp index d46bef92..4ea91c1f 100644 --- a/lumina-desktop/LWinInfo.cpp +++ b/lumina-desktop/LWinInfo.cpp @@ -24,7 +24,7 @@ QString LWinInfo::text(){ QIcon LWinInfo::icon(bool &noicon){ if(window==0){ noicon = true; return QIcon();} noicon = false; - QIcon ico = LX11::WindowIcon(window); + QIcon ico = LSession::handle()->XCB->WindowIcon(window); //Check for a null icon, and supply one if necessary if(ico.isNull()){ ico = LXDG::findIcon( this->Class().toLower(),""); } if(ico.isNull()){ico = LXDG::findIcon("preferences-system-windows",""); noicon=true;} diff --git a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp index 7e0a30f6..23453eed 100644 --- a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp +++ b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp @@ -12,6 +12,8 @@ //#include <xcb/damage.h> //static xcb_damage_damage_t dmgID; + +#include <LSession.h> static int dmgID = 0; TrayIcon::TrayIcon(QWidget *parent) : QWidget(parent){ @@ -115,7 +117,8 @@ void TrayIcon::paintEvent(QPaintEvent *event){ //qDebug() << " - Draw tray:" << AID << IID << this->winId(); //qDebug() << " - - " << event->rect().x() << event->rect().y() << event->rect().width() << event->rect().height(); //qDebug() << " - Get image:" << AID; - QPixmap pix = LX11::WindowImage(AID, false); + QPixmap pix = LSession::handle()->XCB->WindowImage(AID, false); + //LX11::WindowImage(AID, false); if(pix.isNull()){ //Try to grab the window directly with Qt qDebug() << " - - Grab window directly"; |