]> git.lizzy.rs Git - plan9front.git/commitdiff
screenlock: don't poll to top window (thanks Stuart Morrow)
authorcinap_lenrek <cinap_lenrek@felloff.net>
Sun, 18 Jul 2021 19:54:58 +0000 (19:54 +0000)
committercinap_lenrek <cinap_lenrek@felloff.net>
Sun, 18 Jul 2021 19:54:58 +0000 (19:54 +0000)
> String becomes stringbg so we have guaranteed max contrast in case the
> user changes the picture. (If you don't change the picture, it's
> white-on-black-on-black (sic) and you would never notice the change.)

sys/src/cmd/screenlock.c

index 9ac9fa06442b68315f1bc7e2e351f614019a7568..1b46fc97ea94b0a4c3a70944af0efaa64ba70284 100644 (file)
@@ -119,14 +119,19 @@ grabmouse(void*)
 void
 top(void*)
 {
-       int fd;
+       int fd, n;
+       char buf[128];
 
-       if((fd = open("/dev/wctl", OWRITE)) < 0)
+       if((fd = open("/dev/wctl", ORDWR)) < 0)
                return;
 
        for(;;){
-               write(fd, "current", 7);
-               sleep(500);
+               n = read(fd, buf, sizeof buf-1);
+               if(n > 48){
+                       buf[n] = '\0';
+                       if(strstr(buf+48, "notcurrent"))
+                               write(fd, "current", 7);
+               }
        }
 }
 
@@ -186,7 +191,7 @@ lockscreen(void)
                tm = localtime(time(&blank));
                s = smprint("user %s at %d:%02.2d", getuser(), tm->hour, tm->min);
                p = subpt(p, Pt(stringwidth(font, "m") * strlen(s) / 2, 0));
-               string(screen, p, screen->display->white, ZP, font, s);
+               stringbg(screen, p, display->white, ZP, font, s, display->black, ZP);
        }
        flushimage(display, 1);