Adding alpha-focus-highlight patch
This commit is contained in:
parent
56e208e0de
commit
1a1d492cd8
5 changed files with 85 additions and 2 deletions
60
x.c
60
x.c
|
|
@ -185,6 +185,10 @@ static char *opt_title = NULL;
|
|||
static char *opt_dir = NULL;
|
||||
#endif // WORKINGDIR_PATCH
|
||||
|
||||
#if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
static int focused = 0;
|
||||
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
|
||||
static int oldbutton = 3; /* button event on startup: 3 = release */
|
||||
#if BLINKING_CURSOR_PATCH
|
||||
static int cursorblinks = 0;
|
||||
|
|
@ -772,6 +776,44 @@ xloadcolor(int i, const char *name, Color *ncolor)
|
|||
return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
|
||||
}
|
||||
|
||||
#if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
void
|
||||
xloadalpha(void)
|
||||
{
|
||||
float const usedAlpha = focused ? alpha : alphaUnfocused;
|
||||
if (opt_alpha) alpha = strtof(opt_alpha, NULL);
|
||||
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
|
||||
dc.col[defaultbg].pixel &= 0x00FFFFFF;
|
||||
dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
|
||||
}
|
||||
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
|
||||
#if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
void
|
||||
xloadcols(void)
|
||||
{
|
||||
static int loaded;
|
||||
Color *cp;
|
||||
|
||||
if (!loaded) {
|
||||
dc.collen = 1 + (defaultbg = MAX(LEN(colorname), 256));
|
||||
dc.col = xmalloc((dc.collen) * sizeof(Color));
|
||||
}
|
||||
|
||||
for (int i = 0; i+1 < dc.collen; ++i)
|
||||
if (!xloadcolor(i, NULL, &dc.col[i])) {
|
||||
if (colorname[i])
|
||||
die("could not allocate color '%s'\n", colorname[i]);
|
||||
else
|
||||
die("could not allocate color %d\n", i);
|
||||
}
|
||||
if (dc.collen) // cannot die, as the color is already loaded.
|
||||
xloadcolor(focused ? bg : bgUnfocused, NULL, &dc.col[defaultbg]);
|
||||
|
||||
xloadalpha();
|
||||
loaded = 1;
|
||||
}
|
||||
#else
|
||||
void
|
||||
xloadcols(void)
|
||||
{
|
||||
|
|
@ -804,6 +846,7 @@ xloadcols(void)
|
|||
#endif // ALPHA_PATCH
|
||||
loaded = 1;
|
||||
}
|
||||
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
|
||||
int
|
||||
xsetcolorname(int x, const char *name)
|
||||
|
|
@ -2344,12 +2387,26 @@ focus(XEvent *ev)
|
|||
xseturgency(0);
|
||||
if (IS_SET(MODE_FOCUS))
|
||||
ttywrite("\033[I", 3, 0);
|
||||
#if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
if (!focused) {
|
||||
focused = 1;
|
||||
xloadcols();
|
||||
redraw();
|
||||
}
|
||||
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
} else {
|
||||
if (xw.ime.xic)
|
||||
XUnsetICFocus(xw.ime.xic);
|
||||
win.mode &= ~MODE_FOCUSED;
|
||||
if (IS_SET(MODE_FOCUS))
|
||||
ttywrite("\033[O", 3, 0);
|
||||
#if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
if (focused) {
|
||||
focused = 0;
|
||||
xloadcols();
|
||||
redraw();
|
||||
}
|
||||
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2771,6 +2828,9 @@ run:
|
|||
#endif // XRESOURCES_RELOAD_PATCH
|
||||
cols = MAX(cols, 1);
|
||||
rows = MAX(rows, 1);
|
||||
#if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
defaultbg = MAX(LEN(colorname), 256);
|
||||
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
|
||||
tnew(cols, rows);
|
||||
xinit(cols, rows);
|
||||
xsetenv();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue