diff options
author | Moritz Biering <moritzbiering.mb@gmail.com> | 2021-05-06 14:32:57 +0200 |
---|---|---|
committer | Moritz Biering <moritzbiering.mb@gmail.com> | 2021-05-06 14:41:36 +0200 |
commit | bb56685063532f732f4fbdba1d890931dad3d891 (patch) | |
tree | 8c9b5b12df5d8c57530c2945761dff0d9003c958 /x.c | |
parent | 69925ee23b8b1590f65e1f71f2d9ea5156629868 (diff) |
Use the additional alpha-value as offset to support a changing alpha properly
Diffstat (limited to 'x.c')
-rw-r--r-- | x.c | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -182,6 +182,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 *); @@ -319,10 +320,8 @@ changealpha(const Arg *arg) { if((alpha > 0 && arg->f < 0) || (alpha < 1 && arg->f > 0)) alpha += arg->f; - if(alpha < 0) - alpha = 0; - if(alpha > 1) - alpha = 1; + alpha = clamp(alpha, 0.0, 1.0); + alphaUnfocus = clamp(alpha-alphaOffset, 0.0, 1.0); xloadcols(); redraw(); @@ -381,6 +380,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) { @@ -2298,6 +2306,7 @@ run: cols = MAX(cols, 1); rows = MAX(rows, 1); defaultbg = MAX(LEN(colorname), 256); + alphaUnfocus = alpha-alphaOffset; tnew(cols, rows); xinit(cols, rows); xsetenv(); |