summaryrefslogtreecommitdiff
path: root/slock
diff options
context:
space:
mode:
authorauric <104602845+ihateamongus@users.noreply.github.com>2025-09-07 22:42:45 -0500
committerauric <104602845+ihateamongus@users.noreply.github.com>2025-09-07 22:42:45 -0500
commit2020c8059e6328a3020e4d8c7cfd2265a9dc7caa (patch)
treee7ec5cdfe6ae687bcf047f5f8d4fd17dae8a1df1 /slock
parentc1f57a70f482dab6d5c6326b17195aadce7fb63b (diff)
Add accent-aware ascii logo with blurred background
Diffstat (limited to 'slock')
-rw-r--r--slock/config.mk4
-rw-r--r--slock/slock.c400
2 files changed, 288 insertions, 116 deletions
diff --git a/slock/config.mk b/slock/config.mk
index dcd27d0..5c17d5e 100644
--- a/slock/config.mk
+++ b/slock/config.mk
@@ -11,8 +11,8 @@ X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib
# includes and libs
-INCS = -I. -I/usr/include -I${X11INC}
-LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr
+INCS = -I. -I/usr/include -I${X11INC} $(shell pkg-config --cflags xft imlib2)
+LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr $(shell pkg-config --libs xft imlib2)
# flags
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
diff --git a/slock/slock.c b/slock/slock.c
index f16781f..2ecc59d 100644
--- a/slock/slock.c
+++ b/slock/slock.c
@@ -15,10 +15,15 @@
#include <unistd.h>
#include <spawn.h>
#include <sys/types.h>
+#include <time.h>
+#include <poll.h>
#include <X11/extensions/Xrandr.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
+#include <X11/Xft/Xft.h>
+#include <Imlib2.h>
+#include "../accent.h"
#include "arg.h"
#include "util.h"
@@ -33,20 +38,152 @@ enum {
};
struct lock {
- int screen;
- Window root, win;
- Pixmap pmap;
- unsigned long colors[NUMCOLS];
+ int screen;
+ Window root, win;
+ Pixmap pmap;
+ Pixmap bgmap;
+ unsigned long colors[NUMCOLS];
+ XftDraw *draw;
};
struct xrandr {
- int active;
- int evbase;
- int errbase;
+ int active;
+ int evbase;
+ int errbase;
};
#include "config.h"
+static ColorShm *accentshm;
+static char accentcol[8] = "#005577";
+static XftFont *font;
+
+static const char *icon[] = {
+" ██████████████ ██████████████ ",
+" ██████████████ █████████████ ",
+" ██████▓▓▓█████ █████▓▓▓██████ ",
+" █████▓▓▓▓█████ █████▓▓▓▓█████ ",
+" █████▓▓▓▓█████ █████▓▓▓▓█████ ",
+" █████▓▓▓▓▓████ ████▓▓▓▓▓█████ ",
+" █████▓▓▓▓▓████████ █████████████████████ ████████▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓█████ █████████████████████ █████▓▓▓▓▓▓▓██████ ",
+"▓▓▓▓▓▓▓▓ ██████▓▓▓▓▓▓▓█████ █████████████████████ █████▓▓▓▓▓▓▓██████ ▓▓▓▓▓▓▓▓",
+"▓▓▓▓▓▓▓▓▓ █████▓▓▓▓▓████ ████▓▒▒▒▒▓▓▓▒▒▒▒▓████ ████▓▓▓▓▓█████ ▓▓▓▓▓▓▓▓▓",
+"▓▓▓▓▓▓▓▓▓ █████▓▓▓▓▓████ ████▓▒▒▒▒▓▓▓▒▒▒▒▓████ ████▓▓▓▓▓█████ ▓▓▓▓▓▓▓▓▓",
+"▓▓▓▓▒░░░▒▓▓▓▓ █████▓▓▓▓▓▓▓▓█████▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓█████▓▓▓▓▓▓▓▓█████ ▓▓▓▓▒░░░▒▓▓▓▓",
+"▓▓▓▓▒░░░▒▓▓▓▓ █████▓▓▓▓▓▓▓▓█████▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓█████▓▓▓▓▓▓▓▓█████ ▓▓▓▓▒░░░░▓▓▓▓",
+"▓▓▓▓▒▒▒▒░░░░▒▓▓▓▓ █████████▓▓▓▓▓▒▒▒▓███▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓███▓▒▒▒▒▓▓▓▓█████████ ▓▓▓▓▒░░░░▒▒▒▒▓▓▓▓",
+" ▒▒▒▒▒░░░░▒▓▓▓▓ ██████████▓▓▓▒▒▒▒▓███▓▓▓▓▓███████████▓▓▓▓▓███▓▒▒▒▒▓▓▓▓█████████ ▓▓▓▓▒░░░░▒▒▒▒▒ ",
+" ▓▓▓▓▓░░░░▒▒▒▒▓▓▓▓████████████▓▒▒▒▓███████▓▓▓▓█████▓▓▓▓███████▓▒▒▒▒▓████████████▓▓▓▒▒▒▒░░░░▒▓▓▓▓ ",
+" ████▓▒░░░░░░▒▒▓▓▓████████████▓▒▒▒▓████████▓▓▓▓▓▓▓▓▓▓▓████████▓▒▒▒▓████████████▓▓▓▓▒░░░░░░░▓████ ",
+" ████▓▒▒▒▒░░░░▒▓▓▓▓███████████▓▒▒▒▓▓▓▓████▓▒▒▒▒▒▒▒▒▒▒▒▓████▓▓▓▓▒▒▒▓████████████▓▓▓▒▒░░░▒▒▒▒▓████ ",
+" ▓▓▓▓▓▒░░░▒▒▒▒▓▓▓▓▓███████▓▒▒▒▒▒▒▒▓███▒░░░░░░░░░░░▒▓██▓▒▒▒▒▒▒▒▒▓██████▓▓▓▓▓▒▒▒▒░░░▒▓▓▓▓▓ ",
+" ▓▓▓▓▓▒░░░▒▒▒▒▒▓▓▓▓███████▓▒▒▒▒▒▒▒▓███▒░░░░░░░░░░▒▓██▓▒▒▒▒▒▒▒▓▓██████▓▓▓▓▓▒▒▒▒░░░▒▓▓▓▓▓ ",
+" ▓▓▓▓▓▒░░░▒▒▒▒▒▒▒▒▓▓▓▓████▓▓▓▒▒░░░▒███▒░░░░░░░░░░░▒▓██▓░░░▒▒▓▓▓████▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▓▓▓▓▓ ",
+" ▓▓▓▓▓▒░░░▒▒▒▒▒▒▒▒▓▓▓▓████▓▓▓▒▒░░░▒███▒░░░░░░░░░░░▒▓██▓░░░▒▒▓▓▓████▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▓▓▓▓▓ ",
+" ▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▓██████▓▒░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░▒▓██████▓▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓ ",
+" ▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▓██████▓▒░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░░▒▓██████▓▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓ ",
+" ████▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓████ ",
+" ████▓▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███▓▓▓▓▓▓▓▓▓▓▓▓▓███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓▓████ ",
+" █████▓▓▓▓▓███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███▓▓▓▓█████ ",
+" █████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████████████ ",
+" █████▓▓▓▓████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████▓▓▓▓█████ ",
+" ████▓▓▒▒▒▓███████████▓▓▓▓▓▓▓▓▒░░░░░░░░░░░░░░░░░░░▒▒▓▓▓▓▓▓▓███████████▓▒▒▒▒▓████ ",
+" ████▓▓▓▓▒▒▒▒▓▓▓▓████████▓▓▓▓▓▓▓▓▒▒▒▒▒░░░░░░░░░░░░▒▒▒▒▓▓▓▓▓▓▓▓█████████▓▓▓▒▒▒▒▓▓▓▓████ ",
+" █████▓▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓████████████▓▓▓▓▒░░░░░░░░░░░▒▓▓▓▓████████████▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓█████ ",
+" █████▓▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓████████████▓▓▓▓▒░░░░░░░░░░░▒▓▓▓▓████████████▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓█████ ",
+" █████▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓███████████████████████████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓█████ ",
+" █████▓▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓██████████████████████████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▓█████ ",
+" █████▓▓▓▓▓▓▓▓▓▓▓▓█████████████████████▓▓▓██████▓▓█████████████████████▓▓▓▓▓▓▓▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓▓████████▓▓▓█████████████▓▓▓█████▓▓▓█████████████▓▓▓████████▓▓▓▓▓▓▓▓▓█████ ",
+" █████████▓▓▓▓▓████████▓▓▓▓████████████▓▓▓█████▓▓▓▓████████████▓▓▓████████▓▓▓▓▓█████████ ",
+" █████▓▓▓▓▓████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓████████▓▓▓▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓▓████████▓▓▓█████████▓▓▓▓▓▓▓▓▓▓▓█████████▓▓▓████████▓▓▓▓▓▓▓▓██████ ",
+" ██████▓▓▓▓▓▓▓▓████████████████████▓▓▓▓▓▓▓▓▓▓▓████████████████████▓▓▓▓▓▓▓▓██████ ",
+" ██████████████████████████████████▓▓▓▓▓▓▓▓▓▓▓██████████████████████████████████ ",
+" ██████████████████████████████████▓▓▓▓▓▓▓▓▓▓▓██████████████████████████████████ ",
+" ██████▓▓▓▓▓▓██████▓▓▓████▓▓▓▓▓████▓▓▓██████▓▓▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓█████▓▓▓████▓▓▓▓▓████▓▓▓██████▓▓▓▓▓▓▓█████ ",
+" █████▓▓▓▓▓▓▓▓█████████████████████████████▓▓▓▓▓▓▓▓█████ ",
+" █████▓▓▓▓▓▓▓▓█████████▓▓▓█████▓▓▓█████████▓▓▓▓▓▓▓▓█████ ",
+" ██████▓▓▓▓▓▓▓█████████▓▓▓▓███▓▓▓▓██████████▓▓▓▓▓▓██████ ",
+" ██████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██████████████████ ",
+" █████████████████████▓▓▓▓▓▓▓▓▓▓▓▓▓█████████████████████ ",
+" ████████████████▓▓▓▓▓▓▓▓▓▓▓██████████████████ ",
+" ██████████████████████████████████████████████ ",
+" █████████████ ",
+" █████████████ ",
+NULL};
+
+static void
+updateaccent(void)
+{
+ if (!readaccent(&accentshm, accentcol))
+ memcpy(accentcol, "#005577", 8);
+}
+
+static void
+drawlogo(Display *dpy, struct lock *lock, const char *col)
+{
+ XftColor xftc;
+ XGlyphInfo ext;
+ int i, x, y, w, h, lines = 0, maxw = 0, lineh;
+
+ w = DisplayWidth(dpy, lock->screen);
+ h = DisplayHeight(dpy, lock->screen);
+ lineh = font->ascent + font->descent;
+
+ for (i = 0; icon[i]; i++) {
+ XftTextExtentsUtf8(dpy, font, (FcChar8 *)icon[i], strlen(icon[i]), &ext);
+ if (ext.xOff > maxw)
+ maxw = ext.xOff;
+ lines++;
+ }
+ x = (w - maxw) / 2;
+ y = (h - lines * lineh) / 2 + font->ascent;
+
+ if (!XftColorAllocName(dpy, DefaultVisual(dpy, lock->screen),
+ DefaultColormap(dpy, lock->screen), col, &xftc))
+ return;
+
+ XClearWindow(dpy, lock->win);
+ for (i = 0; icon[i]; i++) {
+ XftDrawStringUtf8(lock->draw, &xftc, font, x, y,
+ (FcChar8 *)icon[i], strlen(icon[i]));
+ y += lineh;
+ }
+
+ XftColorFree(dpy, DefaultVisual(dpy, lock->screen),
+ DefaultColormap(dpy, lock->screen), &xftc);
+}
+
+static void
+blurbackground(Display *dpy, struct lock *lock)
+{
+ int w = DisplayWidth(dpy, lock->screen);
+ int h = DisplayHeight(dpy, lock->screen);
+
+ imlib_context_set_display(dpy);
+ imlib_context_set_visual(DefaultVisual(dpy, lock->screen));
+ imlib_context_set_colormap(DefaultColormap(dpy, lock->screen));
+ imlib_context_set_drawable(lock->root);
+
+ Imlib_Image img = imlib_create_image_from_drawable(0, 0, 0, w, h, 1);
+ if (!img)
+ return;
+ imlib_context_set_image(img);
+ imlib_image_blur(20);
+
+ lock->bgmap = XCreatePixmap(dpy, lock->root, w, h,
+ DefaultDepth(dpy, lock->screen));
+ imlib_context_set_drawable(lock->bgmap);
+ imlib_render_image_on_drawable(0, 0);
+ imlib_free_image();
+
+ XSetWindowBackgroundPixmap(dpy, lock->win, lock->bgmap);
+}
+
static void
die(const char *errstr, ...)
{
@@ -129,98 +266,125 @@ static void
readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
const char *hash)
{
- XRRScreenChangeNotifyEvent *rre;
- char buf[32], passwd[256], *inputhash;
- int num, screen, running, failure, oldc;
- unsigned int len, color;
- KeySym ksym;
- XEvent ev;
-
- len = 0;
- running = 1;
- failure = 0;
- oldc = INIT;
-
- while (running && !XNextEvent(dpy, &ev)) {
- if (ev.type == KeyPress) {
- explicit_bzero(&buf, sizeof(buf));
- num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
- if (IsKeypadKey(ksym)) {
- if (ksym == XK_KP_Enter)
- ksym = XK_Return;
- else if (ksym >= XK_KP_0 && ksym <= XK_KP_9)
- ksym = (ksym - XK_KP_0) + XK_0;
- }
- if (IsFunctionKey(ksym) ||
- IsKeypadKey(ksym) ||
- IsMiscFunctionKey(ksym) ||
- IsPFKey(ksym) ||
- IsPrivateKeypadKey(ksym))
- continue;
- switch (ksym) {
- case XK_Return:
- passwd[len] = '\0';
- errno = 0;
- if (!(inputhash = crypt(passwd, hash)))
- fprintf(stderr, "slock: crypt: %s\n", strerror(errno));
- else
- running = !!strcmp(inputhash, hash);
- if (running) {
- XBell(dpy, 100);
- failure = 1;
- }
- explicit_bzero(&passwd, sizeof(passwd));
- len = 0;
- break;
- case XK_Escape:
- explicit_bzero(&passwd, sizeof(passwd));
- len = 0;
- break;
- case XK_BackSpace:
- if (len)
- passwd[--len] = '\0';
- break;
- default:
- if (num && !iscntrl((int)buf[0]) &&
- (len + num < sizeof(passwd))) {
- memcpy(passwd + len, buf, num);
- len += num;
- } else if (buf[0] == '\025') { /* ctrl-u clears input */
- explicit_bzero(&passwd, sizeof(passwd));
- len = 0;
- }
- break;
- }
- color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT);
- if (running && oldc != color) {
- for (screen = 0; screen < nscreens; screen++) {
- XSetWindowBackground(dpy,
- locks[screen]->win,
- locks[screen]->colors[color]);
- XClearWindow(dpy, locks[screen]->win);
- }
- oldc = color;
- }
- } else if (rr->active && ev.type == rr->evbase + RRScreenChangeNotify) {
- rre = (XRRScreenChangeNotifyEvent*)&ev;
- for (screen = 0; screen < nscreens; screen++) {
- if (locks[screen]->win == rre->window) {
- if (rre->rotation == RR_Rotate_90 ||
- rre->rotation == RR_Rotate_270)
- XResizeWindow(dpy, locks[screen]->win,
- rre->height, rre->width);
- else
- XResizeWindow(dpy, locks[screen]->win,
- rre->width, rre->height);
- XClearWindow(dpy, locks[screen]->win);
- break;
- }
- }
- } else {
- for (screen = 0; screen < nscreens; screen++)
- XRaiseWindow(dpy, locks[screen]->win);
- }
- }
+ XRRScreenChangeNotifyEvent *rre;
+ char buf[32], passwd[256], *inputhash;
+ int num, screen, running, failure;
+ unsigned int len;
+ KeySym ksym;
+ XEvent ev;
+ struct pollfd pfd;
+ time_t last;
+ const char *col, *oldcol = NULL;
+ char lastaccent[8];
+
+ len = 0;
+ running = 1;
+ failure = 0;
+
+ updateaccent();
+ memcpy(lastaccent, accentcol, 8);
+ col = accentcol;
+ last = time(NULL);
+ for (screen = 0; screen < nscreens; screen++)
+ drawlogo(dpy, locks[screen], col);
+
+ pfd.fd = ConnectionNumber(dpy);
+ pfd.events = POLLIN;
+
+ while (running) {
+ if (poll(&pfd, 1, 1000) > 0) {
+ while (XPending(dpy)) {
+ XNextEvent(dpy, &ev);
+ if (ev.type == KeyPress) {
+ last = time(NULL);
+ explicit_bzero(&buf, sizeof(buf));
+ num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
+ if (IsKeypadKey(ksym)) {
+ if (ksym == XK_KP_Enter)
+ ksym = XK_Return;
+ else if (ksym >= XK_KP_0 && ksym <= XK_KP_9)
+ ksym = (ksym - XK_KP_0) + XK_0;
+ }
+ if (IsFunctionKey(ksym) ||
+ IsKeypadKey(ksym) ||
+ IsMiscFunctionKey(ksym) ||
+ IsPFKey(ksym) ||
+ IsPrivateKeypadKey(ksym))
+ continue;
+ switch (ksym) {
+ case XK_Return:
+ passwd[len] = '\0';
+ errno = 0;
+ if (!(inputhash = crypt(passwd, hash)))
+ fprintf(stderr, "slock: crypt: %s\n", strerror(errno));
+ else
+ running = !!strcmp(inputhash, hash);
+ if (running) {
+ XBell(dpy, 100);
+ failure = 1;
+ }
+ explicit_bzero(&passwd, sizeof(passwd));
+ len = 0;
+ break;
+ case XK_Escape:
+ explicit_bzero(&passwd, sizeof(passwd));
+ len = 0;
+ break;
+ case XK_BackSpace:
+ if (len)
+ passwd[--len] = '\0';
+ break;
+ default:
+ if (num && !iscntrl((int)buf[0]) &&
+ (len + num < sizeof(passwd))) {
+ memcpy(passwd + len, buf, num);
+ len += num;
+ } else if (buf[0] == '\025') { /* ctrl-u clears input */
+ explicit_bzero(&passwd, sizeof(passwd));
+ len = 0;
+ }
+ break;
+ }
+ } else if (rr->active && ev.type == rr->evbase + RRScreenChangeNotify) {
+ rre = (XRRScreenChangeNotifyEvent*)&ev;
+ for (screen = 0; screen < nscreens; screen++) {
+ if (locks[screen]->win == rre->window) {
+ if (rre->rotation == RR_Rotate_90 ||
+ rre->rotation == RR_Rotate_270)
+ XResizeWindow(dpy, locks[screen]->win,
+ rre->height, rre->width);
+ else
+ XResizeWindow(dpy, locks[screen]->win,
+ rre->width, rre->height);
+ XClearWindow(dpy, locks[screen]->win);
+ drawlogo(dpy, locks[screen], col);
+ break;
+ }
+ }
+ } else {
+ for (screen = 0; screen < nscreens; screen++)
+ XRaiseWindow(dpy, locks[screen]->win);
+ }
+ }
+ }
+
+ updateaccent();
+ int idle = time(NULL) - last >= 3;
+
+ if (!idle && len)
+ col = colorname[INPUT];
+ else if (!idle && (failure || failonclear))
+ col = colorname[FAILED];
+ else
+ col = accentcol;
+
+ if ((col == accentcol && memcmp(accentcol, lastaccent, 8) != 0) || col != oldcol) {
+ memcpy(lastaccent, accentcol, 8);
+ for (screen = 0; screen < nscreens; screen++)
+ drawlogo(dpy, locks[screen], col);
+ oldcol = col;
+ }
+ }
}
static struct lock *
@@ -239,26 +403,34 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
lock->screen = screen;
lock->root = RootWindow(dpy, lock->screen);
- for (i = 0; i < NUMCOLS; i++) {
- XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen),
- colorname[i], &color, &dummy);
- lock->colors[i] = color.pixel;
- }
+ for (i = 0; i < NUMCOLS; i++) {
+ XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen),
+ colorname[i], &color, &dummy);
+ lock->colors[i] = color.pixel;
+ }
/* init */
- wa.override_redirect = 1;
- wa.background_pixel = lock->colors[INIT];
- 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);
+ wa.override_redirect = 1;
+ wa.background_pixel = lock->colors[INIT];
+ 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);
lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);
invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap,
&color, &color, 0, 0);
- XDefineCursor(dpy, lock->win, invisible);
+ XDefineCursor(dpy, lock->win, invisible);
+
+ blurbackground(dpy, lock);
+
+ if (!font)
+ font = XftFontOpenName(dpy, lock->screen, "monospace:size=10");
+ lock->draw = XftDrawCreate(dpy, lock->win,
+ DefaultVisual(dpy, lock->screen),
+ DefaultColormap(dpy, lock->screen));
/* Try to grab mouse pointer *and* keyboard for 600ms, else fail the lock */
for (i = 0, ptgrab = kbgrab = -1; i < 6; i++) {