Exemple #1
0
bool tiling_managed_add_default(WTiling *ws, WRegion *reg)
{
    Window bottom=None, top=None;
    WFrame *frame;
    
    if(TILING_STDISP_OF(ws)!=reg){
        if(!ptrlist_insert_last(&(ws->managed_list), reg))
            return FALSE;
    }
    
    region_set_manager(reg, (WRegion*)ws);
    
    frame=OBJ_CAST(reg, WFrame);
    if(frame!=NULL){
        if(framemode_unalt(frame_mode(frame))!=FRAME_MODE_TILED)
            frame_set_mode(frame, FRAME_MODE_TILED);
    }
    
    if(REGION_IS_MAPPED(ws))
        region_map(reg);
    
    if(region_may_control_focus((WRegion*)ws)){
        WRegion *curr=tiling_current(ws);
        if(curr==NULL || !REGION_IS_ACTIVE(curr))
            region_warp(reg);
    }
    
    return TRUE;
}
Exemple #2
0
bool pholder_attach_mcfgoto(WPHolder *ph, int flags, WRegion *reg)
{
    bool cf=region_may_control_focus(reg);

    if(!pholder_attach(ph, flags, reg))
        return FALSE;

    if(cf)
        region_goto(reg);

    return TRUE;
}
Exemple #3
0
static void menu_managed_remove(WMenu *menu, WRegion *sub)
{
    bool mcf=region_may_control_focus((WRegion*)menu);
    
    if(sub!=(WRegion*)menu->submenu)
        return;
    
    menu->submenu=NULL;

    region_unset_manager(sub, (WRegion*)menu);
    
    if(mcf)
        region_do_set_focus((WRegion*)menu, FALSE);
}
Exemple #4
0
void tiling_unmanage_stdisp(WTiling *ws, bool permanent, bool nofocus)
{
    WSplitRegion *tofocus=NULL;
    bool setfocus=FALSE;
    WRegion *od;
    
    if(ws->stdispnode==NULL)
        return;
    
    od=ws->stdispnode->regnode.reg;
    
    if(od!=NULL){
        if(!nofocus && REGION_IS_ACTIVE(od) && 
           region_may_control_focus((WRegion*)ws)){
            setfocus=TRUE;
            tofocus=(WSplitRegion*)split_nextto((WSplit*)(ws->stdispnode), 
                                                PRIMN_ANY, PRIMN_ANY,
                                                regnodefilter);
        }
        /* Reset node_of info here so tiling_managed_remove will not
         * remove the node.
         */
        splittree_set_node_of(od, NULL);
        tiling_do_managed_remove(ws, od);
    }
    
    if(permanent){
        WSplit *node=(WSplit*)ws->stdispnode;
        ws->stdispnode=NULL;
        splittree_remove(node, TRUE);
    }
    
    if(setfocus){
        if(tofocus!=NULL)
            region_set_focus(tofocus->reg);
        else
            tiling_fallback_focus(ws, FALSE);
    }
}
Exemple #5
0
bool clientwin_fullscreen_may_switchto(WClientWin *cwin)
{
    return (region_may_control_focus((WRegion*)cwin)
            || !REGION_IS_ACTIVE(region_screen_of((WRegion*)cwin)));
}
Exemple #6
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);
}
Exemple #7
0
void tiling_manage_stdisp(WTiling *ws, WRegion *stdisp, 
                         const WMPlexSTDispInfo *di)
{
    bool mcf=region_may_control_focus((WRegion*)ws);
    int flags=REGION_RQGEOM_WEAK_X|REGION_RQGEOM_WEAK_Y;
    int orientation=region_orientation(stdisp);
    bool act=FALSE;
    WRectangle dg, *stdg;
    
    if(orientation!=REGION_ORIENTATION_VERTICAL /*&&
       orientation!=REGION_ORIENTATION_HORIZONTAL*/){
        orientation=REGION_ORIENTATION_HORIZONTAL;
    }
    
    if(ws->stdispnode==NULL || ws->stdispnode->regnode.reg!=stdisp)
        region_detach_manager(stdisp);

    /* Remove old stdisp if corner and orientation don't match.
     */
    if(ws->stdispnode!=NULL && (di->pos!=ws->stdispnode->corner ||
                                orientation!=ws->stdispnode->orientation)){
        tiling_unmanage_stdisp(ws, TRUE, TRUE);
    }

    if(ws->stdispnode==NULL){
        tiling_create_stdispnode(ws, stdisp, di->pos, orientation, 
                                di->fullsize);
        if(ws->stdispnode==NULL)
            return;
    }else{
        WRegion *od=ws->stdispnode->regnode.reg;
        if(od!=NULL){
            act=REGION_IS_ACTIVE(od);
            splittree_set_node_of(od, NULL);
            tiling_managed_remove(ws, od);
            assert(ws->stdispnode->regnode.reg==NULL);
        }
        
        ws->stdispnode->fullsize=di->fullsize;
        ws->stdispnode->regnode.reg=stdisp;
        splittree_set_node_of(stdisp, &(ws->stdispnode->regnode));
    }
    
    if(!tiling_managed_add(ws, stdisp)){
        tiling_unmanage_stdisp(ws, TRUE, TRUE);
        return;
    }

    stdisp->flags|=REGION_SKIP_FOCUS;
    
    dg=((WSplit*)(ws->stdispnode))->geom;
    
    dg.h=stdisp_recommended_h(ws->stdispnode);
    dg.w=stdisp_recommended_w(ws->stdispnode);
    
    splittree_rqgeom((WSplit*)(ws->stdispnode), flags, &dg, FALSE);
    
    stdg=&(((WSplit*)ws->stdispnode)->geom);
    
    if(stdisp->geom.x!=stdg->x || stdisp->geom.y!=stdg->y ||
       stdisp->geom.w!=stdg->w || stdisp->geom.h!=stdg->h){
        region_fit(stdisp, stdg, REGION_FIT_EXACT);
    }

    /* Restack to ensure the split tree is stacked in the expected order. */
    if(ws->split_tree!=NULL)
        split_restack(ws->split_tree, ws->dummywin, Above);
    
    if(mcf && act)
        region_set_focus(stdisp);
}