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.
master
Miles Alan 5 years ago
parent a50f1d3093
commit 92e048a153
  1. 4
      programs/sxmo_screenlock.c

@ -6,6 +6,7 @@
#include <unistd.h> #include <unistd.h>
#include <X11/keysym.h> #include <X11/keysym.h>
#include <X11/XF86keysym.h> #include <X11/XF86keysym.h>
#include <X11/XKBlib.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -177,7 +178,7 @@ readinputloop(Display *dpy, int screen) {
if (FD_ISSET(xfd, &fdset) && XPending(dpy)) { if (FD_ISSET(xfd, &fdset) && XPending(dpy)) {
XNextEvent(dpy, &ev); XNextEvent(dpy, &ev);
if (ev.type == KeyPress) { if (ev.type == KeyRelease) {
XLookupString(&ev.xkey, buf, sizeof(buf), &keysym, 0); XLookupString(&ev.xkey, buf, sizeof(buf), &keysym, 0);
if (lastkeysym == keysym) { if (lastkeysym == keysym) {
lastkeyn++; lastkeyn++;
@ -282,6 +283,7 @@ main(int argc, char **argv) {
if (!(dpy = XOpenDisplay(NULL))) if (!(dpy = XOpenDisplay(NULL)))
die("Cannot open display\n"); die("Cannot open display\n");
XkbSetDetectableAutoRepeat(dpy, True, NULL);
screen = XDefaultScreen(dpy); screen = XDefaultScreen(dpy);
XSync(dpy, 0); XSync(dpy, 0);
getoldbrightness(); getoldbrightness();

Loading…
Cancel
Save