void frame_update_attr(WFrame *frame, int i, WRegion *reg) { GrStyleSpec *spec; bool selected, tagged, dragged, activity; if(i>=frame->titles_n){ /* Might happen when deinitialising */ return; } ensure_create_attrs(); spec=&frame->titles[i].attr; selected=(reg==FRAME_CURRENT(frame)); tagged=(reg!=NULL && reg->flags®ION_TAGGED); dragged=(i==frame->tab_dragged_idx); activity=(reg!=NULL && region_is_activity_r(reg)); gr_stylespec_unalloc(spec); gr_stylespec_set(spec, selected ? GR_ATTR(selected) : GR_ATTR(unselected)); gr_stylespec_set(spec, tagged ? GR_ATTR(tagged) : GR_ATTR(not_tagged)); gr_stylespec_set(spec, dragged ? GR_ATTR(dragged) : GR_ATTR(not_dragged)); gr_stylespec_set(spec, activity ? GR_ATTR(activity) : GR_ATTR(no_activity)); }
static void deinit_entries(WMenu *menu) { int i; for(i=0; i<menu->n_entries; i++){ gr_stylespec_unalloc(&menu->entries[i].attr); if(menu->entries[i].title!=NULL) free(menu->entries[i].title); } free(menu->entries); }
void de_free_colour_group(WRootWin *rootwin, DEColourGroup *cg) { DEColour pixels[5]; pixels[0]=cg->bg; pixels[1]=cg->fg; pixels[2]=cg->hl; pixels[3]=cg->sh; pixels[4]=cg->pad; XFreeColors(ioncore_g.dpy, rootwin->default_cmap, pixels, 5, 0); gr_stylespec_unalloc(&cg->spec); }
bool infowin_init(WInfoWin *p, WWindow *parent, const WFitParams *fp, const char *style) { XSetWindowAttributes attr; if(!window_init(&(p->wwin), parent, fp)) return FALSE; p->buffer=ALLOC_N(char, INFOWIN_BUFFER_LEN); if(p->buffer==NULL) goto fail; p->buffer[0]='\0'; if(style==NULL) p->style=scopy("*"); else p->style=scopy(style); if(p->style==NULL) goto fail2; p->brush=NULL; gr_stylespec_init(&p->attr); infowin_updategr(p); if(p->brush==NULL) goto fail3; /* Enable save unders */ attr.save_under=True; XChangeWindowAttributes(ioncore_g.dpy, p->wwin.win, CWSaveUnder, &attr); window_select_input(&(p->wwin), IONCORE_EVENTMASK_NORMAL); return TRUE; fail3: gr_stylespec_unalloc(&p->attr); free(p->style); fail2: free(p->buffer); fail: window_deinit(&(p->wwin)); return FALSE; }
void infowin_deinit(WInfoWin *p) { if(p->buffer!=NULL){ free(p->buffer); p->buffer=NULL; } if(p->style!=NULL){ free(p->style); p->style=NULL; } if(p->brush!=NULL){ grbrush_release(p->brush); p->brush=NULL; } gr_stylespec_unalloc(&p->attr); window_deinit(&(p->wwin)); }
void de_free_colour_group(WRootWin *rootwin, DEColourGroup *cg) { #ifdef HAVE_X11_XFT de_free_colour(rootwin, cg->bg); de_free_colour(rootwin, cg->fg); de_free_colour(rootwin, cg->hl); de_free_colour(rootwin, cg->sh); de_free_colour(rootwin, cg->pad); #else /* HAVE_X11_XFT */ DEColour pixels[5]; pixels[0]=cg->bg; pixels[1]=cg->fg; pixels[2]=cg->hl; pixels[3]=cg->sh; pixels[4]=cg->pad; XFreeColors(ioncore_g.dpy, rootwin->default_cmap, pixels, 5, 0); gr_stylespec_unalloc(&cg->spec); #endif /* HAVE_X11_XFT */ }
bool gr_stylespec_load_(GrStyleSpec *spec, const char *str, bool no_order_score) { uint score=(no_order_score ? 1 : count_dashes(str)+1); gr_stylespec_init(spec); while(str!=NULL){ GrAttr a; const char *p=strchr(str, '-'); if(p==NULL){ a=stringstore_alloc(str); str=p; }else{ a=stringstore_alloc_n(str, p-str); str=p+1; } if(a==STRINGID_NONE) goto fail; if(!gr_stylespec_add(spec, a, score)) goto fail; stringstore_free(a); if(!no_order_score) score--; } return TRUE; fail: gr_stylespec_unalloc(spec); return FALSE; }
/*EXTL_DOC * Define a style for the root window \var{rootwin}. */ EXTL_EXPORT bool de_defstyle_rootwin(WRootWin *rootwin, const char *name, ExtlTab tab) { DEStyle *style, *based_on=NULL; char *fnt, *bss; if(name==NULL) return FALSE; style=de_create_style(rootwin, name); if(style==NULL) return FALSE; if(extl_table_gets_s(tab, "based_on", &bss)){ GrStyleSpec bs; gr_stylespec_load(&bs, bss); based_on=de_get_style(rootwin, &bs); gr_stylespec_unalloc(&bs); free(bss); }else{ based_on=de_get_style(rootwin, &style->spec); } if(based_on!=NULL){ style->based_on=based_on; based_on->usecount++; } de_get_nonfont(rootwin, style, tab); if(extl_table_gets_s(tab, "font", &fnt)){ de_load_font_for_style(style, fnt); free(fnt); }else if(based_on!=NULL && based_on->font!=NULL){ de_set_font_for_style(style, based_on->font); } if(style->font==NULL) de_load_font_for_style(style, de_default_fontname()); if(based_on!=NULL && gr_stylespec_equals(&based_on->spec, &style->spec)){ /* The new style replaces based_on, so it may be dumped. */ if(!based_on->is_fallback) destyle_dump(based_on); if(based_on->usecount==1){ uint nb=based_on->n_extra_cgrps; uint ns=style->n_extra_cgrps; /* Nothing else is using based_on: optimise and move * extra colour groups here, so that based_on can be freed. */ if(nb>0){ DEColourGroup *cgs=ALLOC_N(DEColourGroup, nb+ns); if(cgs!=NULL){ memcpy(cgs, based_on->extra_cgrps, sizeof(DEColourGroup)*nb); memcpy(cgs+nb, style->extra_cgrps, sizeof(DEColourGroup)*ns); free(style->extra_cgrps); style->extra_cgrps=cgs; style->n_extra_cgrps=nb+ns; free(based_on->extra_cgrps); based_on->extra_cgrps=NULL; based_on->n_extra_cgrps=0; } } /* style->extras_table should be none still */ style->extras_table=based_on->extras_table; based_on->extras_table=extl_table_none(); style->based_on=based_on->based_on; based_on->based_on=NULL; destyle_unref(based_on); } } filter_extras(&style->extras_table, tab); destyle_add(style); return TRUE; }