ref: f40a45b580b3efef25133f9b47f9e4427ff5ad0c
dir: /hidpi-1.patch/
diff c7dcc82b0be805717efbe77c98eaadf3ee1e31af uncommitted --- a/sys/include/ape/draw.h +++ b/sys/include/ape/draw.h @@ -208,6 +208,7 @@ Image *windows; Image *screenimage; int _isnewdisplay; + int dpi; }; struct Image --- a/sys/include/draw.h +++ b/sys/include/draw.h @@ -200,6 +200,7 @@ Image *windows; Image *screenimage; int _isnewdisplay; + int dpi; }; struct Image --- a/sys/src/9/port/devdraw.c +++ b/sys/src/9/port/devdraw.c @@ -77,6 +77,8 @@ int refreshme; int infoid; int op; + int displaydpi; + int forcedpi; }; struct Refresh @@ -166,6 +168,8 @@ void drawfreedimage(DImage*); Client* drawclientofpath(ulong); DImage* allocdimage(Memimage*); + +int displaydpi = 100; static char Enodrawimage[] = "unknown id for draw image"; static char Enodrawscreen[] = "unknown id for draw screen"; @@ -785,6 +789,7 @@ cl->slot = i; cl->clientid = ++sdraw.clientid; cl->op = SoverD; + cl->displaydpi=100; sdraw.client[i] = cl; return cl; } @@ -1396,6 +1401,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; @@ -1643,6 +1649,35 @@ 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"); + 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] */ case 'l': --- 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; @@ -319,6 +320,18 @@ if(dir!=nil && dir->qid.vers==1) /* other way to tell */ 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) { + if((read(datafd, info, sizeof info)) == 12) + disp->dpi = atoi(info); + } return disp; }