void handle_maprequest(XEvent *evt) { XMapRequestEvent * mre = &(evt->xmaprequest); XWindowAttributes attr; if (init_stage == 1) { init_stage = 2; XGetWindowAttributes(gdi.display, mre->window, &attr); init_tabbar(attr.width); the_bar.x=0; the_bar.y = attr.height; realize_tab_bar(gdi.mainw); XResizeWindow(gdi.display, gdi.mainw, attr.width, attr.height + the_bar.height); match_size_hints(mre->window, the_bar.height); new_tab(mre->window); } else if(the_bar.win == mre->window) { } else { /* it's our new child */ XMoveResizeWindow(gdi.display, mre->window, 0, tab_options.tabs_on_top?the_bar.height:0, gdi.width, gdi.height - the_bar.height); new_tab(mre->window); } XMapWindow(gdi.display, mre->window); }
static void on_context_new_tab(GtkWidget *widget, ChmSee *self) { g_debug("On context open new tab: %s", selfp->context_menu_link); if (selfp->context_menu_link != NULL) { new_tab(self, selfp->context_menu_link); } }
void handle_reparent(XEvent * evt) { XReparentEvent * xre = &(evt->xreparent); /* news about a child window, maybe: it's our own window; (fine) it's the first free xterm; (fine) it's the wm giving it up; (we'll take it) it's sawfish hesitating giving it up (we ask again) it's we giving out a child */ #ifdef WRESTLE_FOR_CHILD fprintf(stderr, "Reparent: e%08x w%08x p%08x\n", xre->event, xre->window, xre->parent); fprintf(stderr, "\tWe are: %08x\n", gdi.mainw); #endif/*WRESTLE_FOR_CHILD*/ if (xre->parent != gdi.mainw && is_tabbed_window(xre->window)) /* WM wants it back. No. */ { #ifdef WRESTLE_FOR_CHILD fprintf(stderr, "WM wants child back. No way.\n"); #endif/*WRESTLE_FOR_CHILD*/ XReparentWindow(gdi.display, xre->window, gdi.mainw, 0, 0); return; } if (!is_expected_child(xre->window)) /* "don't care" category */ return; /* so we do expect this child, whose was it? */ Window parent = get_parent(xre->window); if (parent == gdi.mainw) { #ifdef WRESTLE_FOR_CHILD fprintf(stderr, "\tit's our child\n"); #endif/*WRESTLE_FOR_CHILD*/ received_child(xre->window); XMoveResizeWindow(gdi.display, xre->window, 0, tab_options.tabs_on_top?the_bar.height:0, gdi.width, gdi.height - the_bar.height); // match_size_hints(xre->window, the_bar.height); new_tab(xre->window); } else { /* One has to ask twice to take a child from sawfish. So we do that. */ #ifdef WRESTLE_FOR_CHILD fprintf(stderr, "\tit's NOT our child, i'll ask again\n"); #endif/*WRESTLE_FOR_CHILD*/ XReparentWindow(gdi.display, xre->window, gdi.mainw, 0, 0); } return; }
static void on_open_new_tab(GtkWidget *widget, ChmSee *self) { ChmseeIhtml *html; const gchar *location; g_message("Open new tab"); html = get_active_html(self); location = chmsee_ihtml_get_location(html); if (location != NULL) { new_tab(self, location); } }
/****** check_write ******************************************************** PROTO void check_write(fieldstruct *field, char *checkname, checkenum checktype, int ext, int next, int cubeflag) PURPOSE Write a FITS image for check. INPUT Pointer to the field, Pointer to the set, Check-image filename, Check-image type, Extension number, Number of extensions, Datacube flag. OUTPUT -. NOTES Check-image is written as a datacube if cubeflag!=0. AUTHOR E. Bertin (IAP) VERSION 21/09/2015 ***/ void check_write(fieldstruct *field, setstruct *set, char *checkname, checkenum checktype, int ext, int next, int cubeflag) { psfstruct *psf; catstruct *cat; tabstruct *tab; samplestruct **gridsample, *sample,*osample; char filename[MAXCHAR], str[82], *head, *pstr,*pstr2; static double dpos[POLY_MAXDIM], *dpost; double dstep,dstart, dval1,dval2, scalefac, dstepx,dstepy; float *pix,*pix0, *vig,*vig0, *fpix,*fpixsym, val; int i,g,j,l,x,y, w,h,n, npc,nt, nw,nh,np, npos,npos2, step,step2, ipos, inpos, ival1,ival2, npix; /* Create the new cat (well it is not a "cat", but simply a FITS table */ if (!ext) { cat = new_cat(1); init_cat(cat); strcpy(cat->filename, checkname); if (!(pstr = strrchr(cat->filename, '.'))) pstr = cat->filename+strlen(cat->filename); strcpy(filename, field->rcatname); if (!(pstr2 = strrchr(filename, '.'))) pstr2 = filename+strlen(filename); *pstr2 = '\0'; sprintf(pstr, "_%s.fits", filename); if (open_cat(cat, WRITE_ONLY) != RETURN_OK) error(EXIT_FAILURE, "*Error*: cannot open for writing ", cat->filename); if (next>1) { addkeywordto_head(cat->tab, "NEXTEND ", "Number of extensions"); fitswrite(cat->tab->headbuf, "NEXTEND", &next, H_INT, T_LONG); save_tab(cat, cat->tab); } field->ccat[checktype] = cat; } else cat = field->ccat[checktype]; sprintf(str, "chip%02d", ext+1); psf = field->psf[ext]; tab = new_tab(str); head = tab->headbuf; tab->bitpix = BP_FLOAT; tab->bytepix = t_size[T_FLOAT]; switch(checktype) { case PSF_BASIS: /*---- View basis vectors as small vignets */ if (cubeflag) { tab->naxis = 3; QREALLOC(tab->naxisn, int, tab->naxis); tab->naxisn[0] = psf->size[0]; tab->naxisn[1] = psf->size[1]; tab->naxisn[2] = psf->nbasis; npix = tab->naxisn[0]*tab->naxisn[1]*tab->naxisn[2]; tab->tabsize = tab->bytepix*npix; QCALLOC(pix0, float, tab->tabsize); tab->bodybuf = (char *)pix0; pix = pix0; fpix = psf->basis; for (i=npix; i--;) *(pix++) = *(fpix++); } else { nw = (int)sqrt((double)psf->nbasis); nw = ((nw-1)/10+1)*10; nh = (psf->nbasis-1)/nw + 1; w = psf->size[0]; h = psf->dim>1? psf->size[1] : 1; tab->naxisn[0] = nw*w; tab->naxisn[1] = nh*h; step = (nw-1)*w; tab->tabsize = tab->bytepix*tab->naxisn[0]*tab->naxisn[1]; QCALLOC(pix0, float, tab->tabsize); tab->bodybuf = (char *)pix0; fpix = psf->basis; for (n=0; n<psf->nbasis; n++) { pix = pix0 + ((n%nw) + (n/nw)*nw*h)*w; for (y=h; y--; pix += step) for (x=w; x--;) *(pix++) = *(fpix++); } } break; case PSF_CHI: /*---- sqrt(chi2) map in PSF pixel-space nw = 1; nh = 1; w = psf->size[0]; h = psf->size[1]; tab->naxisn[0] = nw*w; tab->naxisn[1] = nh*h; tab->tabsize = tab->bytepix*tab->naxisn[0]*tab->naxisn[1]; QCALLOC(pix0, float, tab->tabsize); tab->bodybuf = (char *)pix0; pix = pix0; fpix = psf->resi; for (i=w*h; i--;) *(pix++) = *(fpix++); break; */ if (cubeflag) { tab->naxis = 3; QREALLOC(tab->naxisn, int, tab->naxis); tab->naxisn[0] = set->vigsize[0]; tab->naxisn[1] = set->vigsize[1]; tab->naxisn[2] = set->ngood? set->ngood : 1; npix = tab->naxisn[0]*tab->naxisn[1]; tab->tabsize = tab->bytepix*npix*tab->naxisn[2]; QCALLOC(pix0, float, tab->tabsize); tab->bodybuf = (char *)pix0; pix = pix0; sample = set->sample; for (n=set->nsample; n--; sample++) { if (sample->badflag) continue; fpix = sample->vigchi; for (i=npix; i--;) *(pix++) = *(fpix++); } } else {
/* Read the catalog config file */ void readcatparams(char *filename) { keystruct *key; FILE *infile; char str[MAXCHAR], *keyword, *sstr; int i, size; /* Prepare the OBJECTS tables*/ objtab = new_tab("OBJECTS"); if ((infile = fopen(filename,"r")) == NULL) error(EXIT_FAILURE, "*ERROR*: can't read ", filename); /* Scan the catalog config file*/ thecat.nparam = 0; while (fgets(str, MAXCHAR, infile)) { sstr = str + strspn(str," \t"); if (*sstr!=(char)'#' && *sstr!=(char)'\n') { keyword = strtok(sstr, " \t{[(\n\r"); if (keyword && (i = findkey(keyword,(char *)objkey,sizeof(keystruct)))!=RETURN_ERROR) { key = objkey+i; add_key(key, objtab, 0); *((char *)key->ptr) = (char)'\1'; thecat.nparam++; if (key->naxis) { for (i=0; i<key->naxis; i++) key->naxisn[i] = 1; size=t_size[key->ttype]; for (i=0; (sstr = strtok(NULL, " \t,;.)]}\r")) && *sstr!=(char)'#' && *sstr!=(char)'\n'; i++) { if (i>=key->naxis) error(EXIT_FAILURE, "*Error*: too many dimensions for keyword ", keyword); if (!(size*=(key->naxisn[i]=atoi(sstr)))) error(EXIT_FAILURE, "*Error*: wrong array syntax for keyword ", keyword); } key->nbytes = size; } } else warning(keyword, " catalog parameter unknown"); } } fclose(infile); /* Now we copy the flags to the proper structures */ flagobj = outobj; flagobj2 = outobj2; /* Differentiate between outobj and outobj2 vectors */ memset(&outobj2, 0, sizeof(outobj2)); updateparamflags(); return; }