2015-02-06 22 views
0

我正在嘗試做與this question中相同的事情。如何用XCB去除窗飾?

到目前爲止,我從official documentation瞭解xcb_change_property功能。

但仍然下面的代碼不會給出任何結果。

xcb_connection_t *c = xcb_connect (NULL, NULL); 

/* get the first screen */ 
xcb_screen_t *screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data; 

xcb_window_t win = xcb_generate_id (c); 

xcb_create_window (c,        /* Connection   */ 
        XCB_COPY_FROM_PARENT,   /* depth (same as root)*/ 
        win,       /* window Id   */ 
        screen->root,     /* parent window  */ 
        0, 0,       /* x, y    */ 
        system::getCore()->screen.width(), /* width */ 
        system::getCore()->screen.height(), /* height  */ 
        0,       /* border_width  */ 
        XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class    */ 
        screen->root_visual,   /* visual    */ 
        0, 
        NULL);      /* masks*/ 


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, 
        win, 
        (*reply).atom, 
        XCB_ATOM_INTEGER, 
        32, 
        0, 
        0); 

xcb_map_window (c, win); 
xcb_flush (c); 

我在做什麼錯?

+0

請勿使用_MOTIF_MW_HINTS,而是閱讀[EWMH](http://standards.freedesktop.org/wm-spec/wm-spec-latest.html)。順便說一句,如果用C++編碼,你最好使用一些C++工具包,如[Qt](http://qt-project.org/)或[Fox](http://fox-toolkit.org/)或[fltk] (http://www.fltk.org)或[Gtkmm](http://gtkmm.org/),因爲生命太短而無法在Xcb中編寫代碼 – 2015-02-06 13:38:20

+0

是的,我正在使用Qt,但現在正在使用該函數, Qt沒有提供。所以我有這樣的低級編程的必要性。 – Sb0y 2015-02-06 13:46:39

+0

然後使用一些低級別的Qt繪畫。並問一個Qt特定的論壇。我相信Qt已經有避免裝飾的功能...(因爲一些Qt窗口沒有) – 2015-02-06 13:48:15

回答

0

的關鍵是使用(*回覆).atom,兩次,而不是XCB_ATOM_INTEGER:

代碼爲我的作品:

xcb_intern_atom_cookie_t cookie3 = xcb_intern_atom(connection, 0, strlen ("_MOTIF_WM_HINTS"), "_MOTIF_WM_HINTS"); 
xcb_intern_atom_reply_t *reply3 = xcb_intern_atom_reply (connection, cookie3, NULL); 

// motif hints 
typedef struct MotifHints 
{ 
    uint32_t flags; 
    uint32_t functions; 
    uint32_t decorations; 
    int32_t input_mode; 
    uint32_t status; 
}; 

MotifHints hints; 

hints.flags = 2; 
hints.functions = 0; 
hints.decorations = 0; 
hints.input_mode = 0; 
hints.status = 0; 

xcb_change_property (connection, 
    XCB_PROP_MODE_REPLACE, 
    window, 
    reply3->atom, 
    reply3->atom, // THIS is essential 
    32, // format of property 
    5, // length of data (5x32 bit) , followed by pointer to data 
    &hints); // is this is a motif hints struct 

free(reply3); 

一看SFML源也有幫助,文件WindowImplX11.cpp