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>
This commit is contained in:
LuXu 2021-10-27 11:00:46 +08:00 committed by NRK
parent 1f01c670c5
commit 57754572bc
5 changed files with 8 additions and 3 deletions

View file

@ -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) if ((int)(img.w * img.zoom) <= win.w && (int)(img.h * img.zoom) <= win.h)
return false; 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); win_cursor_pos(&win, &x, &y);
ox = x; ox = x;
oy = y; oy = y;

View file

@ -158,6 +158,7 @@ static const keymap_t keys[] = {
static const button_t buttons[] = { static const button_t buttons[] = {
/* modifiers button function argument */ /* modifiers button function argument */
{ 0, 1, i_cursor_navigate, None }, { 0, 1, i_cursor_navigate, None },
{ ControlMask, 1, i_drag, DRAG_RELATIVE },
{ 0, 2, i_drag, DRAG_ABSOLUTE }, { 0, 2, i_drag, DRAG_ABSOLUTE },
{ 0, 3, g_switch_mode, None }, { 0, 3, g_switch_mode, None },
{ 0, 4, g_zoom, +1 }, { 0, 4, g_zoom, +1 },

View file

@ -390,6 +390,9 @@ Panning:
Pan the image according to the mouse cursor position in the window while Pan the image according to the mouse cursor position in the window while
keeping this button pressed down. keeping this button pressed down.
.TP .TP
.B Ctrl-Button1
Pan the image relative to the mouse cursor.
.TP
Zooming: Zooming:
.TP .TP
.B ScrollUp .B ScrollUp

View file

@ -99,7 +99,8 @@ typedef enum {
typedef enum { typedef enum {
CURSOR_ARROW, CURSOR_ARROW,
CURSOR_DRAG, CURSOR_DRAG_ABSOLUTE,
CURSOR_DRAG_RELATIVE,
CURSOR_WATCH, CURSOR_WATCH,
CURSOR_LEFT, CURSOR_LEFT,
CURSOR_RIGHT, CURSOR_RIGHT,

View file

@ -51,7 +51,7 @@ 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_fleur }, { XC_watch },
{ XC_sb_left_arrow }, { XC_sb_right_arrow } { XC_sb_left_arrow }, { XC_sb_right_arrow }
}; };