static void cleanup() { if (nil_.key_syms) { xcb_key_symbols_free(nil_.key_syms); } if (nil_.font.id) { xcb_close_font(nil_.con, nil_.font.id); } if (nil_.cursor[CURSOR_NORMAL]) { xcb_free_cursor(nil_.con, nil_.cursor[CURSOR_NORMAL]); } if (nil_.cursor[CURSOR_MOVE] && (nil_.cursor[CURSOR_MOVE] != nil_.cursor[CURSOR_NORMAL])) { xcb_free_cursor(nil_.con, nil_.cursor[CURSOR_MOVE]); } if (nil_.cursor[CURSOR_RESIZE] && (nil_.cursor[CURSOR_RESIZE] != nil_.cursor[CURSOR_NORMAL])) { xcb_free_cursor(nil_.con, nil_.cursor[CURSOR_RESIZE]); } if (bar_.win) { xcb_destroy_window(nil_.con, bar_.win); } xcb_ungrab_keyboard(nil_.con, XCB_TIME_CURRENT_TIME); xcb_destroy_subwindows(nil_.con, nil_.scr->root); xcb_flush(nil_.con); xcb_disconnect(nil_.con); if (nil_.ws) { free(nil_.ws); } }
xcb_gc_t get_font_gc(xcb_connection_t *dpy, xcb_window_t win, const char *font_name) { xcb_void_cookie_t ck; xcb_font_t font = xcb_generate_id(dpy); ck = xcb_open_font_checked(dpy, font, strlen(font_name), font_name); check_request(dpy, ck, "Can't open font"); xcb_gcontext_t gc = xcb_generate_id(dpy); uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT; uint32_t values[] = {0xffcccccc, 0xff111111, font}; xcb_create_gc(dpy, gc, win, mask, values); xcb_close_font(dpy, font); return gc; }
static int init_cursor() { xcb_font_t font; xcb_void_cookie_t cookie; xcb_generic_error_t *error; font = xcb_generate_id(nil_.con); xcb_open_font(nil_.con, font, strlen(CURSOR_FONT_), CURSOR_FONT_); nil_.cursor[CURSOR_NORMAL] = xcb_generate_id(nil_.con); cookie = xcb_create_glyph_cursor_checked(nil_.con, nil_.cursor[CURSOR_NORMAL], font, font, CURSOR_PTR_LEFT_, CURSOR_PTR_LEFT_ + 1, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF); error = xcb_request_check(nil_.con, cookie); if (error) { NIL_ERR("create cursor %d %d", CURSOR_PTR_LEFT_, error->error_code); xcb_close_font(nil_.con, font); return -1; } nil_.cursor[CURSOR_MOVE] = xcb_generate_id(nil_.con); cookie = xcb_create_glyph_cursor_checked(nil_.con, nil_.cursor[CURSOR_NORMAL], font, font, CURSOR_PTR_MOVE_, CURSOR_PTR_MOVE_ + 1, 0, 0, 0, 0, 0, 0); error = xcb_request_check(nil_.con, cookie); if (error) { NIL_ERR("create cursor %d %d", CURSOR_PTR_MOVE_, error->error_code); nil_.cursor[CURSOR_MOVE] = nil_.cursor[CURSOR_NORMAL]; } nil_.cursor[CURSOR_RESIZE] = xcb_generate_id(nil_.con); cookie = xcb_create_glyph_cursor_checked(nil_.con, nil_.cursor[CURSOR_NORMAL], font, font, CURSOR_PTR_RESIZE_, CURSOR_PTR_RESIZE_ + 1, 0, 0, 0, 0, 0, 0); error = xcb_request_check(nil_.con, cookie); if (error) { NIL_ERR("create cursor %d %d", CURSOR_PTR_RESIZE_, error->error_code); nil_.cursor[CURSOR_RESIZE] = nil_.cursor[CURSOR_NORMAL]; } xcb_close_font(nil_.con, font); return 0; }
static void _e_alert_shutdown(void) { if (!xcb_connection_has_error(conn)) { xcb_close_font(conn, font); xcb_destroy_window(conn, btn1); xcb_destroy_window(conn, btn2); xcb_destroy_window(conn, win); if (comp_win) xcb_destroy_window(conn, comp_win); xcb_free_gc(conn, gc); xcb_disconnect(conn); } }
QXcbCursor::~QXcbCursor() { xcb_connection_t *conn = xcb_connection(); if (m_gtkCursorThemeInitialized) { m_screen->xSettings()->removeCallbackForHandle(this); } if (!--cursorCount) xcb_close_font(conn, cursorFont); foreach (xcb_cursor_t cursor, m_cursorHash) xcb_free_cursor(conn, cursor); }
QXcbCursor::~QXcbCursor() { xcb_connection_t *conn = xcb_connection(); if (m_gtkCursorThemeInitialized) { m_screen->xSettings()->removeCallbackForHandle(this); } if (!--cursorCount) xcb_close_font(conn, cursorFont); #ifndef QT_NO_CURSOR for (xcb_cursor_t cursor : qAsConst(m_cursorHash)) xcb_free_cursor(conn, cursor); #endif }