X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fgroup-cw.c;h=f117cf66d84b144a1d01370bf77ec9a43de2359b;hp=dc5cc69e6b43aca6dadc2e8cbc9e05a73aae8e47;hb=HEAD;hpb=8366314611bf30a0f31d25bf5f5023186fa87692 diff --git a/ioncore/group-cw.c b/ioncore/group-cw.c index dc5cc69..f117cf6 100644 --- a/ioncore/group-cw.c +++ b/ioncore/group-cw.c @@ -1,12 +1,9 @@ /* * ion/ioncore/group-cw.c * - * Copyright (c) Tuomo Valkonen 1999-2006. + * Copyright (c) Tuomo Valkonen 1999-2009. * - * Ion is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. + * See the included file LICENSE for details. */ #include @@ -25,6 +22,8 @@ #include "names.h" #include "framedpholder.h" #include "grouppholder.h" +#include "return.h" +#include "saveload.h" #define DFLT_SZPLCY SIZEPOLICY_FREE_GLUE__SOUTH @@ -33,13 +32,6 @@ /*{{{ Add/remove managed */ -WRegion *create_transient_frame(WWindow *par, - const WFitParams *fp) -{ - return (WRegion*)create_frame(par, fp, FRAME_MODE_TRANSIENT); -} - - static WPHolder *groupcw_transient_pholder(WGroupCW *cwg, const WClientWin *cwin, const WManageParams *mp) @@ -69,7 +61,7 @@ static WPHolder *groupcw_transient_pholder(WGroupCW *cwg, fp.inner_geom_gravity_set=1; fp.inner_geom=mp->geom; fp.gravity=ForgetGravity; - fp.mkframe=create_transient_frame; + fp.mode=FRAME_MODE_TRANSIENT; ph=(WPHolder*)create_grouppholder(&cwg->grp, NULL, ¶m); @@ -79,9 +71,9 @@ static WPHolder *groupcw_transient_pholder(WGroupCW *cwg, WPHolder *groupcw_prepare_manage(WGroupCW *cwg, const WClientWin *cwin, - const WManageParams *param, int redir) + const WManageParams *param, int priority) { - if(redir==MANAGE_REDIR_STRICT_YES) + if(!MANAGE_PRIORITY_OK(priority, MANAGE_PRIORITY_GROUP)) return NULL; /* Only catch windows with transient mode set to current here. */ @@ -126,6 +118,23 @@ WPHolder *groupcw_prepare_manage_transient(WGroupCW *cwg, } +static WRegion *groupcw_managed_disposeroot(WGroupCW *ws, WRegion *reg) +{ + WGroupIterTmp tmp; + WStacking *st; + WRegion *tmpr; + + FOR_ALL_NODES_IN_GROUP(&ws->grp, st, tmp){ + if(st!=ws->grp.managed_stdisp && st->reg!=reg){ + return reg; + } + } + + tmpr=region_disposeroot((WRegion*)ws); + return (tmpr!=NULL ? tmpr : reg); +} + + /*}}}*/ @@ -156,7 +165,8 @@ void groupcw_toggle_transients_pos(WGroupCW *cwg) if(st->reg!=NULL){ WFitParams fp; - + + fp.mode=0; fp.g=REGION_GEOM(cwg); sizepolicy(&st->szplcy, st->reg, NULL, @@ -181,32 +191,76 @@ const char *groupcw_displayname(WGroupCW *cwg) } -void groupcw_managed_notify(WGroupCW *cwg, WRegion *reg, const char *how) +void groupcw_managed_notify(WGroupCW *cwg, WRegion *reg, WRegionNotify how) { - if(group_bottom(&cwg->grp)==reg - && strcmp(how, "name")==0){ + if(group_bottom(&cwg->grp)==reg && how==ioncore_g.notifies.name){ /* Title has changed */ region_notify_change((WRegion*)cwg, how); } + + group_managed_notify(&cwg->grp, reg, how); +} + + +void groupcw_bottom_set(WGroupCW *cwg) +{ + region_notify_change((WRegion*)cwg, ioncore_g.notifies.name); +} + + +/*}}}*/ + + +/*{{{ Rescue */ + + +static void group_migrate_phs_to_ph(WGroup *group, WPHolder *rph) +{ + WGroupPHolder *phs, *ph; + + phs=group->phs; + group->phs=NULL; + + phs->recreate_pholder=rph; + + for(ph=phs; ph!=NULL; ph=ph->next) + ph->group=NULL; +} + + +bool groupcw_rescue_clientwins(WGroupCW *cwg, WRescueInfo *info) +{ + bool ret=group_rescue_clientwins(&cwg->grp, info); + + /* If this group can be recreated, arrange remaining placeholders + * to do so. This takes care of e.g. recreating client window groups + * when recreating layout delayedly under a session manager. + */ + if(cwg->grp.phs!=NULL){ + WPHolder *rph=region_make_return_pholder((WRegion*)cwg); + + if(rph!=NULL) + group_migrate_phs_to_ph(&cwg->grp, rph); + } + + return ret; } /*}}}*/ + /*{{{ WGroupCW class */ bool groupcw_init(WGroupCW *cwg, WWindow *parent, const WFitParams *fp) { cwg->transient_szplcy=DFLT_SZPLCY; - /*cwg->fs_pholder=NULL;*/ if(!group_init(&(cwg->grp), parent, fp)) return FALSE; - cwg->grp.bottom_last_close=TRUE; - region_add_bindmap((WRegion*)cwg, ioncore_groupcw_bindmap); return TRUE; @@ -227,34 +281,29 @@ void groupcw_deinit(WGroupCW *cwg) WRegion *groupcw_load(WWindow *par, const WFitParams *fp, ExtlTab tab) { - WGroupCW *ws; + WGroupCW *cwg; ExtlTab substab, subtab; int i, n; - ws=create_groupcw(par, fp); + cwg=create_groupcw(par, fp); - if(ws==NULL) + if(cwg==NULL) return NULL; - - if(!extl_table_gets_t(tab, "managed", &substab)) - return (WRegion*)ws; - - n=extl_table_get_n(substab); - for(i=1; i<=n; i++){ - if(extl_table_geti_t(substab, i, &subtab)){ - group_attach_new(&ws->grp, subtab); - extl_unref_table(subtab); - } - } - - extl_unref_table(substab); + + group_do_load(&cwg->grp, tab); - if(ws->grp.managed_list==NULL){ - destroy_obj((Obj*)ws); + if(cwg->grp.managed_list==NULL){ + if(cwg->grp.phs!=NULL){ + /* Session management hack */ + WPHolder *ph=ioncore_get_load_pholder(); + if(ph!=NULL) + group_migrate_phs_to_ph(&cwg->grp, ph); + } + destroy_obj((Obj*)cwg); return NULL; } - return (WRegion*)ws; + return (WRegion*)cwg; } @@ -283,12 +332,21 @@ static DynFunTab groupcw_dynfuntab[]={ {(DynFun*)region_prepare_manage_transient, (DynFun*)groupcw_prepare_manage_transient}, + + {(DynFun*)region_managed_disposeroot, + (DynFun*)groupcw_managed_disposeroot}, {(DynFun*)region_displayname, (DynFun*)groupcw_displayname}, {region_managed_notify, groupcw_managed_notify}, + + {group_bottom_set, + groupcw_bottom_set}, + + {(DynFun*)region_rescue_clientwins, + (DynFun*)groupcw_rescue_clientwins}, END_DYNFUNTAB };