diff options
author | Ken Moore <ken@pcbsd.org> | 2015-03-11 22:38:31 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-03-11 22:38:31 -0400 |
commit | 5ecabc4daef6cd3ee739387ecf091f345d65f4f2 (patch) | |
tree | d562297a267515915859cfeccbc6a39eb9c17bb7 /libLumina/LuminaX11.cpp | |
parent | Add a new XCB-based function for fetching the _NET_WM_ICON information as a Q... (diff) | |
download | lumina-5ecabc4daef6cd3ee739387ecf091f345d65f4f2.tar.gz lumina-5ecabc4daef6cd3ee739387ecf091f345d65f4f2.tar.bz2 lumina-5ecabc4daef6cd3ee739387ecf091f345d65f4f2.zip |
Convert the windowImage routine to XCB from XLib, and set the desktop (system tray) to use the new routine.
Also setup the desktop to use the new XCB routine for window icons as well.
Both are tested on 10.x and appear to work perfectly.
Diffstat (limited to 'libLumina/LuminaX11.cpp')
-rw-r--r-- | libLumina/LuminaX11.cpp | 39 |
1 files changed, 37 insertions, 2 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 |