From 3672c0bc636aa82f8fc38aa75f226915686d0bd3 Mon Sep 17 00:00:00 2001 From: Bert Date: Thu, 10 Mar 2011 11:41:40 +0100 Subject: Toggle image transparency with A-key --- Makefile | 2 +- image.c | 3 ++- image.h | 1 + main.c | 4 ++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3bd788e..0afa901 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: sxiv -VERSION=git-20110309 +VERSION=git-20110310 CC?=gcc PREFIX?=/usr/local diff --git a/image.c b/image.c index 854e50b..4245993 100644 --- a/image.c +++ b/image.c @@ -43,6 +43,7 @@ void img_init(img_t *img, win_t *win) { img->zoom = MAX(img->zoom, zoom_min); img->zoom = MIN(img->zoom, zoom_max); img->aa = options->aa; + img->alpha = 1; } if (win) { @@ -211,7 +212,7 @@ void img_render(img_t *img, win_t *win) { else imlib_context_set_image(im_broken); - if (imlib_image_has_alpha()) + if (imlib_image_has_alpha() && !img->alpha) win_draw_rect(win, win->pm, dx, dy, dw, dh, True, 0, win->white); imlib_context_set_drawable(win->pm); diff --git a/image.h b/image.h index 370345f..5fc4ec6 100644 --- a/image.h +++ b/image.h @@ -45,6 +45,7 @@ typedef struct { unsigned char re; unsigned char checkpan; unsigned char aa; + unsigned char alpha; int x; int y; diff --git a/main.c b/main.c index 339eb95..558980e 100644 --- a/main.c +++ b/main.c @@ -496,6 +496,10 @@ void on_keypress(XKeyEvent *kev) { img_toggle_antialias(&img); changed = 1; break; + case XK_A: + img.alpha ^= 1; + changed = 1; + break; case XK_r: changed = load_image(fileidx); break; -- cgit v1.2.3-54-g00ecf