/* ARGSUSED */ static void draw_it ( XtPointer client_data, XtIntervalId *id) /* unused */ { EyesWidget w = (EyesWidget)client_data; Window rep_root, rep_child; int rep_rootx, rep_rooty; unsigned int rep_mask; int dx, dy; TPoint mouse; Display *dpy = XtDisplay (w); Window win = XtWindow (w); TPoint newpupil[2]; XPoint xnewpupil, xpupil; if (XtIsRealized((Widget)w)) { XQueryPointer (dpy, win, &rep_root, &rep_child, &rep_rootx, &rep_rooty, &dx, &dy, &rep_mask); mouse.x = Tx(dx, dy, &w->eyes.t); mouse.y = Ty(dx, dy, &w->eyes.t); if (!TPointEqual (mouse, w->eyes.mouse)) { computePupils (mouse, newpupil); xpupil.x = Xx(w->eyes.pupil[0].x, w->eyes.pupil[0].y, &w->eyes.t); xpupil.y = Xy(w->eyes.pupil[0].x, w->eyes.pupil[0].y, &w->eyes.t); xnewpupil.x = Xx(newpupil[0].x, newpupil[0].y, &w->eyes.t); xnewpupil.y = Xy(newpupil[0].x, newpupil[0].y, &w->eyes.t); if (!XPointEqual (xpupil, xnewpupil)) { if (w->eyes.pupil[0].x != -1000 || w->eyes.pupil[0].y != -1000) eyeBall (w, w->eyes.centerGC, 0); w->eyes.pupil[0] = newpupil[0]; eyeBall (w, w->eyes.pupGC, 0); } xpupil.x = Xx(w->eyes.pupil[1].x, w->eyes.pupil[1].y, &w->eyes.t); xpupil.y = Xy(w->eyes.pupil[1].x, w->eyes.pupil[1].y, &w->eyes.t); xnewpupil.x = Xx(newpupil[1].x, newpupil[1].y, &w->eyes.t); xnewpupil.y = Xy(newpupil[1].x, newpupil[1].y, &w->eyes.t); if (!XPointEqual (xpupil, xnewpupil)) { if (w->eyes.pupil[1].x != -1 || w->eyes.pupil[1].y != -1) eyeBall (w, w->eyes.centerGC, 1); w->eyes.pupil[1] = newpupil[1]; eyeBall (w, w->eyes.pupGC, 1); } w->eyes.mouse = mouse; w->eyes.update = 0; } else { if (delays[w->eyes.update + 1] != 0) ++w->eyes.update; } } w->eyes.interval_id = XtAppAddTimeOut(XtWidgetToApplicationContext((Widget) w), delays[w->eyes.update], draw_it, (XtPointer)w); } /* draw_it */
static void TFillArc(register Display * dpy, Drawable d, GC gc, Transform * t, double x, double y, double width, double height, int angle1, int angle2, XRectangle * rect) { int xx, xy, xw, xh; xx = Xx(x, y, t); xy = Xy(x, y, t); xw = Xwidth(width, height, t); xh = Xheight(width, height, t); if (xw < 0) { xx += xw; xw = -xw; } if (xh < 0) { xy += xh; xh = -xh; } XFillArc(dpy, d, gc, xx, xy, xw, xh, angle1, angle2); if (rect != NULL) { rect->x = xx; rect->y = xy; rect->width = xw; rect->height = xh; } }
static void drawEye(EyesWidget w, TPoint newpupil, int num) { XPoint xnewpupil, xpupil; xpupil.x = Xx(w->eyes.pupil[num].x, w->eyes.pupil[num].y, &w->eyes.t); xpupil.y = Xy(w->eyes.pupil[num].x, w->eyes.pupil[num].y, &w->eyes.t); xnewpupil.x = Xx(newpupil.x, newpupil.y, &w->eyes.t); xnewpupil.y = Xy(newpupil.x, newpupil.y, &w->eyes.t); if ( !XPointEqual(xpupil, xnewpupil)) { TPoint oldpupil = w->eyes.pupil[num]; w->eyes.pupil[num] = newpupil; eyeBall (w, TRUE, &oldpupil, num); } }
static void FillArc(Display *dpy, Drawable d, GC gc, Transform *t, double x, double y, double width, double height, int angle1, int angle2) { int xx, xy, xw, xh; xx = Xx(x,y,t); xy = Xy(x,y,t); xw = Xwidth (width, height, t); xh = Xheight (width, height, t); if (xw < 0) { xx += xw; xw = -xw; } if (xh < 0) { xy += xh; xh = -xh; } XFillArc(dpy, d, gc, xx, xy, xw, xh, angle1, angle2); }