rework setting window color
This commit is contained in:
parent
10d4e479c5
commit
754195f8d7
17
slock.c
17
slock.c
|
@ -119,11 +119,12 @@ readpw(Display *dpy, const char *pws)
|
||||||
{
|
{
|
||||||
char buf[32], passwd[256];
|
char buf[32], passwd[256];
|
||||||
int num, screen;
|
int num, screen;
|
||||||
unsigned int len, llen;
|
unsigned int len, color;
|
||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
static int oldc = INIT;
|
||||||
|
|
||||||
len = llen = 0;
|
len = 0;
|
||||||
running = True;
|
running = True;
|
||||||
|
|
||||||
/* As "slock" stands for "Simple X display locker", the DPMS settings
|
/* As "slock" stands for "Simple X display locker", the DPMS settings
|
||||||
|
@ -174,18 +175,14 @@ readpw(Display *dpy, const char *pws)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (llen == 0 && len != 0) {
|
color = len ? INPUT : (failure || failonclear ? FAILED : INIT);
|
||||||
|
if (oldc != color) {
|
||||||
for (screen = 0; screen < nscreens; screen++) {
|
for (screen = 0; screen < nscreens; screen++) {
|
||||||
XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[INPUT]);
|
XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]);
|
||||||
XClearWindow(dpy, locks[screen]->win);
|
XClearWindow(dpy, locks[screen]->win);
|
||||||
}
|
}
|
||||||
} else if (llen != 0 && len == 0) {
|
oldc = color;
|
||||||
for (screen = 0; screen < nscreens; screen++) {
|
|
||||||
XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[failure || failonclear ? FAILED : INIT]);
|
|
||||||
XClearWindow(dpy, locks[screen]->win);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
llen = len;
|
|
||||||
} else if (rr && ev.type == rrevbase + RRScreenChangeNotify) {
|
} else if (rr && ev.type == rrevbase + RRScreenChangeNotify) {
|
||||||
XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev;
|
XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev;
|
||||||
for (screen = 0; screen < nscreens; screen++) {
|
for (screen = 0; screen < nscreens; screen++) {
|
||||||
|
|
Loading…
Reference in New Issue