From 6061e046def31b96e727c44d90cd370489f22c1d Mon Sep 17 00:00:00 2001 From: QC Date: Sun, 27 Sep 2015 11:46:19 +0200 Subject: [PATCH] Get color type. --- include/x11-helper.h | 2 ++ source/rofi.c | 2 +- source/textbox.c | 4 ++-- source/x11-helper.c | 11 +++++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/x11-helper.h b/include/x11-helper.h index faedb1d1..0ed62b6b 100644 --- a/include/x11-helper.h +++ b/include/x11-helper.h @@ -151,4 +151,6 @@ unsigned int color_get ( Display *display, const char *const name, const char * unsigned int color_background ( Display *display ); unsigned int color_border ( Display *display ); unsigned int color_separator ( Display *display ); + +cairo_format_t get_format(void); #endif diff --git a/source/rofi.c b/source/rofi.c index cf366556..47073543 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -853,7 +853,7 @@ static void menu_draw ( MenuState *state, cairo_t *draw ) static void menu_update ( MenuState *state ) { - cairo_surface_t *surf = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, state->w, state->h ); + cairo_surface_t *surf = cairo_image_surface_create ( get_format(), state->w, state->h ); cairo_t *d = cairo_create ( surf ); cairo_set_operator ( d, CAIRO_OPERATOR_SOURCE ); diff --git a/source/textbox.c b/source/textbox.c index 8a87cb71..2dfbb4e8 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -72,7 +72,7 @@ textbox* textbox_create ( TextboxFlags flags, short x, short y, short w, short h tb->changed = FALSE; - tb->main_surface = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, tb->w, tb->h ); + tb->main_surface = cairo_image_surface_create ( get_format(), tb->w, tb->h ); tb->main_draw = cairo_create ( tb->main_surface ); tb->layout = pango_cairo_create_layout ( tb->main_draw ); PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font ); @@ -224,7 +224,7 @@ static void texbox_update ( textbox *tb ) tb->main_draw = NULL; tb->main_surface = NULL; } - tb->main_surface = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, tb->w, tb->h ); + tb->main_surface = cairo_image_surface_create ( get_format(), tb->w, tb->h ); tb->main_draw = cairo_create ( tb->main_surface ); PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font ); pango_font_description_free ( pfd ); diff --git a/source/x11-helper.c b/source/x11-helper.c index a311528b..a7a1bb37 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -487,6 +488,16 @@ void create_visual_and_colormap ( Display *display ) map = DefaultColormap ( display, screen ); } } + + +cairo_format_t get_format(void) +{ + if(truecolor){ + return CAIRO_FORMAT_ARGB32; + } + return CAIRO_FORMAT_RGB24; +} + unsigned int color_get ( Display *display, const char *const name, const char * const defn ) { XColor color = { 0, 0, 0, 0, 0, 0 };