With this patch we remove the temporary draw_util_colorpixel_to_color
function we introduced previously by parsing the colors as color_t to
begin with.
relates to #1278
*
*/
struct Colortriple {
*
*/
struct Colortriple {
- uint32_t border;
- uint32_t background;
- uint32_t text;
- uint32_t indicator;
+ color_t border;
+ color_t background;
+ color_t text;
+ color_t indicator;
/* Color codes are stored here */
struct config_client {
/* Color codes are stored here */
struct config_client {
struct Colortriple focused;
struct Colortriple focused_inactive;
struct Colortriple unfocused;
struct Colortriple focused;
struct Colortriple focused_inactive;
struct Colortriple unfocused;
struct width_height con_rect;
struct width_height con_window_rect;
Rect con_deco_rect;
struct width_height con_rect;
struct width_height con_window_rect;
Rect con_deco_rect;
layout_t parent_layout;
bool con_is_leaf;
};
layout_t parent_layout;
bool con_is_leaf;
};
*/
color_t draw_util_hex_to_color(const char *color);
*/
color_t draw_util_hex_to_color(const char *color);
-color_t draw_util_colorpixel_to_color(uint32_t colorpixel);
-
/**
* Draw the given text using libi3.
* This function also marks the surface dirty which is needed if other means of
/**
* Draw the given text using libi3.
* This function also marks the surface dirty which is needed if other means of
.colorpixel = get_colorpixel(color)};
}
.colorpixel = get_colorpixel(color)};
}
-color_t draw_util_colorpixel_to_color(uint32_t colorpixel) {
- return (color_t){
- .red = ((colorpixel >> 16) & 0xFF) / 255.0,
- .green = ((colorpixel >> 8) & 0xFF) / 255.0,
- .blue = (colorpixel & 0xFF) / 255.0,
- .colorpixel = colorpixel};
-}
-
/*
* Set the given color as the source color on the surface.
*
/*
* Set the given color as the source color on the surface.
*
/* Initialize default colors */
#define INIT_COLOR(x, cborder, cbackground, ctext, cindicator) \
do { \
/* Initialize default colors */
#define INIT_COLOR(x, cborder, cbackground, ctext, cindicator) \
do { \
- x.border = get_colorpixel(cborder); \
- x.background = get_colorpixel(cbackground); \
- x.text = get_colorpixel(ctext); \
- x.indicator = get_colorpixel(cindicator); \
+ x.border = draw_util_hex_to_color(cborder); \
+ x.background = draw_util_hex_to_color(cbackground); \
+ x.text = draw_util_hex_to_color(ctext); \
+ x.indicator = draw_util_hex_to_color(cindicator); \
- config.client.background = get_colorpixel("#000000");
+ config.client.background = draw_util_hex_to_color("#000000");
INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff", "#2e9ef4");
INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff", "#484e50");
INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888", "#292d2e");
INIT_COLOR(config.client.focused, "#4c7899", "#285577", "#ffffff", "#2e9ef4");
INIT_COLOR(config.client.focused_inactive, "#333333", "#5f676a", "#ffffff", "#484e50");
INIT_COLOR(config.client.unfocused, "#333333", "#222222", "#888888", "#292d2e");
CFGFUN(color_single, const char *colorclass, const char *color) {
/* used for client.background only currently */
CFGFUN(color_single, const char *colorclass, const char *color) {
/* used for client.background only currently */
- config.client.background = get_colorpixel(color);
+ config.client.background = draw_util_hex_to_color(color);
}
CFGFUN(color, const char *colorclass, const char *border, const char *background, const char *text, const char *indicator) {
}
CFGFUN(color, const char *colorclass, const char *border, const char *background, const char *text, const char *indicator) {
-#define APPLY_COLORS(classname) \
- do { \
- if (strcmp(colorclass, "client." #classname) == 0) { \
- config.client.classname.border = get_colorpixel(border); \
- config.client.classname.background = get_colorpixel(background); \
- config.client.classname.text = get_colorpixel(text); \
- if (indicator != NULL) { \
- config.client.classname.indicator = get_colorpixel(indicator); \
- } \
- } \
+#define APPLY_COLORS(classname) \
+ do { \
+ if (strcmp(colorclass, "client." #classname) == 0) { \
+ config.client.classname.border = draw_util_hex_to_color(border); \
+ config.client.classname.background = draw_util_hex_to_color(background); \
+ config.client.classname.text = draw_util_hex_to_color(text); \
+ if (indicator != NULL) { \
+ config.client.classname.indicator = draw_util_hex_to_color(indicator); \
+ } \
+ } \
} while (0)
APPLY_COLORS(focused_inactive);
} while (0)
APPLY_COLORS(focused_inactive);
}
mask = XCB_CW_BACK_PIXEL;
}
mask = XCB_CW_BACK_PIXEL;
- values[0] = config.client.focused.border;
+ values[0] = config.client.focused.border.colorpixel;
mask |= XCB_CW_OVERRIDE_REDIRECT;
values[1] = 1;
mask |= XCB_CW_OVERRIDE_REDIRECT;
values[1] = 1;
static void update_placeholder_contents(placeholder_state *state) {
xcb_change_gc(restore_conn, state->gc, XCB_GC_FOREGROUND,
static void update_placeholder_contents(placeholder_state *state) {
xcb_change_gc(restore_conn, state->gc, XCB_GC_FOREGROUND,
- (uint32_t[]){config.client.placeholder.background});
+ (uint32_t[]){config.client.placeholder.background.colorpixel});
xcb_poly_fill_rectangle(restore_conn, state->pixmap, state->gc, 1,
(xcb_rectangle_t[]){{0, 0, state->rect.width, state->rect.height}});
xcb_poly_fill_rectangle(restore_conn, state->pixmap, state->gc, 1,
(xcb_rectangle_t[]){{0, 0, state->rect.width, state->rect.height}});
xcb_flush(restore_conn);
xcb_aux_sync(restore_conn);
xcb_flush(restore_conn);
xcb_aux_sync(restore_conn);
- set_font_colors(state->gc, config.client.placeholder.text, config.client.placeholder.background);
+ set_font_colors(state->gc, config.client.placeholder.text.colorpixel, config.client.placeholder.background.colorpixel);
Match *swallows;
int n = 0;
Match *swallows;
int n = 0;
true,
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
(uint32_t[]){
true,
XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
(uint32_t[]){
- config.client.placeholder.background,
+ config.client.placeholder.background.colorpixel,
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY,
});
/* Make i3 not focus this window. */
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY,
});
/* Make i3 not focus this window. */
- draw_util_rectangle(conn, &(con->parent->frame_buffer), draw_util_colorpixel_to_color(p->color->border),
+ draw_util_rectangle(conn, &(con->parent->frame_buffer), p->color->border,
dr->x, dr->y, dr->width, 1);
dr->x, dr->y, dr->width, 1);
- draw_util_rectangle(conn, &(con->parent->frame_buffer), draw_util_colorpixel_to_color(p->color->border),
+ draw_util_rectangle(conn, &(con->parent->frame_buffer), p->color->border,
dr->x + deco_diff_l, dr->y + dr->height - 1, dr->width - (deco_diff_l + deco_diff_r), 1);
}
dr->x + deco_diff_l, dr->y + dr->height - 1, dr->width - (deco_diff_l + deco_diff_r), 1);
}
/* Redraw the right border to cut off any text that went past it.
* This is necessary when the text was drawn using XCB since cutting text off
* automatically does not work there. For pango rendering, this isn't necessary. */
/* Redraw the right border to cut off any text that went past it.
* This is necessary when the text was drawn using XCB since cutting text off
* automatically does not work there. For pango rendering, this isn't necessary. */
- draw_util_rectangle(conn, &(con->parent->frame_buffer), draw_util_colorpixel_to_color(p->color->background),
+ draw_util_rectangle(conn, &(con->parent->frame_buffer), p->color->background,
dr->x + dr->width + br.width, dr->y, -br.width, dr->height);
/* Draw a 1px separator line before and after every tab, so that tabs can
* be easily distinguished. */
if (con->parent->layout == L_TABBED) {
/* Left side */
dr->x + dr->width + br.width, dr->y, -br.width, dr->height);
/* Draw a 1px separator line before and after every tab, so that tabs can
* be easily distinguished. */
if (con->parent->layout == L_TABBED) {
/* Left side */
- draw_util_rectangle(conn, &(con->parent->frame_buffer), draw_util_colorpixel_to_color(p->color->border),
+ draw_util_rectangle(conn, &(con->parent->frame_buffer), p->color->border,
dr->x, dr->y, 1, dr->height);
/* Right side */
dr->x, dr->y, 1, dr->height);
/* Right side */
- draw_util_rectangle(conn, &(con->parent->frame_buffer), draw_util_colorpixel_to_color(p->color->border),
+ draw_util_rectangle(conn, &(con->parent->frame_buffer), p->color->border,
dr->x + dr->width - 1, dr->y, 1, dr->height);
}
dr->x + dr->width - 1, dr->y, 1, dr->height);
}
/* 2: draw the client.background, but only for the parts around the window_rect */
if (con->window != NULL) {
/* top area */
/* 2: draw the client.background, but only for the parts around the window_rect */
if (con->window != NULL) {
/* top area */
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(config.client.background),
+ draw_util_rectangle(conn, &(con->frame_buffer), config.client.background,
0, 0, r->width, w->y);
/* bottom area */
0, 0, r->width, w->y);
/* bottom area */
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(config.client.background),
+ draw_util_rectangle(conn, &(con->frame_buffer), config.client.background,
0, w->y + w->height, r->width, r->height - (w->y + w->height));
/* left area */
0, w->y + w->height, r->width, r->height - (w->y + w->height));
/* left area */
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(config.client.background),
+ draw_util_rectangle(conn, &(con->frame_buffer), config.client.background,
0, 0, w->x, r->height);
/* right area */
0, 0, w->x, r->height);
/* right area */
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(config.client.background),
+ draw_util_rectangle(conn, &(con->frame_buffer), config.client.background,
w->x + w->width, 0, r->width - (w->x + w->width), r->height);
}
w->x + w->width, 0, r->width - (w->x + w->width), r->height);
}
* rectangle because some childs are not freely resizable and we want
* their background color to "shine through". */
if (!(borders_to_hide & ADJ_LEFT_SCREEN_EDGE)) {
* rectangle because some childs are not freely resizable and we want
* their background color to "shine through". */
if (!(borders_to_hide & ADJ_LEFT_SCREEN_EDGE)) {
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(p->color->background),
+ draw_util_rectangle(conn, &(con->frame_buffer), p->color->background,
0, 0, br.x, r->height);
}
if (!(borders_to_hide & ADJ_RIGHT_SCREEN_EDGE)) {
0, 0, br.x, r->height);
}
if (!(borders_to_hide & ADJ_RIGHT_SCREEN_EDGE)) {
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(p->color->background),
+ draw_util_rectangle(conn, &(con->frame_buffer), p->color->background,
r->width + (br.width + br.x), 0, -(br.width + br.x), r->height);
}
if (!(borders_to_hide & ADJ_LOWER_SCREEN_EDGE)) {
r->width + (br.width + br.x), 0, -(br.width + br.x), r->height);
}
if (!(borders_to_hide & ADJ_LOWER_SCREEN_EDGE)) {
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(p->color->background),
+ draw_util_rectangle(conn, &(con->frame_buffer), p->color->background,
br.x, r->height + (br.height + br.y), r->width + br.width, -(br.height + br.y));
}
/* pixel border needs an additional line at the top */
if (p->border_style == BS_PIXEL && !(borders_to_hide & ADJ_UPPER_SCREEN_EDGE)) {
br.x, r->height + (br.height + br.y), r->width + br.width, -(br.height + br.y));
}
/* pixel border needs an additional line at the top */
if (p->border_style == BS_PIXEL && !(borders_to_hide & ADJ_UPPER_SCREEN_EDGE)) {
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(p->color->background),
+ draw_util_rectangle(conn, &(con->frame_buffer), p->color->background,
br.x, 0, r->width + br.width, br.y);
}
br.x, 0, r->width + br.width, br.y);
}
TAILQ_PREV(con, nodes_head, nodes) == NULL &&
con->parent->type != CT_FLOATING_CON) {
if (p->parent_layout == L_SPLITH) {
TAILQ_PREV(con, nodes_head, nodes) == NULL &&
con->parent->type != CT_FLOATING_CON) {
if (p->parent_layout == L_SPLITH) {
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(p->color->indicator),
+ draw_util_rectangle(conn, &(con->frame_buffer), p->color->indicator,
r->width + (br.width + br.x), br.y, -(br.width + br.x), r->height + br.height);
} else if (p->parent_layout == L_SPLITV) {
r->width + (br.width + br.x), br.y, -(br.width + br.x), r->height + br.height);
} else if (p->parent_layout == L_SPLITV) {
- draw_util_rectangle(conn, &(con->frame_buffer), draw_util_colorpixel_to_color(p->color->indicator),
+ draw_util_rectangle(conn, &(con->frame_buffer), p->color->indicator,
br.x, r->height + (br.height + br.y), r->width + br.width, -(br.height + br.y));
}
}
br.x, r->height + (br.height + br.y), r->width + br.width, -(br.height + br.y));
}
}
goto copy_pixmaps;
/* 4: paint the bar */
goto copy_pixmaps;
/* 4: paint the bar */
- draw_util_rectangle(conn, &(parent->frame_buffer), draw_util_colorpixel_to_color(p->color->background),
+ draw_util_rectangle(conn, &(parent->frame_buffer), p->color->background,
con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height);
/* 5: draw two unconnected horizontal lines in border color */
con->deco_rect.x, con->deco_rect.y, con->deco_rect.width, con->deco_rect.height);
/* 5: draw two unconnected horizontal lines in border color */
i3String *title = i3string_from_utf8(_title);
draw_util_text(title, &(parent->frame_buffer),
i3String *title = i3string_from_utf8(_title);
draw_util_text(title, &(parent->frame_buffer),
- draw_util_colorpixel_to_color(p->color->text), draw_util_colorpixel_to_color(p->color->background),
+ p->color->text, p->color->background,
con->deco_rect.x + 2, con->deco_rect.y + text_offset_y,
con->deco_rect.width - 2);
FREE(_title);
con->deco_rect.x + 2, con->deco_rect.y + text_offset_y,
con->deco_rect.width - 2);
FREE(_title);
mark_width = predict_text_width(mark);
draw_util_text(mark, &(parent->frame_buffer),
mark_width = predict_text_width(mark);
draw_util_text(mark, &(parent->frame_buffer),
- draw_util_colorpixel_to_color(p->color->text), draw_util_colorpixel_to_color(p->color->background),
+ p->color->text, p->color->background,
con->deco_rect.x + con->deco_rect.width - mark_width - logical_px(2),
con->deco_rect.y + text_offset_y, mark_width);
con->deco_rect.x + con->deco_rect.width - mark_width - logical_px(2),
con->deco_rect.y + text_offset_y, mark_width);
i3String *title = win->title_format == NULL ? win->name : window_parse_title_format(win);
draw_util_text(title, &(parent->frame_buffer),
i3String *title = win->title_format == NULL ? win->name : window_parse_title_format(win);
draw_util_text(title, &(parent->frame_buffer),
- draw_util_colorpixel_to_color(p->color->text), draw_util_colorpixel_to_color(p->color->background),
+ p->color->text, p->color->background,
con->deco_rect.x + logical_px(2) + indent_px, con->deco_rect.y + text_offset_y,
con->deco_rect.width - logical_px(2) - indent_px - mark_width - logical_px(2));
if (win->title_format != NULL)
con->deco_rect.x + logical_px(2) + indent_px, con->deco_rect.y + text_offset_y,
con->deco_rect.width - logical_px(2) - indent_px - mark_width - logical_px(2));
if (win->title_format != NULL)