我创建了两个窗口。一个是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);