Eliminate xcb_change_gc_single everywhere with C99
This commit is contained in:
parent
9eda7fb6fb
commit
6dc6ba11fc
|
@ -19,6 +19,5 @@ char *convert_utf8_to_ucs2(char *input, int *real_strlen);
|
||||||
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);
|
||||||
void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -68,14 +68,6 @@ i3Font load_font(const char *pattern, bool fallback);
|
||||||
xcb_window_t create_window(xcb_connection_t *conn, Rect r, uint16_t window_class,
|
xcb_window_t create_window(xcb_connection_t *conn, Rect r, uint16_t window_class,
|
||||||
enum xcursor_cursor_t cursor, bool map, uint32_t mask, uint32_t *values);
|
enum xcursor_cursor_t cursor, bool map, uint32_t mask, uint32_t *values);
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes a single value in the graphic context (so one doesn’t have to
|
|
||||||
* define an array of values)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc,
|
|
||||||
uint32_t mask, uint32_t value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a line from x,y to to_x,to_y using the given color
|
* Draws a line from x,y to to_x,to_y using the given color
|
||||||
*
|
*
|
||||||
|
|
|
@ -41,13 +41,13 @@ static int sig_draw_window(xcb_window_t win, int width, int height, int font_hei
|
||||||
/* re-draw the background */
|
/* re-draw the background */
|
||||||
xcb_rectangle_t border = { 0, 0, width, height},
|
xcb_rectangle_t border = { 0, 0, width, height},
|
||||||
inner = { 2, 2, width - 4, height - 4};
|
inner = { 2, 2, width - 4, height - 4};
|
||||||
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") });
|
||||||
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_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, &inner);
|
xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &inner);
|
||||||
|
|
||||||
/* 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") });
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(crash_text) / sizeof(char*); i++) {
|
for (int i = 0; i < sizeof(crash_text) / sizeof(char*); i++) {
|
||||||
int text_len = strlen(crash_text[i]);
|
int text_len = strlen(crash_text[i]);
|
||||||
|
@ -170,7 +170,7 @@ void handle_signal(int sig, siginfo_t *info, void *data) {
|
||||||
xcb_create_gc(conn, pixmap_gc, pixmap, 0, 0);
|
xcb_create_gc(conn, pixmap_gc, pixmap, 0, 0);
|
||||||
|
|
||||||
/* Create graphics context */
|
/* Create graphics context */
|
||||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FONT, config.font.id);
|
xcb_change_gc(conn, pixmap_gc, XCB_GC_FONT, (uint32_t[]){ config.font.id });
|
||||||
|
|
||||||
/* Grab the keyboard to get all input */
|
/* Grab the keyboard to get all input */
|
||||||
xcb_grab_keyboard(conn, false, win, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
xcb_grab_keyboard(conn, false, win, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
|
||||||
|
|
8
src/x.c
8
src/x.c
|
@ -354,7 +354,7 @@ void x_draw_decoration(Con *con) {
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
xcb_change_gc_single(conn, con->pm_gc, XCB_GC_FOREGROUND, config.client.background);
|
xcb_change_gc(conn, con->pm_gc, XCB_GC_FOREGROUND, (uint32_t[]) { config.client.background });
|
||||||
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, sizeof(background) / sizeof(xcb_rectangle_t), background);
|
xcb_poly_fill_rectangle(conn, con->pixmap, con->pm_gc, sizeof(background) / sizeof(xcb_rectangle_t), background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ void x_draw_decoration(Con *con) {
|
||||||
* (left, bottom and right part). We don’t just fill the whole
|
* (left, bottom and right part). We don’t just fill the whole
|
||||||
* rectangle because some childs are not freely resizable and we want
|
* rectangle because some childs are not freely resizable and we want
|
||||||
* their background color to "shine through". */
|
* their background color to "shine through". */
|
||||||
xcb_change_gc_single(conn, con->pm_gc, XCB_GC_FOREGROUND, p->color->background);
|
xcb_change_gc(conn, con->pm_gc, XCB_GC_FOREGROUND, (uint32_t[]){ p->color->background });
|
||||||
xcb_rectangle_t borders[] = {
|
xcb_rectangle_t borders[] = {
|
||||||
{ 0, 0, br.x, r->height },
|
{ 0, 0, br.x, r->height },
|
||||||
{ 0, r->height + br.height + br.y, r->width, r->height },
|
{ 0, r->height + br.height + br.y, r->width, r->height },
|
||||||
|
@ -391,12 +391,12 @@ void x_draw_decoration(Con *con) {
|
||||||
goto copy_pixmaps;
|
goto copy_pixmaps;
|
||||||
|
|
||||||
/* 4: paint the bar */
|
/* 4: paint the bar */
|
||||||
xcb_change_gc_single(conn, parent->pm_gc, XCB_GC_FOREGROUND, p->color->background);
|
xcb_change_gc(conn, parent->pm_gc, XCB_GC_FOREGROUND, (uint32_t[]){ p->color->background });
|
||||||
xcb_rectangle_t drect = { con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height };
|
xcb_rectangle_t drect = { con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height };
|
||||||
xcb_poly_fill_rectangle(conn, parent->pixmap, parent->pm_gc, 1, &drect);
|
xcb_poly_fill_rectangle(conn, parent->pixmap, parent->pm_gc, 1, &drect);
|
||||||
|
|
||||||
/* 5: draw two unconnected lines in border color */
|
/* 5: draw two unconnected lines in border color */
|
||||||
xcb_change_gc_single(conn, parent->pm_gc, XCB_GC_FOREGROUND, p->color->border);
|
xcb_change_gc(conn, parent->pm_gc, XCB_GC_FOREGROUND, (uint32_t[]){ p->color->border });
|
||||||
Rect *dr = &(con->deco_rect);
|
Rect *dr = &(con->deco_rect);
|
||||||
xcb_segment_t segments[] = {
|
xcb_segment_t segments[] = {
|
||||||
{ dr->x, dr->y,
|
{ dr->x, dr->y,
|
||||||
|
|
16
src/xcb.c
16
src/xcb.c
|
@ -108,23 +108,15 @@ xcb_window_t create_window(xcb_connection_t *conn, Rect dims, uint16_t window_cl
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Changes a single value in the graphic context (so one doesn’t have to define an array of values)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Draws a line from x,y to to_x,to_y using the given color
|
* Draws a line from x,y to to_x,to_y using the given color
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void xcb_draw_line(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc,
|
void xcb_draw_line(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc,
|
||||||
uint32_t colorpixel, uint32_t x, uint32_t y, uint32_t to_x, uint32_t to_y) {
|
uint32_t colorpixel, uint32_t x, uint32_t y, uint32_t to_x, uint32_t to_y) {
|
||||||
xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, colorpixel);
|
xcb_change_gc(conn, gc, XCB_GC_FOREGROUND, (uint32_t[]){ colorpixel });
|
||||||
xcb_point_t points[] = {{x, y}, {to_x, to_y}};
|
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, drawable, gc, 2,
|
||||||
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, drawable, gc, 2, points);
|
(xcb_point_t[]) { {x, y}, {to_x, to_y} });
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -133,7 +125,7 @@ void xcb_draw_line(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext
|
||||||
*/
|
*/
|
||||||
void xcb_draw_rect(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc,
|
void xcb_draw_rect(xcb_connection_t *conn, xcb_drawable_t drawable, xcb_gcontext_t gc,
|
||||||
uint32_t colorpixel, uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
uint32_t colorpixel, uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||||
xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, colorpixel);
|
xcb_change_gc(conn, gc, XCB_GC_FOREGROUND, (uint32_t[]){ colorpixel });
|
||||||
xcb_rectangle_t rect = {x, y, width, height};
|
xcb_rectangle_t rect = {x, y, width, height};
|
||||||
xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
|
xcb_poly_fill_rectangle(conn, drawable, gc, 1, &rect);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue