From 78fea8e1fb2e4a36295201a7b9d73473170c5e92 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 23 Oct 2011 17:55:58 +0100 Subject: [PATCH] i3-nagbar: eliminate xcb_change_gc_single with C99 --- i3-nagbar/i3-nagbar.h | 1 - i3-nagbar/main.c | 12 ++++++------ i3-nagbar/xcb.c | 8 -------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/i3-nagbar/i3-nagbar.h b/i3-nagbar/i3-nagbar.h index 04131e4b..951e264f 100644 --- a/i3-nagbar/i3-nagbar.h +++ b/i3-nagbar/i3-nagbar.h @@ -20,6 +20,5 @@ extern xcb_window_t root; 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); -void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value); #endif diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index 0a3e5150..71225c1a 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -128,7 +128,7 @@ static void handle_button_release(xcb_connection_t *conn, xcb_button_release_eve */ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) { /* re-draw the background */ - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, color_background); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ color_background }); xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &rect); /* restore font color */ @@ -150,7 +150,7 @@ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) { xcb_rectangle_t close = { y - w - (2 * line_width), 0, w + (2 * line_width), rect.height }; xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &close); - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, color_border); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ color_border }); xcb_point_t points[] = { { y - w - (2 * line_width), line_width / 2 }, { y - (line_width / 2), line_width / 2 }, @@ -176,11 +176,11 @@ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) { /* TODO: make w = text extents of the label */ w = 100; y -= 30; - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, color_button_background); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ color_button_background }); close = (xcb_rectangle_t){ y - w - (2 * line_width), 2, w + (2 * line_width), rect.height - 6 }; xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &close); - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, color_border); + xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ color_border }); buttons[c].x = y - w - (2 * line_width); buttons[c].width = w; xcb_point_t points2[] = { @@ -366,7 +366,7 @@ int main(int argc, char *argv[]) { xcb_create_gc(conn, pixmap_gc, pixmap, 0, 0); /* Create graphics context */ - 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 }); /* Grab the keyboard to get all input */ xcb_flush(conn); @@ -411,7 +411,7 @@ int main(int argc, char *argv[]) { xcb_create_gc(conn, pixmap_gc, pixmap, 0, 0); /* Create graphics context */ - 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 }); break; } } diff --git a/i3-nagbar/xcb.c b/i3-nagbar/xcb.c index 7148133d..8c70875f 100644 --- a/i3-nagbar/xcb.c +++ b/i3-nagbar/xcb.c @@ -20,14 +20,6 @@ #include "i3-nagbar.h" -/* - * 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); -} - /* * Opens the window we use for input/output and maps it * -- 2.39.5