aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuXu <oliver_lew@outlook.com>2021-10-27 11:00:46 +0800
committerNRK <nrk@disroot.org>2021-10-27 09:02:07 +0600
commit57754572bc20769575b888565dc192c9d6e14f05 (patch)
tree30b655219d372924b1820a1733401278b49d9944
parent1f01c670c5fac1829e46ed8bc6b033e3680e645f (diff)
Add default key-binding for DRAG_RELATIVE (#117)
Ctrl-Button1 now has a relative drag using the XC_fleur cursor. XC_fleur is normally the cursor for "size all" action, which has 4 arrows pointing to 4 directions. Co-authored-by: NRK <nrk@disroot.org>
-rw-r--r--commands.c2
-rw-r--r--config.def.h1
-rw-r--r--nsxiv.13
-rw-r--r--nsxiv.h3
-rw-r--r--window.c2
5 files changed, 8 insertions, 3 deletions
diff --git a/commands.c b/commands.c
index e52b381..b7fe9f4 100644
--- a/commands.c
+++ b/commands.c
@@ -338,7 +338,7 @@ bool ci_drag(arg_t mode)
if ((int)(img.w * img.zoom) <= win.w && (int)(img.h * img.zoom) <= win.h)
return false;
- win_set_cursor(&win, CURSOR_DRAG);
+ win_set_cursor(&win, mode == DRAG_ABSOLUTE ? CURSOR_DRAG_ABSOLUTE : CURSOR_DRAG_RELATIVE);
win_cursor_pos(&win, &x, &y);
ox = x;
oy = y;
diff --git a/config.def.h b/config.def.h
index 39135ff..1085a39 100644
--- a/config.def.h
+++ b/config.def.h
@@ -158,6 +158,7 @@ static const keymap_t keys[] = {
static const button_t buttons[] = {
/* modifiers button function argument */
{ 0, 1, i_cursor_navigate, None },
+ { ControlMask, 1, i_drag, DRAG_RELATIVE },
{ 0, 2, i_drag, DRAG_ABSOLUTE },
{ 0, 3, g_switch_mode, None },
{ 0, 4, g_zoom, +1 },
diff --git a/nsxiv.1 b/nsxiv.1
index 27b0914..04228a9 100644
--- a/nsxiv.1
+++ b/nsxiv.1
@@ -390,6 +390,9 @@ Panning:
Pan the image according to the mouse cursor position in the window while
keeping this button pressed down.
.TP
+.B Ctrl-Button1
+Pan the image relative to the mouse cursor.
+.TP
Zooming:
.TP
.B ScrollUp
diff --git a/nsxiv.h b/nsxiv.h
index 45d1772..8f288b3 100644
--- a/nsxiv.h
+++ b/nsxiv.h
@@ -99,7 +99,8 @@ typedef enum {
typedef enum {
CURSOR_ARROW,
- CURSOR_DRAG,
+ CURSOR_DRAG_ABSOLUTE,
+ CURSOR_DRAG_RELATIVE,
CURSOR_WATCH,
CURSOR_LEFT,
CURSOR_RIGHT,
diff --git a/window.c b/window.c
index 5e1392f..1c4eed6 100644
--- a/window.c
+++ b/window.c
@@ -51,7 +51,7 @@ static struct {
int name;
Cursor icon;
} cursors[CURSOR_COUNT] = {
- { XC_left_ptr }, { XC_dotbox }, { XC_watch },
+ { XC_left_ptr }, { XC_dotbox }, { XC_fleur }, { XC_watch },
{ XC_sb_left_arrow }, { XC_sb_right_arrow }
};