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.
This commit is contained in:
Miles Alan 2020-07-15 21:32:16 -05:00
vanhempi a50f1d3093
commit 92e048a153

Näytä tiedosto

@ -6,6 +6,7 @@
#include <unistd.h>
#include <X11/keysym.h>
#include <X11/XF86keysym.h>
#include <X11/XKBlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@ -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();