Exemplo n.º 1
0
/*EXTL_DOC
 * Get a property \var{atom} of type \var{atom_type} for window \var{win}. 
 * The \var{n32expected} parameter indicates the expected number of 32bit
 * words, and \var{more} indicates whether all or just this amount of data
 * should be fetched. Each 8, 16 or 32bit element of the property, as
 * deciphered from \var{atom_type} is a field in the returned table.
 * See \code{XGetWindowProperty}(3) manual page for more information.
 */
EXTL_SAFE
EXTL_EXPORT
ExtlTab ioncore_x_get_window_property(int win, int atom, int atom_type,
                                      int n32expected, bool more)
{
    uchar *p=NULL;
    ExtlTab tab;
    int format=0;
    int i, n;
    
    n=xwindow_get_property_(win, atom, atom_type, n32expected, more, &p, 
                            &format);
    
    if(p==NULL)
        return extl_table_none();
    
    if(n<=0 || (format!=8 && format!=16 && format!=32)){
        free(p);
        return extl_table_none();
    }
    
    tab=extl_create_table();
    
    switch(format){
    case 8: CP(char); break;
    case 16: CP(short); break;
    case 32: CP(long); break;
    }

    return tab;
}
Exemplo n.º 2
0
ExtlTab extl_extl_read_savefile(const char *basename)
{
    ExtlTab tab;
    if(!extl_read_savefile(basename, &tab))
        return extl_table_none();
    return tab;
}
Exemplo n.º 3
0
static bool handle_target_winprops(WClientWin *cwin, const WManageParams *param,
                                   WScreen *scr, WPHolder **ph_ret)
{
    char *layout=NULL, *target=NULL;
    WPHolder *ph=NULL;
    bool mgd=FALSE;

    if(extl_table_gets_s(cwin->proptab, "target", &target))
        ph=try_target(cwin, param, target);

    if(ph==NULL && extl_table_gets_s(cwin->proptab, "new_group", &layout)){
        ExtlTab lo=ioncore_get_layout(layout);

        free(layout);

        if(lo!=extl_table_none()){
            WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
            int mask=MPLEX_ATTACH_SWITCHTO;
            WRegion *reg;

            if(param->switchto)
                par.flags|=MPLEX_ATTACH_SWITCHTO;

            /*ioncore_newly_created=(WRegion*)cwin;*/

            reg=mplex_attach_new_(&scr->mplex, &par, mask, lo);

            extl_unref_table(lo);

            /*ioncore_newly_created=NULL;*/

            mgd=(region_manager((WRegion*)cwin)!=NULL);

            if(reg!=NULL && !mgd){
                if(target!=NULL)
                    ph=try_target(cwin, param, target);

                if(ph==NULL){
                    ph=region_prepare_manage(reg, cwin, param,
                                             MANAGE_PRIORITY_NONE);

                    if(ph==NULL)
                        destroy_obj((Obj*)reg);
                }
            }
        }
    }

    if(target!=NULL)
        free(target);

    *ph_ret=ph;

    return mgd;
}
Exemplo n.º 4
0
Arquivo: dock.c Projeto: dkogan/notion
ExtlTab dock_get_configuration(WDock *dock)
{
    ExtlTab tab;

    if(dock->save==FALSE)
        return extl_table_none();

    tab=region_get_base_configuration((WRegion*)dock);
    dock_do_get(dock, tab);

    return tab;
}
Exemplo n.º 5
0
ExtlTab ioncore_get_layout(const char *layout)
{
    ExtlTab tab=extl_table_none();
    
    if(get_layout_fn_set){
        extl_protect(NULL);
        extl_call(get_layout_fn, "s", "t", layout, &tab);
        extl_unprotect(NULL);
    }
    
    return tab;
}
Exemplo n.º 6
0
ExtlTab ioncore_get_winprop(WClientWin *cwin)
{
    ExtlTab tab=extl_table_none();
    
    if(get_winprop_fn_set){
        extl_protect(NULL);
        extl_call(get_winprop_fn, "o", "t", cwin, &tab);
        extl_unprotect(NULL);
    }
    
    return tab;
}
Exemplo n.º 7
0
bool extl_read_savefile(const char *basename, ExtlTab *tabret)
{
    TryCallParam param;
    int retval;
    
    param.status=0;
    param.tab=extl_table_none();
    
    retval=extl_try_config(basename, NULL, (ExtlTryConfigFn*)try_read_savefile,
                              &param, EXTL_EXTENSION, NULL);

    *tabret=param.tab;
    
    return (retval==EXTL_TRYCONFIG_OK);
}
Exemplo n.º 8
0
static bool filter_extras_iter_fn(ExtlAny k, ExtlAny v, void *p)
{
    ExtlTab *tgt=(ExtlTab*)p;
    int i;
    
    if(k.type!='s' && k.type!='S')
        return TRUE;
    
    for(i=0; known_values[i]; i++){
        if(strcmp(known_values[i], k.value.s)==0)
            return TRUE;
    }
    
    if(*tgt==extl_table_none())
        *tgt=extl_create_table();
        
    extl_table_set(*tgt, 'a', 'a', k, v);
    
    return TRUE;
}
Exemplo n.º 9
0
/*EXTL_DOC
 * Get a text property for a window. The fields in the returned
 * table (starting from 1) are the null-separated parts of the property.
 * See the \code{XGetTextProperty}(3) manual page for more information.
 */
