[hackers] [slock] applied Eckehard Bern's dualcolor patch to slock || anselm

From: <hg_AT_suckless.org>
Date: Sat, 17 Mar 2012 18:03:28 +0100 (CET)

changeset: 51:0eade055cef0
tag: tip
user: anselm_AT_garbe.us
date: Sat Mar 17 18:03:25 2012 +0100
files: config.mk slock.c
description:
applied Eckehard Bern's dualcolor patch to slock


diff -r e0d42e127656 -r 0eade055cef0 config.mk
--- a/config.mk Sat Feb 11 10:51:31 2012 +0100
+++ b/config.mk Sat Mar 17 18:03:25 2012 +0100
_AT_@ -1,5 +1,5 @@
 # slock version
-VERSION = 1.0
+VERSION = 1.0-tip
 
 # Customize below to fit your system
 
_AT_@ -14,7 +14,7 @@
 LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext
 
 # flags
-CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H
+CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\"
 CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
 LDFLAGS = -s ${LIBS}
 
diff -r e0d42e127656 -r 0eade055cef0 slock.c
--- a/slock.c Sat Feb 11 10:51:31 2012 +0100
+++ b/slock.c Sat Mar 17 18:03:25 2012 +0100
_AT_@ -26,6 +26,7 @@
         int screen;
         Window root, win;
         Pixmap pmap;
+ unsigned long colors[2];
 } Lock;
 
 static Lock **locks;
_AT_@ -81,11 +82,11 @@
 {
         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
_AT_@ -132,6 +133,18 @@
                                 }
                                 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);
_AT_@ -144,6 +157,7 @@
                 return;
 
         XUngrabPointer(dpy, CurrentTime);
+ XFreeColors(dpy, DefaultColormap(dpy, lock->screen), lock->colors, 2, 0);
         XFreePixmap(dpy, lock->pmap);
         XDestroyWindow(dpy, lock->win);
 
_AT_@ -155,7 +169,7 @@
         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;
 
_AT_@ -176,9 +190,12 @@
         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--) {
Received on Sat Mar 17 2012 - 18:03:28 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 17 2012 - 18:12:12 CET