Use a single gc for all graphics operation
The GC isn't really used, we just need one because X11 wants one. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
3b2f6329a9
commit
16286f0b75
|
@ -361,6 +361,12 @@ main(int argc, char **argv)
|
|||
|
||||
globalconf.screen = xcb_aux_get_screen(globalconf.connection, globalconf.default_screen);
|
||||
|
||||
/* The default GC is just a newly created associated to the root window */
|
||||
globalconf.gc = xcb_generate_id(globalconf.connection);
|
||||
xcb_create_gc(globalconf.connection, globalconf.gc, globalconf.screen->root, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND,
|
||||
(const uint32_t[]) { globalconf.screen->black_pixel, globalconf.screen->white_pixel });
|
||||
|
||||
|
||||
/* Prefetch all the extensions we might need */
|
||||
xcb_prefetch_extension_data(globalconf.connection, &xcb_big_requests_id);
|
||||
xcb_prefetch_extension_data(globalconf.connection, &xcb_test_id);
|
||||
|
|
|
@ -111,6 +111,8 @@ typedef struct
|
|||
xcb_visualtype_t *visual;
|
||||
/** The screen's information */
|
||||
xcb_screen_t *screen;
|
||||
/** A graphic context. */
|
||||
xcb_gcontext_t gc;
|
||||
} awesome_t;
|
||||
|
||||
extern awesome_t globalconf;
|
||||
|
|
|
@ -190,7 +190,6 @@ xcb_pixmap_t
|
|||
image_to_1bit_pixmap(image_t *image, xcb_drawable_t d)
|
||||
{
|
||||
xcb_pixmap_t pixmap;
|
||||
xcb_gcontext_t gc;
|
||||
xcb_image_t *img;
|
||||
uint16_t width, height;
|
||||
|
||||
|
@ -201,18 +200,13 @@ image_to_1bit_pixmap(image_t *image, xcb_drawable_t d)
|
|||
pixmap = xcb_generate_id(globalconf.connection);
|
||||
xcb_create_pixmap(globalconf.connection, 1, pixmap, d, width, height);
|
||||
|
||||
gc = xcb_generate_id(globalconf.connection);
|
||||
xcb_create_gc(globalconf.connection, gc, pixmap, 0, NULL);
|
||||
|
||||
/* Prepare the image */
|
||||
img = xcb_image_create_native(globalconf.connection, width, height,
|
||||
XCB_IMAGE_FORMAT_XY_BITMAP, 1, NULL, 0, NULL);
|
||||
image_draw_to_1bit_ximage(image, img);
|
||||
|
||||
/* Paint the image to the pixmap */
|
||||
xcb_image_put(globalconf.connection, pixmap, gc, img, 0, 0, 0);
|
||||
|
||||
xcb_free_gc(globalconf.connection, gc);
|
||||
xcb_image_put(globalconf.connection, pixmap, globalconf.gc, img, 0, 0, 0);
|
||||
|
||||
xcb_image_destroy(img);
|
||||
|
||||
|
|
|
@ -76,11 +76,6 @@ wibox_wipe_resources(wibox_t *w)
|
|||
xcb_free_pixmap(globalconf.connection, w->pixmap);
|
||||
w->pixmap = XCB_NONE;
|
||||
}
|
||||
if(w->gc)
|
||||
{
|
||||
xcb_free_gc(globalconf.connection, w->gc);
|
||||
w->gc = XCB_NONE;
|
||||
}
|
||||
draw_context_wipe(&w->ctx);
|
||||
}
|
||||
|
||||
|
@ -245,11 +240,6 @@ wibox_init(wibox_t *w)
|
|||
/* Update draw context physical screen, important for Zaphod. */
|
||||
wibox_draw_context_update(w);
|
||||
|
||||
/* The default GC is just a newly created associated to the root window */
|
||||
w->gc = xcb_generate_id(globalconf.connection);
|
||||
xcb_create_gc(globalconf.connection, w->gc, s->root, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND,
|
||||
(const uint32_t[]) { s->black_pixel, s->white_pixel });
|
||||
|
||||
wibox_shape_update(w);
|
||||
}
|
||||
|
||||
|
@ -364,7 +354,7 @@ wibox_refresh_pixmap_partial(wibox_t *wibox,
|
|||
uint16_t w, uint16_t h)
|
||||
{
|
||||
xcb_copy_area(globalconf.connection, wibox->pixmap,
|
||||
wibox->window, wibox->gc, x, y, x, y,
|
||||
wibox->window, globalconf.gc, x, y, x, y,
|
||||
w, h);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,8 +49,6 @@ struct wibox_t
|
|||
image_t *bg_image;
|
||||
/** The pixmap copied to the window object. */
|
||||
xcb_pixmap_t pixmap;
|
||||
/** The graphic context. */
|
||||
xcb_gcontext_t gc;
|
||||
/** The window geometry. */
|
||||
area_t geometry;
|
||||
/** Draw context */
|
||||
|
|
|
@ -281,7 +281,7 @@ widget_render(wibox_t *wibox)
|
|||
break;
|
||||
case East:
|
||||
xcb_copy_area(globalconf.connection, rootpix,
|
||||
wibox->pixmap, wibox->gc,
|
||||
wibox->pixmap, globalconf.gc,
|
||||
x, y,
|
||||
0, 0,
|
||||
ctx->width, ctx->height);
|
||||
|
|
Loading…
Reference in New Issue