简体   繁体   中英

xcb_get_image_reply fails for window on another workspace/desktop

Ubuntu (xfce) provides virtual desktops aka workspaces. I would like to get a screenshot of an application which is placed on another virtual desktop. I successfully create xcb connection and I can find window of application by its title. Problem is that xcb_get_image_reply fails. I do something like this:

    auto cookie = xcb_get_image(m_XCBConnection, XCB_IMAGE_FORMAT_Z_PIXMAP, m_XCBWindow, x, y, width, height, ~0);
    xcb_generic_error_t * err = nullptr;
    auto image = xcb_get_image_reply(m_XCBConnection, cookie, &err);

    // xcb_connection_has_error( m_XCBConnection ) returns no error

    if ( err ) {
        // here I have err->error_code == 8
        free( err );
    }

If I understand correctly XCB errors encodings and general XCB errors explanation I get error described as:

Match An InputOnly window is used as a DRAWABLE. In a graphics request, the GCONTEXT argument does not have the same root and depth as the destination DRAWABLE argument. Some argument (or pair of arguments) has the correct type and range, but it fails to match in some other way required by the request.

But I have no idea what I should do with this.

Note: above solution works fine if both applications are on the same virtual desktop.

To quote from https://www.x.org/releases/X11R7.6/doc/xproto/x11protocol.html#requests:GetImage :

If the drawable is a window, the window must be viewable, [...] (or a Match error results).

So, the GetImage request fails, because the window that you want to screenshot is not visible. The X11 server does not (really) keep any content besides what is visible on screen. Everything else is not saved anywhere.

I would like to get a screenshot of an application which is placed on another virtual desktop.

Basically: X11 cannot do this, besides by switching to that other virtual desktop, waiting until (how?) the window in question redrew itself, and then grabbing a screenshot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM