summaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorN-R-K <79544946+N-R-K@users.noreply.github.com>2022-01-10 17:52:06 +0100
committerGitHub <noreply@github.com>2022-01-10 17:52:06 +0100
commit7a75c42b37b08f44c72f9a7c98eb6076967470fb (patch)
tree9171a7929d43cb2a6d72703374970ac7e60c9509 /commands.c
parent157cda5b31d51ea1379d907489fa982bcba36f44 (diff)
downloadnsxiv-7a75c42b37b08f44c72f9a7c98eb6076967470fb.tar.zst
make thumbnail bindings configureable via config.h (#167)
this allows for configuring thumbnail mode mouse bindings similar to image mode bindings. however we can't put the thumbnails bindings into the existing buttons[] array due to fallthrough. For example M3 would switch mode and then end up selecting an image. which is why thumbnail bindings have been put into it's own array `buttons_tns[]` and `buttons[]` has been renamed to `buttons_img[]` for consistency. Closes: https://github.com/nsxiv/nsxiv/issues/131
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/commands.c b/commands.c
index a751c94..aafc510 100644
--- a/commands.c
+++ b/commands.c
@@ -42,6 +42,7 @@ extern appmode_t mode;
extern img_t img;
extern tns_t tns;
extern win_t win;
+extern const XButtonEvent *xbutton_ev;
extern fileinfo_t *files;
extern int filecnt, fileidx;
@@ -436,3 +437,57 @@ bool ct_reload_all(arg_t _)
tns.dirty = true;
return true;
}
+
+bool ct_scroll(arg_t dir)
+{
+ return tns_scroll(&tns, dir, false);
+}
+
+bool ct_drag_mark_image(arg_t _)
+{
+ int sel;
+
+ if ((sel = tns_translate(&tns, xbutton_ev->x, xbutton_ev->y)) >= 0) {
+ XEvent e;
+ bool on = !(files[sel].flags & FF_MARK);
+
+ while (true) {
+ if (sel >= 0 && mark_image(sel, on))
+ redraw();
+ XMaskEvent(win.env.dpy,
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask, &e);
+ if (e.type == ButtonPress || e.type == ButtonRelease)
+ break;
+ while (XCheckTypedEvent(win.env.dpy, MotionNotify, &e));
+ sel = tns_translate(&tns, e.xbutton.x, e.xbutton.y);
+ }
+ }
+
+ return false;
+}
+
+bool ct_select(arg_t _)
+{
+ int sel;
+ bool dirty = false;
+ static Time firstclick;
+
+ if ((sel = tns_translate(&tns, xbutton_ev->x, xbutton_ev->y)) >= 0) {
+ if (sel != fileidx) {
+ tns_highlight(&tns, fileidx, false);
+ tns_highlight(&tns, sel, true);
+ fileidx = sel;
+ firstclick = xbutton_ev->time;
+ dirty = true;
+ } else if (xbutton_ev->time - firstclick <= TO_DOUBLE_CLICK) {
+ mode = MODE_IMAGE;
+ set_timeout(reset_cursor, TO_CURSOR_HIDE, true);
+ load_image(fileidx);
+ dirty = true;
+ } else {
+ firstclick = xbutton_ev->time;
+ }
+ }
+
+ return dirty;
+}