void drawbookdepth() { int bid,cnt,h,len,lw,mw,my,ndx; int *yext; double del,max,mid,min,s,t,*size,*w,*y; axis *x; len=Size->n; bid=0;DO(len,bid+=0>Size->v[i]); size=g_malloc(len*sizeof(double)); DO(len,size[i]=fabs(Size->v[i])); min=dvec_min(Size); max=dvec_max(Size); cnt=MAX(2,MIN(8,(Rw-2*Lx)/XLabWid)); YLab=fmtlabel((dvec *)Data); yext=g_malloc(len*sizeof(int)); pango_layout_set_font_description(PL,LabelFont); DO(len,yext[i]=gettextwidth(YLab->v[i])); my=(int)My; lw=XLabWid/2; mw=TicLen+MAX(lw,maxi(len,yext)); setgxywh(Rx+mw,Ry+my,Rw-(mw+lw),Rh-(my+LabelHit+Ly)); x=getaxis(cnt,min,max); XPos=x->p; XLab=fmtlabel(XPos); XTic=dvec_dup(XPos); del=x->max-x->min; DO(XTic->n,XTic->v[i]=(XTic->v[i]-x->min)/del); YMin=x->min; YMax=x->max; YTic=dvec_dup(x->p); DO(YTic->n,YTic->v[i]=(YTic->v[i]-YMin)/(YMax-YMin)); h=Gh/(1+len); y=g_malloc(len*sizeof(double)); s=len;t=1.0/(2*s); DO(len,y[i]=Gy+Gh*(1-(t+i/s))); h=h/4; cairo_set_line_width(CR,1); cairo_set_source(CR,GridColor); DO(len,{ cairo_move_to(CR,Gx-TicLen,y[i]); cairo_line_to(CR,Gx+Gw,y[i]);});
static int GII_fmouse_handler(gii_input *inp, gii_event *event) { fmouse_priv *priv = inp->priv; mapping_entry *entry; int ret = 0; int has = 0; int invalue=0; static int di_sent=0; gii_pmove_event pmrel,pmabs; /* Did we already send the device info record ? Do so, if we didn't. */ if (di_sent==0) { di_sent=1; send_devinfo(inp); } DPRINT_MISC("filter-mouse: Filt check.\n"); if (event->any.origin==inp->origin) return 0; /* avoid recursion ! */ DPRINT_MISC("filter-mouse: Real check.\n"); /* Track modifiers. This allows to use stuff like shift-clicking */ if (event->any.type==evKeyPress || event->any.type==evKeyRepeat || event->any.type==evKeyRelease) { priv->modifiers=event->key.modifiers; } /* Clear the eventual relative and absolute events that will * get sent after evaluating all rules. We should probably keep the * absolute events between calls. */ _giiEventBlank((gii_event *)&pmrel, sizeof(gii_pmove_event)); pmrel.type = evPtrRelative; pmrel.size = sizeof(gii_pmove_event); pmrel.origin = inp->origin; pmrel.target = GII_EV_TARGET_ALL; pmrel.x = pmrel.y = pmrel.z = pmrel.wheel = 0; _giiEventBlank((gii_event *)&pmabs, sizeof(gii_pmove_event)); pmabs.type = evPtrAbsolute; pmabs.size = sizeof(gii_pmove_event); pmabs.origin = inp->origin; pmabs.target = GII_EV_TARGET_ALL; pmabs.x = pmabs.y = pmabs.z = pmabs.wheel = 0; /* Now go through the entries and convert as appropriate. */ for(entry = priv->entry;entry;entry = entry->next) { DPRINT_MISC("filter-mouse: Checking entry %p.\n",entry); if ((priv->modifiers&entry->modifier_mask)!= entry->modifier_value) continue; /* Modifiers are wrong. Forget it. */ switch(entry->from) { case MAP_KEY: if (event->any.type==evKeyPress|| event->any.type==evKeyRepeat) invalue=1; /* Key press */ else if (event->any.type==evKeyRelease) invalue=0; /* Key release*/ else continue; /* Something else - forget it. */ /* Continue, if the button/label/symbol doesn't match */ if (entry->fromdata.key.button!=GIIK_NIL&& entry->fromdata.key.button!=event->key.button) continue; if (entry->fromdata.key.label!=GIIK_NIL&& entry->fromdata.key.label!=event->key.label) continue; if (entry->fromdata.key.symbol!=GIIK_NIL&& entry->fromdata.key.symbol!=event->key.sym) continue; break; case MAP_REL: if (event->any.type==evPtrRelative) invalue=getaxis(&event->pmove,entry->fromdata.axis); else continue; break; case MAP_ABS: if (event->any.type==evPtrAbsolute) invalue=getaxis(&event->pmove,entry->fromdata.axis); else continue; break; case MAP_BUTTON: if (event->any.type==evPtrButtonPress && event->pbutton.button==entry->fromdata.button) invalue=1; else if (event->any.type==evPtrButtonRelease && event->pbutton.button==entry->fromdata.button) invalue=0; else continue; break; default:continue; /* Something is wrong */ } switch(entry->to) { case MAP_REL: setaxis(&pmrel, entry->todata.trans.axis, gettrans(&entry->todata.trans, (double)invalue)); ret=1;has|=HASREL; break; case MAP_ABS: setaxis(&pmabs, entry->todata.trans.axis, gettrans(&entry->todata.trans, (double)invalue)); ret = 1; has |= HASABS; break; case MAP_BUTTON: fmouse_send_pbutton(inp, invalue ? evPtrButtonPress : evPtrButtonRelease, entry->todata.button); ret = 1; break; default: continue; /* Something is WRONG here. */ } } DPRINT_MISC("filter-mouse: Checking entry %p.\n",entry); if (has&HASABS) { _giiEvQueueAdd(inp, (gii_event *) &pmabs); } if (has&HASREL) { _giiEvQueueAdd(inp, (gii_event *) &pmrel); } if (ret) DPRINT_MISC("filter-mouse: Eating event.\n"); return ret; }