6 Commits
1.4 ... master

Author SHA1 Message Date
krrishg
ad511590d5 Change user and group 2020-07-18 13:27:16 +05:45
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
4 changed files with 28 additions and 8 deletions

2
README
View File

@@ -1,6 +1,6 @@
slock - simple screen locker
============================
simple screen locker utility for X.
simple screen locker utility for X.
Requirements

View File

@@ -1,6 +1,6 @@
/* user and group to drop privileges to */
static const char *user = "nobody";
static const char *group = "nogroup";
static const char *user = "krrish";
static const char *group = "krrish";
static const char *colorname[NUMCOLS] = {
[INIT] = "black", /* after initialization */

12
config.h Normal file
View File

@@ -0,0 +1,12 @@
/* user and group to drop privileges to */
static const char *user = "krrish";
static const char *group = "krrish";
static const char *colorname[NUMCOLS] = {
[INIT] = "black", /* after initialization */
[INPUT] = "#005577", /* during input */
[FAILED] = "#CC3333", /* wrong password */
};
/* treat a cleared input like a wrong password (color) */
static const int failonclear = 1;

18
slock.c
View File

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