为什么window无边框总是在最前面

Why window without borders is always on top

我正在尝试在 xlib 中创建 window 无边框(弹出窗口?)。我正在使用此代码:

#include <stdio.h>
#include <X11/Xlib.h>

int main( int argc, char **argv )
{
    Display *display = NULL;
    Window window;
    XSetWindowAttributes attribs;

    display = XOpenDisplay( NULL );
    if( !display )
    {
        printf( "Cannot to open display." );
        return 1;
    }

    attribs.override_redirect = 1;

    window = XCreateWindow( display, RootWindow(display, 0), 20, 20, 400, 300, 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attribs );
    XSetWindowBackground( display, window, 0x00F0FF );
    XClearWindow( display, window );

    XMapWindow( display, window );
    XFlush( display );

    getchar( );
    return 0;
}

它创造了 window 无边界,但是这个 window 总是在最上面。 问题是:为什么以及如何在 xlib 中将其显示为正常 window.

这就是覆盖重定向 windows 的行为方式。它们是为实现弹出式菜单和类似的 windows 而设计的,它们是暂时的并且保持在其他 windows.

之上

如果这不是您想要的,请不要使用覆盖重定向标志。相反,请使用 WM 提示。有关用法示例,请参阅 here for the full list of hints. You want to tell your WM which window type you have (_NET_WM_WINDOW_TYPE_TOOLBAR etc), not how it's decorated. See here

如果这仍然不是您想要的,请使用(有点过时的)Motif WM 提示。例如参见 [​​=12=].