Fake background should only be done once every run.

Not on every re-run, as you will capture old rofi window.
This commit is contained in:
Dave Davenport 2015-11-30 10:15:53 +01:00
parent 01a770770b
commit f3897b2a60

View file

@ -91,6 +91,7 @@ unsigned int curr_switcher = 0;
XVisualInfo vinfo;
cairo_surface_t *surface = NULL;
cairo_surface_t *fake_bg = NULL;
cairo_t *draw = NULL;
XIM xim;
XIC xic;
@ -226,7 +227,6 @@ typedef struct MenuState
int *lines_not_ascii;
int line_height;
unsigned int border;
cairo_surface_t *bg;
workarea mon;
}MenuState;
@ -289,10 +289,6 @@ static void menu_free_state ( MenuState *state )
textbox_free ( state->prompt_tb );
textbox_free ( state->case_indicator );
scrollbar_free ( state->scrollbar );
if ( state->bg ) {
cairo_surface_destroy ( state->bg );
state->bg = NULL;
}
for ( unsigned int i = 0; i < state->max_elements; i++ ) {
textbox_free ( state->boxes[i] );
@ -973,8 +969,8 @@ static void menu_update ( MenuState *state )
cairo_t *d = cairo_create ( surf );
cairo_set_operator ( d, CAIRO_OPERATOR_SOURCE );
if ( config.fake_transparency ) {
if ( state->bg != NULL ) {
cairo_set_source_surface ( d, state->bg,
if ( fake_bg != NULL ) {
cairo_set_source_surface ( d, fake_bg,
-(double) ( state->x - state->mon.x ),
-(double) ( state->y - state->mon.y ) );
cairo_paint ( d );
@ -1155,6 +1151,7 @@ static void menu_resize ( MenuState *state )
static void menu_setup_fake_transparency ( Display *display, MenuState *state )
{
if ( fake_bg == NULL ) {
Window root = DefaultRootWindow ( display );
int screen = DefaultScreen ( display );
cairo_surface_t *s = cairo_xlib_surface_create ( display,
@ -1163,13 +1160,14 @@ static void menu_setup_fake_transparency ( Display *display, MenuState *state )
DisplayWidth ( display, screen ),
DisplayHeight ( display, screen ) );
state->bg = cairo_image_surface_create ( get_format (), state->mon.w, state->mon.h );
cairo_t *dr = cairo_create ( state->bg );
fake_bg = cairo_image_surface_create ( get_format (), state->mon.w, state->mon.h );
cairo_t *dr = cairo_create ( fake_bg );
cairo_set_source_surface ( dr, s, -state->mon.x, -state->mon.y );
cairo_paint ( dr );
cairo_destroy ( dr );
cairo_surface_destroy ( s );
TICK_N ( "Fake transparency" );
}
}
MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
@ -1754,6 +1752,11 @@ static void teardown ( int pfd )
// Release the window.
release_keyboard ( display );
if ( fake_bg ) {
cairo_surface_destroy ( fake_bg );
fake_bg = NULL;
}
if ( draw ) {
cairo_destroy ( draw );
draw = NULL;