From 92e048a153a6bfdf8fbc0544ac8949209af646bb Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Wed, 15 Jul 2020 21:32:16 -0500 Subject: [PATCH] Screenlock: Recognize keyrelease rather than keydown to avoid inadvertent exits E.g. so now you distinctively have to press down the powerbutton three times rather than holding (which is easy to do inadvertently in pocket) to exit screenlock. --- programs/sxmo_screenlock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/programs/sxmo_screenlock.c b/programs/sxmo_screenlock.c index 30231de..c38824b 100644 --- a/programs/sxmo_screenlock.c +++ b/programs/sxmo_screenlock.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -177,7 +178,7 @@ readinputloop(Display *dpy, int screen) { if (FD_ISSET(xfd, &fdset) && XPending(dpy)) { XNextEvent(dpy, &ev); - if (ev.type == KeyPress) { + if (ev.type == KeyRelease) { XLookupString(&ev.xkey, buf, sizeof(buf), &keysym, 0); if (lastkeysym == keysym) { lastkeyn++; @@ -282,6 +283,7 @@ main(int argc, char **argv) { if (!(dpy = XOpenDisplay(NULL))) die("Cannot open display\n"); + XkbSetDetectableAutoRepeat(dpy, True, NULL); screen = XDefaultScreen(dpy); XSync(dpy, 0); getoldbrightness();