From 91ae73b1f6dc7e33f7ab1c1468b1ddb24fa2e107 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 23 Oct 2011 17:45:40 +0100 Subject: [PATCH] i3-config-wizard: eliminate xcb_change_gc_single with C99 --- i3-config-wizard/main.c | 21 ++++++++++----------- i3-config-wizard/xcb.c | 8 -------- i3-config-wizard/xcb.h | 1 - 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 2355750f..df0db1fc 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -137,16 +137,16 @@ static char *resolve_tilde(const char *path) { static int handle_expose() { /* re-draw the background */ xcb_rectangle_t border = {0, 0, 300, (15*font_height) + 8}; - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#000000")); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#000000") }); xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &border); - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FONT, font_id); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FONT, (uint32_t[]){ font_id }); #define txt(x, row, text) xcb_image_text_8(conn, strlen(text), pixmap, pixmap_gc, x, (row * font_height) + 2, text) if (current_step == STEP_WELCOME) { /* restore font color */ - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FFFFFF")); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#FFFFFF") }); txt(10, 2, "You have not configured i3 yet."); txt(10, 3, "Do you want me to generate ~/.i3/config?"); @@ -154,16 +154,16 @@ static int handle_expose() { txt(85, 7, "No, I will use the defaults"); /* green */ - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#00FF00")); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#00FF00") }); txt(25, 5, ""); /* red */ - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FF0000")); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#FF0000") }); txt(31, 7, ""); } if (current_step == STEP_GENERATE) { - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FFFFFF")); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#FFFFFF") }); txt(10, 2, "Please choose either:"); txt(85, 4, "Win as default modifier"); @@ -178,20 +178,19 @@ static int handle_expose() { else txt(31, 4, ""); /* the selected modifier */ - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FONT, font_bold_id); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FONT, (uint32_t[]){ font_bold_id }); if (modifier == MOD_Mod4) txt(31, 4, ""); else txt(31, 5, ""); /* green */ - uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_FONT; - uint32_t values[] = { get_colorpixel("#00FF00"), font_id }; - xcb_change_gc(conn, pixmap_gc, mask, values); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_FONT, + (uint32_t[]) { get_colorpixel("#00FF00"), font_id }); txt(25, 9, ""); /* red */ - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FF0000")); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#FF0000") }); txt(31, 10, ""); } diff --git a/i3-config-wizard/xcb.c b/i3-config-wizard/xcb.c index 438c6507..e5fdee92 100644 --- a/i3-config-wizard/xcb.c +++ b/i3-config-wizard/xcb.c @@ -24,14 +24,6 @@ extern xcb_window_t root; unsigned int xcb_numlock_mask; -/* - * Convenience-wrapper around xcb_change_gc which saves us declaring a variable - * - */ -void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value) { - xcb_change_gc(conn, gc, mask, &value); -} - /* * Returns the mask for Mode_switch (to be used for looking up keysymbols by * keycode). diff --git a/i3-config-wizard/xcb.h b/i3-config-wizard/xcb.h index 748fb1db..f0416aae 100644 --- a/i3-config-wizard/xcb.h +++ b/i3-config-wizard/xcb.h @@ -10,7 +10,6 @@ extern unsigned int xcb_numlock_mask; -void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value); uint32_t get_mod_mask(xcb_connection_t *conn, uint32_t keycode); xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height); int get_font_id(xcb_connection_t *conn, char *pattern, int *font_height);