From: Ingo Bürk Date: Sat, 10 Oct 2015 19:27:23 +0000 (+0200) Subject: Remove support for 32-bit visuals and RGBA colors. X-Git-Tag: 4.12~142^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fpull%2F1985%2Fhead;p=i3%2Fi3 Remove support for 32-bit visuals and RGBA colors. fixes #1984 --- diff --git a/i3bar/include/cairo_util.h b/i3bar/include/cairo_util.h index ce1d3180..37eaa6e2 100644 --- a/i3bar/include/cairo_util.h +++ b/i3bar/include/cairo_util.h @@ -15,7 +15,6 @@ typedef struct color_t { double red; double green; double blue; - double alpha; /* For compatibility, we also store the colorpixel for now. */ uint32_t colorpixel; diff --git a/i3bar/src/cairo_util.c b/i3bar/src/cairo_util.c index e1728786..52181aee 100644 --- a/i3bar/src/cairo_util.c +++ b/i3bar/src/cairo_util.c @@ -51,25 +51,15 @@ void cairo_surface_free(surface_t *surface) { * */ color_t cairo_hex_to_color(const char *color) { - char alpha[2]; - if (strlen(color) == strlen("#rrggbbaa")) { - alpha[0] = color[7]; - alpha[1] = color[8]; - } else { - alpha[0] = alpha[1] = 'F'; - } - - char groups[4][3] = { + char groups[3][3] = { {color[1], color[2], '\0'}, {color[3], color[4], '\0'}, - {color[5], color[6], '\0'}, - {alpha[0], alpha[1], '\0'}}; + {color[5], color[6], '\0'}}; return (color_t){ .red = strtol(groups[0], NULL, 16) / 255.0, .green = strtol(groups[1], NULL, 16) / 255.0, .blue = strtol(groups[2], NULL, 16) / 255.0, - .alpha = strtol(groups[3], NULL, 16) / 255.0, .colorpixel = get_colorpixel(color)}; } @@ -78,7 +68,7 @@ color_t cairo_hex_to_color(const char *color) { * */ void cairo_set_source_color(surface_t *surface, color_t color) { - cairo_set_source_rgba(surface->cr, color.red, color.green, color.blue, color.alpha); + cairo_set_source_rgb(surface->cr, color.red, color.green, color.blue); } /** diff --git a/i3bar/src/xcb.c b/i3bar/src/xcb.c index 2cd3bd6e..ac9b50f9 100644 --- a/i3bar/src/xcb.c +++ b/i3bar/src/xcb.c @@ -1122,21 +1122,7 @@ char *init_xcb_early() { depth = root_screen->root_depth; colormap = root_screen->default_colormap; - visual_type = xcb_aux_find_visual_by_attrs(root_screen, -1, 32); - if (visual_type) { - depth = xcb_aux_get_depth_of_visual(root_screen, visual_type->visual_id); - colormap = xcb_generate_id(xcb_connection); - xcb_void_cookie_t cm_cookie = xcb_create_colormap_checked(xcb_connection, - XCB_COLORMAP_ALLOC_NONE, - colormap, - xcb_root, - visual_type->visual_id); - if (xcb_request_failed(cm_cookie, "Could not allocate colormap")) { - exit(EXIT_FAILURE); - } - } else { - visual_type = get_visualtype(root_screen); - } + visual_type = get_visualtype(root_screen); /* We draw the statusline to a seperate pixmap, because it looks the same on all bars and * this way, we can choose to crop it */ diff --git a/libi3/font.c b/libi3/font.c index e14bb080..9e808a89 100644 --- a/libi3/font.c +++ b/libi3/font.c @@ -29,7 +29,6 @@ static xcb_visualtype_t *root_visual_type; static double pango_font_red; static double pango_font_green; static double pango_font_blue; -static double pango_font_alpha; /* Necessary to track whether the dpi changes and trigger a LOG() message, * which is more easily visible to users. */ @@ -124,8 +123,8 @@ static void draw_text_pango(const char *text, size_t text_len, pango_layout_set_text(layout, text, text_len); /* Do the drawing */ - cairo_set_source_rgba(cr, pango_font_red, pango_font_green, pango_font_blue, pango_font_alpha); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgb(cr, pango_font_red, pango_font_green, pango_font_blue); pango_cairo_update_layout(cr, layout); pango_layout_get_pixel_size(layout, NULL, &height); /* Center the piece of text vertically if its height is smaller than the @@ -334,7 +333,6 @@ void set_font_colors(xcb_gcontext_t gc, uint32_t foreground, uint32_t background pango_font_red = ((foreground >> 16) & 0xff) / 255.0; pango_font_green = ((foreground >> 8) & 0xff) / 255.0; pango_font_blue = (foreground & 0xff) / 255.0; - pango_font_alpha = ((foreground >> 24) & 0xff) / 255.0; break; #endif default: diff --git a/libi3/get_colorpixel.c b/libi3/get_colorpixel.c index 3a62a8e4..f81ea6c2 100644 --- a/libi3/get_colorpixel.c +++ b/libi3/get_colorpixel.c @@ -26,23 +26,13 @@ * */ uint32_t get_colorpixel(const char *hex) { - char alpha[2]; - if (strlen(hex) == strlen("#rrggbbaa")) { - alpha[0] = hex[7]; - alpha[1] = hex[8]; - } else { - alpha[0] = alpha[1] = 'F'; - } - - char strgroups[4][3] = { + char strgroups[3][3] = { {hex[1], hex[2], '\0'}, {hex[3], hex[4], '\0'}, - {hex[5], hex[6], '\0'}, - {alpha[0], alpha[1], '\0'}}; + {hex[5], hex[6], '\0'}}; uint8_t r = strtol(strgroups[0], NULL, 16); uint8_t g = strtol(strgroups[1], NULL, 16); uint8_t b = strtol(strgroups[2], NULL, 16); - uint8_t a = strtol(strgroups[3], NULL, 16); - return (a << 24) | (r << 16 | g << 8 | b); + return (0xFF << 24) | (r << 16 | g << 8 | b); }