void splitfloat_tl_cnt_to_pwin(WSplitFloat *split, WRectangle *g) { if(split->ssplit.dir==SPLIT_HORIZONTAL) g->w=MAXOF(1, g->w+split->tlpwin->bdw.right); else g->h=MAXOF(1, g->h+split->tlpwin->bdw.bottom); }
int diameterOfTree(tree_node *root){ if(root == NULL) return 0; int ldiameter = diameterOfTree(root->left); int rdiameter = diameterOfTree(root->right); int lHeight = height_of_tree(root->left); int rHeight = height_of_tree(root->right); return MAXOF((lHeight + rHeight + 1), MAXOF(ldiameter, rdiameter)); }
/*EXTL_DOC * Set module basic settings. The parameter table may contain the * following fields: * * \begin{tabularx}{\linewidth}{lX} * \tabhead{Field & Description} * \var{scroll_amount} & Number of pixels to scroll at a time in * pointer-controlled menus when one extends * beyond a border of the screen and the pointer * touches that border. \\ * \var{scroll_delay} & Time between such scrolling events in * milliseconds. * \end{tabularx} */ EXTL_EXPORT void mod_menu_set(ExtlTab tab) { int a, t; if(extl_table_gets_i(tab, "scroll_amount", &a)) scroll_amount=MAXOF(0, a); if(extl_table_gets_i(tab, "scroll_delay", &t)) scroll_time=MAXOF(0, t); }
// -- set the nullable flag and recompute the alignment of the type // // If physical nulls are not supported, then logical nulls are not either // (if physicalNulls is False, then logicalNulls is ignored). // void NAType::setNullable(NABoolean physicalNulls, NABoolean logicalNulls) { if (physicalNulls && !logicalNulls) SQLnullFlag_ = NOT_NULL_DROPPABLE; else SQLnullFlag_ = physicalNulls ? ALLOWS_NULLS : NOT_NULL_NOT_DROPPABLE; SQLnullHdrSize_ = physicalNulls ? SQL_NULL_HDR_SIZE : 0; totalAlignment_ = MAXOF(MAXOF(dataAlignment_,SQLnullHdrSize_),lengthHdrSize_); }
void splitfloat_br_cnt_to_pwin(WSplitFloat *split, WRectangle *g) { if(split->ssplit.dir==SPLIT_HORIZONTAL){ int delta=split->tlpwin->bdw.left; g->w=MAXOF(1, g->w+delta); g->x-=delta; }else{ int delta=split->tlpwin->bdw.top; g->h=MAXOF(1, g->h+delta); g->y-=delta; } }
Window create_xwindow(WRootWin *rw, Window par, const WRectangle *geom, const char *name) { int w=MAXOF(1, geom->w); int h=MAXOF(1, geom->h); const char *p[1]; Window window; window = XCreateSimpleWindow(ioncore_g.dpy, par, geom->x, geom->y, w, h, 0, 0, BlackPixel(ioncore_g.dpy, rw->xscr)); p[0] = name; xwindow_set_text_property(window, XA_WM_NAME, p, 1); return window; }
void frame_border_inner_geom(const WFrame *frame, WRectangle *geom) { GrBorderWidths bdw; frame_border_geom(frame, geom); if(frame->brush!=NULL){ grbrush_get_border_widths(frame->brush, &bdw); geom->x+=bdw.left; geom->y+=bdw.top; geom->w=MAXOF(0, geom->w-(bdw.left+bdw.right)); geom->h=MAXOF(0, geom->h-(bdw.top+bdw.bottom)); } }
static void adjust_tls_brs(int *tls, int *brs, int total) { if(*tls<=0) *tls=MINS; if(*brs<=0) *brs=MINS; if(*tls+*brs<total){ *tls=total*(*tls)/(*tls+*brs); *brs=total-(*tls); } *tls=MINOF(MAXOF(MINS, *tls), total); *brs=MINOF(MAXOF(MINS, *brs), total); }
static void get_inner_geom(WMenu *menu, WRectangle *geom) { GrBorderWidths bdw; get_outer_geom(menu, geom); if(menu->brush!=NULL){ grbrush_get_border_widths(menu->brush, &bdw); geom->x+=bdw.left; geom->y+=bdw.top; geom->w-=bdw.left+bdw.right; geom->h-=bdw.top+bdw.bottom; geom->w=MAXOF(0, geom->w); geom->h=MAXOF(0, geom->h); } }
static void menu_firstfit(WMenu *menu, bool submenu, const WRectangle *refg) { WRectangle geom; calc_size(menu, &(geom.w), &(geom.h)); if(!(menu->last_fp.mode®ION_FIT_BOUNDS)){ geom.x=menu->last_fp.g.x; geom.y=menu->last_fp.g.y; }else if(menu->pmenu_mode){ geom.x=refg->x; geom.y=refg->y; if(!submenu){ const WRectangle *maxg = ®ION_GEOM(REGION_PARENT((WRegion*)menu)); geom.x-=geom.w/2; geom.y+=POINTER_OFFSET; if(geom.y+MINIMUM_Y_VISIBILITY>maxg->y+maxg->h){ geom.y=maxg->y+maxg->h-MINIMUM_Y_VISIBILITY; geom.x=refg->x+POINTER_OFFSET; if(geom.x+geom.w>maxg->x+maxg->w) geom.x=refg->x-geom.w-POINTER_OFFSET; }else{ if(geom.x<0) geom.x=0; else if(geom.x+geom.w>maxg->x+maxg->w) geom.x=maxg->x+maxg->w-geom.w; } } }else{ const WRectangle *maxg=&(menu->last_fp.g); if(submenu){ int l, r, t, b, xoff, yoff; get_placement_offs(menu, &xoff, &yoff); l=refg->x+xoff; r=refg->x+refg->w+xoff; t=refg->y-yoff; b=refg->y+refg->h-yoff; geom.x=MAXOF(l, r-geom.w); if(geom.x+geom.w>maxg->x+maxg->w) geom.x=maxg->x; geom.y=MINOF(b-geom.h, t); if(geom.y<maxg->y) geom.y=maxg->y; }else{ geom.x=maxg->x; geom.y=maxg->y+maxg->h-geom.h; } } window_do_fitrep(&menu->win, NULL, &geom); }
NAType::NAType( const NAString& adtName, NABuiltInTypeEnum ev, Lng32 dataStorageSize, NABoolean nullable, Lng32 SQLnullHdrSize, NABoolean varLenFlag, Lng32 lengthHdrSize, Lng32 dataAlignment, NAMemory * h ) : typeName_ (h) // memleak fix , displayDataType_ (h) { // The following assertion is commented out so that zero-length // strings can be supported. // ComASSERT(dataStorageSize > 0); // for now, both null indicator has to be a short and the // var len size can be a short or a long?? // The following assertion is commented out. // Records can contain nullable fields and not have a // null Header. Same for arrays. // ComASSERT(SQLnullHdrSize == 2 || !nullable); ComASSERT(lengthHdrSize == 2 || lengthHdrSize == 4 || !varLenFlag); // supported alignments are none, 2, 4, and 8 bytes if (dataAlignment == 0) dataAlignment = 1; ComASSERT((dataAlignment == 1) || (dataAlignment == 2) || (dataAlignment == 4) || (dataAlignment == 8)); // Do NOT assert(dataStorageSize>0); that is the NAType::isValid() method. typeName_ = adtName; qualifier_ = ev; dataStorageSize_ = dataStorageSize; SQLnullFlag_ = nullable ? ALLOWS_NULLS : NOT_NULL_NOT_DROPPABLE; SQLnullHdrSize_ = nullable ? SQLnullHdrSize : 0; varLenFlag_ = varLenFlag; lengthHdrSize_ = varLenFlag_ ? lengthHdrSize : 0; dataAlignment_ = dataAlignment; // the total alignment of the type is the max of the alignments of // the null indicator, the var len field, and the data itself, // where the former two are aligned as numbers totalAlignment_ = MAXOF(MAXOF(dataAlignment_,SQLnullHdrSize_),lengthHdrSize_); } // NAType()
void rqgeomparams_from_table(WRQGeomParams *rq, const WRectangle *origg, ExtlTab g) { rq->geom=*origg; rq->flags=REGION_RQGEOM_WEAK_ALL; if(extl_table_gets_i(g, "x", &(rq->geom.x))) rq->flags&=~REGION_RQGEOM_WEAK_X; if(extl_table_gets_i(g, "y", &(rq->geom.y))) rq->flags&=~REGION_RQGEOM_WEAK_Y; if(extl_table_gets_i(g, "w", &(rq->geom.w))) rq->flags&=~REGION_RQGEOM_WEAK_W; if(extl_table_gets_i(g, "h", &(rq->geom.h))) rq->flags&=~REGION_RQGEOM_WEAK_H; rq->geom.w=MAXOF(1, rq->geom.w); rq->geom.h=MAXOF(1, rq->geom.h); }
void ioncore_set_moveres_accel(ExtlTab tab) { int t_max, t_min, rd, er; double step, maxacc; if(extl_table_gets_i(tab, "kbresize_t_max", &t_max)) actmax=(t_max>0 ? t_max : INT_MAX); if(extl_table_gets_i(tab, "kbresize_t_min", &t_min)) uptmin=(t_min>0 ? t_min : INT_MAX); if(extl_table_gets_d(tab, "kbresize_step", &step)) accelinc=(step>0 ? step : 1); if(extl_table_gets_d(tab, "kbresize_maxacc", &maxacc)) accelmax=(maxacc>0 ? maxacc*maxacc : 1); if(extl_table_gets_i(tab, "kbresize_delay", &rd)) resize_delay=MAXOF(0, rd); if(extl_table_gets_i(tab, "edge_resistance", &er)) ioncore_edge_resistance=MAXOF(0, er); }
/** \brief gets the maximum number of digits of a double * * \param x double the input double * \return uint the maximum number of digits * */ uint get_nodd(double x) { char strf[128], stre[128]; snprintf(strf, 128, "%f", x); snprintf(stre, 128, "%e", x); uint f = strlen(strf), e = strlen(stre); return MAXOF(f, e); }
void priority_handle_request (flux_t *h, struct queue *queue, struct event_ctx *event_ctx, const flux_msg_t *msg) { uint32_t userid; uint32_t rolemask; flux_jobid_t id; struct job *job; int priority; const char *errstr = NULL; if (flux_request_unpack (msg, NULL, "{s:I s:i}", "id", &id, "priority", &priority) < 0 || flux_msg_get_userid (msg, &userid) < 0 || flux_msg_get_rolemask (msg, &rolemask) < 0) goto error; if (priority < FLUX_JOB_PRIORITY_MIN || priority > FLUX_JOB_PRIORITY_MAX) { errstr = "priority value is out of range"; errno = EINVAL; goto error; } if (!(job = queue_lookup_by_id (queue, id))) { errstr = "unknown job"; goto error; } /* Security: guests can only adjust jobs that they submitted. */ if (!(rolemask & FLUX_ROLE_OWNER) && userid != job->userid) { errstr = "guests can only reprioritize their own jobs"; errno = EPERM; goto error; } /* Security: guests can only reduce priority, or increase up to default. */ if (!(rolemask & FLUX_ROLE_OWNER) && priority > MAXOF (FLUX_JOB_PRIORITY_DEFAULT, job->priority)) { errstr = "guests can only adjust priority <= default"; errno = EPERM; goto error; } /* Post event, change job's queue position, and respond. */ if (event_job_post_pack (event_ctx, job, "priority", "{ s:i s:i }", "userid", userid, "priority", priority) < 0) goto error; queue_reorder (queue, job, job->queue_handle); if (flux_respond (h, msg, NULL) < 0) flux_log_error (h, "%s: flux_respond", __FUNCTION__); return; error: if (flux_respond_error (h, msg, errno, errstr) < 0) flux_log_error (h, "%s: flux_respond_error", __FUNCTION__); }
static int scrolld_subs(WMenu *menu, int d) { int diff=0; WRegion *p=REGION_PARENT_REG(menu); const WRectangle *pg; if(p==NULL) return 0; pg=®ION_GEOM(p); while(menu!=NULL){ int new_diff = calc_diff(®ION_GEOM(menu), pg, d); diff=MAXOF(diff, new_diff); menu=menu->submenu; } return MINOF(MAXOF(0, diff), scroll_amount); }
void region_clear_mgd_activity(WRegion *mgr) { if(mgr==NULL) return; mgr->mgd_activity=MAXOF(0, mgr->mgd_activity-1); if(!region_is_activity_r(mgr)){ region_notify_change(mgr, ioncore_g.notifies.sub_activity); region_clear_mgd_activity(REGION_MANAGER(mgr)); } }
void frame_border_geom(const WFrame *frame, WRectangle *geom) { geom->x=0; geom->y=0; geom->w=REGION_GEOM(frame).w; geom->h=REGION_GEOM(frame).h; if(!BAR_INSIDE_BORDER(frame) && frame->brush!=NULL){ geom->y+=frame->bar_h; geom->h=MAXOF(0, geom->h-frame->bar_h); } }
void frame_managed_geom(const WFrame *frame, WRectangle *geom) { uint spacing=get_spacing(frame); frame_border_inner_geom(frame, geom); /* geom->x+=spacing; geom->y+=spacing; geom->w-=2*spacing; geom->h-=2*spacing; */ if(BAR_INSIDE_BORDER(frame) && BAR_EXISTS(frame)){ geom->y+=frame->bar_h+spacing; geom->h-=frame->bar_h+spacing; } geom->w=MAXOF(geom->w, 0); geom->h=MAXOF(geom->h, 0); }
static void calc_amount(int *amount, int *oamount, int rs, WSplitSplit *p, int omax, const WRectangle *ng, const WRectangle *og) { *oamount=0; if(rs>=0){ if(p->dir==SPLIT_VERTICAL) *amount=MAXOF(0, MINOF(rs, GEOM(p).h-ng->h)); else *amount=MAXOF(0, MINOF(rs, GEOM(p).w-ng->w)); }else{ if(p->dir==SPLIT_VERTICAL){ int overlap=MAXOF(0, og->h-(GEOM(p).h-ng->h)); *amount=-MINOF(-rs, overlap); *oamount=MAXOF(0, MINOF(*amount-rs, omax-og->h)); *amount-=*oamount; }else{ int overlap=MAXOF(0, og->w-(GEOM(p).w-ng->w)); *amount=-MINOF(-rs, overlap); *oamount=MAXOF(0, MINOF(*amount-rs, omax-og->w)); *amount-=*oamount; } } }
static void adjust_sizes(int *tls_, int *brs_, int nsize, int tlmin, int brmin, int tlmax, int brmax, int primn) { int tls=MAXOF(0, *tls_); int brs=MAXOF(0, *brs_); nsize=MAXOF(1, nsize); if(primn==PRIMN_TL){ tls=MAXOF(1, nsize-brs); bound(&tls, tlmin, tlmax); brs=nsize-tls; bound(&brs, brmin, brmax); tls=nsize-brs; bound(&tls, tlmin, tlmax); }else if(primn==PRIMN_BR){ brs=MAXOF(1, nsize-tls); bound(&brs, brmin, brmax); tls=nsize-brs; bound(&tls, tlmin, tlmax); brs=nsize-tls; bound(&brs, brmin, brmax); }else{ /* && PRIMN_ANY */ tls=tls*nsize/MAXOF(2, tls+brs); bound(&tls, tlmin, tlmax); brs=nsize-tls; bound(&brs, brmin, brmax); tls=nsize-brs; bound(&tls, tlmin, tlmax); } *tls_=tls; *brs_=brs; }
void CacheWA::operator+=(const char* s) { // If the current remaining space on qryText_ is less than // strlen(s)+1, we double the capacity for qryText_ in one call // to adjustMemory(). size_t cap = qryText_.capacity(); size_t len = strlen(s); if ( cap - qryText_.length() < len + 1) { qryText_.adjustMemory(MAXOF(len, 2 * cap)); } qryText_.append(s, len); }
static void menu_do_refit(WMenu *menu, WWindow *par, const WFitParams *oldfp) { WRectangle geom; calc_size(menu, &(geom.w), &(geom.h)); if(!(menu->last_fp.mode®ION_FIT_BOUNDS)){ geom.x=menu->last_fp.g.x; geom.y=menu->last_fp.g.y; }else if(menu->pmenu_mode){ geom.x=REGION_GEOM(menu).x; geom.y=REGION_GEOM(menu).y; }else{ const WRectangle *maxg=&(menu->last_fp.g); int xdiff=REGION_GEOM(menu).x-oldfp->g.x; int ydiff=(REGION_GEOM(menu).y+REGION_GEOM(menu).h -(oldfp->g.y+oldfp->g.h)); geom.x=MAXOF(0, MINOF(maxg->x+xdiff, maxg->x+maxg->w-geom.w)); geom.y=MAXOF(0, MINOF(maxg->y+maxg->h+ydiff, maxg->y+maxg->h)-geom.h); } window_do_fitrep(&menu->win, par, &geom); }
static void splitfloat_update_bounds(WSplitFloat *split, bool recursive) { WSplit *tl=split->ssplit.tl, *br=split->ssplit.br; WSplit *node=(WSplit*)split; int tl_max_w, br_max_w, tl_max_h, br_max_h; int tl_min_w, br_min_w, tl_min_h, br_min_h; if(recursive){ split_update_bounds(tl, recursive); split_update_bounds(br, recursive); } tl_max_w=splitfloat_get_max(split, SPLIT_HORIZONTAL, tl); br_max_w=splitfloat_get_max(split, SPLIT_HORIZONTAL, br); tl_max_h=splitfloat_get_max(split, SPLIT_VERTICAL, tl); br_max_h=splitfloat_get_max(split, SPLIT_VERTICAL, br); tl_min_w=splitfloat_get_min(split, SPLIT_HORIZONTAL, tl); br_min_w=splitfloat_get_min(split, SPLIT_HORIZONTAL, br); tl_min_h=splitfloat_get_min(split, SPLIT_VERTICAL, tl); br_min_h=splitfloat_get_min(split, SPLIT_VERTICAL, br); if(split->ssplit.dir==SPLIT_HORIZONTAL){ node->max_w=infadd(tl_max_w, br_max_w); node->min_w=MINOF(tl_min_w, br_min_w); node->unused_w=0; node->min_h=MAXOF(tl_min_h, br_min_h); node->max_h=MAXOF(MINOF(tl_max_h, br_max_h), node->min_h); node->unused_h=MINOF(tl->unused_h, br->unused_h); }else{ node->max_h=infadd(tl_max_h, br_max_h); node->min_h=MINOF(tl_min_h, br_min_h); node->unused_h=0; node->min_w=MAXOF(tl_min_w, br_min_w); node->max_w=MAXOF(MINOF(tl_max_w, br_max_w), node->min_w); node->unused_w=MINOF(tl->unused_w, br->unused_w); } }
static void moveres_draw_infowin(WMoveresMode *mode) { char *buf; if(mode->infowin==NULL) return; buf=INFOWIN_BUFFER(mode->infowin); if(buf==NULL) return; if(mode->mode==MOVERES_SIZE){ int w, h; w=mode->geom.w; h=mode->geom.h; if(mode->hints.base_set){ w=MAXOF(0, w-mode->hints.base_width); h=MAXOF(0, h-mode->hints.base_height); } if(mode->hints.inc_set){ w/=MAXOF(1, mode->hints.width_inc); h/=MAXOF(1, mode->hints.height_inc); } snprintf(buf, INFOWIN_BUFFER_LEN, "%dx%d", w, h); }else{ snprintf(buf, INFOWIN_BUFFER_LEN, "%+d %+d", mode->geom.x, mode->geom.y); } window_draw((WWindow*)mode->infowin, TRUE); }
// this method is temp CostScalar MultiJoin::getChildrenDataFlow() const { CostScalar childrenDataFlow(0); UInt32 minRecordLength = (ActiveSchemaDB()->getDefaults())\ .getAsLong(COMP_INT_50); Int32 arity = getArity(); for (Int32 i = 0; i < arity; i++) { childrenDataFlow += child(i)->getGroupAttr()->getResultCardinalityForEmptyInput() * MAXOF(child(i)->getGroupAttr()->getRecordLength(), minRecordLength); } return childrenDataFlow; }
void menu_size_hints(WMenu *menu, WSizeHints *hints_ret) { int n=menu->n_entries; int w=menu->max_entry_w; int h=menu->entry_h*n + menu->entry_spacing*MAXOF(0, n-1); if(menu->brush!=NULL){ GrBorderWidths bdw; grbrush_get_border_widths(menu->brush, &bdw); w+=bdw.left+bdw.right; h+=bdw.top+bdw.bottom; } hints_ret->min_set=TRUE; hints_ret->min_width=w; hints_ret->min_height=h; }
WStacking *stacking_find_to_focus(WStacking *stacking, WStacking *to_try, WStackingFilter *include_filt, WStackingFilter *approve_filt, void *filt_data) { uint min_level=STACKING_LEVEL_BOTTOM; WStacking *st=NULL, *found=NULL; if(stacking==NULL) return NULL; st=stacking; do{ st=st->prev; if(st->reg==NULL) continue; if(st!=to_try && (st->reg->flags®ION_SKIP_FOCUS || !cf(include_filt, filt_data, st))){ /* skip */ continue; } if(st->level<min_level) break; /* no luck */ if(st==to_try) return st; if(found==NULL && cf(approve_filt, filt_data, st)){ found=st; if(to_try==NULL) break; } if(st->level>=STACKING_LEVEL_MODAL1) min_level=MAXOF(min_level, st->level); }while(st!=stacking); return found; }
void ioncore_groupws_set(ExtlTab tab) { char *method=NULL; int fpp; if(extl_table_gets_s(tab, "float_placement_method", &method)){ if(strcmp(method, "udlr")==0) ioncore_placement_method=PLACEMENT_UDLR; else if(strcmp(method, "lrud")==0) ioncore_placement_method=PLACEMENT_LRUD; else if(strcmp(method, "random")==0) ioncore_placement_method=PLACEMENT_RANDOM; else warn(TR("Unknown placement method \"%s\"."), method); free(method); } if(extl_table_gets_i(tab, "float_placement_padding", &fpp)) ioncore_placement_padding=MAXOF(0, fpp); }
void frame_bar_geom(const WFrame *frame, WRectangle *geom) { uint off; if(BAR_INSIDE_BORDER(frame)){ off=0; /*get_spacing(frame);*/ frame_border_inner_geom(frame, geom); }else{ off=0; geom->x=0; geom->y=0; geom->w=(frame->barmode==FRAME_BAR_SHAPED ? frame->bar_w : REGION_GEOM(frame).w); } geom->x+=off; geom->y+=off; geom->w=MAXOF(0, geom->w-2*off); geom->h=BAR_H(frame); }