--- ray/src/hd/rhd_x11.c 2004/01/01 11:21:55 3.37 +++ ray/src/hd/rhd_x11.c 2005/02/08 01:03:27 3.40 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rhd_x11.c,v 3.37 2004/01/01 11:21:55 schorsch Exp $"; +static const char RCSid[] = "$Id: rhd_x11.c,v 3.40 2005/02/08 01:03:27 greg Exp $"; #endif /* * X11 driver for holodeck display. @@ -19,7 +19,7 @@ static const char RCSid[] = "$Id: rhd_x11.c,v 3.37 200 #include "plocate.h" #include "rhdisp.h" #include "rhd_qtree.h" -#include "x11icon.h" +#include "x11icon.h" #ifndef RAYQLEN #define RAYQLEN 50000 /* max. rays to queue before flush */ @@ -54,6 +54,8 @@ static const char RCSid[] = "$Id: rhd_x11.c,v 3.37 200 struct driver odev; /* global device driver structure */ +TMstruct *tmGlobal; /* global tone-mapping structure */ + char odev_args[64]; /* command arguments */ static XEvent currentevent; /* current event */ @@ -165,7 +167,8 @@ dev_open( /* initialize X11 driver */ &myprims[BLU][CIEX],&myprims[BLU][CIEY], &myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) dpri = myprims; - if (tmInit(mytmflags(), dpri, gamval) == NULL) + tmGlobal = tmInit(mytmflags(), dpri, gamval); + if (tmGlobal == NULL) error(SYSTEM, "not enough memory in dev_open"); /* open window */ ourwinattr.background_pixel = ourblack; @@ -225,7 +228,7 @@ dev_close(void) /* close our display */ XCloseDisplay(ourdisplay); ourdisplay = NULL; qtFreeLeaves(); - tmDone(NULL); + tmDone(tmGlobal); odev.v.type = 0; odev.hres = odev.vres = 0; odev.ifd = -1; @@ -637,15 +640,23 @@ getframe( /* get focus frame */ ) { int startx = ebut->x, starty = ebut->y; - int endx, endy; - + int endx, endy, midx, midy; + FVECT v1; + int li; + /* get mouse drag */ XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent)); endx = levptr(XButtonReleasedEvent)->x; endy = levptr(XButtonReleasedEvent)->y; - if ((endx == startx) | (endy == starty)) { - XBell(ourdisplay, 0); + midx = (startx + endx) >> 1; + midy = (starty + endy) >> 1; + /* set focus distance */ + if ((li = qtFindLeaf(midx, midy)) < 0) + return; /* not on window */ + VCOPY(v1, qtL.wp[li]); + odev.v.vdist = sqrt(dist2(odev.v.vp, v1)); + /* set frame for rendering */ + if ((endx == startx) | (endy == starty)) return; - } if (endx < startx) {register int c = endx; endx = startx; startx = c;} if (endy < starty) {register int c = endy; endy = starty; starty = c;} sprintf(odev_args, "%.3f %.3f %.3f %.3f",