<div dir="ltr">I'm looking for help with selection change event in xcb-xfixes.<br>I want capture selection change event and I write a simple program with xcb-xfixes. But it does not work.<br>Please help, thanks.<br><br>
code: <a href="https://gist.github.com/xiangxw/8132154" target="_blank">https://gist.github.com/xiangxw/8132154</a><br><br>#include <stdio.h><br>#include <xcb/xcb.h><br>#include <xcb/xfixes.h><br><br>int main(void)<br>
{<br>    xcb_connection_t    *c;<br>    xcb_screen_t        *screen;<br>    xcb_window_t         win;<br>    xcb_generic_event_t *e;<br>    uint32_t             mask = 0;<br>    uint32_t             values[2];<br><br>    /* Create the window */<br>
    c = xcb_connect (NULL, NULL);<br>    screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;<br>    win = xcb_generate_id (c);<br>    mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;<br>    values[0] = screen->white_pixel;<br>
    values[1] = XCB_EVENT_MASK_PROPERTY_CHANGE;<br>    xcb_create_window (c,                             /* Connection          */<br>                       XCB_COPY_FROM_PARENT,          /* depth               */<br>                       win,                           /* window Id           */<br>
                       screen->root,                  /* parent window       */<br>                       0, 0,                          /* x, y                */<br>                       150, 150,                      /* width, height       */<br>
                       10,                            /* border_width        */<br>                       XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */<br>                       screen->root_visual,           /* visual              */<br>
                       mask, values);                 /* masks */<br>    xcb_map_window (c, win);<br>    xcb_flush (c);<br><br>    // init xfixes<br>    xcb_generic_error_t *error = 0;<br>    const xcb_query_extension_reply_t *reply = xcb_get_extension_data(c, &xcb_xfixes_id);<br>
    if (!reply || !reply->present) {<br>        return -1;<br>    }<br>    xcb_xfixes_query_version_cookie_t xfixes_query_cookie = xcb_xfixes_query_version(c,<br>                                                                                     XCB_XFIXES_MAJOR_VERSION,<br>
                                                                                     XCB_XFIXES_MINOR_VERSION);<br>    xcb_xfixes_query_version_reply_t *xfixes_query = xcb_xfixes_query_version_reply (c,<br>                                                                                     xfixes_query_cookie, &error);<br>
    if (!xfixes_query || error || xfixes_query->major_version < 2) {<br>        free(error);<br>    }<br>    free(xfixes_query);<br><br>    // delivers request<br>    mask =  XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE<br>
            | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY<br>            | XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER;<br>    xcb_xfixes_select_selection_input_checked(c, win, XCB_ATOM_PRIMARY, mask);<br>
    xcb_xfixes_select_selection_input_checked(c, win, XCB_ATOM_SECONDARY, mask);<br><br>    // recevie events<br>    uint response_type;<br>    while (e = xcb_wait_for_event(c)) {<br>        response_type = e->response_type & ~0x80;<br>
        if (response_type == reply->first_event + XCB_XFIXES_SELECTION_NOTIFY) {<br>            printf("notify\n");<br>        } else {<br>            printf("code:%d\n", response_type);<br>        }<br>
    }<br><br>    return 0;<br>}<br><br><br></div>