Krolyxon
Commit ed69b48

Branches

Refs →

nsxived69b48

Double click on thumbnail to open image

Author
Bert Münnich
Date
2014-01-11 22:52 +0100
Parent
304fd38
Commit
ed69b483ed9d37818f483ccc9340ca7c197724d5

+12 −7

2 files changed

  1. M main.c +10 −6
  2. M types.h +2 −1
M main.c View
@@ -553,6 +553,7 @@ void on_keypress(XKeyEvent *kev)
553553 void on_buttonpress(XButtonEvent *bev)
554554 {
555555 int i, sel;
556+ static Time firstclick;
556557
557558 if (bev == NULL)
558559 return;
@@ -580,17 +581,20 @@ void on_buttonpress(XButtonEvent *bev)
580581 switch (bev->button) {
581582 case Button1:
582583 if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) {
583− if (sel == tns.sel) {
584+ if (sel != tns.sel) {
585+ tns_highlight(&tns, tns.sel, false);
586+ tns_highlight(&tns, sel, true);
587+ tns.sel = sel;
588+ firstclick = bev->time;
589+ redraw();
590+ } else if (bev->time - firstclick <= TO_DOUBLE_CLICK) {
584591 mode = MODE_IMAGE;
585592 set_timeout(reset_cursor, TO_CURSOR_HIDE, true);
586593 load_image(tns.sel);
594+ redraw();
587595 } else {
588− tns_highlight(&tns, tns.sel, false);
589− tns_highlight(&tns, sel, true);
590− tns.sel = sel;
596+ firstclick = bev->time;
591597 }
592− redraw();
593− break;
594598 }
595599 break;
596600 case Button3:
M types.h View
@@ -76,7 +76,8 @@ typedef struct {
7676 enum {
7777 TO_REDRAW_RESIZE = 75,
7878 TO_REDRAW_THUMBS = 200,
79− TO_CURSOR_HIDE = 1200
79+ TO_CURSOR_HIDE = 1200,
80+ TO_DOUBLE_CLICK = 300
8081 };
8182
8283 typedef void (*timeout_f)(void);