static void _eventd_nd_xcb_stop(EventdNdBackendContext *self) { if ( self->custom_map ) xcb_free_colormap(self->xcb_connection, self->map); xcb_ewmh_connection_wipe(&self->ewmh); g_hash_table_unref(self->bubbles); g_water_xcb_source_free(self->source); self->bubbles = NULL; self->source = NULL; }
static gboolean _eventd_nd_xcb_get_colormap(EventdNdBackendContext *self) { xcb_depth_t *root_depth = NULL; xcb_visualtype_t *root_visual = NULL; xcb_depth_iterator_t depth_iter; for ( depth_iter = xcb_screen_allowed_depths_iterator(self->screen) ; depth_iter.rem ; xcb_depth_next(&depth_iter) ) { xcb_depth_t *d = depth_iter.data; xcb_visualtype_iterator_t visual_iter; for ( visual_iter = xcb_depth_visuals_iterator(d) ; visual_iter.rem ; xcb_visualtype_next(&visual_iter) ) { xcb_visualtype_t *v = visual_iter.data; if ( ( d->depth == 32 ) && ( v->_class >= XCB_VISUAL_CLASS_TRUE_COLOR ) ) { self->depth = d; self->visual = v; } if ( self->screen->root_visual == v->visual_id ) { root_depth = d; root_visual = v; } } } if ( self->visual != NULL ) { xcb_void_cookie_t c; xcb_generic_error_t *e; self->map = xcb_generate_id(self->xcb_connection); c = xcb_create_colormap_checked(self->xcb_connection, XCB_COLORMAP_ALLOC_NONE, self->map, self->screen->root, self->visual->visual_id); e = xcb_request_check(self->xcb_connection, c); if ( e == NULL ) return TRUE; xcb_free_colormap(self->xcb_connection, self->map); free(e); } self->depth = root_depth; self->visual = root_visual; self->map = self->screen->default_colormap; return FALSE; }
void xcbosd_destroy(xcbosd *osd) { assert (osd); xcb_free_gc(osd->connection, osd->gc); xcb_free_pixmap(osd->connection, osd->bitmap); xcb_free_colormap(osd->connection, osd->cmap); if(osd->mode==XCBOSD_SHAPED) { xcb_free_gc(osd->connection, osd->u.shaped.mask_gc); xcb_free_gc(osd->connection, osd->u.shaped.mask_gc_back); xcb_free_pixmap(osd->connection, osd->u.shaped.mask_bitmap); xcb_destroy_window(osd->connection, osd->u.shaped.window); } free (osd); }
void xcbosd_drawable_changed(xcbosd *osd, xcb_window_t window) { xcb_get_geometry_cookie_t get_geometry_cookie; xcb_get_geometry_reply_t *get_geometry_reply; assert (osd); lprintf("drawable changed\n"); /* Do I need to recreate the GC's?? XFreeGC (osd->display, osd->gc); XFreeGC (osd->display, osd->mask_gc); XFreeGC (osd->display, osd->mask_gc_back); */ xcb_free_pixmap(osd->connection, osd->bitmap); xcb_free_colormap(osd->connection, osd->cmap); /* we need to call XSync(), because otherwise, calling XDestroyWindow() on the parent window could destroy our OSD window twice !! */ /* XSync (osd->display, False); FIXME don't think that we need that --pfister */ osd->window = window; get_geometry_cookie = xcb_get_geometry(osd->connection, osd->window); get_geometry_reply = xcb_get_geometry_reply(osd->connection, get_geometry_cookie, NULL); osd->depth = get_geometry_reply->depth; osd->width = get_geometry_reply->width; osd->height = get_geometry_reply->height; free(get_geometry_reply); assert(osd->width); assert(osd->height); switch(osd->mode) { case XCBOSD_SHAPED: { xcb_free_pixmap(osd->connection, osd->u.shaped.mask_bitmap); xcb_destroy_window(osd->connection, osd->u.shaped.window); unsigned int window_params[] = { osd->screen->black_pixel, 1, XCB_EVENT_MASK_EXPOSURE }; osd->u.shaped.window = xcb_generate_id(osd->connection); xcb_create_window(osd->connection, XCB_COPY_FROM_PARENT, osd->u.shaped.window, osd->window, 0, 0, osd->width, osd->height, 0, XCB_COPY_FROM_PARENT, XCB_COPY_FROM_PARENT, XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK, window_params); osd->u.shaped.mapped = 0; osd->u.shaped.mask_bitmap = xcb_generate_id(osd->connection); xcb_create_pixmap(osd->connection, 1, osd->u.shaped.mask_bitmap, osd->u.shaped.window, osd->width, osd->height); osd->bitmap = xcb_generate_id(osd->connection); xcb_create_pixmap(osd->connection, osd->depth, osd->bitmap, osd->u.shaped.window, osd->width, osd->height); osd->cmap = xcb_generate_id(osd->connection); xcb_create_colormap(osd->connection, XCB_COLORMAP_ALLOC_NONE, osd->cmap, osd->u.shaped.window, osd->visual); break; } case XCBOSD_COLORKEY: osd->bitmap = xcb_generate_id(osd->connection); xcb_create_pixmap(osd->connection, osd->depth, osd->bitmap, osd->window, osd->width, osd->height); osd->cmap = xcb_generate_id(osd->connection); xcb_create_colormap(osd->connection, XCB_COLORMAP_ALLOC_NONE, osd->cmap, osd->window, osd->visual); break; } osd->clean = UNDEFINED; /* do not xcbosd_clear() here: osd->u.colorkey.sc has not being updated yet */ }