X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=ioncore%2Fmplexpholder.c;h=8bb7ddb1e89ee279d3f99ec0229b68dd3e956d63;hb=b355f9832d094cdb9e700e01cbc063e3fdb4f58b;hp=f6d089a2a5cc89fbbbcbec7fb9f1739c90a184ec;hpb=471a5e5f9928e2d324b2e10422a420f458bd63ff;p=ion3.git diff --git a/ioncore/mplexpholder.c b/ioncore/mplexpholder.c index f6d089a..8bb7ddb 100644 --- a/ioncore/mplexpholder.c +++ b/ioncore/mplexpholder.c @@ -3,10 +3,7 @@ * * Copyright (c) Tuomo Valkonen 2005-2007. * - * 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 @@ -18,6 +15,7 @@ #include "mplexpholder.h" #include "llist.h" #include "framedpholder.h" +#include "basicpholder.h" static void mplex_watch_handler(Watch *watch, Obj *mplex); @@ -105,7 +103,18 @@ static void mplex_watch_handler(Watch *watch, Obj *mplex) } -static WMPlexAttachParams dummy_param={0, 0, {0, 0, 0, 0}, 0, 0}; +static void mplex_get_attach_params(WMPlex *mplex, WStacking *st, + WMPlexAttachParams *param) +{ + param->flags=(MPLEX_ATTACH_SIZEPOLICY| + MPLEX_ATTACH_GEOM| + MPLEX_ATTACH_LEVEL| + (st->hidden ? MPLEX_ATTACH_HIDDEN : 0)| + (st->lnode==NULL ? MPLEX_ATTACH_UNNUMBERED : 0)); + param->szplcy=st->szplcy; + param->geom=REGION_GEOM(st->reg); + param->level=st->level; +} bool mplexpholder_init(WMPlexPHolder *ph, WMPlex *mplex, WStacking *st, @@ -125,25 +134,20 @@ bool mplexpholder_init(WMPlexPHolder *ph, WMPlex *mplex, WStacking *st, return FALSE; } - if(param==NULL) - param=&dummy_param; - if(st!=NULL){ - if(st->lnode!=NULL) + mplex_get_attach_params(mplex, st, &ph->param); + + if(st->lnode!=NULL){ mplexpholder_do_link(ph, mplex, LIST_LAST(st->lnode->phs, next, prev), st->lnode); - else - ph->param.flags|=MPLEX_ATTACH_UNNUMBERED; - - ph->param.flags|=(MPLEX_ATTACH_SIZEPOLICY| - MPLEX_ATTACH_GEOM| - MPLEX_ATTACH_LEVEL| - (st->hidden ? MPLEX_ATTACH_HIDDEN : 0)); - ph->param.szplcy=st->szplcy; - ph->param.geom=REGION_GEOM(st->reg); - ph->param.level=st->level; + } }else{ + static WMPlexAttachParams dummy_param={0, 0, {0, 0, 0, 0}, 0, 0}; + + if(param==NULL) + param=&dummy_param; + ph->param=*param; if(!(param->flags&MPLEX_ATTACH_UNNUMBERED)){ @@ -186,7 +190,7 @@ void mplexpholder_deinit(WMPlexPHolder *ph) /*}}}*/ -/*{{{ Move, attach, layer */ +/*{{{ Move, attach */ typedef struct{ @@ -245,7 +249,8 @@ WRegion *recreate_handler(WWindow *par, static WMPlexPHolder *get_head(WMPlexPHolder *ph) { while(1){ - if(ph->prev->next==NULL) + /* ph->prev==NULL should not happen.. */ + if(ph->prev==NULL || ph->prev->next==NULL) break; ph=ph->prev; } @@ -439,11 +444,51 @@ WMPlexPHolder *mplex_managed_get_pholder(WMPlex *mplex, WRegion *mgd) } -WMPlexPHolder *mplex_get_rescue_pholder_for(WMPlex *mplex, WRegion *mgd) +/*}}}*/ + + +/*{{ Rescue */ + + +WRegion *mplex_rescue_attach(WMPlex *mplex, int flags, WRegionAttachData *data) { + WMPlexAttachParams param; + + param.flags=0; + + /* Improved attach parametrisation hack for WMPlex source */ + if(data->type==REGION_ATTACH_REPARENT){ + WRegion *reg=data->u.reg; + WMPlex *src_mplex=REGION_MANAGER_CHK(reg, WMPlex); + if(src_mplex!=NULL){ + WStacking *st=ioncore_find_stacking(reg); + if(st!=NULL) + mplex_get_attach_params(src_mplex, st, ¶m); + } + } + + param.flags|=(MPLEX_ATTACH_INDEX| + (flags&PHOLDER_ATTACH_SWITCHTO ? MPLEX_ATTACH_SWITCHTO : 0)); + param.index=LLIST_INDEX_LAST; + + return mplex_do_attach(mplex, ¶m, data); +} + + +WPHolder *mplex_get_rescue_pholder_for(WMPlex *mplex, WRegion *mgd) +{ +#if 0 WStacking *st=mplex_find_stacking(mplex, mgd); + WMPlexAttachParams param; + + param.flags=MPLEX_ATTACH_INDEX; + param.index=LLIST_INDEX_LAST; - return create_mplexpholder(mplex, st, NULL); + return create_mplexpholder(mplex, st, ¶m); +#else + return (WPHolder*)create_basicpholder((WRegion*)mplex, + (WBasicPHolderHandler*)mplex_rescue_attach); +#endif }