aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--commands.c13
-rw-r--r--commands.h2
-rw-r--r--config.h2
-rw-r--r--thumbs.c5
-rw-r--r--thumbs.h1
6 files changed, 15 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index dcf805a..68c00d0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
all: sxiv
-VERSION = git-20110903
+VERSION = git-20110904
CC = gcc
DESTDIR =
diff --git a/commands.c b/commands.c
index f8a6e81..2a791f6 100644
--- a/commands.c
+++ b/commands.c
@@ -327,13 +327,12 @@ int i_toggle_antialias(arg_t a) {
}
}
-int i_toggle_alpha(arg_t a) {
- if (mode == MODE_IMAGE) {
- img.alpha ^= 1;
- return 1;
- } else {
- return 0;
- }
+int it_toggle_alpha(arg_t a) {
+ img.alpha ^= 1;
+ tns.alpha = img.alpha;
+ if (mode == MODE_THUMB)
+ tns.dirty = 1;
+ return 1;
}
int it_open_with(arg_t a) {
diff --git a/commands.h b/commands.h
index 2ea8ae1..580ea82 100644
--- a/commands.h
+++ b/commands.h
@@ -58,7 +58,7 @@ int i_fit_to_win(arg_t);
int i_fit_to_img(arg_t);
int i_rotate(arg_t);
int i_toggle_antialias(arg_t);
-int i_toggle_alpha(arg_t);
+int it_toggle_alpha(arg_t);
int it_open_with(arg_t);
int it_shell_cmd(arg_t);
diff --git a/config.h b/config.h
index aa8bc8a..d5a9463 100644
--- a/config.h
+++ b/config.h
@@ -105,7 +105,7 @@ static const keymap_t keys[] = {
{ False, XK_greater, i_rotate, (arg_t) DIR_RIGHT },
{ False, XK_a, i_toggle_antialias, (arg_t) None },
- { False, XK_A, i_toggle_alpha, (arg_t) None },
+ { False, XK_A, it_toggle_alpha, (arg_t) None },
/* open current image with given program: */
{ True, XK_g, it_open_with, (arg_t) "gimp" },
diff --git a/thumbs.c b/thumbs.c
index 5895c99..5708651 100644
--- a/thumbs.c
+++ b/thumbs.c
@@ -176,6 +176,7 @@ void tns_init(tns_t *tns, int cnt) {
tns->cnt = tns->first = tns->sel = 0;
tns->cap = cnt;
+ tns->alpha = 1;
tns->dirty = 0;
if ((homedir = getenv("HOME"))) {
@@ -335,6 +336,10 @@ void tns_render(tns_t *tns, win_t *win) {
t->x = x + (THUMB_SIZE - t->w) / 2;
t->y = y + (THUMB_SIZE - t->h) / 2;
imlib_context_set_image(t->im);
+
+ if (imlib_image_has_alpha() && !tns->alpha)
+ win_draw_rect(win, win->pm, t->x, t->y, t->w, t->h, True, 0, win->white);
+
imlib_render_image_part_on_drawable_at_size(0, 0, t->w, t->h,
t->x, t->y, t->w, t->h);
if ((i + 1) % tns->cols == 0) {
diff --git a/thumbs.h b/thumbs.h
index 5be09fb..47f7ba8 100644
--- a/thumbs.h
+++ b/thumbs.h
@@ -44,6 +44,7 @@ typedef struct {
int rows;
int first;
int sel;
+ unsigned char alpha;
unsigned char dirty;
} tns_t;