Update title when moving selection

This commit is contained in:
Bert 2011-02-19 09:47:53 +01:00
parent c6726ed331
commit a367d35ba0
4 changed files with 22 additions and 13 deletions

View file

@ -1,6 +1,6 @@
all: sxiv
VERSION=git-20110218
VERSION=git-20110219
CC?=gcc
PREFIX?=/usr/local

12
main.c
View file

@ -386,7 +386,7 @@ void on_keypress(XKeyEvent *kev) {
else
tns.sel = 0;
mode = MODE_THUMBS;
changed = 1;
changed = tns.dirty = 1;
}
break;
@ -416,19 +416,19 @@ void on_keypress(XKeyEvent *kev) {
/* move selection */
case XK_h:
case XK_Left:
tns_move_selection(&tns, &win, MOVE_LEFT);
changed = tns_move_selection(&tns, &win, MOVE_LEFT);
break;
case XK_j:
case XK_Down:
tns_move_selection(&tns, &win, MOVE_DOWN);
changed = tns_move_selection(&tns, &win, MOVE_DOWN);
break;
case XK_k:
case XK_Up:
tns_move_selection(&tns, &win, MOVE_UP);
changed = tns_move_selection(&tns, &win, MOVE_UP);
break;
case XK_l:
case XK_Right:
tns_move_selection(&tns, &win, MOVE_RIGHT);
changed = tns_move_selection(&tns, &win, MOVE_RIGHT);
break;
}
}
@ -594,6 +594,8 @@ void run() {
timeout = 75000;
if (mode == MODE_NORMAL)
img.checkpan = 1;
else
tns.dirty = 1;
}
break;
case ClientMessage:

View file

@ -35,6 +35,7 @@ void tns_init(tns_t *tns, int cnt) {
tns->cnt = tns->first = tns->sel = 0;
tns->thumbs = (thumb_t*) s_malloc(cnt * sizeof(thumb_t));
memset(tns->thumbs, 0, cnt * sizeof(thumb_t));
tns->dirty = 0;
}
void tns_free(tns_t *tns, win_t *win) {
@ -81,12 +82,14 @@ void tns_load(tns_t *tns, win_t *win, const char *filename) {
imlib_render_image_part_on_drawable_at_size(0, 0, w, h,
0, 0, t->w, t->h);
imlib_free_image();
tns->dirty = 1;
}
void tns_render(tns_t *tns, win_t *win) {
int i, cnt, x, y;
if (!tns || !win)
if (!tns || !tns->dirty || !win)
return;
tns->cols = MAX(1, win->w / thumb_dim);
@ -117,6 +120,8 @@ void tns_render(tns_t *tns, win_t *win) {
}
}
tns->dirty = 0;
tns_highlight(tns, win, -1);
}
@ -138,13 +143,13 @@ void tns_highlight(tns_t *tns, win_t *win, int old) {
win_draw(win);
}
void tns_move_selection(tns_t *tns, win_t *win, movedir_t dir) {
int tns_move_selection(tns_t *tns, win_t *win, movedir_t dir) {
int sel, old;
if (!tns || !win)
return;
return 0;
sel = tns->sel;
sel = old = tns->sel;
switch (dir) {
case MOVE_LEFT:
@ -165,11 +170,12 @@ void tns_move_selection(tns_t *tns, win_t *win, movedir_t dir) {
break;
}
if (sel != tns->sel && tns->thumbs[sel].x != 0) {
old = tns->sel;
if (sel != old && tns->thumbs[sel].x != 0) {
tns->sel = sel;
tns_highlight(tns, win, old);
}
return sel != old;
}
int tns_translate(tns_t *tns, int x, int y) {

View file

@ -45,6 +45,7 @@ typedef struct tns_s {
int rows;
int first;
int sel;
unsigned char dirty;
} tns_t;
void tns_init(tns_t*, int);
@ -55,7 +56,7 @@ void tns_load(tns_t*, win_t*, const char*);
void tns_render(tns_t*, win_t*);
void tns_highlight(tns_t*, win_t*, int);
void tns_move_selection(tns_t*, win_t*, movedir_t);
int tns_move_selection(tns_t*, win_t*, movedir_t);
int tns_translate(tns_t*, int, int);