Get color type.

This commit is contained in:
QC 2015-09-27 11:46:19 +02:00
parent eba2170241
commit 6061e046de
4 changed files with 16 additions and 3 deletions

View file

@ -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

View file

@ -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 );

View file

@ -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 );

View file

@ -32,6 +32,7 @@
#include <unistd.h>
#include <stdint.h>
#include <glib.h>
#include <cairo.h>
#include <X11/X.h>
#include <X11/Xatom.h>
@ -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 };