shithub: misc

ref: 2fa1f898d154e57225ba8a95c3c682de7dc3553f
dir: /hidpi-drawterm-metal-cocoa.patch/

View raw version
diff 0b7990cf2b84e7a80cf3f3a9e7eadca10d51a2c5 uncommitted
--- a/include/draw.h
+++ b/include/draw.h
@@ -193,6 +193,7 @@
 	Image		*windows;
 	Image		*screenimage;
 	int		_isnewdisplay;
+	int		dpi;
 };
 
 struct Image
--- a/kern/devdraw.c
+++ b/kern/devdraw.c
@@ -76,6 +76,8 @@
 	int		refreshme;
 	int		infoid;
 	int		op;
+	int		displaydpi;
+	int		forcedpi;
 };
 
 struct Refresh
@@ -166,6 +168,8 @@
 	Client*		drawclientofpath(ulong);
 	DImage*	allocdimage(Memimage*);
 
+int displaydpi = 200;
+
 static	char Enodrawimage[] =	"unknown id for draw image";
 static	char Enodrawscreen[] =	"unknown id for draw screen";
 static	char Eshortdraw[] =	"short draw message";
@@ -783,6 +787,7 @@
 	cl->slot = i;
 	cl->clientid = ++sdraw.clientid;
 	cl->op = SoverD;
+	cl->displaydpi = displaydpi;
 	sdraw.client[i] = cl;
 	return cl;
 }
@@ -1408,6 +1413,7 @@
 	int c, repl, m, y, dstid, scrnid, ni, ci, j, nw, e0, e1, op, ox, oy, oesize, esize, doflush;
 	uchar *u, *a, refresh;
 	char *fmt;
+	Fmt f;
 	ulong value, chan;
 	Rectangle r, clipr;
 	Point p, q, *pp, sp;
@@ -1654,6 +1660,34 @@
 			memset(font->fchar, 0, ni*sizeof(FChar));
 			font->nfchar = ni;
 			font->ascent = a[9];
+			continue;
+
+		/* query: 'Q' n[1] queryspec[n] */
+		case 'q':
+			if(n < 2)
+				error(Eshortdraw);
+			m = 1+1+a[1];
+			if(n < m)
+				error(Eshortdraw);
+			fmtstrinit(&f);
+			for(c=0; c<a[1]; c++){
+				switch(a[2+c]){
+				default:
+					error("unknown query");
+					break;
+				case 'd':       /* dpi */
+					if(client->forcedpi)
+						fmtprint(&f, "%11d ", client->forcedpi);
+					else {
+						fmtprint(&f, "%11d ", client->displaydpi);
+					}
+					break;
+				}
+			}
+			client->readdata = (uchar*)fmtstrflush(&f);
+			if(client->readdata == nil)
+				error(Enomem);
+			client->nreaddata = strlen((char*)client->readdata);
 			continue;
 
 		/* load character: 'l' fontid[4] srcid[4] index[2] R[4*4] P[2*4] left[1] width[1] */