#include #include #include #include #include int main(int argc, char *argv[]) { int screen; xcb_connection_t *c = xcb_connect(NULL, &screen); if (!c || xcb_connection_has_error(c)) { fprintf(stderr, "Cannot open default display \"%s\"\n", getenv("DISPLAY")); return EXIT_FAILURE; } // Find root window const xcb_setup_t *setup = xcb_get_setup(c); if (screen >= setup->roots_len) screen = 0; xcb_screen_iterator_t si = xcb_setup_roots_iterator(setup); for (int i=0; i < screen; i++) xcb_screen_next(&si); xcb_window_t root = si.data->root; // Create window and gc xcb_window_t window = xcb_generate_id(c); uint32_t list[] = { si.data->black_pixel, XCB_EVENT_MASK_EXPOSURE }; xcb_create_window(c, XCB_COPY_FROM_PARENT, window, root, 0, 0, 100, 100, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, list); xcb_map_window(c, window); xcb_gc_t gc = xcb_generate_id(c); uint32_t gc_list[] = { si.data->white_pixel, 2, XCB_LINE_STYLE_DOUBLE_DASH, XCB_JOIN_STYLE_BEVEL }; xcb_create_gc(c, gc, root, XCB_GC_FOREGROUND|XCB_GC_LINE_WIDTH|XCB_GC_LINE_STYLE|XCB_GC_JOIN_STYLE, gc_list); uint8_t dashes[] = { 10, 4, 4, 4 }; xcb_set_dashes(c, gc, 0, sizeof(dashes)/sizeof(*dashes), dashes); // Wait for window to be mapped xcb_flush(c); for (xcb_generic_event_t *ev = xcb_wait_for_event(c); ev; ev = xcb_wait_for_event(c)) { int type = ev->response_type; free(ev); if (type == XCB_EXPOSE) break; } xcb_clear_area(c, 0, window, 0, 0, 0, 0); // Draw problematic line xcb_point_t line[] = { { -851, -1200 }, { -757, -875 }, { -738, -812 }, { -675, -596 }, }; xcb_poly_line(c, XCB_COORD_MODE_ORIGIN, window, gc, sizeof(line)/sizeof(*line), line); xcb_flush(c); sleep(1); return EXIT_SUCCESS; }