【问题标题】:Why window without borders is always on top为什么没有边框的窗口总是在最上面
【发布时间】:2015-03-08 07:28:35
【问题描述】:

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

#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;
}

它创建一个没有边框的窗口,但是这个窗口总是在顶部。 问题是:为什么以及如何在 xlib 中将其显示为普通窗口。

【问题讨论】:

    标签: c window x11 xlib


    【解决方案1】:

    这就是覆盖重定向窗口的行为方式。它们旨在实现弹出菜单和类似的临时窗口,并位于其他窗口之上。

    如果这不是您想要的,请不要使用覆盖重定向标志。相反,使用 WM 提示。有关提示的完整列表,请参阅 here。您想告诉您的 WM 您拥有哪种窗口类型(_NET_WM_WINDOW_TYPE_TOOLBAR 等),而不是它的装饰方式。使用示例见here

    如果这仍然不是您想要的,请使用(有些过时的)Motif WM 提示。参见例如here

    【讨论】:

    • 是的,就是这样。感谢您的帮助:)
    猜你喜欢
    • 2017-04-27
    • 1970-01-01
    • 2016-08-17
    • 2016-08-14
    • 1970-01-01
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多