From 838c838d31b327dfbd469df77ae4638ebb55236a Mon Sep 17 00:00:00 2001 From: QC Date: Sun, 27 Sep 2015 12:57:54 +0200 Subject: [PATCH] Try to fix #234 --- include/rofi.h | 2 ++ include/x11-helper.h | 2 +- source/rofi.c | 20 +++++++++++--------- source/textbox.c | 8 +++++--- source/x11-helper.c | 5 ++--- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/rofi.h b/include/rofi.h index 23401841..bf7ee333 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include "keyb.h" /** diff --git a/include/x11-helper.h b/include/x11-helper.h index 0ed62b6b..e8222da8 100644 --- a/include/x11-helper.h +++ b/include/x11-helper.h @@ -152,5 +152,5 @@ unsigned int color_background ( Display *display ); unsigned int color_border ( Display *display ); unsigned int color_separator ( Display *display ); -cairo_format_t get_format(void); +cairo_format_t get_format ( void ); #endif diff --git a/source/rofi.c b/source/rofi.c index 47073543..29573bf2 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -762,18 +762,18 @@ static void menu_refilter ( MenuState *state ) state->rchanged = TRUE; } -static void menu_draw ( MenuState *state, cairo_t *draw ) +static void menu_draw ( MenuState *state, cairo_t *d ) { unsigned int i, offset = 0; unsigned pixel = color_background ( display ); - cairo_set_source_rgba ( draw, + cairo_set_source_rgba ( d, ( ( pixel & 0x00FF0000 ) >> 16 ) / 256.0, ( ( pixel & 0x0000FF00 ) >> 8 ) / 256.0, ( ( pixel & 0x000000FF ) >> 0 ) / 256.0, ( ( pixel & 0xFF000000 ) >> 24 ) / 256.0 ); - cairo_paint ( draw ); + cairo_paint ( d ); // selected row is always visible. // If selected is visible do not scroll. @@ -802,7 +802,7 @@ static void menu_draw ( MenuState *state, cairo_t *draw ) // Update the handle length. scrollbar_set_handle_length ( state->scrollbar, columns * state->max_rows ); - scrollbar_draw ( state->scrollbar, draw ); + scrollbar_draw ( state->scrollbar, d ); // Element width. unsigned int element_width = state->w - ( 2 * ( config.padding ) ); if ( state->scrollbar != NULL ) { @@ -833,7 +833,7 @@ static void menu_draw ( MenuState *state, cairo_t *draw ) textbox_font ( state->boxes[i], tbft ); textbox_text ( state->boxes[i], text ); } - textbox_draw ( state->boxes[i], draw ); + textbox_draw ( state->boxes[i], d ); } state->rchanged = FALSE; } @@ -845,15 +845,14 @@ static void menu_draw ( MenuState *state, cairo_t *draw ) state->sw->mgrv ( state->line_map[i + offset], state->sw, &fstate ); TextBoxFontType tbft = fstate | ( ( i + offset ) == state->selected ? HIGHLIGHT : type ); textbox_font ( state->boxes[i], tbft ); - textbox_draw ( state->boxes[i], draw ); + textbox_draw ( state->boxes[i], d ); } } - cairo_show_page ( draw ); } static void menu_update ( MenuState *state ) { - cairo_surface_t *surf = cairo_image_surface_create ( get_format(), 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 ); @@ -899,9 +898,12 @@ static void menu_update ( MenuState *state ) cairo_set_source_surface ( draw, surf, 0, 0 ); cairo_paint ( draw ); - + cairo_show_page ( draw ); cairo_destroy ( d ); cairo_surface_destroy ( surf ); + + // Flush the surface. + cairo_surface_flush ( surface ); } /** diff --git a/source/textbox.c b/source/textbox.c index 2dfbb4e8..6b3f8dc1 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -33,11 +33,13 @@ #include #include #include +#include #include #include "rofi.h" #include "textbox.h" #include "keyb.h" -#include +#include "x11-helper.h" + #define SIDE_MARGIN 1 /** @@ -72,7 +74,7 @@ textbox* textbox_create ( TextboxFlags flags, short x, short y, short w, short h tb->changed = FALSE; - tb->main_surface = cairo_image_surface_create ( get_format(), 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 +226,7 @@ static void texbox_update ( textbox *tb ) tb->main_draw = NULL; tb->main_surface = NULL; } - tb->main_surface = cairo_image_surface_create ( get_format(), 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 a7a1bb37..b27462fe 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -489,10 +489,9 @@ void create_visual_and_colormap ( Display *display ) } } - -cairo_format_t get_format(void) +cairo_format_t get_format ( void ) { - if(truecolor){ + if ( truecolor ) { return CAIRO_FORMAT_ARGB32; } return CAIRO_FORMAT_RGB24;