i3-config-wizard: eliminate xcb_change_gc_single with C99

This commit is contained in:
Michael Stapelberg 2011-10-23 17:45:40 +01:00
parent cb9bbcfccf
commit 91ae73b1f6
3 changed files with 10 additions and 20 deletions

View File

@ -137,16 +137,16 @@ static char *resolve_tilde(const char *path) {
static int handle_expose() { static int handle_expose() {
/* re-draw the background */ /* re-draw the background */
xcb_rectangle_t border = {0, 0, 300, (15*font_height) + 8}; 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_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) #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) { if (current_step == STEP_WELCOME) {
/* restore font color */ /* 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, 2, "You have not configured i3 yet.");
txt(10, 3, "Do you want me to generate ~/.i3/config?"); 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"); txt(85, 7, "No, I will use the defaults");
/* green */ /* 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, "<Enter>"); txt(25, 5, "<Enter>");
/* red */ /* 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, "<ESC>"); txt(31, 7, "<ESC>");
} }
if (current_step == STEP_GENERATE) { 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(10, 2, "Please choose either:");
txt(85, 4, "Win as default modifier"); txt(85, 4, "Win as default modifier");
@ -178,20 +178,19 @@ static int handle_expose() {
else txt(31, 4, "<Win>"); else txt(31, 4, "<Win>");
/* the selected modifier */ /* 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) if (modifier == MOD_Mod4)
txt(31, 4, "<Win>"); txt(31, 4, "<Win>");
else txt(31, 5, "<Alt>"); else txt(31, 5, "<Alt>");
/* green */ /* green */
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_FONT; xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_FONT,
uint32_t values[] = { get_colorpixel("#00FF00"), font_id }; (uint32_t[]) { get_colorpixel("#00FF00"), font_id });
xcb_change_gc(conn, pixmap_gc, mask, values);
txt(25, 9, "<Enter>"); txt(25, 9, "<Enter>");
/* red */ /* 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, "<ESC>"); txt(31, 10, "<ESC>");
} }

View File

@ -24,14 +24,6 @@
extern xcb_window_t root; extern xcb_window_t root;
unsigned int xcb_numlock_mask; 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 * Returns the mask for Mode_switch (to be used for looking up keysymbols by
* keycode). * keycode).

View File

@ -10,7 +10,6 @@
extern unsigned int xcb_numlock_mask; 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); 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); 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); int get_font_id(xcb_connection_t *conn, char *pattern, int *font_height);