在哪里可以找到 /usr/include/X11/extensions/Xcomposite.h
Where to find /usr/include/X11/extensions/Xcomposite.h
我需要将我的应用程序放在全屏视频上并捕获它以放入我的 python tkinter 应用程序中的“画中画”框架。我审查了常见的嫌疑人(ImageGrab、mss 等),但他们似乎都只是抓取显示器上可见的内容. None 似乎可以抓到一个隐形的 window.
我在 Stack Overflow 上找到了这个看起来很有前途的 C 程序:
- Get a screenshot of a window that is cover or not visible or minimized with Xcomposite extension for X11
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
int
main ()
{
Display *display = XOpenDisplay (NULL);
XID xid = 90177543; // xdotool search --name "World of Warcraft" | head -1
// Check if Composite extension is enabled
int event_base_return;
int error_base_return;
if (XCompositeQueryExtension (display, &event_base_return, &error_base_return))
printf ("COMPOSITE IS ENABLED!\n");
// Requests the X server to direct the hierarchy starting at window to off-screen storage
XCompositeRedirectWindow (display, xid, CompositeRedirectAutomatic);
// Preventing the backing pixmap from being freed when the window is hidden/destroyed
// If you want the window contents to still be available after the window has been destroyed,
// or after the window has been resized (but not yet redrawn), you can increment the backing
// pixmaps ref count to prevent it from being deallocated.
Pixmap pixmap = XCompositeNameWindowPixmap (display, xid);
// Get window attributes
XWindowAttributes attr;
Status s = XGetWindowAttributes (display, xid, &attr);
if (s == 0)
printf ("Fail to get window attributes!\n");
// Extract the data
XRenderPictFormat *format = XRenderFindVisualFormat (display, attr.visual);
int width = attr.width;
int height = attr.height;
int depth = attr.depth;
// What we need to do now is to create an XRender Picture for the window,
// which we'll need to draw it with the Render extension.
// A picture is a basically a handle to a server side struct with some
// additional information about a drawable (in this case a window),
// such as its format, which clipping region should be used when
// drawing it (if any), whether it should be tiled etc.
XRenderPictureAttributes pa;
pa.subwindow_mode = IncludeInferiors;
Picture picture = XRenderCreatePicture (display, xid, format, CPSubwindowMode, &pa);
// We now have all the information we need in order to be able to draw the window
// using the Xrender extension, and we've created and prepared a source picture
// for the window for this purpose.
// The Xrender function we'll use to draw the window is XRenderComposite().
//XRenderComposite (display, PictOpSrc, picture, None, ???destination???, 0,0, 0,0, 0,0, width, height);
XFreePixmap (display, pixmap);
XCompositeUnredirectWindow (display, xid, CompositeRedirectAutomatic);
return 0;
}
现在真正的问题...
我的问题是这部分:
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
除 <X11/extensions/Xcomposite.h>
外,所有这些文件都在 /usr/include/X11
下。我在哪里可以找到它?
Ubuntu 16.04 LTS (ESM),内核 4.14.216-0414216-通用。忙于学习新东西无暇休息,嗯,呃,升级到新版本吧。
FWIW 这是一个音乐播放器应用程序,它可以在单击按钮时关闭电视音量并恢复播放音乐。我只是增强它以移动到电视上,拍摄全屏视频并将其放入专辑插图通常旋转的 tkinter 框架中。计时器结束后,电视恢复播放,音乐播放器移回它来自的其他显示器。因此,我认为我找到的这个 C 程序是唯一的解决方案,但我欢迎罐装解决方案。
如果你 search packages.ubuntu.com,你会发现它位于 libxcomposite-dev
包中,因此你需要安装它。
为了找到这个,我去了 packages.ubuntu.com,然后在“搜索包的内容”下输入“Xcomposite.h”,为“分发”选择“xenial”,然后“包含的包”名称以关键字结尾的文件”,如下所示:
我需要将我的应用程序放在全屏视频上并捕获它以放入我的 python tkinter 应用程序中的“画中画”框架。我审查了常见的嫌疑人(ImageGrab、mss 等),但他们似乎都只是抓取显示器上可见的内容. None 似乎可以抓到一个隐形的 window.
我在 Stack Overflow 上找到了这个看起来很有前途的 C 程序:
- Get a screenshot of a window that is cover or not visible or minimized with Xcomposite extension for X11
#include <stdlib.h>
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
int
main ()
{
Display *display = XOpenDisplay (NULL);
XID xid = 90177543; // xdotool search --name "World of Warcraft" | head -1
// Check if Composite extension is enabled
int event_base_return;
int error_base_return;
if (XCompositeQueryExtension (display, &event_base_return, &error_base_return))
printf ("COMPOSITE IS ENABLED!\n");
// Requests the X server to direct the hierarchy starting at window to off-screen storage
XCompositeRedirectWindow (display, xid, CompositeRedirectAutomatic);
// Preventing the backing pixmap from being freed when the window is hidden/destroyed
// If you want the window contents to still be available after the window has been destroyed,
// or after the window has been resized (but not yet redrawn), you can increment the backing
// pixmaps ref count to prevent it from being deallocated.
Pixmap pixmap = XCompositeNameWindowPixmap (display, xid);
// Get window attributes
XWindowAttributes attr;
Status s = XGetWindowAttributes (display, xid, &attr);
if (s == 0)
printf ("Fail to get window attributes!\n");
// Extract the data
XRenderPictFormat *format = XRenderFindVisualFormat (display, attr.visual);
int width = attr.width;
int height = attr.height;
int depth = attr.depth;
// What we need to do now is to create an XRender Picture for the window,
// which we'll need to draw it with the Render extension.
// A picture is a basically a handle to a server side struct with some
// additional information about a drawable (in this case a window),
// such as its format, which clipping region should be used when
// drawing it (if any), whether it should be tiled etc.
XRenderPictureAttributes pa;
pa.subwindow_mode = IncludeInferiors;
Picture picture = XRenderCreatePicture (display, xid, format, CPSubwindowMode, &pa);
// We now have all the information we need in order to be able to draw the window
// using the Xrender extension, and we've created and prepared a source picture
// for the window for this purpose.
// The Xrender function we'll use to draw the window is XRenderComposite().
//XRenderComposite (display, PictOpSrc, picture, None, ???destination???, 0,0, 0,0, 0,0, width, height);
XFreePixmap (display, pixmap);
XCompositeUnredirectWindow (display, xid, CompositeRedirectAutomatic);
return 0;
}
现在真正的问题...
我的问题是这部分:
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/Xrender.h>
除 <X11/extensions/Xcomposite.h>
外,所有这些文件都在 /usr/include/X11
下。我在哪里可以找到它?
Ubuntu 16.04 LTS (ESM),内核 4.14.216-0414216-通用。忙于学习新东西无暇休息,嗯,呃,升级到新版本吧。
FWIW 这是一个音乐播放器应用程序,它可以在单击按钮时关闭电视音量并恢复播放音乐。我只是增强它以移动到电视上,拍摄全屏视频并将其放入专辑插图通常旋转的 tkinter 框架中。计时器结束后,电视恢复播放,音乐播放器移回它来自的其他显示器。因此,我认为我找到的这个 C 程序是唯一的解决方案,但我欢迎罐装解决方案。
如果你 search packages.ubuntu.com,你会发现它位于 libxcomposite-dev
包中,因此你需要安装它。
为了找到这个,我去了 packages.ubuntu.com,然后在“搜索包的内容”下输入“Xcomposite.h”,为“分发”选择“xenial”,然后“包含的包”名称以关键字结尾的文件”,如下所示: