Compare commits

...

10 Commits

Author SHA1 Message Date
Hiltjo Posthuma 4f045545a2 bump version to 1.5 2022-10-04 19:45:14 +02:00
Hiltjo Posthuma 265704d736 Makefile: explicit_bzero.c was copied twice (GNU make gives a warning) 2022-10-04 19:44:47 +02:00
Tobias Stoeckmann 35633d4567 Properly clear the last entered character
When enter is pressed, passwd[len] will be set to '\0'. Pressing
backspace is supposed to remove the last entered character.

But currently, the clearing has an off-by-one, as in setting
passwd[len] to '\0' just like enter would do.

You can also verify it by imagining len=1 and that it's impossible to
clear passwd[0] by pressing backspace with the current code.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2017-03-25 21:51:29 +01:00
Markus Teich 2d2a21a90a rm trailing whitespace in README 2016-11-23 00:29:18 +01:00
Markus Teich 325581b935 syntax fix 2016-11-23 00:28:43 +01:00
Markus Teich 0ff0d9f7a7 there can only be one window in the event 2016-11-23 00:28:25 +01:00
Bob Uhl 7a604ec1fa Fix resize with multiple monitors and portrait mode
When connecting/disconnecting a portrait monitor, the
XRRScreenChangeNotifyEvent height & width are reversed due to the XRandR
rotation; detect this and DTRT.
2016-11-23 00:26:51 +01:00
Markus Teich fa11589584 bump version 2016-11-20 01:07:11 +01:00
Markus Teich d5da84cf5a add arg.h and util.h to Makefile 2016-11-20 01:01:47 +01:00
Markus Teich ae96836f90 clarify colors in config.def.h 2016-11-20 00:29:41 +01:00
5 changed files with 22 additions and 14 deletions

View File

@ -18,7 +18,7 @@ options:
@echo CC $< @echo CC $<
@${CC} -c ${CFLAGS} $< @${CC} -c ${CFLAGS} $<
${OBJ}: config.h config.mk ${OBJ}: config.h config.mk arg.h util.h
config.h: config.h:
@echo creating $@ from config.def.h @echo creating $@ from config.def.h
@ -35,8 +35,8 @@ clean:
dist: clean dist: clean
@echo creating dist tarball @echo creating dist tarball
@mkdir -p slock-${VERSION} @mkdir -p slock-${VERSION}
@cp -R LICENSE Makefile README config.def.h config.mk ${SRC} \ @cp -R LICENSE Makefile README slock.1 config.mk \
explicit_bzero.c slock.1 slock-${VERSION} ${SRC} config.def.h arg.h util.h slock-${VERSION}
@tar -cf slock-${VERSION}.tar slock-${VERSION} @tar -cf slock-${VERSION}.tar slock-${VERSION}
@gzip slock-${VERSION}.tar @gzip slock-${VERSION}.tar
@rm -rf slock-${VERSION} @rm -rf slock-${VERSION}

View File

@ -3,10 +3,10 @@ static const char *user = "nobody";
static const char *group = "nogroup"; static const char *group = "nogroup";
static const char *colorname[NUMCOLS] = { static const char *colorname[NUMCOLS] = {
"black", /* after initialization */ [INIT] = "black", /* after initialization */
"#005577", /* during input */ [INPUT] = "#005577", /* during input */
"#CC3333", /* wrong password */ [FAILED] = "#CC3333", /* wrong password */
}; };
/* treat a cleared input like a wrong password */ /* treat a cleared input like a wrong password (color) */
static const int failonclear = 1; static const int failonclear = 1;

View File

@ -1,5 +1,5 @@
# slock version # slock version
VERSION = 1.3 VERSION = 1.5
# Customize below to fit your system # Customize below to fit your system

12
slock.c
View File

@ -177,7 +177,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
break; break;
case XK_BackSpace: case XK_BackSpace:
if (len) if (len)
passwd[len--] = '\0'; passwd[--len] = '\0';
break; break;
default: default:
if (num && !iscntrl((int)buf[0]) && if (num && !iscntrl((int)buf[0]) &&
@ -201,14 +201,22 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
rre = (XRRScreenChangeNotifyEvent*)&ev; rre = (XRRScreenChangeNotifyEvent*)&ev;
for (screen = 0; screen < nscreens; screen++) { for (screen = 0; screen < nscreens; screen++) {
if (locks[screen]->win == rre->window) { 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, XResizeWindow(dpy, locks[screen]->win,
rre->width, rre->height); rre->width, rre->height);
XClearWindow(dpy, locks[screen]->win); XClearWindow(dpy, locks[screen]->win);
break;
} }
} }
} else for (screen = 0; screen < nscreens; screen++) } else {
for (screen = 0; screen < nscreens; screen++)
XRaiseWindow(dpy, locks[screen]->win); XRaiseWindow(dpy, locks[screen]->win);
} }
}
} }
static struct lock * static struct lock *