From cb8626410c58cfce2289f4891556f13e2e5ffa4f Mon Sep 17 00:00:00 2001 From: yuzu-eva Date: Fri, 16 Dec 2022 17:09:21 +0100 Subject: added changealpha function --- x.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'x.c') diff --git a/x.c b/x.c index 6b74bc1..18237ef 100644 --- a/x.c +++ b/x.c @@ -55,6 +55,7 @@ static void clipcopy(const Arg *); static void clippaste(const Arg *); static void numlock(const Arg *); static void selpaste(const Arg *); +static void changealpha(const Arg *); static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); @@ -166,6 +167,7 @@ static void xsetenv(void); static void xseturgency(int); static int evcol(XEvent *); static int evrow(XEvent *); +static float clamp(float, float, float); static void expose(XEvent *); static void visibility(XEvent *); @@ -298,6 +300,18 @@ numlock(const Arg *dummy) win.mode ^= MODE_NUMLOCK; } +void +changealpha(const Arg *arg) +{ + if((alpha > 0 && arg->f < 0) || (alpha < 1 && arg->f > 0)) + alpha += arg->f; + alpha = clamp(alpha, 0.0, 1.0); + alphaUnfocused = clamp(alpha-alphaOffset, 0.0, 1.0); + + xloadcols(); + redraw(); +} + void zoom(const Arg *arg) { @@ -351,6 +365,15 @@ evrow(XEvent *e) return y / win.ch; } +float +clamp(float value, float lower, float upper) { + if(value < lower) + return lower; + if(value > upper) + return upper; + return value; +} + void mousesel(XEvent *e, int done) { @@ -2228,6 +2251,7 @@ run: cols = MAX(cols, 1); rows = MAX(rows, 1); defaultbg = MAX(LEN(colorname), 256); + alphaUnfocused = alpha-alphaOffset; tnew(cols, rows); xinit(cols, rows); xsetenv(); -- cgit v1.2.3