9front - general discussion about 9front
 help / color / mirror / Atom feed
* [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

* Re: [9front] screenlock
  2021-07-18 19:31   ` Stuart Morrow
@ 2021-07-18 20:23     ` cinap_lenrek
  0 siblings, 0 replies; 4+ messages in thread
From: cinap_lenrek @ 2021-07-18 20:23 UTC (permalink / raw)
  To: 9front

ok, applied.

--
cinap

^ 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

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ http://inbox.vuxu.org/9front \
		9front@9front.org
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9front


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git