wsk3q

导航

用xcb在linux创建一个无标题窗口

//从我的新浪博客搬过来

最近,在ubuntu系统开发一个小软件,需要创建一个无标题的窗口。我使用的是xcb库(它对Xlib进行了封装),可惜一直没有找到方便的接口。于是搜索了一番之后,写成了这个函数:

 
void xcb_hide_title_bar(xcb_connection_t *c, xcb_window_t window)
{
    struct {
        unsigned long flags;
        unsigned long functions;
        unsigned long decorations;
        signed   long input_mode;
        unsigned long status;
    } motifWmHints;
    memset(&motifWmHints, 0, sizeof(motifWmHints));
    motifWmHints.flags = 2;    // MWM_HINTS_DECORATIONS;
    motifWmHints.decorations = 0;
    
    xcb_intern_atom_cookie_t cookie = xcb_intern_atom( c, 0, strlen( "_MOTIF_WM_HINTS"), "_MOTIF_WM_HINTS");
    xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply( c, cookie, NULL);
    
    xcb_change_property( c,
        XCB_PROP_MODE_REPLACE,
        window,
        (*reply).atom,
        (*reply).atom,
        32,
        sizeof(motifWmHints)/sizeof(long),
        &motifWmHints);
}
 

posted on 2022-12-07 21:44  wsk3q  阅读(448)  评论(0编辑  收藏  举报