devdraw, libdraw: add display->dpi

Fixed at 100 right now, but the plan is to make it accurate
and then use it.

R=rsc
http://codereview.appspot.com/6856091
This commit is contained in:
Russ Cox 2012-11-25 21:41:52 -05:00
parent 7b9ef735a8
commit d0e0701913
4 changed files with 38 additions and 2 deletions

View file

@ -204,6 +204,7 @@ struct Display
int _isnewdisplay;
struct Mux *mux;
int srvfd;
int dpi;
};
struct Image

View file

@ -11,6 +11,7 @@
#include "devdraw.h"
extern void _flushmemscreen(Rectangle);
int displaydpi = 100;
#define NHASH (1<<5)
#define HASHMASK (NHASH-1)
@ -776,6 +777,7 @@ _drawmsgwrite(void *v, int n)
DName *dn;
DScreen *dscrn;
FChar *fc;
Fmt fmt;
Memimage *dst, *i, *l, **lp, *mask, *src;
Memscreen *scrn;
Point p, *pp, q, sp;
@ -1083,7 +1085,31 @@ _drawmsgwrite(void *v, int n)
memmove(client->readdata, ibuf, ni);
client->nreaddata = ni;
client->infoid = -1;
continue;
continue;
/* query: 'Q' n[1] queryspec[n] */
case 'q':
if(n < 2)
goto Eshortdraw;
m = 1+1+a[1];
if(n < m)
goto Eshortdraw;
fmtstrinit(&fmt);
for(c=0; c<a[1]; c++) {
switch(a[2+c]) {
default:
err = "unknown query";
goto error;
case 'd': /* dpi */
fmtprint(&fmt, "%11d ", displaydpi);
break;
}
}
client->readdata = (uchar*)fmtstrflush(&fmt);
if(client->readdata == nil)
goto 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':

View file

@ -6,4 +6,4 @@ int parsewinsize(char*, Rectangle*, int*);
int mouseswap(int);
void abortcompose(void);
extern int displaydpi;

View file

@ -179,6 +179,15 @@ getimage0(Display *d, Image *image)
image->clipr.min.y = atoi(info+9*12);
image->clipr.max.x = atoi(info+10*12);
image->clipr.max.y = atoi(info+11*12);
a = bufimage(d, 3);
a[0] = 'q';
a[1] = 1;
a[2] = 'd';
d->dpi = 100;
if(flushimage(d, 0) >= 0 && _displayrddraw(d, info, 12) == 12)
d->dpi = atoi(info);
return image;
}