diff options
| author | Markus Teich <markus.teich@stusta.mhn.de> | 2015-05-08 17:10:15 +0200 |
|---|---|---|
| committer | Markus Teich <markus.teich@stusta.mhn.de> | 2015-05-08 18:07:05 +0200 |
| commit | 754195f8d75586e23d1cc69cad00710802e0cb5d (patch) | |
| tree | 78fa30d75f06f43ebce1b4d66f122e6fb762164a | |
| parent | 10d4e479c5f6d91bf86e15be3a12c6b09c9808be (diff) | |
rework setting window color
| -rw-r--r-- | slock.c | 17 |
1 files changed, 7 insertions, 10 deletions
| @@ -119,11 +119,12 @@ readpw(Display *dpy, const char *pws) | |||
| 119 | { | 119 | { |
| 120 | char buf[32], passwd[256]; | 120 | char buf[32], passwd[256]; |
| 121 | int num, screen; | 121 | int num, screen; |
| 122 | unsigned int len, llen; | 122 | unsigned int len, color; |
| 123 | KeySym ksym; | 123 | KeySym ksym; |
| 124 | XEvent ev; | 124 | XEvent ev; |
| 125 | static int oldc = INIT; | ||
| 125 | 126 | ||
| 126 | len = llen = 0; | 127 | len = 0; |
| 127 | running = True; | 128 | running = True; |
| 128 | 129 | ||
| 129 | /* As "slock" stands for "Simple X display locker", the DPMS settings | 130 | /* As "slock" stands for "Simple X display locker", the DPMS settings |
| @@ -174,18 +175,14 @@ readpw(Display *dpy, const char *pws) | |||
| 174 | } | 175 | } |
| 175 | break; | 176 | break; |
| 176 | } | 177 | } |
| 177 | if (llen == 0 && len != 0) { | 178 | color = len ? INPUT : (failure || failonclear ? FAILED : INIT); |
| 179 | if (oldc != color) { | ||
| 178 | for (screen = 0; screen < nscreens; screen++) { | 180 | for (screen = 0; screen < nscreens; screen++) { |
| 179 | XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[INPUT]); | 181 | XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]); |
| 180 | XClearWindow(dpy, locks[screen]->win); | ||
| 181 | } | ||
| 182 | } else if (llen != 0 && len == 0) { | ||
| 183 | for (screen = 0; screen < nscreens; screen++) { | ||
| 184 | XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[failure || failonclear ? FAILED : INIT]); | ||
| 185 | XClearWindow(dpy, locks[screen]->win); | 182 | XClearWindow(dpy, locks[screen]->win); |
| 186 | } | 183 | } |
| 184 | oldc = color; | ||
| 187 | } | 185 | } |
| 188 | llen = len; | ||
| 189 | } else if (rr && ev.type == rrevbase + RRScreenChangeNotify) { | 186 | } else if (rr && ev.type == rrevbase + RRScreenChangeNotify) { |
| 190 | XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev; | 187 | XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev; |
| 191 | for (screen = 0; screen < nscreens; screen++) { | 188 | for (screen = 0; screen < nscreens; screen++) { |
