X-Git-Url: https://git.xinqibao.xyz/slock.git/blobdiff_plain/27d8d248275ca3eb63882202dcc21ecf2f81e72a..11642443f520a3f7fe6ecfd7411bf18b3f2081d3:/slock.c?ds=sidebyside diff --git a/slock.c b/slock.c index 6541b70..aafc7c0 100644 --- a/slock.c +++ b/slock.c @@ -2,6 +2,9 @@ * See LICENSE file for license details. */ #define _XOPEN_SOURCE 500 +#if HAVE_SHADOW_H +#include +#endif #include #include @@ -9,9 +12,6 @@ #include #include #include -#if HAVE_SHADOW_H -#include -#endif #include #include #include @@ -75,8 +75,6 @@ main(int argc, char **argv) { screen = DefaultScreen(dpy); /* init */ - len = 0; - wa.override_redirect = 1; wa.background_pixel = BlackPixel(dpy, screen); w = XCreateWindow(dpy, RootWindow(dpy, screen), 0, 0, @@ -96,6 +94,7 @@ main(int argc, char **argv) { GrabModeAsync, CurrentTime) != GrabSuccess); len--) usleep(1000); running = running && (len > 0); + len = 0; XMapRaised(dpy, w); XSync(dpy, False); @@ -103,7 +102,7 @@ main(int argc, char **argv) { while(running && !XNextEvent(dpy, &ev)) if(ev.type == KeyPress) { buf[0] = 0; - num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0); + num = XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 0); if(IsFunctionKey(ksym) || IsKeypadKey(ksym) || IsMiscFunctionKey(ksym) || IsPFKey(ksym) || IsPrivateKeypadKey(ksym)) @@ -120,11 +119,11 @@ main(int argc, char **argv) { break; case XK_BackSpace: if(len) - --len; + --len; break; default: if(num && !iscntrl((int) buf[0])) { - memcpy(passwd + len,buf,num); + memcpy(passwd + len, buf, num); len += num; } break;