shithub: misc

Download patch

ref: de4d9ede4661ac64b603772a81e5c33c155bff26
parent: ace7b13ccd4af5c5a6c15509e47fe72c295b6807
author: Philip Silva <philip.silva@protonmail.com>
date: Sat Oct 2 06:30:09 EDT 2021

fix setting disp->dpi

--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 Various unsorted stuff
 
-- hidpi-1.patch: wip from p9p to add dpi field to Display (libdraw changes don't work yet)
+- hidpi-1.patch: wip from p9p to add dpi field to Display
               (p9p commit d0e0701913f3aede1fcb256f3d1e9c60c9a)
 - hidpi-2.patch: be able to configure dpi via plan9.cfg
 - acme-at.patch: can be applied to open paths containing @s (e.g. the internal Go module paths)
--- a/hidpi-1.patch
+++ b/hidpi-1.patch
@@ -91,24 +91,32 @@
  
  		/* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] left[1] width[1] */
  		case 'l':
---- a/sys/src/libdraw/alloc.c
-+++ b/sys/src/libdraw/alloc.c
-@@ -170,6 +170,19 @@
- 	i->clipr.max.y = atoi(buf+11*12);
- 	i->screen = nil;
- 	i->next = nil;
-+		
-+		/* flush pending data so we don't get error allocating the image */
-+		flushimage(d, 0);
-+		a = bufimage(d, 3);
-+		if(a == nil)
-+			goto Error;
-+		a[0] = 'q';
-+		a[1] = 1;
-+		a[2] = 'd';
-+		d->dpi = 100;
-+		if (flushimage(d, 0) >= 0 && pread(d->ctlfd, buf, 12, 0) == 12)
-+			d->dpi = atoi(buf);
- 	return i;
+--- a/sys/src/libdraw/init.c
++++ b/sys/src/libdraw/init.c
+@@ -197,6 +197,7 @@
+ Display*
+ initdisplay(char *dev, char *win, void(*error)(Display*, char*))
+ {
++	uchar *a;
+ 	char buf[128], info[NINFO+1], *t, isnew;
+ 	int n, datafd, ctlfd, reffd;
+ 	Display *disp;
+@@ -320,6 +321,18 @@
+ 		disp->_isnewdisplay = 1;
+ 	free(dir);
+ 
++	a = bufimage(disp, 3);
++	if(a == nil)
++		goto Error5;
++	a[0] = 'q';
++	a[1] = 1;
++	a[2] = 'd';
++	disp->dpi = 100;
++	if(flushimage(disp, 0) < 0)
++		goto Error5;
++	if((read(datafd, info, sizeof info)) == 12)
++		disp->dpi = atoi(info);
++
+ 	return disp;
  }