summaryrefslogtreecommitdiff
path: root/slock.c
diff options
context:
space:
mode:
authoranselm@garbe.us <unknown>2012-03-17 18:03:25 +0100
committeranselm@garbe.us <unknown>2012-03-17 18:03:25 +0100
commitc1507cd225a34ef69045cfc20519b16212dba8dd (patch)
tree7df367b260e78164983facea5a4855a2f555aaa8 /slock.c
parent88d968496652401eba8fa98615c6196618c91fcd (diff)
downloadslock-c1507cd225a34ef69045cfc20519b16212dba8dd.tar.gz
slock-c1507cd225a34ef69045cfc20519b16212dba8dd.tar.xz
applied Eckehard Bern's dualcolor patch to slock
Diffstat (limited to 'slock.c')
-rw-r--r--slock.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/slock.c b/slock.c
index 96d4379..12b8d4d 100644
--- a/slock.c
+++ b/slock.c
@@ -26,6 +26,7 @@ typedef struct {
int screen;
Window root, win;
Pixmap pmap;
+ unsigned long colors[2];
} Lock;
static Lock **locks;
@@ -81,11 +82,11 @@ readpw(Display *dpy, const char *pws)
{
char buf[32], passwd[256];
int num, screen;
- unsigned int len;
+ unsigned int len, llen;
KeySym ksym;
XEvent ev;
- len = 0;
+ len = llen = 0;
running = True;
/* As "slock" stands for "Simple X display locker", the DPMS settings
@@ -132,6 +133,18 @@ readpw(Display *dpy, const char *pws)
}
break;
}
+ if(llen == 0 && len != 0) {
+ for(screen = 0; screen < nscreens; screen++) {
+ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[1]);
+ 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[0]);
+ XClearWindow(dpy, locks[screen]->win);
+ }
+ }
+ llen = len;
}
else for(screen = 0; screen < nscreens; screen++)
XRaiseWindow(dpy, locks[screen]->win);
@@ -144,6 +157,7 @@ unlockscreen(Display *dpy, Lock *lock) {
return;
XUngrabPointer(dpy, CurrentTime);
+ XFreeColors(dpy, DefaultColormap(dpy, lock->screen), lock->colors, 2, 0);
XFreePixmap(dpy, lock->pmap);
XDestroyWindow(dpy, lock->win);
@@ -155,7 +169,7 @@ lockscreen(Display *dpy, int screen) {
char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
unsigned int len;
Lock *lock;
- XColor black, dummy;
+ XColor color, dummy;
XSetWindowAttributes wa;
Cursor invisible;
@@ -176,9 +190,12 @@ lockscreen(Display *dpy, int screen) {
lock->win = XCreateWindow(dpy, lock->root, 0, 0, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen),
0, DefaultDepth(dpy, lock->screen), CopyFromParent,
DefaultVisual(dpy, lock->screen), CWOverrideRedirect | CWBackPixel, &wa);
- XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), "black", &black, &dummy);
+ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR2, &color, &dummy);
+ lock->colors[1] = color.pixel;
+ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen), COLOR1, &color, &dummy);
+ lock->colors[0] = color.pixel;
lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);
- invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &black, &black, 0, 0);
+ invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);
XDefineCursor(dpy, lock->win, invisible);
XMapRaised(dpy, lock->win);
for(len = 1000; len; len--) {