Use the additional alpha-value as offset to support a changing alpha properly
This commit is contained in:
parent
69925ee23b
commit
bb56685063
3 changed files with 17 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
!! Transparency (0-1):
|
!! Transparency (0-1):
|
||||||
st.alpha: 0.92
|
st.alpha: 0.92
|
||||||
st.alphaUnfocus: 0.62
|
st.alphaOffset: 0.3
|
||||||
|
|
||||||
!! Set a default font and font size as below:
|
!! Set a default font and font size as below:
|
||||||
st.font: Monospace-11;
|
st.font: Monospace-11;
|
||||||
|
|
5
config.h
5
config.h
|
@ -108,7 +108,8 @@ unsigned int tabspaces = 8;
|
||||||
|
|
||||||
/* bg opacity */
|
/* bg opacity */
|
||||||
float alpha = 0.8;
|
float alpha = 0.8;
|
||||||
float alphaUnfocus = 0.8;
|
float alphaOffset = 0.0;
|
||||||
|
float alphaUnfocus;
|
||||||
|
|
||||||
/* Terminal colors (16 first used in escape sequence) */
|
/* Terminal colors (16 first used in escape sequence) */
|
||||||
static const char *colorname[] = {
|
static const char *colorname[] = {
|
||||||
|
@ -219,7 +220,7 @@ ResourcePref resources[] = {
|
||||||
{ "cwscale", FLOAT, &cwscale },
|
{ "cwscale", FLOAT, &cwscale },
|
||||||
{ "chscale", FLOAT, &chscale },
|
{ "chscale", FLOAT, &chscale },
|
||||||
{ "alpha", FLOAT, &alpha },
|
{ "alpha", FLOAT, &alpha },
|
||||||
{ "alphaUnfocus", FLOAT, &alphaUnfocus },
|
{ "alphaOffset", FLOAT, &alphaOffset },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
17
x.c
17
x.c
|
@ -182,6 +182,7 @@ static void xsetenv(void);
|
||||||
static void xseturgency(int);
|
static void xseturgency(int);
|
||||||
static int evcol(XEvent *);
|
static int evcol(XEvent *);
|
||||||
static int evrow(XEvent *);
|
static int evrow(XEvent *);
|
||||||
|
static float clamp(float, float, float);
|
||||||
|
|
||||||
static void expose(XEvent *);
|
static void expose(XEvent *);
|
||||||
static void visibility(XEvent *);
|
static void visibility(XEvent *);
|
||||||
|
@ -319,10 +320,8 @@ changealpha(const Arg *arg)
|
||||||
{
|
{
|
||||||
if((alpha > 0 && arg->f < 0) || (alpha < 1 && arg->f > 0))
|
if((alpha > 0 && arg->f < 0) || (alpha < 1 && arg->f > 0))
|
||||||
alpha += arg->f;
|
alpha += arg->f;
|
||||||
if(alpha < 0)
|
alpha = clamp(alpha, 0.0, 1.0);
|
||||||
alpha = 0;
|
alphaUnfocus = clamp(alpha-alphaOffset, 0.0, 1.0);
|
||||||
if(alpha > 1)
|
|
||||||
alpha = 1;
|
|
||||||
|
|
||||||
xloadcols();
|
xloadcols();
|
||||||
redraw();
|
redraw();
|
||||||
|
@ -381,6 +380,15 @@ evrow(XEvent *e)
|
||||||
return y / win.ch;
|
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
|
void
|
||||||
mousesel(XEvent *e, int done)
|
mousesel(XEvent *e, int done)
|
||||||
{
|
{
|
||||||
|
@ -2298,6 +2306,7 @@ run:
|
||||||
cols = MAX(cols, 1);
|
cols = MAX(cols, 1);
|
||||||
rows = MAX(rows, 1);
|
rows = MAX(rows, 1);
|
||||||
defaultbg = MAX(LEN(colorname), 256);
|
defaultbg = MAX(LEN(colorname), 256);
|
||||||
|
alphaUnfocus = alpha-alphaOffset;
|
||||||
tnew(cols, rows);
|
tnew(cols, rows);
|
||||||
xinit(cols, rows);
|
xinit(cols, rows);
|
||||||
xsetenv();
|
xsetenv();
|
||||||
|
|
Loading…
Reference in a new issue