Merge pull request #208 from trissim/wal-osc

Pywal live reload with OSC patch and transparency fix
This commit is contained in:
Luke Smith 2020-05-13 18:10:29 -04:00 committed by GitHub
commit 74b68b32fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 5 deletions

View file

@ -143,8 +143,8 @@ static const char *colorname[] = {
*/ */
unsigned int defaultfg = 259; unsigned int defaultfg = 259;
unsigned int defaultbg = 258; unsigned int defaultbg = 258;
static unsigned int defaultcs = 256; unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257; unsigned int defaultrcs = 257;
/* /*
* Default shape of cursor * Default shape of cursor

17
st.c
View file

@ -1943,12 +1943,23 @@ strhandle(void)
} }
return; return;
case 4: /* color set */ case 4: /* color set */
if (narg < 3) case 10: /* foreground set */
case 11: /* background set */
case 12: /* cursor color */
if ((par == 4 && narg < 3) || narg < 2)
break; break;
p = strescseq.args[2]; p = strescseq.args[((par == 4) ? 2 : 1)];
/* FALLTHROUGH */ /* FALLTHROUGH */
case 104: /* color reset, here p = NULL */ case 104: /* color reset, here p = NULL */
if (par == 10)
j = defaultfg;
else if (par == 11)
j = defaultbg;
else if (par == 12)
j = defaultcs;
else
j = (narg > 1) ? atoi(strescseq.args[1]) : -1; j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
if (xsetcolorname(j, p)) { if (xsetcolorname(j, p)) {
if (par == 104 && narg <= 1) if (par == 104 && narg <= 1)
return; /* color reset without parameter */ return; /* color reset without parameter */
@ -1959,6 +1970,8 @@ strhandle(void)
* TODO if defaultbg color is changed, borders * TODO if defaultbg color is changed, borders
* are dirty * are dirty
*/ */
if (j == defaultbg)
xclearwin();
redraw(); redraw();
} }
return; return;

1
st.h
View file

@ -140,6 +140,7 @@ extern char *termname;
extern unsigned int tabspaces; extern unsigned int tabspaces;
extern unsigned int defaultfg; extern unsigned int defaultfg;
extern unsigned int defaultbg; extern unsigned int defaultbg;
extern unsigned int defaultcs;
extern const int boxdraw, boxdraw_bold, boxdraw_braille; extern const int boxdraw, boxdraw_bold, boxdraw_braille;
extern float alpha; extern float alpha;
extern MouseKey mkeys[]; extern MouseKey mkeys[];

1
win.h
View file

@ -37,3 +37,4 @@ void xsetpointermotion(int);
void xsetsel(char *); void xsetsel(char *);
int xstartdraw(void); int xstartdraw(void);
void xximspot(int, int); void xximspot(int, int);
void xclearwin(void);

9
x.c
View file

@ -814,6 +814,8 @@ xsetcolorname(int x, const char *name)
XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]); XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]);
dc.col[x] = ncolor; dc.col[x] = ncolor;
if (x == defaultbg)
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
return 0; return 0;
} }
@ -829,6 +831,13 @@ xclear(int x1, int y1, int x2, int y2)
x1, y1, x2-x1, y2-y1); x1, y1, x2-x1, y2-y1);
} }
void
xclearwin(void)
{
xclear(0, 0, win.w, win.h);
}
void void
xhints(void) xhints(void)
{ {