如何在Mac上使用libxcb?

时间:2018-08-11 10:24:58

标签: c x11 xcb

我的笔记本电脑是Macbook Pro。 我在上面安装了libxcb,并尝试了x.org给出的一个简单示例:

#include <unistd.h>      /* pause() */
#include <xcb/xcb.h>

int main ()
{
    xcb_connection_t *c;
    xcb_screen_t     *screen;
    xcb_window_t      win;

    /* Open the connection to the X server */
    c = xcb_connect (NULL, NULL);

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

    /* Ask for our window's Id */
    win = xcb_generate_id(c);

    /* Create the window */
    xcb_create_window (c,                             /* Connection        */
                       XCB_COPY_FROM_PARENT,          /* depth (same as root)*/
                       win,                           /* window Id           */
                       screen->root,                  /* parent window       */
                       0, 0,                          /* x, y                */
                       150, 150,                      /* width, height       */
                       10,                            /* border_width        */
                       XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */
                       screen->root_visual,           /* visual              */
                       0, NULL);                      /* masks, not used yet */

    /* Map the window on the screen */
    xcb_map_window (c, win);

    /* Make sure commands are sent before we pause, so window is shown */
    xcb_flush (c);

    pause ();    /* hold client until Ctrl-C */

    return 0;
}

但是屏幕上没有显示窗口。有什么我忘了吗?

0 个答案:

没有答案