diff options
-rw-r--r-- | src/events.c | 9 | ||||
-rw-r--r-- | src/thumbnail.c | 47 | ||||
-rw-r--r-- | src/thumbnail.h | 1 |
3 files changed, 30 insertions, 27 deletions
diff --git a/src/events.c b/src/events.c index fe87513..5fa44c1 100644 --- a/src/events.c +++ b/src/events.c @@ -492,20 +492,13 @@ static void feh_event_handle_MotionNotify(XEvent * ev) while (XCheckTypedWindowEvent(disp, ev->xmotion.window, MotionNotify, ev)); winwid = winwidget_get_from_window(ev->xmotion.window); if ((winwid != NULL) && (winwid->type == WIN_TYPE_THUMBNAIL)) { - static feh_thumbnail *last_thumb = NULL; feh_thumbnail *thumbnail; int x, y; x = (ev->xbutton.x - winwid->im_x) / winwid->zoom; y = (ev->xbutton.y - winwid->im_y) / winwid->zoom; thumbnail = feh_thumbnail_get_thumbnail_from_coords(x, y); - if (thumbnail != last_thumb) { - if (thumbnail) - feh_thumbnail_mark_selected(winwid, thumbnail); - else - winwidget_render_image(winwid, 0, 0); - } - last_thumb = thumbnail; + feh_thumbnail_mark_selected(winwid, thumbnail); } } return; diff --git a/src/thumbnail.c b/src/thumbnail.c index 4dbc76f..e997364 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -929,25 +929,34 @@ void feh_thumbnail_show_fullsize(feh_file *thumbfile) void feh_thumbnail_mark_selected(winwidget winwid, feh_thumbnail *thumbnail) { Imlib_Image origwin; - origwin = winwid->im; - winwid->im = gib_imlib_clone_image(origwin); - gib_imlib_image_fill_rectangle(winwid->im, - thumbnail->x, thumbnail->y, thumbnail->w, - thumbnail->h, 50, 50, 255, 100); - gib_imlib_image_draw_rectangle(winwid->im, - thumbnail->x, thumbnail->y, thumbnail->w, - thumbnail->h, 255, 255, 255, 255); - gib_imlib_image_draw_rectangle(winwid->im, - thumbnail->x + 1, thumbnail->y + 1, - thumbnail->w - 2, thumbnail->h - 2, - 0, 0, 0, 255); - gib_imlib_image_draw_rectangle(winwid->im, - thumbnail->x + 2, thumbnail->y + 2, - thumbnail->w - 4, thumbnail->h - 4, - 255, 255, 255, 255); - winwidget_render_image(winwid, 0, 0); - gib_imlib_free_image_and_decache(winwid->im); - winwid->im = origwin; + + if (thumbnail == td.selected) + return; + + if (thumbnail) { + origwin = winwid->im; + winwid->im = gib_imlib_clone_image(origwin); + gib_imlib_image_fill_rectangle(winwid->im, + thumbnail->x, thumbnail->y, thumbnail->w, + thumbnail->h, 50, 50, 255, 100); + gib_imlib_image_draw_rectangle(winwid->im, + thumbnail->x, thumbnail->y, thumbnail->w, + thumbnail->h, 255, 255, 255, 255); + gib_imlib_image_draw_rectangle(winwid->im, + thumbnail->x + 1, thumbnail->y + 1, + thumbnail->w - 2, thumbnail->h - 2, + 0, 0, 0, 255); + gib_imlib_image_draw_rectangle(winwid->im, + thumbnail->x + 2, thumbnail->y + 2, + thumbnail->w - 4, thumbnail->h - 4, + 255, 255, 255, 255); + winwidget_render_image(winwid, 0, 0); + gib_imlib_free_image_and_decache(winwid->im); + winwid->im = origwin; + } else + winwidget_render_image(winwid, 0, 0); + + td.selected = thumbnail; } diff --git a/src/thumbnail.h b/src/thumbnail.h index e9c3f09..5bc2864 100644 --- a/src/thumbnail.h +++ b/src/thumbnail.h @@ -63,6 +63,7 @@ typedef struct thumbmode_data { int cache_thumbnails; /* use cached thumbnails from ~/.thumbnails */ int cache_dim; /* 128 = 128x128 ("normal"), 256 = 256x256 ("large") */ char *cache_dir; /* "normal"/"large" (.thumbnails/...) */ + feh_thumbnail *selected; /* currently selected thumbnail */ } thumbmode_data; |