From b798d12c693fad69823cb905858179a779d29170 Mon Sep 17 00:00:00 2001 From: speedie Date: Wed, 8 Mar 2023 20:13:39 +0100 Subject: [PATCH] add image gap keybind --- keybinds.h | 10 ++++++++-- libs/arg.c | 21 ++++++++++++++++++--- libs/arg.h | 1 + 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/keybinds.h b/keybinds.h index 0ef9db6..e1f9706 100644 --- a/keybinds.h +++ b/keybinds.h @@ -52,8 +52,14 @@ static Key keys[] = { { 0, SHIFT, XK_minus, setimgsize, {.i = -100 } }, { 0, SHIFT, XK_0, defaultimg, {0} }, { 0, 0, XK_r, rotateimg, {0} }, - { 0, SHIFT, XK_r, setimgpos, {0} }, - { 0, 0, XK_t, toggleimg, {0} }, + { 0, 0, XK_p, setimgpos, {.i = +1 } }, + { 0, CONTROL, XK_1, setimggaps, {.i = -1 } }, + { 0, CONTROL, XK_2, setimggaps, {.i = +1 } }, + { 0, 0, XK_1, setimggaps, {.i = -10 } }, + { 0, 0, XK_2, setimggaps, {.i = +10 } }, + { 0, SHIFT, XK_1, setimggaps, {.i = -100 } }, + { 0, SHIFT, XK_2, setimggaps, {.i = +100 } }, + { 0, SHIFT, XK_t, toggleimg, {0} }, { 0, 0, XK_h, flipimg, {.i = 1 } }, { 0, 0, XK_v, flipimg, {.i = 0 } }, { 0, 0, XK_k, move, {.i = 1 } }, diff --git a/libs/arg.c b/libs/arg.c index cfe717f..2412420 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -325,15 +325,30 @@ flipimg(const Arg *arg) void setimgpos(const Arg *arg) { - if (imageposition++ > 3) { - imageposition = 0; + if (imageposition < 3) { + imageposition += arg->i; } else { - imageposition++; + imageposition = 0; } drawmenu(); } +void +setimggaps(const Arg *arg) +{ + imagegaps += arg->i; + + if (imagegaps < 0) + imagegaps = 0; + + /* limitation to make sure we have a reasonable gap size */ + if (imagegaps > imagewidth / 2) + imagegaps -= arg->i; + + drawmenu(); +} + void rotateimg(const Arg *arg) { diff --git a/libs/arg.h b/libs/arg.h index 269b12e..cfe8e38 100644 --- a/libs/arg.h +++ b/libs/arg.h @@ -28,3 +28,4 @@ static void defaultimg(const Arg *arg); static void rotateimg(const Arg *arg); static void flipimg(const Arg *arg); static void setimgpos(const Arg *arg); +static void setimggaps(const Arg *arg);