diff --git a/i3lock.c b/i3lock.c index 473ea15..8f66129 100644 --- a/i3lock.c +++ b/i3lock.c @@ -244,6 +244,7 @@ static int randr_base = -1; cairo_surface_t *img = NULL; cairo_surface_t *img_slideshow[256]; +cairo_surface_t *blur_bg_img = NULL; int slideshow_image_count = 0; int slideshow_interval = 10; bool slideshow_random_selection = false; @@ -2362,29 +2363,20 @@ int main(int argc, char *argv[]) { free(image_raw_format); - xcb_pixmap_t* blur_pixmap = NULL; if (blur) { - blur_pixmap = malloc(sizeof(xcb_pixmap_t)); - xcb_visualtype_t *vistype = get_root_visual_type(screen); - *blur_pixmap = capture_bg_pixmap(conn, screen, last_resolution); - cairo_surface_t *xcb_img = cairo_xcb_surface_create(conn, *blur_pixmap, vistype, last_resolution[0], last_resolution[1]); + xcb_pixmap_t bg_pixmap = capture_bg_pixmap(conn, screen, last_resolution); + cairo_surface_t *xcb_img = cairo_xcb_surface_create(conn, bg_pixmap, get_root_visual_type(screen), last_resolution[0], last_resolution[1]); + + blur_bg_img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, last_resolution[0], last_resolution[1]); + cairo_t *ctx = cairo_create(blur_bg_img); - cairo_surface_t *blur_img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, last_resolution[0], last_resolution[1]); - cairo_t *ctx = cairo_create(blur_img); cairo_set_source_surface(ctx, xcb_img, 0, 0); cairo_paint(ctx); + blur_image_surface(blur_bg_img, blur_sigma); - blur_image_surface(blur_img, blur_sigma); - if (img) { - // Display image on all outputs. - draw_image(last_resolution, img, ctx); - cairo_surface_destroy(img); - } cairo_destroy(ctx); cairo_surface_destroy(xcb_img); - - img = blur_img; - bg_type = NONE; + xcb_free_pixmap(conn, bg_pixmap); } xcb_window_t stolen_focus = find_focused_window(conn, screen->root); @@ -2395,14 +2387,7 @@ int main(int argc, char *argv[]) { xcb_pixmap_t pixmap = create_bg_pixmap(conn, win, last_resolution, color); render_lock(last_resolution, pixmap); xcb_change_window_attributes(conn, win, XCB_CW_BACK_PIXMAP, (uint32_t[]){pixmap}); - xcb_free_pixmap(conn, pixmap); - if (blur_pixmap) { - xcb_free_pixmap(conn, *blur_pixmap); - free(blur_pixmap); - blur_pixmap = NULL; - } - cursor = create_cursor(conn, screen, win, curs_choice); diff --git a/unlock_indicator.c b/unlock_indicator.c index 4b4c811..4028bcd 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -63,6 +63,7 @@ extern char *modifier_string; /* A Cairo surface containing the specified image (-i), if any. */ extern cairo_surface_t *img; extern cairo_surface_t *img_slideshow[256]; +extern cairo_surface_t *blur_bg_img; extern int slideshow_image_count; extern int slideshow_interval; extern bool slideshow_random_selection; @@ -697,14 +698,19 @@ void render_lock(uint32_t *resolution, xcb_drawable_t drawable) { } } - if (img) { - draw_image(resolution, img, xcb_ctx); + if (blur_bg_img) { + cairo_set_source_surface(xcb_ctx, blur_bg_img, 0, 0); + cairo_paint(xcb_ctx); } else { cairo_set_source_rgba(xcb_ctx, background.red, background.green, background.blue, background.alpha); cairo_rectangle(xcb_ctx, 0, 0, resolution[0], resolution[1]); cairo_fill(xcb_ctx); } + if (img) { + draw_image(resolution, img, xcb_ctx); + } + /* * gen text * calc vars