shithub: misc

Download patch

ref: 001e60ea4b45fec9cb40ab8fbbebc334b4d3e9f4
parent: 4ffcb7af644c7dcef8a845bf94dcfd159ec01aa6
author: Philip Silva <[email protected]>
date: Sat Jul 30 05:27:45 EDT 2022

add hidpi-2fs.patch

- first sketch for /dev/draw/geom

--- a/README
+++ b/README
@@ -6,5 +6,7 @@
 - hidpi-3.patch: scale borders of rio and acme
               (p9p commit c96d832)
 - hidpi-drawterm-metal-cocoa.patch: hardcodes displaydpi to 200 (https://github.com/Plan9-Archive/drawterm-metal-cocoa)
+(- hidpi-2fs.patch: optional patch with /dev/draw/geom - at this point not super useful and very wip)
+
 - acme-at.patch: can be applied to open paths containing @s (e.g. the internal Go module paths)
 - wikidiff: diff 2 words using wikidiff.com
--- /dev/null
+++ b/hidpi-2fs.patch
@@ -1,0 +1,142 @@
+diff 8076b346fc51790964070d39e65c0afaaad49a0f uncommitted
+r--- a/sys/src/9/port/devdraw.c
++++ b/sys/src/9/port/devdraw.c
+@@ -15,6 +15,7 @@
+ enum
+ {
+ 	Qtopdir		= 0,
++	Qgeom,
+ 	Qnew,
+ 	Qwinname,
+ 	Q3rd,
+@@ -262,14 +263,22 @@
+ 	 */
+ 	switch(t){
+ 	case Q2nd:
+-		if(s == 0){
++		if(s == 0 || s == 1){
+ 	case Qnew:
+-			mkqid(&q, Qnew, 0, QTFILE);
+-			devdir(c, q, "new", 0, eve, 0666, dp);
+-			return 1;
++			if (s == 0) {
++				mkqid(&q, Qnew, 0, QTFILE);
++				devdir(c, q, "new", 0, eve, 0666, dp);
++				return 1;
++			}
++	case Qgeom:
++			if (s == 1) {
++				mkqid(&q, Qgeom, 0, QTFILE);
++				devdir(c, q, "geom", 0, eve, 0666, dp);
++				return 1;
++			}
+ 		}
+-		if(s <= sdraw.nclient){
+-			cl = sdraw.client[s-1];
++		if(s <= sdraw.nclient+1){
++			cl = sdraw.client[s-2];
+ 			if(cl == nil)
+ 				return 0;
+ 			sprint(up->genbuf, "%d", cl->clientid);
+@@ -812,9 +821,9 @@
+ 	int slot;
+ 
+ 	slot = CLIENTPATH(path);
+-	if(slot == 0)
++	if(slot < 2)
+ 		return nil;
+-	cl = sdraw.client[slot-1];
++	cl = sdraw.client[slot-2];
+ 	if(cl==0 || cl->clientid==0)
+ 		return nil;
+ 	return cl;
+@@ -1024,7 +1033,7 @@
+ 		cl = drawnewclient();
+ 		if(cl == 0)
+ 			error(Enodev);
+-		c->qid.path = Qctl|((cl->slot+1)<<QSHIFT);
++		c->qid.path = Qctl|((cl->slot+2)<<QSHIFT);
+ 	}
+ 
+ 	switch(QID(c->qid)){
+@@ -1031,6 +1040,9 @@
+ 	case Qwinname:
+ 		break;
+ 
++	case Qgeom:
++		break;
++
+ 	case Qnew:
+ 		break;
+ 
+@@ -1124,7 +1136,7 @@
+ long
+ drawread(Chan *c, void *a, long n, vlong off)
+ {
+-	int index, m;
++	int dpi, index, m;
+ 	ulong red, green, blue;
+ 	Client *cl;
+ 	uchar *p;
+@@ -1139,7 +1151,8 @@
+ 	if(QID(c->qid) == Qwinname)
+ 		return readstr(off, a, n, screenname);
+ 
+-	cl = drawclient(c);
++	if(QID(c->qid) != Qgeom)
++		cl = drawclient(c);
+ 	dlock();
+ 	if(waserror()){
+ 		dunlock();
+@@ -1146,6 +1159,21 @@
+ 		nexterror();
+ 	}
+ 	switch(QID(c->qid)){
++	case Qgeom:
++		i = screenimage;
++		if(i == nil)
++			error(Enodrawimage);
++		if((p = (uchar*)getconf("dpi")) == nil || (dpi = atoi((char*)p)) == 0){
++			dpi=100;
++		}
++		p = malloc(6*12+1);
++		if(p == 0)
++			error(Enomem);
++		sprint((char*)p, "%11d %11d %11d %11d %11d %11d\n", i->r.min.x, i->r.min.y, i->r.max.x, i->r.max.y, dpi, dpi);
++		n = readstr(offset, a, n, (char*)p);
++		free(p);
++		break;
++
+ 	case Qctl:
+ 		if(n < 12*12)
+ 			error(Eshortread);
+@@ -1253,13 +1281,14 @@
+ static long
+ drawwrite(Chan *c, void *a, long n, vlong)
+ {
+-	char buf[128], *fields[4], *q;
++	char buf[128], *fields[6], *q;
+ 	Client *cl;
+ 	int i, m, red, green, blue, x;
+ 
+ 	if(c->qid.type & QTDIR)
+ 		error(Eisdir);
+-	cl = drawclient(c);
++	if(QID(c->qid) != Qgeom)
++		cl = drawclient(c);
+ 	dlock();
+ 	if(waserror()){
+ 		drawwakeall();
+@@ -1267,6 +1296,12 @@
+ 		nexterror();
+ 	}
+ 	switch(QID(c->qid)){
++	case Qgeom:
++		if(tokenize(a, fields, nelem(fields)) != 6)
++			error(Ebadarg);
++		n = strlen(a);
++		break;
++
+ 	case Qctl:
+ 		if(n != 4)
+ 			error("unknown draw control request");