Introduction
Introduction Statistics Contact Development Disclaimer Help
slock-foreground-image-20211210.diff - sites - public wiki contents of suckless…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
slock-foreground-image-20211210.diff (2564B)
---
1 From: Viliam Kováč <[email protected]>
2 Date: Fri, 10 Dec 2021 17:22:00
3 Subject: [PATCH] Add a image foreground
4 diff --git a/config.def.h b/config.def.h
5 index 9855e21..dfa61d6 100644
6 --- a/config.def.h
7 +++ b/config.def.h
8 @@ -10,3 +10,10 @@ static const char *colorname[NUMCOLS] = {
9
10 /* treat a cleared input like a wrong password (color) */
11 static const int failonclear = 1;
12 +
13 +static const char *imgpath = "img.xpm";
14 +static const int imgwidth = 1920;
15 +static const int imgheight = 1080;
16 +static const int imgoffsetx = 0;
17 +static const int imgoffsety = 0;
18 +static const int showimgonlyatstart = 1;
19 diff --git a/config.mk b/config.mk
20 index 74429ae..6145285 100644
21 --- a/config.mk
22 +++ b/config.mk
23 @@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib
24
25 # includes and libs
26 INCS = -I. -I/usr/include -I${X11INC}
27 -LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr
28 +LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lXpm
29
30 # flags
31 CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
32 diff --git a/slock.c b/slock.c
33 index 5ae738c..b36c347 100644
34 --- a/slock.c
35 +++ b/slock.c
36 @@ -18,6 +18,7 @@
37 #include <X11/keysym.h>
38 #include <X11/Xlib.h>
39 #include <X11/Xutil.h>
40 +#include <X11/xpm.h>
41
42 #include "arg.h"
43 #include "util.h"
44 @@ -124,6 +125,19 @@ gethash(void)
45 return hash;
46 }
47
48 +static void
49 +showimage(Display *dpy, Window win)
50 +{
51 + XImage *ximage;
52 +
53 + if (!XpmReadFileToImage (dpy, imgpath, &ximage, NULL, NULL)) {
54 + XSelectInput(dpy, win, ButtonPressMask|ExposureMask);
55 + XMapWindow(dpy, win);
56 +
57 + XPutImage(dpy, win, DefaultGC(dpy, 0), ximage, 0, 0, imgoffsetx, im…
58 + }
59 +}
60 +
61 static void
62 readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscree…
63 const char *hash)
64 @@ -194,6 +208,8 @@ readpw(Display *dpy, struct xrandr *rr, struct lock …
65 locks[scre…
66 locks[scre…
67 XClearWindow(dpy, locks[screen]…
68 + if (showimgonlyatstart != 1)
69 + showimage(dpy, locks[screen]->win);
70 }
71 oldc = color;
72 }
73 @@ -256,6 +272,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int scre…
74 &color, &color, 0, 0);
75 XDefineCursor(dpy, lock->win, invisible);
76
77 + showimage(dpy, lock->win);
78 +
79 /* Try to grab mouse pointer *and* keyboard for 600ms, else fai…
80 for (i = 0, ptgrab = kbgrab = -1; i < 6; i++) {
81 if (ptgrab != GrabSuccess) {
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.