[wiki] [sites] [slock][patch][auto-timeout] Fix previous update The previus update I made was boggus : the timout could not be reached unless an X event append. || Adrian Amaglio

From: <git_AT_suckless.org>
Date: Sun, 02 Oct 2022 14:40:29 +0200

commit fe2d23e7280bc6834c82db5cd5a654859ea72a3a
Author: Adrian Amaglio <adrian_AT_amaglio.fr>
Date: Sun Oct 2 14:40:13 2022 +0200

    [slock][patch][auto-timeout] Fix previous update
    The previus update I made was boggus : the timout could not be
    reached unless an X event append.

diff --git a/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff b/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff
index dc073191..974de32e 100644
--- a/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff
+++ b/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff
_AT_@ -16,7 +16,7 @@ index 9855e21..354980b 100644
 +/* command to be run after [timeoffset] seconds has passed */
 +static const char *command = "doas poweroff";
 diff --git a/slock.c b/slock.c
-index 5ae738c..5ece0ae 100644
+index 5ae738c..7644bd9 100644
 --- a/slock.c
 +++ b/slock.c
 _AT_@ -19,11 +19,16 @@
_AT_@ -36,10 +36,21 @@ index 5ae738c..5ece0ae 100644
  enum {
          INIT,
          INPUT,
-_AT_@ -216,6 +221,16 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
- for (screen = 0; screen < nscreens; screen++)
- XRaiseWindow(dpy, locks[screen]->win);
- }
+_AT_@ -140,7 +145,9 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
+ failure = 0;
+ oldc = INIT;
+
+- while (running && !XNextEvent(dpy, &ev)) {
++ while (running) {
++ while (XPending(dpy)) {
++ XNextEvent(dpy, &ev);
+ if (ev.type == KeyPress) {
+ explicit_bzero(&buf, sizeof(buf));
+ num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
+_AT_@ -217,6 +224,17 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
+ XRaiseWindow(dpy, locks[screen]->win);
+ }
+ }
 +
 + time_t currenttime;
 + time(&currenttime);
_AT_@ -50,10 +61,11 @@ index 5ae738c..5ece0ae 100644
 + system(command);
 + }
 + }
- }
++ }
  }
  
-_AT_@ -229,6 +244,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
+ static struct lock *
+_AT_@ -229,6 +247,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
          XSetWindowAttributes wa;
          Cursor invisible;
  
Received on Sun Oct 02 2022 - 14:40:29 CEST

This archive was generated by hypermail 2.3.0 : Sun Oct 02 2022 - 14:48:54 CEST