我正在尝试做与 this question 中相同的事情.
到目前为止,我从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 );
我做错了什么?
关键是使用 (*reply).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
。
我是一名优秀的程序员,十分优秀!