diff options
author | wi <william.os4y@gmail.com> | 2015-04-12 22:21:19 +0200 |
---|---|---|
committer | wi <william.os4y@gmail.com> | 2015-04-12 22:21:19 +0200 |
commit | b26a12931cc2488359cc2bd26e508a01efded9d5 (patch) | |
tree | b27468f3aa3d79b878a7881934bbbc50ca158474 /libLumina/LuminaX11.cpp | |
parent | refactring of lumina-fileinfo: (diff) | |
parent | Fix location of ogg / vorbis gstreamer plugins (diff) | |
download | lumina-b26a12931cc2488359cc2bd26e508a01efded9d5.tar.gz lumina-b26a12931cc2488359cc2bd26e508a01efded9d5.tar.bz2 lumina-b26a12931cc2488359cc2bd26e508a01efded9d5.zip |
Merge remote-tracking branch 'upstream/master' into deskEditor
Diffstat (limited to 'libLumina/LuminaX11.cpp')
-rw-r--r-- | libLumina/LuminaX11.cpp | 83 |
1 files changed, 63 insertions, 20 deletions
diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp index 43d4e577..51df70d5 100644 --- a/libLumina/LuminaX11.cpp +++ b/libLumina/LuminaX11.cpp @@ -26,6 +26,7 @@ #include <xcb/xcb_ewmh.h> #include <xcb/xcb_icccm.h> #include <xcb/xcb_image.h> +#include <xcb/composite.h> //===== WindowList() ======== @@ -1133,26 +1134,6 @@ QIcon LXCB::WindowIcon(WId win){ return icon; } -// === WindowImage() === -QPixmap LXCB::WindowImage(WId win){ - QPixmap pix; - - //First get the size of the window - 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 @@ -1351,6 +1332,68 @@ void LXCB::MoveResizeWindow(WId win, QRect geom){ } +// === EmbedWindow() === +bool LXCB::EmbedWindow(WId win, WId container){ + if(win==0 || container==0){ return false; } + //qDebug() << "Embed Window:" << win << container; + + //Initialize any atoms that will be needed + xcb_intern_atom_cookie_t ecookie = xcb_intern_atom_unchecked(QX11Info::connection(), 0, 7, "_XEMBED"); + + xcb_intern_atom_reply_t *ereply = xcb_intern_atom_reply(QX11Info::connection(), ecookie, NULL); + if(ereply==0){ return false; } //unable to initialize the atom + xcb_atom_t emb = ereply->atom; + free(ereply); //done with this structure + + //Reparent the window into the container + xcb_reparent_window(QX11Info::connection(), win, container, 0, 0); + xcb_map_window(QX11Info::connection(), win); + + //Now send the embed event to the app + //qDebug() << " - send _XEMBED event"; + xcb_client_message_event_t event; + event.response_type = XCB_CLIENT_MESSAGE; + event.format = 32; + event.window = win; + event.type = emb; //_XEMBED + event.data.data32[0] = CurrentTime; + event.data.data32[1] = 0; //XEMBED_EMBEDDED_NOTIFY + event.data.data32[2] = 0; + event.data.data32[3] = container; //WID of the container + event.data.data32[4] = 0; + + xcb_send_event(QX11Info::connection(), 0, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *) &event); + + //Now setup any redirects and return + //qDebug() << " - select Input"; + //XSelectInput(disp, win, StructureNotifyMask); //Notify of structure changes + uint32_t val[] = {XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY}; + xcb_change_window_attributes(QX11Info::connection(), win, XCB_CW_EVENT_MASK, val); + //qDebug() << " - Composite Redirect"; + xcb_composite_redirect_window(QX11Info::connection(), win, XCB_COMPOSITE_REDIRECT_MANUAL); + + //Now map the window (will be a transparent child of the container) + xcb_map_window(QX11Info::connection(), win); + + //qDebug() << " - Done"; + return true; +} + +// === Unembed Window() === +bool LXCB::UnembedWindow(WId win){ + //Display *disp = QX11Info::display(); + //Remove redirects + //XSelectInput(disp, win, NoEventMask); + uint32_t val[] = {XCB_EVENT_MASK_NO_EVENT}; + xcb_change_window_attributes(QX11Info::connection(), win, XCB_CW_EVENT_MASK, val); + //Make sure it is invisible + xcb_unmap_window(QX11Info::connection(), win); + //Reparent the window back to the root window + xcb_reparent_window(QX11Info::connection(), win, QX11Info::appRootWindow(), 0, 0); + return true; +} + + // === SetScreenWorkArea() === /*void LXCB::SetScreenWorkArea(unsigned int screen, QRect rect){ //This is only useful because Fluxbox does not set the _NET_WORKAREA root atom |