diff --git a/Makefile b/Makefile index 2c5b701..9e29648 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := git-20171005 +VERSION := git-20171006 all: sxiv diff --git a/commands.c b/commands.c index 522413d..6c5fb1a 100644 --- a/commands.c +++ b/commands.c @@ -33,6 +33,7 @@ void remove_file(int, bool); void load_image(int); void open_info(void); +int ptr_third_x(void); void redraw(void); void reset_cursor(void); void animate(void); @@ -281,6 +282,11 @@ bool ci_navigate(arg_t n) } } +bool ci_cursor_navigate(arg_t _) +{ + return ci_navigate(ptr_third_x() - 1); +} + bool ci_alternate(arg_t _) { load_image(alternate); diff --git a/commands.lst b/commands.lst index a658dd4..bf9e3ed 100644 --- a/commands.lst +++ b/commands.lst @@ -16,6 +16,7 @@ G_CMD(navigate_marked) G_CMD(change_gamma) I_CMD(navigate) +I_CMD(cursor_navigate) I_CMD(alternate) I_CMD(navigate_frame) I_CMD(toggle_animation) diff --git a/config.def.h b/config.def.h index e211c0d..5af745d 100644 --- a/config.def.h +++ b/config.def.h @@ -150,17 +150,11 @@ static const keymap_t keys[] = { /* mouse button mappings for image mode: */ static const button_t buttons[] = { /* modifiers button function argument */ - { 0, 1, i_navigate, +1 }, - { 0, 3, i_navigate, -1 }, + { 0, 1, i_cursor_navigate, None }, { 0, 2, i_drag, None }, - { 0, 4, i_scroll, DIR_UP }, - { 0, 5, i_scroll, DIR_DOWN }, - { ShiftMask, 4, i_scroll, DIR_LEFT }, - { ShiftMask, 5, i_scroll, DIR_RIGHT }, - { 0, 6, i_scroll, DIR_LEFT }, - { 0, 7, i_scroll, DIR_RIGHT }, - { ControlMask, 4, g_zoom, +1 }, - { ControlMask, 5, g_zoom, -1 }, + { 0, 3, g_switch_mode, None }, + { 0, 4, g_zoom, +1 }, + { 0, 5, g_zoom, -1 }, }; #endif diff --git a/main.c b/main.c index 5a828a9..406c2b9 100644 --- a/main.c +++ b/main.c @@ -98,6 +98,10 @@ timeout_t timeouts[] = { { { 0, 0 }, false, clear_resize }, }; +cursor_t imgcursor[3] = { + CURSOR_ARROW, CURSOR_ARROW, CURSOR_ARROW +}; + void cleanup(void) { img_close(&img, false); @@ -405,6 +409,14 @@ void update_info(void) } } +int ptr_third_x(void) +{ + int x, y; + + win_cursor_pos(&win, &x, &y); + return MAX(0, MIN(2, (x / (win.w * 0.33)))); +} + void redraw(void) { int t; @@ -428,14 +440,18 @@ void redraw(void) void reset_cursor(void) { - int i; + int c, i; cursor_t cursor = CURSOR_NONE; if (mode == MODE_IMAGE) { for (i = 0; i < ARRLEN(timeouts); i++) { if (timeouts[i].handler == reset_cursor) { - if (timeouts[i].active) - cursor = CURSOR_ARROW; + if (timeouts[i].active) { + c = ptr_third_x(); + c = MAX(fileidx > 0 ? 0 : 1, c); + c = MIN(fileidx + 1 < filecnt ? 2 : 1, c); + cursor = imgcursor[c]; + } break; } } @@ -872,6 +888,14 @@ int main(int argc, char **argv) filecnt = fileidx; fileidx = options->startnum < filecnt ? options->startnum : 0; + for (i = 0; i < ARRLEN(buttons); i++) { + if (buttons[i].cmd == i_cursor_navigate) { + imgcursor[0] = CURSOR_LEFT; + imgcursor[2] = CURSOR_RIGHT; + break; + } + } + win_init(&win); img_init(&img, &win); arl_init(&arl); diff --git a/sxiv.1 b/sxiv.1 index bf738f8..e8cb04a 100644 --- a/sxiv.1 +++ b/sxiv.1 @@ -348,37 +348,27 @@ seconds. .SH MOUSE COMMANDS The following mouse mappings are available in image mode: .TP +General: +.TP +.B Button3 Navigate image list: .TP .B Button1 -Go to next image. -.TP -.B Button3 -Go to the previous image. +Go to the next image if the mouse cursor is in the right part of the window or +to the previous image if it is in the left part. .TP Panning: .TP .B Button2 -Drag the image with the mouse while keeping this button pressed down. -.TP -.B ScrollUp -Scroll image up. -.TP -.B ScrollDown -Scroll image down. -.TP -.B Shift+ScrollUp -Scroll image left. -.TP -.B Shift+ScrollDown -Scroll image right. +Pan the image according to the mouse cursor position in the window while +keeping this button pressed down. .TP Zooming: .TP -.B Ctrl+ScrollUp +.B ScrollUp Zoom in. .TP -.B Ctrl+ScrollDown +.B ScrollDown Zoom out. .SH STATUS BAR The information displayed on the left side of the status bar can be replaced diff --git a/types.h b/types.h index eacbd62..6c3fb3d 100644 --- a/types.h +++ b/types.h @@ -67,6 +67,8 @@ typedef enum { CURSOR_ARROW, CURSOR_DRAG, CURSOR_WATCH, + CURSOR_LEFT, + CURSOR_RIGHT, CURSOR_NONE, CURSOR_COUNT diff --git a/window.c b/window.c index be2c9fa..463e52a 100644 --- a/window.c +++ b/window.c @@ -39,7 +39,8 @@ static struct { int name; Cursor icon; } cursors[CURSOR_COUNT] = { - { XC_left_ptr }, { XC_dotbox }, { XC_watch } + { XC_left_ptr }, { XC_dotbox }, { XC_watch }, + { XC_sb_left_arrow }, { XC_sb_right_arrow } }; static GC gc;