From ed69b483ed9d37818f483ccc9340ca7c197724d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Sat, 11 Jan 2014 22:52:37 +0100 Subject: Double click on thumbnail to open image --- main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 9fe0010..be91d68 100644 --- a/main.c +++ b/main.c @@ -553,6 +553,7 @@ void on_keypress(XKeyEvent *kev) void on_buttonpress(XButtonEvent *bev) { int i, sel; + static Time firstclick; if (bev == NULL) return; @@ -580,17 +581,20 @@ void on_buttonpress(XButtonEvent *bev) switch (bev->button) { case Button1: if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) { - if (sel == tns.sel) { + if (sel != tns.sel) { + tns_highlight(&tns, tns.sel, false); + tns_highlight(&tns, sel, true); + tns.sel = sel; + firstclick = bev->time; + redraw(); + } else if (bev->time - firstclick <= TO_DOUBLE_CLICK) { mode = MODE_IMAGE; set_timeout(reset_cursor, TO_CURSOR_HIDE, true); load_image(tns.sel); + redraw(); } else { - tns_highlight(&tns, tns.sel, false); - tns_highlight(&tns, sel, true); - tns.sel = sel; + firstclick = bev->time; } - redraw(); - break; } break; case Button3: -- cgit v1.2.3