draw.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. #pragma src "/usr/inferno/libdraw"
  2. #pragma varargck argpos _drawprint 2
  3. typedef struct Cachefont Cachefont;
  4. typedef struct Cacheinfo Cacheinfo;
  5. typedef struct Cachesubf Cachesubf;
  6. typedef struct Display Display;
  7. typedef struct Font Font;
  8. typedef struct Fontchar Fontchar;
  9. typedef struct Image Image;
  10. typedef struct Mouse Mouse;
  11. typedef struct Point Point;
  12. typedef struct Rectangle Rectangle;
  13. typedef struct RGB RGB;
  14. typedef struct Refreshq Refreshq;
  15. typedef struct Screen Screen;
  16. typedef struct Subfont Subfont;
  17. #pragma varargck type "R" Rectangle
  18. #pragma varargck type "P" Point
  19. extern int Rfmt(Fmt*);
  20. extern int Pfmt(Fmt*);
  21. enum
  22. {
  23. DOpaque = 0xFFFFFFFF,
  24. DTransparent = 0x00000000, /* only useful for allocimage, memfillcolor */
  25. DBlack = 0x000000FF,
  26. DWhite = 0xFFFFFFFF,
  27. DRed = 0xFF0000FF,
  28. DGreen = 0x00FF00FF,
  29. DBlue = 0x0000FFFF,
  30. DCyan = 0x00FFFFFF,
  31. DMagenta = 0xFF00FFFF,
  32. DYellow = 0xFFFF00FF,
  33. DPaleyellow = 0xFFFFAAFF,
  34. DDarkyellow = 0xEEEE9EFF,
  35. DDarkgreen = 0x448844FF,
  36. DPalegreen = 0xAAFFAAFF,
  37. DMedgreen = 0x88CC88FF,
  38. DDarkblue = 0x000055FF,
  39. DPalebluegreen= 0xAAFFFFFF,
  40. DPaleblue = 0x0000BBFF,
  41. DBluegreen = 0x008888FF,
  42. DGreygreen = 0x55AAAAFF,
  43. DPalegreygreen = 0x9EEEEEFF,
  44. DYellowgreen = 0x99994CFF,
  45. DMedblue = 0x000099FF,
  46. DGreyblue = 0x005DBBFF,
  47. DPalegreyblue = 0x4993DDFF,
  48. DPurpleblue = 0x8888CCFF,
  49. DNotacolor = 0xFFFFFF00,
  50. DNofill = DNotacolor,
  51. };
  52. enum
  53. {
  54. Displaybufsize = 8000,
  55. ICOSSCALE = 1024,
  56. Borderwidth = 4,
  57. };
  58. enum
  59. {
  60. /* refresh methods */
  61. Refbackup = 0,
  62. Refnone = 1,
  63. Refmesg = 2
  64. };
  65. #define NOREFRESH ((void*)-1)
  66. enum
  67. {
  68. /* line ends */
  69. Endsquare = 0,
  70. Enddisc = 1,
  71. Endarrow = 2,
  72. Endmask = 0x1F
  73. };
  74. #define ARROW(a, b, c) (Endarrow|((a)<<5)|((b)<<14)|((c)<<23))
  75. /*
  76. * image channel descriptors
  77. */
  78. enum {
  79. CRed = 0,
  80. CGreen,
  81. CBlue,
  82. CGrey,
  83. CAlpha,
  84. CMap,
  85. CIgnore,
  86. NChan,
  87. };
  88. #define __DC(type, nbits) ((((type)&15)<<4)|((nbits)&15))
  89. #define CHAN1(a,b) __DC(a,b)
  90. #define CHAN2(a,b,c,d) (CHAN1((a),(b))<<8|__DC((c),(d)))
  91. #define CHAN3(a,b,c,d,e,f) (CHAN2((a),(b),(c),(d))<<8|__DC((e),(f)))
  92. #define CHAN4(a,b,c,d,e,f,g,h) (CHAN3((a),(b),(c),(d),(e),(f))<<8|__DC((g),(h)))
  93. #define NBITS(c) ((c)&15)
  94. #define TYPE(c) (((c)>>4)&15)
  95. enum {
  96. GREY1 = CHAN1(CGrey, 1),
  97. GREY2 = CHAN1(CGrey, 2),
  98. GREY4 = CHAN1(CGrey, 4),
  99. GREY8 = CHAN1(CGrey, 8),
  100. CMAP8 = CHAN1(CMap, 8),
  101. RGB15 = CHAN4(CIgnore, 1, CRed, 5, CGreen, 5, CBlue, 5),
  102. RGB16 = CHAN3(CRed, 5, CGreen, 6, CBlue, 5),
  103. RGB24 = CHAN3(CRed, 8, CGreen, 8, CBlue, 8),
  104. RGBA32 = CHAN4(CRed, 8, CGreen, 8, CBlue, 8, CAlpha, 8),
  105. ARGB32 = CHAN4(CAlpha, 8, CRed, 8, CGreen, 8, CBlue, 8), /* stupid VGAs */
  106. XRGB32 = CHAN4(CIgnore, 8, CRed, 8, CGreen, 8, CBlue, 8),
  107. BGR24 = CHAN3(CBlue, 8, CGreen, 8, CRed, 8),
  108. ABGR32 = CHAN4(CAlpha, 8, CBlue, 8, CGreen, 8, CRed, 8),
  109. XBGR32 = CHAN4(CIgnore, 8, CBlue, 8, CGreen, 8, CRed, 8),
  110. };
  111. /* compositing operators */
  112. typedef enum
  113. {
  114. SinD = 1<<3,
  115. DinS = 1<<2,
  116. SoutD = 1<<1,
  117. DoutS = 1 <<0,
  118. S = SinD|SoutD,
  119. SoverD = SinD|SoutD|DoutS,
  120. SatopD = SinD|DoutS,
  121. SxorD = SoutD|DoutS,
  122. D = DinS|DoutS,
  123. DoverS = DinS|DoutS|SoutD,
  124. DatopS = DinS|SoutD,
  125. DxorS = DoutS|SoutD,
  126. Clear = 0,
  127. Ncomp = 12,
  128. } Drawop;
  129. extern char* chantostr(char*, ulong);
  130. extern ulong strtochan(char*);
  131. extern int chantodepth(ulong);
  132. struct Point
  133. {
  134. int x;
  135. int y;
  136. };
  137. struct Rectangle
  138. {
  139. Point min;
  140. Point max;
  141. };
  142. typedef void (*Reffn)(Image*, Rectangle, void*);
  143. struct Screen
  144. {
  145. Display *display; /* display holding data */
  146. int id; /* id of system-held Screen */
  147. Image *image; /* unused; for reference only */
  148. Image *fill; /* color to paint behind windows */
  149. };
  150. struct Refreshq
  151. {
  152. Reffn reffn;
  153. void *refptr;
  154. Rectangle r;
  155. Refreshq *next;
  156. };
  157. struct Display
  158. {
  159. void* qlock;
  160. int locking; /*program is using lockdisplay */
  161. int dirno;
  162. void *datachan;
  163. void *refchan;
  164. void *ctlchan;
  165. int imageid;
  166. int local;
  167. int depth;
  168. ulong chan;
  169. void (*error)(Display*, char*);
  170. char *devdir;
  171. char *windir;
  172. char oldlabel[64];
  173. ulong dataqid;
  174. Image *white;
  175. Image *black;
  176. Image *image;
  177. Image *opaque;
  178. Image *transparent;
  179. uchar buf[Displaybufsize+1]; /* +1 for flush message */
  180. int bufsize;
  181. uchar *bufp;
  182. Font *defaultfont;
  183. Subfont *defaultsubfont;
  184. Image *windows;
  185. void *limbo;
  186. Refreshq *refhead;
  187. Refreshq *reftail;
  188. };
  189. struct Image
  190. {
  191. Display *display; /* display holding data */
  192. int id; /* id of system-held Image */
  193. Rectangle r; /* rectangle in data area, local coords */
  194. Rectangle clipr; /* clipping region */
  195. int depth; /* number of bits per pixel */
  196. ulong chan;
  197. int repl; /* flag: data replicates to tile clipr */
  198. Screen *screen; /* 0 if not a window */
  199. Image *next; /* next in list of windows */
  200. Reffn reffn;
  201. void *refptr;
  202. };
  203. struct RGB
  204. {
  205. ulong red;
  206. ulong green;
  207. ulong blue;
  208. };
  209. /*
  210. * Subfonts
  211. *
  212. * given char c, Subfont *f, Fontchar *i, and Point p, one says
  213. * i = f->info+c;
  214. * draw(b, Rect(p.x+i->left, p.y+i->top,
  215. * p.x+i->left+((i+1)->x-i->x), p.y+i->bottom),
  216. * color, f->bits, Pt(i->x, i->top));
  217. * p.x += i->width;
  218. * to draw characters in the specified color (itself an Image) in Image b.
  219. */
  220. struct Fontchar
  221. {
  222. int x; /* left edge of bits */
  223. uchar top; /* first non-zero scan-line */
  224. uchar bottom; /* last non-zero scan-line + 1 */
  225. char left; /* offset of baseline */
  226. uchar width; /* width of baseline */
  227. };
  228. struct Subfont
  229. {
  230. char *name;
  231. short n; /* number of chars in font */
  232. uchar height; /* height of image */
  233. char ascent; /* top of image to baseline */
  234. Fontchar *info; /* n+1 character descriptors */
  235. Image *bits; /* of font */
  236. int ref;
  237. };
  238. enum
  239. {
  240. /* starting values */
  241. LOG2NFCACHE = 6,
  242. NFCACHE = (1<<LOG2NFCACHE), /* #chars cached */
  243. NFLOOK = 5, /* #chars to scan in cache */
  244. NFSUBF = 2, /* #subfonts to cache */
  245. /* max value */
  246. MAXFCACHE = 1024+NFLOOK, /* upper limit */
  247. MAXSUBF = 50, /* generous upper limit */
  248. /* deltas */
  249. DSUBF = 4,
  250. /* expiry ages */
  251. SUBFAGE = 10000,
  252. CACHEAGE = 10000
  253. };
  254. struct Cachefont
  255. {
  256. Rune min; /* lowest rune value to be taken from subfont */
  257. Rune max; /* highest rune value+1 to be taken from subfont */
  258. int offset; /* position in subfont of character at min */
  259. char *name; /* stored in font */
  260. char *subfontname; /* to access subfont */
  261. };
  262. struct Cacheinfo
  263. {
  264. ushort x; /* left edge of bits */
  265. uchar width; /* width of baseline */
  266. schar left; /* offset of baseline */
  267. Rune value; /* value of character at this slot in cache */
  268. ushort age;
  269. };
  270. struct Cachesubf
  271. {
  272. ulong age; /* for replacement */
  273. Cachefont *cf; /* font info that owns us */
  274. Subfont *f; /* attached subfont */
  275. };
  276. struct Font
  277. {
  278. char *name;
  279. Display *display;
  280. short height; /* max height of image, interline spacing */
  281. short ascent; /* top of image to baseline */
  282. short width; /* widest so far; used in caching only */
  283. short nsub; /* number of subfonts */
  284. ulong age; /* increasing counter; used for LRU */
  285. int maxdepth; /* maximum depth of all loaded subfonts */
  286. int ncache; /* size of cache */
  287. int nsubf; /* size of subfont list */
  288. Cacheinfo *cache;
  289. Cachesubf *subf;
  290. Cachefont **sub; /* as read from file */
  291. Image *cacheimage;
  292. };
  293. #define Dx(r) ((r).max.x-(r).min.x)
  294. #define Dy(r) ((r).max.y-(r).min.y)
  295. /*
  296. * Image management
  297. */
  298. extern Image* _allocimage(Image*, Display*, Rectangle, ulong, int, ulong, int, int);
  299. extern Image* allocimage(Display*, Rectangle, ulong, int, ulong);
  300. extern uchar* bufimage(Display*, int);
  301. extern int bytesperline(Rectangle, int);
  302. extern void closedisplay(Display*);
  303. extern void drawerror(Display*, char*);
  304. extern int _drawprint(int, char*, ...);
  305. extern int flushimage(Display*, int);
  306. extern int freeimage(Image*);
  307. extern int _freeimage1(Image*);
  308. extern int geninitdraw(char*, void(*)(Display*, char*), char*, char*, char*, int);
  309. extern int initdraw(void(*)(Display*, char*), char*, char*);
  310. extern Display* initdisplay(char*, char*, void(*)(Display*, char*));
  311. extern int loadimage(Image*, Rectangle, uchar*, int);
  312. extern int cloadimage(Image*, Rectangle, uchar*, int);
  313. extern int getwindow(Display*, int);
  314. extern int gengetwindow(Display*, char*, Image**, Screen**, int);
  315. extern Image* readimage(Display*, int, int);
  316. extern Image* creadimage(Display*, int, int);
  317. extern int unloadimage(Image*, Rectangle, uchar*, int);
  318. extern int wordsperline(Rectangle, int);
  319. extern int writeimage(int, Image*, int);
  320. extern Image* namedimage(Display*, char*);
  321. extern int nameimage(Image*, char*, int);
  322. extern Image* allocimagemix(Display*, ulong, ulong);
  323. /*
  324. * Colors
  325. */
  326. extern void readcolmap(Display*, RGB*);
  327. extern void writecolmap(Display*, RGB*);
  328. extern ulong setalpha(ulong, uchar);
  329. /*
  330. * Windows
  331. */
  332. extern Screen* allocscreen(Image*, Image*, int);
  333. extern Image* _allocwindow(Image*, Screen*, Rectangle, int, ulong);
  334. extern Image* allocwindow(Screen*, Rectangle, int, ulong);
  335. extern void bottomnwindows(Image**, int);
  336. extern void bottomwindow(Image*);
  337. extern int freescreen(Screen*);
  338. extern Screen* publicscreen(Display*, int, ulong);
  339. extern void topnwindows(Image**, int);
  340. extern void topwindow(Image*);
  341. extern int originwindow(Image*, Point, Point);
  342. /*
  343. * Geometry
  344. */
  345. extern Point Pt(int, int);
  346. extern Rectangle Rect(int, int, int, int);
  347. extern Rectangle Rpt(Point, Point);
  348. extern Point addpt(Point, Point);
  349. extern Point subpt(Point, Point);
  350. extern Point divpt(Point, int);
  351. extern Point mulpt(Point, int);
  352. extern int eqpt(Point, Point);
  353. extern int eqrect(Rectangle, Rectangle);
  354. extern Rectangle insetrect(Rectangle, int);
  355. extern Rectangle rectaddpt(Rectangle, Point);
  356. extern Rectangle rectsubpt(Rectangle, Point);
  357. extern Rectangle canonrect(Rectangle);
  358. extern int rectXrect(Rectangle, Rectangle);
  359. extern int rectinrect(Rectangle, Rectangle);
  360. extern void combinerect(Rectangle*, Rectangle);
  361. extern int rectclip(Rectangle*, Rectangle);
  362. extern int ptinrect(Point, Rectangle);
  363. extern void replclipr(Image*, int, Rectangle);
  364. extern int drawreplxy(int, int, int); /* used to be drawsetxy */
  365. extern Point drawrepl(Rectangle, Point);
  366. extern int rgb2cmap(int, int, int);
  367. extern int cmap2rgb(int);
  368. extern int cmap2rgba(int);
  369. extern void icossin(int, int*, int*);
  370. extern void icossin2(int, int, int*, int*);
  371. /*
  372. * Graphics
  373. */
  374. extern void draw(Image*, Rectangle, Image*, Image*, Point);
  375. extern void drawop(Image*, Rectangle, Image*, Image*, Point, Drawop);
  376. extern void gendraw(Image*, Rectangle, Image*, Point, Image*, Point);
  377. extern void gendrawop(Image*, Rectangle, Image*, Point, Image*, Point, Drawop);
  378. extern void line(Image*, Point, Point, int, int, int, Image*, Point);
  379. extern void lineop(Image*, Point, Point, int, int, int, Image*, Point, Drawop);
  380. extern void poly(Image*, Point*, int, int, int, int, Image*, Point);
  381. extern void polyop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
  382. extern void fillpoly(Image*, Point*, int, int, Image*, Point);
  383. extern void fillpolyop(Image*, Point*, int, int, Image*, Point, Drawop);
  384. extern Point string(Image*, Point, Image*, Point, Font*, char*);
  385. extern Point stringop(Image*, Point, Image*, Point, Font*, char*, Drawop);
  386. extern Point stringn(Image*, Point, Image*, Point, Font*, char*, int);
  387. extern Point stringnop(Image*, Point, Image*, Point, Font*, char*, int, Drawop);
  388. extern Point runestring(Image*, Point, Image*, Point, Font*, Rune*);
  389. extern Point runestringop(Image*, Point, Image*, Point, Font*, Rune*, Drawop);
  390. extern Point runestringn(Image*, Point, Image*, Point, Font*, Rune*, int);
  391. extern Point runestringnop(Image*, Point, Image*, Point, Font*, Rune*, int, Drawop);
  392. extern Point stringbg(Image*, Point, Image*, Point, Font*, char*, Image*, Point);
  393. extern Point stringbgop(Image*, Point, Image*, Point, Font*, char*, Image*, Point, Drawop);
  394. extern Point stringnbg(Image*, Point, Image*, Point, Font*, char*, int, Image*, Point);
  395. extern Point stringnbgop(Image*, Point, Image*, Point, Font*, char*, int, Image*, Point, Drawop);
  396. extern Point runestringbg(Image*, Point, Image*, Point, Font*, Rune*, Image*, Point);
  397. extern Point runestringbgop(Image*, Point, Image*, Point, Font*, Rune*, Image*, Point, Drawop);
  398. extern Point runestringnbg(Image*, Point, Image*, Point, Font*, Rune*, int, Image*, Point);
  399. extern Point runestringnbgop(Image*, Point, Image*, Point, Font*, Rune*, int, Image*, Point, Drawop);
  400. extern Point _string(Image*, Point, Image*, Point, Font*, char*, Rune*, int, Rectangle, Image*, Point, Drawop);
  401. extern Point stringsubfont(Image*, Point, Image*, Subfont*, char*);
  402. extern int bezier(Image*, Point, Point, Point, Point, int, int, int, Image*, Point);
  403. extern int bezierop(Image*, Point, Point, Point, Point, int, int, int, Image*, Point, Drawop);
  404. extern int bezspline(Image*, Point*, int, int, int, int, Image*, Point);
  405. extern int bezsplineop(Image*, Point*, int, int, int, int, Image*, Point, Drawop);
  406. extern int getbezsplinepts(Point*, int, Point**);
  407. extern int fillbezier(Image*, Point, Point, Point, Point, int, Image*, Point);
  408. extern int fillbezierop(Image*, Point, Point, Point, Point, int, Image*, Point, Drawop);
  409. extern int fillbezspline(Image*, Point*, int, int, Image*, Point);
  410. extern int fillbezsplineop(Image*, Point*, int, int, Image*, Point, Drawop);
  411. extern void ellipse(Image*, Point, int, int, int, Image*, Point);
  412. extern void ellipseop(Image*, Point, int, int, int, Image*, Point, Drawop);
  413. extern void fillellipse(Image*, Point, int, int, Image*, Point);
  414. extern void fillellipseop(Image*, Point, int, int, Image*, Point, Drawop);
  415. extern void arc(Image*, Point, int, int, int, Image*, Point, int, int);
  416. extern void arcop(Image*, Point, int, int, int, Image*, Point, int, int, Drawop);
  417. extern void fillarc(Image*, Point, int, int, Image*, Point, int, int);
  418. extern void fillarcop(Image*, Point, int, int, Image*, Point, int, int, Drawop);
  419. extern void border(Image*, Rectangle, int, Image*, Point);
  420. extern void borderop(Image*, Rectangle, int, Image*, Point, Drawop);
  421. /*
  422. * Font management
  423. */
  424. extern Font* openfont(Display*, char*);
  425. extern Font* buildfont(Display*, char*, char*);
  426. extern void freefont(Font*);
  427. extern Font* mkfont(Subfont*, Rune);
  428. extern int cachechars(Font*, char**, Rune**, ushort*, int, int*, char**);
  429. extern void agefont(Font*);
  430. extern Subfont* allocsubfont(char*, int, int, int, Fontchar*, Image*);
  431. extern Subfont* lookupsubfont(Display*, char*);
  432. extern void installsubfont(char*, Subfont*);
  433. extern void uninstallsubfont(Subfont*);
  434. extern void freesubfont(Subfont*);
  435. extern Subfont* readsubfont(Display*, char*, int, int);
  436. extern Subfont* readsubfonti(Display*, char*, int, Image*, int);
  437. extern int writesubfont(int, Subfont*);
  438. extern void _unpackinfo(Fontchar*, uchar*, int);
  439. extern Point stringsize(Font*, char*);
  440. extern int stringwidth(Font*, char*);
  441. extern int stringnwidth(Font*, char*, int);
  442. extern Point runestringsize(Font*, Rune*);
  443. extern int runestringwidth(Font*, Rune*);
  444. extern int runestringnwidth(Font*, Rune*, int);
  445. extern Point strsubfontwidth(Subfont*, char*);
  446. extern int loadchar(Font*, Rune, Cacheinfo*, int, int, char**);
  447. extern char* subfontname(char*, char*, int);
  448. extern Subfont* _getsubfont(Display*, char*);
  449. extern Subfont* getdefont(Display*);
  450. extern int lockdisplay(Display*);
  451. extern void unlockdisplay(Display*);
  452. extern int drawlsetrefresh(ulong, int, void*, void*);
  453. /* Compositing operator utility */
  454. extern void _setdrawop(Display*, Drawop);
  455. /*
  456. * Predefined
  457. */
  458. extern uchar defontdata[];
  459. extern int sizeofdefont;
  460. extern Point ZP;
  461. extern Rectangle ZR;
  462. /*
  463. * Set up by initdraw()
  464. */
  465. extern int _cursorfd;
  466. extern int _drawdebug; /* set to 1 to see errors from flushimage */
  467. #define BGSHORT(p) (((p)[0]<<0) | ((p)[1]<<8))
  468. #define BGLONG(p) ((BGSHORT(p)<<0) | (BGSHORT(p+2)<<16))
  469. #define BPSHORT(p, v) ((p)[0]=(v), (p)[1]=((v)>>8))
  470. #define BPLONG(p, v) (BPSHORT(p, (v)), BPSHORT(p+2, (v)>>16))
  471. /*
  472. * Compressed image file parameters
  473. */
  474. #define NMATCH 3 /* shortest match possible */
  475. #define NRUN (NMATCH+31) /* longest match possible */
  476. #define NMEM 1024 /* window size */
  477. #define NDUMP 128 /* maximum length of dump */
  478. #define NCBLOCK 6000 /* size of compressed blocks */
  479. extern void _twiddlecompressed(uchar*, int);
  480. extern int _compblocksize(Rectangle, int);
  481. /* XXX backwards helps; should go */
  482. extern ulong drawld2chan[];
  483. extern void drawsetdebug(int);
  484. /*
  485. * Inferno interface
  486. */
  487. extern Font* font_open(Display*, char*);
  488. extern void font_close(Font*);
  489. /*
  490. * Macros to convert between C and Limbo types
  491. */
  492. #define IRECT(r) (*(Rectangle*)&(r))
  493. #define DRECT(r) (*(Draw_Rect*)&(r))
  494. #define IPOINT(p) (*(Point*)&(p))
  495. #define DPOINT(p) (*(Draw_Point*)&(p))
  496. #define P2P(p1, p2) (p1).x = (p2).x, (p1).y = (p2).y
  497. #define R2R(r1, r2) (r1).min.x = (r2).min.x, (r1).min.y = (r2).min.y,\
  498. (r1).max.x = (r2).max.x, (r1).max.y = (r2).max.y
  499. extern Image* display_open(Display*, char*);