aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2014-01-11 22:52:37 +0100
committerBert Münnich <ber.t@posteo.de>2014-01-11 22:52:37 +0100
commited69b483ed9d37818f483ccc9340ca7c197724d5 (patch)
treed6752fc530bd4d93cfd23319da8bc2aa057ca4a9
parent304fd382db98a6a134e0e281cc6f4cf27fb0789a (diff)
Double click on thumbnail to open image
-rw-r--r--main.c16
-rw-r--r--types.h3
2 files changed, 12 insertions, 7 deletions
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:
diff --git a/types.h b/types.h
index 41bfd5e..2e250ce 100644
--- a/types.h
+++ b/types.h
@@ -76,7 +76,8 @@ typedef struct {
enum {
TO_REDRAW_RESIZE = 75,
TO_REDRAW_THUMBS = 200,
- TO_CURSOR_HIDE = 1200
+ TO_CURSOR_HIDE = 1200,
+ TO_DOUBLE_CLICK = 300
};
typedef void (*timeout_f)(void);