EXTL_SAFE
EXTL_EXPORT
ExtlTab ioncore_x_get_text_property(int win, int atom)
{
    char **list;
    int i, n;
    ExtlTab tab=extl_table_none();
    
    list=xwindow_get_text_property(win, atom, &n);
    
    if(list!=NULL){
        if(n!=0){
            tab=extl_create_table();
            for(i=0; i<n; i++)
                extl_table_seti_s(tab, i+1, list[i]);
        }
        XFreeStringList(list);
    }
    
    return tab;
}
Exemplo n.º 10
0
static void clientwin_get_winprops(WClientWin *cwin)
{
    ExtlTab tab, tab2;
    char *s;
    int i1, i2;
    
    tab=ioncore_get_winprop(cwin);
    
    cwin->proptab=tab;
    
    if(tab==extl_table_none())
        return;

    if(extl_table_is_bool_set(tab, "transparent"))
        cwin->flags|=CLIENTWIN_PROP_TRANSPARENT;

    if(extl_table_is_bool_set(tab, "acrobatic"))
        cwin->flags|=CLIENTWIN_PROP_ACROBATIC;
    
    if(extl_table_is_bool_set(tab, "lazy_resize"))
        cwin->flags|=CLIENTWIN_PROP_LAZY_RESIZE;
    
    DO_SZH("max_size", CLIENTWIN_PROP_MAXSIZE, CLIENTWIN_PROP_I_MAXSIZE,
           PMaxSize, max_width, max_height, { });
           
    DO_SZH("min_size", CLIENTWIN_PROP_MINSIZE, CLIENTWIN_PROP_I_MINSIZE,
           PMinSize, min_width, min_height, { });
           
    DO_SZH("resizeinc", CLIENTWIN_PROP_RSZINC, CLIENTWIN_PROP_I_RSZINC,
           PResizeInc, width_inc, height_inc, { });

    DO_SZH("aspect", CLIENTWIN_PROP_ASPECT, CLIENTWIN_PROP_I_ASPECT,
           PAspect, min_aspect.x, min_aspect.y, 
           { cwin->size_hints.max_aspect.x=i1;
             cwin->size_hints.max_aspect.y=i2;
           });
Exemplo n.º 11
0
int main(int argc, char*argv[])
{
    const char *mod=NULL;
    char *mod2=NULL;
    int loaded=0;
    int opt;
    bool quiet=FALSE;

#ifndef CF_NO_LOCALE
    if(setlocale(LC_ALL, "")==NULL)
        warn("setlocale() call failed.");
#endif

    configtab=extl_table_none();

    libtu_init(argv[0]);

#ifdef CF_RELOCATABLE_BIN_LOCATION
    prefix_set(argv[0], CF_RELOCATABLE_BIN_LOCATION);
#endif

    extl_init();

    if(!statusd_register_exports())
        return EXIT_FAILURE;

    prefix_wrap_simple(extl_add_searchdir, EXTRABINDIR);
    prefix_wrap_simple(extl_add_searchdir, MODULEDIR);
    prefix_wrap_simple(extl_add_searchdir, ETCDIR);
    prefix_wrap_simple(extl_add_searchdir, SHAREDIR);
    prefix_wrap_simple(extl_add_searchdir, LCDIR);
    extl_set_userdirs(CF_ION_EXECUTABLE);

    optparser_init(argc, argv, OPTP_MIDLONG, ion_opts);

    extl_read_config("ioncore_luaext", NULL, TRUE);

    while((opt=optparser_get_opt())){
        switch(opt){
        /*case OPT_ID('d'):
            display=optparser_get_arg();
            break;*/
        case 's':
            extl_add_searchdir(optparser_get_arg());
            break;
        /*case OPT_ID('s'):
            extl_set_sessiondir(optparser_get_arg());
            break;*/
        case 'h':
            help();
            return EXIT_SUCCESS;
        case 'V':
            printf("%s\n", ION_VERSION);
            return EXIT_SUCCESS;
        case OPT_ID('a'):
            printf("%s\n\n%s", statusd_copy, TR(statusd_license));
            return EXIT_SUCCESS;
        case 'c':
            {
                ExtlTab t;
                const char *f=optparser_get_arg();
                if(extl_read_savefile(f, &t)){
                    extl_unref_table(configtab);
                    configtab=t;
                }else{
                    warn(TR("Unable to load configuration file %s"), f);
                }
            }
            break;
        case 'q':
            quiet=TRUE;
            break;
        case 'm':
            mod=optparser_get_arg();
            if(strchr(mod, '/')==NULL && strchr(mod, '.')==NULL){
                mod2=scat("statusd_", mod);
                if(mod2==NULL)
                    return EXIT_FAILURE;
                mod=mod2;
            }
            if(extl_read_config(mod, NULL, !quiet))
                loaded++;
            if(mod2!=NULL)
                free(mod2);
            break;
        default:
            warn(TR("Invalid command line."));
            help();
            return EXIT_FAILURE;
        }
    }

    if(loaded==0 && !quiet){
        warn(TR("No meters loaded."));
        return EXIT_FAILURE;
    }

    mainloop();

    return EXIT_SUCCESS;
}
Exemplo n.º 12
0
/*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;
}
Exemplo n.º 13
0
static void show_sub(WMenu *menu, int n)
{
    WFitParams fp;
    WMenuCreateParams fnp;
    WMenu *submenu;
    WWindow *par;
    
    par=REGION_PARENT(menu);
    
    if(par==NULL)
        return;
    
    fp=menu->last_fp;

    fnp.pmenu_mode=menu->pmenu_mode;
    fnp.big_mode=menu->big_mode;
    fnp.submenu_mode=TRUE;
    
    if(menu->pmenu_mode){
        fnp.refg.x=REGION_GEOM(menu).x+REGION_GEOM(menu).w;
        fnp.refg.y=REGION_GEOM(menu).y+get_sub_y_off(menu, n);
        fnp.refg.w=0;
        fnp.refg.h=0;
    }else{
        fnp.refg=REGION_GEOM(menu);
    }

    fnp.tab=extl_table_none();
    {
        ExtlFn fn;
        if(extl_table_getis(menu->tab, n+1, "submenu_fn", 'f', &fn)){
            extl_protect(NULL);
            extl_call(fn, NULL, "t", &(fnp.tab));
            extl_unprotect(NULL);
            extl_unref_fn(fn);
        }else{
            extl_table_getis(menu->tab, n+1, "submenu", 't', &(fnp.tab));
        }
        if(fnp.tab==extl_table_none())
            return;
    }
    
    fnp.handler=extl_ref_fn(menu->handler);
    
    fnp.initial=0;
    {
        ExtlFn fn;
        if(extl_table_getis(menu->tab, n+1, "initial", 'f', &fn)){
            extl_protect(NULL);
            extl_call(fn, NULL, "i", &(fnp.initial));
            extl_unprotect(NULL);
	    extl_unref_fn(fn);
        }else{
            extl_table_getis(menu->tab, n+1, "initial", 'i', &(fnp.initial));
	}
    }

    submenu=create_menu(par, &fp, &fnp);
    
    if(submenu==NULL)
        return;
    
    menu->submenu=submenu;
    region_set_manager((WRegion*)submenu, (WRegion*)menu);
        
    region_restack((WRegion*)submenu, MENU_WIN(menu), Above);
    region_map((WRegion*)submenu);
    
    if(!menu->pmenu_mode && region_may_control_focus((WRegion*)menu))
        region_do_set_focus((WRegion*)submenu, FALSE);
}