diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | commands.c | 6 | ||||
-rw-r--r-- | commands.lst | 1 | ||||
-rw-r--r-- | config.def.h | 14 | ||||
-rw-r--r-- | main.c | 30 | ||||
-rw-r--r-- | sxiv.1 | 28 | ||||
-rw-r--r-- | types.h | 2 | ||||
-rw-r--r-- | window.c | 3 |
8 files changed, 52 insertions, 34 deletions
@@ -1,4 +1,4 @@ -VERSION := git-20171005 +VERSION := git-20171006 all: sxiv @@ -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 @@ -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); @@ -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 @@ -67,6 +67,8 @@ typedef enum { CURSOR_ARROW, CURSOR_DRAG, CURSOR_WATCH, + CURSOR_LEFT, + CURSOR_RIGHT, CURSOR_NONE, CURSOR_COUNT @@ -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; |