From 27ba87c8e4330fd7b5ff4d5cfa0bbe59a938ead8 Mon Sep 17 00:00:00 2001 From: Chris Guillott Date: Thu, 20 Oct 2016 14:22:12 -0400 Subject: [PATCH 1/4] add compiler optimizations flag --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 020beaa..b0a3dcc 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ endif CFLAGS += -std=c99 CFLAGS += -pipe CFLAGS += -Wall +CFLAGS += -O2 CPPFLAGS += -D_GNU_SOURCE CPPFLAGS += -DXKBCOMPOSE=$(shell if test -e /usr/include/xkbcommon/xkbcommon-compose.h ; then echo 1 ; else echo 0 ; fi ) CFLAGS += $(shell $(PKG_CONFIG) --cflags cairo xcb-dpms xcb-xinerama xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11) From db9e953bde01d4ed17ef72f6c7f2a987ca08a683 Mon Sep 17 00:00:00 2001 From: Chris Guillott Date: Tue, 1 Nov 2016 17:13:09 -0400 Subject: [PATCH 2/4] really hacky blur + overlayed image support --- i3lock.c | 27 +++++++++++++-------------- unlock_indicator.c | 32 ++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/i3lock.c b/i3lock.c index c6a6a45..d411a37 100644 --- a/i3lock.c +++ b/i3lock.c @@ -114,6 +114,7 @@ static uint8_t xkb_base_event; static uint8_t xkb_base_error; cairo_surface_t *img = NULL; +cairo_surface_t *blur_img = NULL; bool tile = false; bool ignore_empty_password = false; bool skip_repeated_empty_password = false; @@ -1194,20 +1195,18 @@ int main(int argc, char *argv[]) { xcb_pixmap_t blur_pixmap; if (blur) { - if(!img) { - 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]); - - img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, last_resolution[0], last_resolution[1]); - cairo_t *ctx = cairo_create(img); - cairo_set_source_surface(ctx, xcb_img, 0, 0); - cairo_paint(ctx); - - cairo_destroy(ctx); - cairo_surface_destroy(xcb_img); - } - blur_image_surface(img, 10000); + 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]); + + 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); + + cairo_destroy(ctx); + cairo_surface_destroy(xcb_img); + blur_image_surface(blur_img, 10000); } /* Pixmap on which the image is rendered to (if any) */ diff --git a/unlock_indicator.c b/unlock_indicator.c index 8aad606..814de21 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -53,6 +53,7 @@ extern char *modifier_string; /* A Cairo surface containing the specified image (-i), if any. */ extern cairo_surface_t *img; +extern cairo_surface_t *blur_img; /* Whether the image should be tiled. */ extern bool tile; @@ -138,19 +139,26 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { cairo_surface_t *xcb_output = cairo_xcb_surface_create(conn, bg_pixmap, vistype, resolution[0], resolution[1]); cairo_t *xcb_ctx = cairo_create(xcb_output); - if (img) { - if (!tile) { - cairo_set_source_surface(xcb_ctx, img, 0, 0); + if (img || blur_img) { + if (blur_img) { + cairo_set_source_surface(xcb_ctx, blur_img, 0, 0); cairo_paint(xcb_ctx); - } else { - /* create a pattern and fill a rectangle as big as the screen */ - cairo_pattern_t *pattern; - pattern = cairo_pattern_create_for_surface(img); - cairo_set_source(xcb_ctx, pattern); - cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); - cairo_rectangle(xcb_ctx, 0, 0, resolution[0], resolution[1]); - cairo_fill(xcb_ctx); - cairo_pattern_destroy(pattern); + } + if (img) { + if (!tile) { + cairo_set_source_surface(xcb_ctx, img, 0, 0); + cairo_paint(xcb_ctx); + } else { + /* create a pattern and fill a rectangle as big as the screen */ + cairo_pattern_t *pattern; + pattern = cairo_pattern_create_for_surface(img); + cairo_set_source(xcb_ctx, pattern); + cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); + cairo_rectangle(xcb_ctx, 0, 0, resolution[0], resolution[1]); + cairo_fill(xcb_ctx); + cairo_pattern_destroy(pattern); + } + } } else { char strgroups[3][3] = {{color[0], color[1], '\0'}, From 0fe47c14e8359db80eda2c29d613346d43034814 Mon Sep 17 00:00:00 2001 From: Chris Guillott Date: Tue, 1 Nov 2016 20:43:25 -0400 Subject: [PATCH 3/4] comment out (seemingly?) unused code to remove warnings --- blur.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blur.c b/blur.c index a5b0bd3..94ff42a 100644 --- a/blur.c +++ b/blur.c @@ -32,7 +32,7 @@ blur_image_surface (cairo_surface_t *surface, int radius) { cairo_surface_t *tmp; int width, height; - int src_stride, dst_stride; +// int src_stride, dst_stride; uint32_t *src, *dst; if (cairo_surface_status (surface)) @@ -64,10 +64,10 @@ blur_image_surface (cairo_surface_t *surface, int radius) return; src = (uint32_t*)cairo_image_surface_get_data (surface); - src_stride = cairo_image_surface_get_stride (surface); +// src_stride = cairo_image_surface_get_stride (surface); dst = (uint32_t*)cairo_image_surface_get_data (tmp); - dst_stride = cairo_image_surface_get_stride (tmp); +// dst_stride = cairo_image_surface_get_stride (tmp); //blur_impl_naive(src, dst, width, height, src_stride, dst_stride, 10000); //blur_impl_sse2(src, dst, width, height, 4.5); From 18907f13ee42770b579c156048681cc0b37f0b24 Mon Sep 17 00:00:00 2001 From: Chris Guillott Date: Tue, 8 Nov 2016 14:37:34 -0500 Subject: [PATCH 4/4] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 07f0e13..9fef2d8 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Many little improvements have been made to i3lock over time: - `-k, --clock` -- enables the clock display. - `--timestr="%H:%M:%S"` -- allows custom overriding of the time format string. Accepts `strftime` formatting. Default is `"%H:%M:%S"`. - `--datestr="%A, %m %Y"` -- allows custom overriding of the date format string. Accepts `strftime` formatting. Default is `"%A, %m %Y"`. + - `-B, --blur` -- enables capturing the display and blurring for use as a background image. - All the colors have an alpha channel now. Please keep in mind that this was not intended when the program was originally written, so making things transparent that weren't before can make it look strange. - You can specify whether i3lock should bell upon a wrong password.