C++ 子窗口未显示在x11中

C++ 子窗口未显示在x11中,c++,linux,window,x11,C++,Linux,Window,X11,我已经创建了两个窗口。一个是32位,另一个是24位。32位窗口渲染opengl并创建带有alpha组件的图形。24位窗口渲染视频。这两个窗口都是32位主窗口的子窗口。据我所知,当我调用XRestackWindows时,它会显示堆栈窗口,使32位窗口位于顶部,同时也会显示底部的24位窗口。事实并非如此。当我这样做时,它只显示32位窗口。我知道24位窗口在那里,因为如果我切换顺序,那么我只能看到24位窗口。为什么会这样 /* Open the standard display (the primar

我已经创建了两个窗口。一个是32位,另一个是24位。32位窗口渲染opengl并创建带有alpha组件的图形。24位窗口渲染视频。这两个窗口都是32位主窗口的子窗口。据我所知,当我调用
XRestackWindows
时,它会显示堆栈窗口,使32位窗口位于顶部,同时也会显示底部的24位窗口。事实并非如此。当我这样做时,它只显示32位窗口。我知道24位窗口在那里,因为如果我切换顺序,那么我只能看到24位窗口。为什么会这样

/* Open the standard display (the primary screen) */
x_display = XOpenDisplay ( NULL );

visual_template.screen = DefaultScreen(x_display);
visual_list = XGetVisualInfo(x_display, VisualScreenMask, &visual_template, &nxvisuals);

XMatchVisualInfo(x_display, XDefaultScreen(x_display), 32, TrueColor, &vinfo))

parent = XDefaultRootWindow(x_display);
XSync(x_display, True);
visual = vinfo.visual;
depth = vinfo.depth;

XSetWindowAttributes  swa;
swa.event_mask = ExposureMask | PointerMotionMask | KeyPressMask;
swa.colormap = XCreateColormap(x_display, XDefaultRootWindow(x_display), visual, AllocNone);
swa.background_pixel = 0;
swa.border_pixel = 0;

main_window = XCreateWindow (
          x_display, parent,
          0, 0, m_plane_width, m_plane_height, 0,
          depth, InputOutput,
          visual, CWEventMask | CWBackPixel | CWColormap | CWBorderPixel,
          &swa );

/* Create a window */
opengl_window = XCreateWindow (
          x_display, main_window,
          0, 0, m_plane_width, m_plane_height, 0,
          depth, InputOutput,
          visual, CWEventMask | CWBackPixel | CWColormap | CWBorderPixel,
          &swa );


int cnxvisuals = 0;
XVisualInfo cvisual_template;
XVisualInfo *cvisual_list;
XVisualInfo cvinfo;
Visual *cvisual;
int cdepth;

cvisual_template.screen = DefaultScreen(x_display);
cvisual_list = XGetVisualInfo(x_display, VisualScreenMask, &cvisual_template, &cnxvisuals);

/* The gstreamer video sink must play on a screen with 24-bit color. Otherwise it will fail */
XMatchVisualInfo(x_display, XDefaultScreen(x_display), 24, TrueColor, &cvinfo)

XSync(x_display, True);
cvisual = cvinfo.visual;
cdepth = cvinfo.depth;

XSetWindowAttributes  cswa;
cswa.event_mask = PointerMotionMask | KeyPressMask;
cswa.colormap = XCreateColormap(x_display, XDefaultRootWindow(x_display), cvisual, AllocNone);
cswa.background_pixel = 0;
cswa.border_pixel = 0;

/* Create the window */
gstreamer_window = XCreateWindow (
          x_display, main_window,
          0, 0, m_plane_width, m_plane_height, 0,
          cdepth, InputOutput,
          cvisual, CWEventMask | CWBackPixel | CWColormap | CWBorderPixel,
          &cswa );

Window stack_position[2] = {opengl_window, gstreamer_window};
XRestackWindows(x_display, stack_position, 2);

您将两个窗口放在同一位置,大小相同。您将只能看到顶部的窗口,因为它们是不透明的。我的32位窗口是一个透明的窗口。当它运行时,我可以看到下面的其他窗口,但不能看到我将父窗口设置为的其他窗口。我有没有办法做到这一点?有两种可能:您的X服务器不允许您这样“混合”32位和24位视觉效果(您可以尝试在gstream_窗口中使用32位视觉效果,如果只是暂时的)。或者,它将允许半透明窗口显示其他客户端(X11程序)的内容,但不显示它们自己的内容。在这种情况下,罪魁祸首将是您的窗口管理器。“我的32位窗口是一个透明的窗口”。你确定吗?X11并不真正支持开箱即用的透明窗口。您需要XCOMPOSITE和一些手肘润滑脂才能工作,或者可能需要一种支持透明度的特殊视觉效果(不是到处都能找到)。在大多数情况下,看起来透明的只是程序员未能清除的背景。