简体   繁体   English

另一个工作区/桌面上的窗口的xcb_get_image_reply失败

[英]xcb_get_image_reply fails for window on another workspace/desktop

Ubuntu (xfce) provides virtual desktops aka workspaces. Ubuntu(xfce)提供虚拟桌面即工作空间。 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. 我成功创建了xcb连接,我可以通过它的标题找到应用程序窗口。 Problem is that xcb_get_image_reply fails. 问题是xcb_get_image_reply失败了。 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: 如果我理解XCB错误编码一般XCB错误解释我得到的错误描述为:

Match An InputOnly window is used as a DRAWABLE. 匹配 InputOnly窗口用作DRAWABLE。 In a graphics request, the GCONTEXT argument does not have the same root and depth as the destination DRAWABLE argument. 在图形请求中,GCONTEXT参数与目标DRAWABLE参数的根和深度不同。 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 : 引用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). 如果drawable是一个窗口,则窗口必须是可见的,[或]匹配错误结果。

So, the GetImage request fails, because the window that you want to screenshot is not visible. 因此,GetImage请求失败,因为您要截取的窗口不可见。 The X11 server does not (really) keep any content besides what is visible on screen. 除了屏幕上可见的内容之外,X11服务器不会(真正)保留任何内容。 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. 基本上:X11不能这样做,除了切换到其他虚拟桌面,等到(如何?)有问题的窗口重新开始,然后抓取截图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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