mirror of
https://github.com/Raymo111/i3lock-color.git
synced 2024-11-18 13:54:55 -05:00
really hacky blur + overlayed image support
This commit is contained in:
parent
27ba87c8e4
commit
db9e953bde
2 changed files with 31 additions and 24 deletions
23
i3lock.c
23
i3lock.c
|
@ -114,6 +114,7 @@ static uint8_t xkb_base_event;
|
||||||
static uint8_t xkb_base_error;
|
static uint8_t xkb_base_error;
|
||||||
|
|
||||||
cairo_surface_t *img = NULL;
|
cairo_surface_t *img = NULL;
|
||||||
|
cairo_surface_t *blur_img = NULL;
|
||||||
bool tile = false;
|
bool tile = false;
|
||||||
bool ignore_empty_password = false;
|
bool ignore_empty_password = false;
|
||||||
bool skip_repeated_empty_password = false;
|
bool skip_repeated_empty_password = false;
|
||||||
|
@ -1194,20 +1195,18 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
xcb_pixmap_t blur_pixmap;
|
xcb_pixmap_t blur_pixmap;
|
||||||
if (blur) {
|
if (blur) {
|
||||||
if(!img) {
|
xcb_visualtype_t *vistype = get_root_visual_type(screen);
|
||||||
xcb_visualtype_t *vistype = get_root_visual_type(screen);
|
blur_pixmap = capture_bg_pixmap(conn, screen, last_resolution);
|
||||||
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]);
|
||||||
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]);
|
blur_img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, last_resolution[0], last_resolution[1]);
|
||||||
cairo_t *ctx = cairo_create(img);
|
cairo_t *ctx = cairo_create(blur_img);
|
||||||
cairo_set_source_surface(ctx, xcb_img, 0, 0);
|
cairo_set_source_surface(ctx, xcb_img, 0, 0);
|
||||||
cairo_paint(ctx);
|
cairo_paint(ctx);
|
||||||
|
|
||||||
cairo_destroy(ctx);
|
cairo_destroy(ctx);
|
||||||
cairo_surface_destroy(xcb_img);
|
cairo_surface_destroy(xcb_img);
|
||||||
}
|
blur_image_surface(blur_img, 10000);
|
||||||
blur_image_surface(img, 10000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pixmap on which the image is rendered to (if any) */
|
/* Pixmap on which the image is rendered to (if any) */
|
||||||
|
|
|
@ -53,6 +53,7 @@ extern char *modifier_string;
|
||||||
|
|
||||||
/* A Cairo surface containing the specified image (-i), if any. */
|
/* A Cairo surface containing the specified image (-i), if any. */
|
||||||
extern cairo_surface_t *img;
|
extern cairo_surface_t *img;
|
||||||
|
extern cairo_surface_t *blur_img;
|
||||||
|
|
||||||
/* Whether the image should be tiled. */
|
/* Whether the image should be tiled. */
|
||||||
extern bool tile;
|
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_surface_t *xcb_output = cairo_xcb_surface_create(conn, bg_pixmap, vistype, resolution[0], resolution[1]);
|
||||||
cairo_t *xcb_ctx = cairo_create(xcb_output);
|
cairo_t *xcb_ctx = cairo_create(xcb_output);
|
||||||
|
|
||||||
if (img) {
|
if (img || blur_img) {
|
||||||
if (!tile) {
|
if (blur_img) {
|
||||||
cairo_set_source_surface(xcb_ctx, img, 0, 0);
|
cairo_set_source_surface(xcb_ctx, blur_img, 0, 0);
|
||||||
cairo_paint(xcb_ctx);
|
cairo_paint(xcb_ctx);
|
||||||
} else {
|
}
|
||||||
/* create a pattern and fill a rectangle as big as the screen */
|
if (img) {
|
||||||
cairo_pattern_t *pattern;
|
if (!tile) {
|
||||||
pattern = cairo_pattern_create_for_surface(img);
|
cairo_set_source_surface(xcb_ctx, img, 0, 0);
|
||||||
cairo_set_source(xcb_ctx, pattern);
|
cairo_paint(xcb_ctx);
|
||||||
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
|
} else {
|
||||||
cairo_rectangle(xcb_ctx, 0, 0, resolution[0], resolution[1]);
|
/* create a pattern and fill a rectangle as big as the screen */
|
||||||
cairo_fill(xcb_ctx);
|
cairo_pattern_t *pattern;
|
||||||
cairo_pattern_destroy(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 {
|
} else {
|
||||||
char strgroups[3][3] = {{color[0], color[1], '\0'},
|
char strgroups[3][3] = {{color[0], color[1], '\0'},
|
||||||
|
|
Loading…
Reference in a new issue