summaryrefslogtreecommitdiff
path: root/slock.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2015-05-08 17:10:15 +0200
committerMarkus Teich <markus.teich@stusta.mhn.de>2015-05-08 18:07:05 +0200
commit754195f8d75586e23d1cc69cad00710802e0cb5d (patch)
tree78fa30d75f06f43ebce1b4d66f122e6fb762164a /slock.c
parent10d4e479c5f6d91bf86e15be3a12c6b09c9808be (diff)
downloadslock-754195f8d75586e23d1cc69cad00710802e0cb5d.tar.gz
rework setting window color
Diffstat (limited to 'slock.c')
-rw-r--r--slock.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/slock.c b/slock.c
index 68e813f..d6053af 100644
--- a/slock.c
+++ b/slock.c
@@ -119,11 +119,12 @@ readpw(Display *dpy, const char *pws)
{
char buf[32], passwd[256];
int num, screen;
- unsigned int len, llen;
+ unsigned int len, color;
KeySym ksym;
XEvent ev;
+ static int oldc = INIT;
- len = llen = 0;
+ len = 0;
running = True;
/* As "slock" stands for "Simple X display locker", the DPMS settings
@@ -174,18 +175,14 @@ readpw(Display *dpy, const char *pws)
}
break;
}
- if (llen == 0 && len != 0) {
+ color = len ? INPUT : (failure || failonclear ? FAILED : INIT);
+ if (oldc != color) {
for (screen = 0; screen < nscreens; screen++) {
- XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[INPUT]);
- XClearWindow(dpy, locks[screen]->win);
- }
- } else if (llen != 0 && len == 0) {
- for (screen = 0; screen < nscreens; screen++) {
- XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[failure || failonclear ? FAILED : INIT]);
+ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]);
XClearWindow(dpy, locks[screen]->win);
}
+ oldc = color;
}
- llen = len;
} else if (rr && ev.type == rrevbase + RRScreenChangeNotify) {
XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev;
for (screen = 0; screen < nscreens; screen++) {