summaryrefslogtreecommitdiff
path: root/st
diff options
context:
space:
mode:
Diffstat (limited to 'st')
-rw-r--r--st/x.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/st/x.c b/st/x.c
index 45033b6..0f11bf4 100644
--- a/st/x.c
+++ b/st/x.c
@@ -1596,14 +1596,18 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x
void
chgalpha(const Arg *arg)
{
- if (arg->f == -1.0f && alpha >= 0.1f)
- alpha -= 0.1f;
- else if (arg->f == 1.0f && alpha < 1.0f)
- alpha += 0.1f;
- else if (arg->f == 0.0f)
- alpha = alpha_def;
- else
- return;
+ if (arg->f == 0.0f) {
+ /* reset */
+ alpha = alpha_def;
+ } else {
+ /* relative change: clamp to [0,1] */
+ float newα = alpha + arg->f;
+ if (newα < 0.0f)
+ newα = 0.0f;
+ else if (newα > 1.0f)
+ newα = 1.0f;
+ alpha = newα;
+ }
dc.col[defaultbg].color.alpha = (unsigned short)(0xFFFF * alpha);
/* Required to remove artifacting from borderpx */