mirror of
https://github.com/LukeSmithxyz/st.git
synced 2025-04-04 02:31:08 +02:00
AlphaFocusHighlight patch instead of Alpha patch
This commit is contained in:
parent
6725a2fde0
commit
69b6d27087
3 changed files with 33 additions and 15 deletions
3
config.h
3
config.h
|
@ -91,7 +91,8 @@ char *termname = "st-256color";
|
|||
unsigned int tabspaces = 8;
|
||||
|
||||
/* bg opacity */
|
||||
float alpha = 0.92;
|
||||
float alpha = 0.92; //< alpha value used when the window is focused.
|
||||
float alphaUnfocussed = 0.8; //< alpha value used when the focus is lost
|
||||
|
||||
/* Terminal colors (16 first used in escape sequence) */
|
||||
static const char *colorname[] = {
|
||||
|
|
1
st.h
1
st.h
|
@ -132,5 +132,6 @@ extern unsigned int tabspaces;
|
|||
extern unsigned int defaultfg;
|
||||
extern unsigned int defaultbg;
|
||||
extern float alpha;
|
||||
extern float alphaUnfocussed;
|
||||
extern MouseKey mkeys[];
|
||||
extern int ximspot_update_interval;
|
||||
|
|
44
x.c
44
x.c
|
@ -4,6 +4,7 @@
|
|||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/select.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
@ -261,6 +262,7 @@ static char *opt_io = NULL;
|
|||
static char *opt_line = NULL;
|
||||
static char *opt_name = NULL;
|
||||
static char *opt_title = NULL;
|
||||
static bool focused = true;
|
||||
|
||||
static int oldbutton = 3; /* button event on startup: 3 = release */
|
||||
|
||||
|
@ -765,6 +767,20 @@ xloadcolor(int i, const char *name, Color *ncolor)
|
|||
return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
|
||||
}
|
||||
|
||||
void
|
||||
xloadalpha(void)
|
||||
{
|
||||
/* set alpha value of bg color */
|
||||
if (opt_alpha)
|
||||
alpha = strtof(opt_alpha, NULL);
|
||||
|
||||
float const usedAlpha = focused ? alpha : alphaUnfocussed;
|
||||
|
||||
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
|
||||
dc.col[defaultbg].pixel &= 0x00FFFFFF;
|
||||
dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
|
||||
}
|
||||
|
||||
void
|
||||
xloadcols(void)
|
||||
{
|
||||
|
@ -788,19 +804,9 @@ xloadcols(void)
|
|||
die("could not allocate color %d\n", i);
|
||||
}
|
||||
|
||||
/* set alpha value of bg color */
|
||||
if (opt_alpha)
|
||||
alpha = strtof(opt_alpha, NULL);
|
||||
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
|
||||
dc.col[defaultbg].color.red =
|
||||
((unsigned short)(dc.col[defaultbg].color.red * alpha)) & 0xff00;
|
||||
dc.col[defaultbg].color.green =
|
||||
((unsigned short)(dc.col[defaultbg].color.green * alpha)) & 0xff00;
|
||||
dc.col[defaultbg].color.blue =
|
||||
((unsigned short)(dc.col[defaultbg].color.blue * alpha)) & 0xff00;
|
||||
dc.col[defaultbg].pixel &= 0x00FFFFFF;
|
||||
dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
|
||||
loaded = 1;
|
||||
xloadalpha();
|
||||
loaded = 1;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1812,13 +1818,23 @@ focus(XEvent *ev)
|
|||
XSetICFocus(xw.xic);
|
||||
win.mode |= MODE_FOCUSED;
|
||||
xseturgency(0);
|
||||
if (IS_SET(MODE_FOCUS))
|
||||
ttywrite("\033[I", 3, 0);
|
||||
if (!focused) {
|
||||
focused = true;
|
||||
xloadalpha();
|
||||
redraw();
|
||||
}
|
||||
} else {
|
||||
XUnsetICFocus(xw.xic);
|
||||
win.mode &= ~MODE_FOCUSED;
|
||||
if (IS_SET(MODE_FOCUS))
|
||||
ttywrite("\033[O", 3, 0);
|
||||
if (focused) {
|
||||
focused = false;
|
||||
xloadalpha();
|
||||
redraw();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue