* [9front] screenlock
@ 2021-07-18 16:04 Stuart Morrow
2021-07-18 17:45 ` cinap_lenrek
0 siblings, 1 reply; 4+ messages in thread
From: Stuart Morrow @ 2021-07-18 16:04 UTC (permalink / raw)
To: 9front
Would like to get this in before release as it all-but-fixes the
horrible visual bug of the green border.
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.)
(Still puzzled and bothered by the getwindow'ing version.)
--- /mnt/git/object/be36c092ac061a04065720e98e5849130487be7f/tree/sys/src/cmd/screenlock.c
+++ sys/src/cmd/screenlock.c
@@ -119,14 +119,17 @@
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);
+ if(n > 48)
+ if(strstr(buf+48, "notcurrent"))
+ write(fd, "current", 7);
}
}
@@ -186,7 +189,7 @@
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);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] screenlock
2021-07-18 16:04 [9front] screenlock Stuart Morrow
@ 2021-07-18 17:45 ` cinap_lenrek
2021-07-18 19:31 ` Stuart Morrow
0 siblings, 1 reply; 4+ messages in thread
From: cinap_lenrek @ 2021-07-18 17:45 UTC (permalink / raw)
To: 9front
+ n = read(fd, buf, sizeof buf);
+ if(n > 48)
+ if(strstr(buf+48, "notcurrent"))
+ write(fd, "current", 7);
thats wrong because the read wont return you a '\0' terminated string.
also, we'r out of time for the release build. i just generated new
images and already seeding..
--
cinap
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] screenlock
2021-07-18 17:45 ` cinap_lenrek
@ 2021-07-18 19:31 ` Stuart Morrow
2021-07-18 20:23 ` cinap_lenrek
0 siblings, 1 reply; 4+ messages in thread
From: Stuart Morrow @ 2021-07-18 19:31 UTC (permalink / raw)
To: 9front
> thats wrong because the read wont return you a '\0' terminated string.
Oh, yeah. And I can even come up with a scenario where wctl will emit
without there being a notcurrent.
--- /mnt/git/object/be36c092ac061a04065720e98e5849130487be7f/tree/sys/src/cmd/screenlock.c
+++ sys/src/cmd/screenlock.c
@@ -119,14 +119,19 @@
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 @@
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);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-19 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-18 16:04 [9front] screenlock Stuart Morrow
2021-07-18 17:45 ` cinap_lenrek
2021-07-18 19:31 ` Stuart Morrow
2021-07-18 20:23 ` cinap_lenrek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).