[Xcb] xcb_create_colormap, how to use?

Thomas Fischer tjfischer98 at gmail.com
Tue Jun 5 00:07:01 UTC 2018


I've been trying to compile the code from
https://xcb.freedesktop.org/opengl/
tl;dr: The code used Xlib to interact with glx, but uses xcb to handle X
events.

It seems to not run because of something happening in xcb_create_colormap,

I changed the code to use create_colormap_checked, and printed out the
error structure, this was the response, if it's useful:
=============ERROR=============
Could not create the colormap
        error->response_type: 0
        error->error_code: 8
        error->sequence: 31
        error->resource_id: 0
        error->minor_code: 0
        error->major_code: 78
        error->full_sequence: 31
===============================

Curious if using xlib was messing something up, I made a version using only
xcb, which works, meaning it creates a window:

xcb_window_t window = xcb_generate_id(connection);
window = xcb_generate_id(connection);
xcb_colormap_t colormap = xcb_generate_id(connection);

//Try to create a colormap
xcb_void_cookie_t cookie_colormap =
xcb_create_colormap_checked(connection,
                            XCB_COLORMAP_ALLOC_NONE,
                            colormap,
                            screen->root, screen->root_visual);

xcb_generic_error_t *error = xcb_request_check(connection,
                             cookie_colormap);
if (error)
{
    fprintf(stderr, "Could not create colormap!\n");
    xcb_disconnect(connection);
    return 1;
}

uint32_t mask;
uint32_t values[3];
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK | XCB_CW_COLORMAP;
values[0] = screen->white_pixel;
values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS;
values[2] = colormap;

xcb_create_window(connection,
                  XCB_COPY_FROM_PARENT,
                  window,
                  screen->root,
                  0, 0,
                  150, 150,
                  10,
                  XCB_WINDOW_CLASS_INPUT_OUTPUT,
                  screen->root_visual,
                  mask, values);

xcb_map_window(connection, window);
xcb_flush(connection);

I'm still confused why the opengl example doesn't work. I'd like to use xcb,
since I think it's a much nicer api than Xlib.

Could anyone kindly help me understand how to use this function?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20180604/61e0d2fb/attachment.html>


More information about the Xcb mailing list