void hxc_scrollbar::do_drag(int y,bool by_top){ //pass the y-position of the top of the scrolling box, or the middle XWindowAttributes wa; XGetWindowAttributes(XD,handle,&wa); int h,w; if(horizontal){ w=wa.height-2; h=wa.width-(2*(arrowheight)); }else{ w=wa.width-2; h=wa.height-(2*(arrowheight)); } int th=((viewrange)*h)/(range); if (th<w){ th=w; } h-=th; if(h<10)h=10; // int y=(my-(This->arrowheight))-(This->drag_y); if(!by_top)y-=th/2; int rr=(range)-(viewrange);if(rr<1)rr=1; pos=(y*rr)/h; rangecheck(); if (notifyproc) notifyproc(this,SBN_SCROLL,pos); }
void hxc_scrollbar::notify_reposition(int newpos) { if (newpos<0) newpos=0; if (newpos>range-viewrange) newpos=max(range-viewrange,0); if (newpos!=pos){ if (notifyproc) notifyproc(this,SBN_SCROLL,newpos); } }
//--------------------------------------------------------------------------- void hxc_popup::close(bool suppress_notify) { if (XD==NULL) return; XUngrabPointer(XD,CurrentTime); RemoveProp(XD,handle,hxc::cModal); RemoveProp(XD,handle,cWinProc); RemoveProp(XD,handle,cWinThis); if (hxc::popup_active==handle) hxc::popup_active=None; XDestroyWindow(XD,handle); hxc::free_res(XD); handle=0; XD=NULL; itemheight=0; lpig=NULL; if (notifyproc && suppress_notify==0) notifyproc(this,POP_CANCEL,-1); }
void main(int argc, char *argv[]) { int kid, pid; char servefile[Maxpath], ext[Maxpath]; Dir *dir; setnetmtpt(mntpt, sizeof mntpt, nil); ext[0] = 0; ARGBEGIN{ case 'a': maxage = atol(EARGF(usage())); if (maxage <= 0) maxage = Defmaxage; break; case 'd': debug = 1; traceactivity = 1; break; case 'f': dbfile = EARGF(usage()); break; case 'F': cfg.justforw = cfg.resolver = 1; break; case 'n': sendnotifies = 1; break; case 'N': target = atol(EARGF(usage())); if (target < 1000) target = 1000; break; case 'o': cfg.straddle = 1; /* straddle inside & outside networks */ break; case 'r': cfg.resolver = 1; break; case 'R': norecursion = 1; break; case 's': cfg.serve = 1; /* serve network */ cfg.cachedb = 1; break; case 't': testing = 1; break; case 'T': addforwtarg(EARGF(usage())); break; case 'x': setnetmtpt(mntpt, sizeof mntpt, EARGF(usage())); setext(ext, sizeof ext, mntpt); break; case 'z': zonerefreshprogram = EARGF(usage()); break; default: usage(); break; }ARGEND if(argc != 0) usage(); if(testing) mainmem->flags |= POOL_NOREUSE | POOL_ANTAGONISM; mainmem->flags |= POOL_ANTAGONISM; rfork(RFREND|RFNOTEG); cfg.inside = (*mntpt == '\0' || strcmp(mntpt, "/net") == 0); /* start syslog before we fork */ fmtinstall('F', fcallfmt); dninit(); /* this really shouldn't be fatal */ if(myipaddr(ipaddr, mntpt) < 0) sysfatal("can't read my ip address"); dnslog("starting %s%sdns %s%s%son %I's %s", (cfg.straddle? "straddling ": ""), (cfg.cachedb? "caching ": ""), (cfg.serve? "udp server ": ""), (cfg.justforw? "forwarding-only ": ""), (cfg.resolver? "resolver ": ""), ipaddr, mntpt); opendatabase(); now = time(nil); /* open time files before we fork */ nowns = nsec(); snprint(servefile, sizeof servefile, "#s/dns%s", ext); dir = dirstat(servefile); if (dir) sysfatal("%s exists; another dns instance is running", servefile); free(dir); /* don't unmount here; could deadlock */ // while (unmount(servefile, mntpt) >= 0) // ; mountinit(servefile, mntpt); /* forks, parent exits */ srand(now*getpid()); db2cache(1); // dnageallnever(); if (cfg.straddle && !seerootns()) dnslog("straddle server misconfigured; can't resolve root name servers"); /* * fork without sharing heap. * parent waits around for child to die, then forks & restarts. * child may spawn udp server, notify procs, etc.; when it gets too * big or too old, it kills itself and any children. * * /srv/dns remains open and valid, but /net/dns was only mounted in * a child's separate namespace from 9p service, to avoid a deadlock * from serving our own namespace, so we must remount it upon restart, * in a separate process and namespace. */ for (;;) { start = time(nil); /* don't unmount here; could deadlock */ // unmount(servefile, mntpt); kid = rfork(RFPROC|RFFDG|RFNOTEG|RFNAMEG); switch (kid) { case -1: sysfatal("fork failed: %r"); case 0: if(cfg.serve) dnudpserver(mntpt); if(sendnotifies) notifyproc(); io(); /* serve 9p; return implies restart */ _exits("restart"); } sleep(1000); /* wait for 9p service to start */ justremount(servefile, mntpt); while ((pid = waitpid()) != kid && pid != -1) continue; dnslog("restarting"); } }