mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
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:
parent
7b9ef735a8
commit
d0e0701913
4 changed files with 38 additions and 2 deletions
|
@ -204,6 +204,7 @@ struct Display
|
|||
int _isnewdisplay;
|
||||
struct Mux *mux;
|
||||
int srvfd;
|
||||
int dpi;
|
||||
};
|
||||
|
||||
struct Image
|
||||
|
|
|
@ -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;
|
||||
|
@ -1085,6 +1087,30 @@ _drawmsgwrite(void *v, int n)
|
|||
client->infoid = -1;
|
||||
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':
|
||||
m = 1+4+4+2+4*4+2*4+1+1;
|
||||
|
|
|
@ -6,4 +6,4 @@ int parsewinsize(char*, Rectangle*, int*);
|
|||
int mouseswap(int);
|
||||
void abortcompose(void);
|
||||
|
||||
|
||||
extern int displaydpi;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue