Improve mouse support
None of the mouse mappings uses a keyboard modifier, making it possible to access the most basic features by only using the mouse. Next/previous image with left button depending on cursor position, middle button for dragging, right button for switching to thumnail mode and wheel for zooming. Users can keep the old behaviour by simply not adapting the changes to the buttons array in config.def.h to their config.h file.
This commit is contained in:
parent
ee908ca0a1
commit
8081cbebf3
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
VERSION := git-20171005
|
VERSION := git-20171006
|
||||||
|
|
||||||
all: sxiv
|
all: sxiv
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
void remove_file(int, bool);
|
void remove_file(int, bool);
|
||||||
void load_image(int);
|
void load_image(int);
|
||||||
void open_info(void);
|
void open_info(void);
|
||||||
|
int ptr_third_x(void);
|
||||||
void redraw(void);
|
void redraw(void);
|
||||||
void reset_cursor(void);
|
void reset_cursor(void);
|
||||||
void animate(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 _)
|
bool ci_alternate(arg_t _)
|
||||||
{
|
{
|
||||||
load_image(alternate);
|
load_image(alternate);
|
||||||
|
|
|
@ -16,6 +16,7 @@ G_CMD(navigate_marked)
|
||||||
G_CMD(change_gamma)
|
G_CMD(change_gamma)
|
||||||
|
|
||||||
I_CMD(navigate)
|
I_CMD(navigate)
|
||||||
|
I_CMD(cursor_navigate)
|
||||||
I_CMD(alternate)
|
I_CMD(alternate)
|
||||||
I_CMD(navigate_frame)
|
I_CMD(navigate_frame)
|
||||||
I_CMD(toggle_animation)
|
I_CMD(toggle_animation)
|
||||||
|
|
14
config.def.h
14
config.def.h
|
@ -150,17 +150,11 @@ static const keymap_t keys[] = {
|
||||||
/* mouse button mappings for image mode: */
|
/* mouse button mappings for image mode: */
|
||||||
static const button_t buttons[] = {
|
static const button_t buttons[] = {
|
||||||
/* modifiers button function argument */
|
/* modifiers button function argument */
|
||||||
{ 0, 1, i_navigate, +1 },
|
{ 0, 1, i_cursor_navigate, None },
|
||||||
{ 0, 3, i_navigate, -1 },
|
|
||||||
{ 0, 2, i_drag, None },
|
{ 0, 2, i_drag, None },
|
||||||
{ 0, 4, i_scroll, DIR_UP },
|
{ 0, 3, g_switch_mode, None },
|
||||||
{ 0, 5, i_scroll, DIR_DOWN },
|
{ 0, 4, g_zoom, +1 },
|
||||||
{ ShiftMask, 4, i_scroll, DIR_LEFT },
|
{ 0, 5, g_zoom, -1 },
|
||||||
{ 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 },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
30
main.c
30
main.c
|
@ -98,6 +98,10 @@ timeout_t timeouts[] = {
|
||||||
{ { 0, 0 }, false, clear_resize },
|
{ { 0, 0 }, false, clear_resize },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cursor_t imgcursor[3] = {
|
||||||
|
CURSOR_ARROW, CURSOR_ARROW, CURSOR_ARROW
|
||||||
|
};
|
||||||
|
|
||||||
void cleanup(void)
|
void cleanup(void)
|
||||||
{
|
{
|
||||||
img_close(&img, false);
|
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)
|
void redraw(void)
|
||||||
{
|
{
|
||||||
int t;
|
int t;
|
||||||
|
@ -428,14 +440,18 @@ void redraw(void)
|
||||||
|
|
||||||
void reset_cursor(void)
|
void reset_cursor(void)
|
||||||
{
|
{
|
||||||
int i;
|
int c, i;
|
||||||
cursor_t cursor = CURSOR_NONE;
|
cursor_t cursor = CURSOR_NONE;
|
||||||
|
|
||||||
if (mode == MODE_IMAGE) {
|
if (mode == MODE_IMAGE) {
|
||||||
for (i = 0; i < ARRLEN(timeouts); i++) {
|
for (i = 0; i < ARRLEN(timeouts); i++) {
|
||||||
if (timeouts[i].handler == reset_cursor) {
|
if (timeouts[i].handler == reset_cursor) {
|
||||||
if (timeouts[i].active)
|
if (timeouts[i].active) {
|
||||||
cursor = CURSOR_ARROW;
|
c = ptr_third_x();
|
||||||
|
c = MAX(fileidx > 0 ? 0 : 1, c);
|
||||||
|
c = MIN(fileidx + 1 < filecnt ? 2 : 1, c);
|
||||||
|
cursor = imgcursor[c];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -872,6 +888,14 @@ int main(int argc, char **argv)
|
||||||
filecnt = fileidx;
|
filecnt = fileidx;
|
||||||
fileidx = options->startnum < filecnt ? options->startnum : 0;
|
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);
|
win_init(&win);
|
||||||
img_init(&img, &win);
|
img_init(&img, &win);
|
||||||
arl_init(&arl);
|
arl_init(&arl);
|
||||||
|
|
28
sxiv.1
28
sxiv.1
|
@ -348,37 +348,27 @@ seconds.
|
||||||
.SH MOUSE COMMANDS
|
.SH MOUSE COMMANDS
|
||||||
The following mouse mappings are available in image mode:
|
The following mouse mappings are available in image mode:
|
||||||
.TP
|
.TP
|
||||||
|
General:
|
||||||
|
.TP
|
||||||
|
.B Button3
|
||||||
Navigate image list:
|
Navigate image list:
|
||||||
.TP
|
.TP
|
||||||
.B Button1
|
.B Button1
|
||||||
Go to next image.
|
Go to the next image if the mouse cursor is in the right part of the window or
|
||||||
.TP
|
to the previous image if it is in the left part.
|
||||||
.B Button3
|
|
||||||
Go to the previous image.
|
|
||||||
.TP
|
.TP
|
||||||
Panning:
|
Panning:
|
||||||
.TP
|
.TP
|
||||||
.B Button2
|
.B Button2
|
||||||
Drag the image with the mouse while keeping this button pressed down.
|
Pan the image according to the mouse cursor position in the window while
|
||||||
.TP
|
keeping this button pressed down.
|
||||||
.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.
|
|
||||||
.TP
|
.TP
|
||||||
Zooming:
|
Zooming:
|
||||||
.TP
|
.TP
|
||||||
.B Ctrl+ScrollUp
|
.B ScrollUp
|
||||||
Zoom in.
|
Zoom in.
|
||||||
.TP
|
.TP
|
||||||
.B Ctrl+ScrollDown
|
.B ScrollDown
|
||||||
Zoom out.
|
Zoom out.
|
||||||
.SH STATUS BAR
|
.SH STATUS BAR
|
||||||
The information displayed on the left side of the status bar can be replaced
|
The information displayed on the left side of the status bar can be replaced
|
||||||
|
|
2
types.h
2
types.h
|
@ -67,6 +67,8 @@ typedef enum {
|
||||||
CURSOR_ARROW,
|
CURSOR_ARROW,
|
||||||
CURSOR_DRAG,
|
CURSOR_DRAG,
|
||||||
CURSOR_WATCH,
|
CURSOR_WATCH,
|
||||||
|
CURSOR_LEFT,
|
||||||
|
CURSOR_RIGHT,
|
||||||
CURSOR_NONE,
|
CURSOR_NONE,
|
||||||
|
|
||||||
CURSOR_COUNT
|
CURSOR_COUNT
|
||||||
|
|
3
window.c
3
window.c
|
@ -39,7 +39,8 @@ static struct {
|
||||||
int name;
|
int name;
|
||||||
Cursor icon;
|
Cursor icon;
|
||||||
} cursors[CURSOR_COUNT] = {
|
} 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;
|
static GC gc;
|
||||||
|
|
Loading…
Reference in a new issue