ソースを参照

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.
master
Bert Münnich 7年前
コミット
8081cbebf3
8個のファイルの変更52行の追加34行の削除
  1. +1
    -1
      Makefile
  2. +6
    -0
      commands.c
  3. +1
    -0
      commands.lst
  4. +4
    -10
      config.def.h
  5. +27
    -3
      main.c
  6. +9
    -19
      sxiv.1
  7. +2
    -0
      types.h
  8. +2
    -1
      window.c

+ 1
- 1
Makefile ファイルの表示

@@ -1,4 +1,4 @@
VERSION := git-20171005
VERSION := git-20171006

all: sxiv



+ 6
- 0
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);


+ 1
- 0
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)


+ 4
- 10
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

+ 27
- 3
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);


+ 9
- 19
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


+ 2
- 0
types.h ファイルの表示

@@ -67,6 +67,8 @@ typedef enum {
CURSOR_ARROW,
CURSOR_DRAG,
CURSOR_WATCH,
CURSOR_LEFT,
CURSOR_RIGHT,
CURSOR_NONE,

CURSOR_COUNT


+ 2
- 1
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;


読み込み中…
キャンセル
保存