1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00
This commit is contained in:
QC 2015-09-27 12:57:54 +02:00
parent 6061e046de
commit 838c838d31
5 changed files with 21 additions and 16 deletions

View file

@ -5,6 +5,8 @@
#include <string.h>
#include <stdlib.h>
#include <textbox.h>
#include <cairo.h>
#include <cairo-xlib.h>
#include "keyb.h"
/**

View file

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

View file

@ -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 );
}
/**

View file

@ -33,11 +33,13 @@
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include <ctype.h>
#include <glib.h>
#include <pango/pangocairo.h>
#include "rofi.h"
#include "textbox.h"
#include "keyb.h"
#include <glib.h>
#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 );

View file

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