X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=ioncore%2Fpholder.c;h=f5f9aae4e1da034ae0c7b9cff63d6265decb7f61;hb=ae4260bb64817c11f9a7140324cd3e3ba113e297;hp=4aed2ccd05159bcf58cb4e5801290355d5b22c0c;hpb=8366314611bf30a0f31d25bf5f5023186fa87692;p=ion3.git diff --git a/ioncore/pholder.c b/ioncore/pholder.c index 4aed2cc..f5f9aae 100644 --- a/ioncore/pholder.c +++ b/ioncore/pholder.c @@ -1,18 +1,16 @@ /* * ion/ioncore/pholder.c * - * Copyright (c) Tuomo Valkonen 2005-2006. + * 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 #include "common.h" #include "attach.h" #include "pholder.h" +#include "focus.h" bool pholder_init(WPHolder *ph) @@ -39,24 +37,17 @@ WRegion *pholder_do_attach(WPHolder *ph, int flags, } -static WRegion *add_fn_reparent(WWindow *par, const WFitParams *fp, - WRegion *reg) -{ - if(!region_fitrep(reg, par, fp)){ - warn(TR("Unable to reparent.")); - return NULL; - } - region_detach_manager(reg); - return reg; -} - - WRegion *pholder_attach_(WPHolder *ph, int flags, WRegionAttachData *data) { - if(ph->redirect!=NULL) - return pholder_attach_(ph->redirect, flags, data); - else - return pholder_do_attach(ph, flags, data); + WPHolder *root=pholder_root(ph); + + /* Use the root, so that extra containers are not added from + * stale chains. + */ + + return (root==NULL + ? NULL + : pholder_do_attach(root, flags, data)); } @@ -71,6 +62,20 @@ bool pholder_attach(WPHolder *ph, int flags, WRegion *reg) } +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; +} + + WRegion *pholder_do_target(WPHolder *ph) { WRegion *ret=NULL; @@ -81,10 +86,9 @@ WRegion *pholder_do_target(WPHolder *ph) WRegion *pholder_target(WPHolder *ph) { - if(ph->redirect!=NULL) - return pholder_target(ph->redirect); - else - return pholder_do_target(ph); + return (ph->redirect!=NULL + ? pholder_target(ph->redirect) + : pholder_do_target(ph)); } @@ -92,10 +96,9 @@ static bool pholder_do_check_reparent_default(WPHolder *ph, WRegion *reg) { WRegion *target=pholder_do_target(ph); - if(target==NULL) - return FALSE; - else - return region_attach_reparent_check(target, reg); + return (target==NULL + ? FALSE + : region_ancestor_check(target, reg)); } @@ -126,13 +129,39 @@ bool pholder_do_goto(WPHolder *ph) bool pholder_goto(WPHolder *ph) { - if(ph->redirect!=NULL) - return pholder_goto(ph->redirect); - else - return pholder_do_goto(ph); + return (ph->redirect!=NULL + ? pholder_goto(ph->redirect) + : pholder_do_goto(ph)); } +WPHolder *pholder_do_root_default(WPHolder *ph) +{ + return ph; +} + + +WPHolder *pholder_do_root(WPHolder *ph) +{ + WPHolder *ret=NULL; + CALL_DYN_RET(ret, WPHolder*, pholder_do_root, ph, (ph)); + return ret; +} + + +WPHolder *pholder_root(WPHolder *ph) +{ + return (ph->redirect!=NULL + ? pholder_root(ph->redirect) + : pholder_do_root(ph)); +} + + +bool pholder_stale(WPHolder *ph) +{ + return (pholder_root(ph)!=ph); +} + bool pholder_redirect(WPHolder *ph, WRegion *old_target) { @@ -201,6 +230,9 @@ WPHolder *pholder_either(WPHolder *a, WPHolder *b) static DynFunTab pholder_dynfuntab[]={ {(DynFun*)pholder_do_check_reparent, (DynFun*)pholder_do_check_reparent_default}, + + {(DynFun*)pholder_do_root, + (DynFun*)pholder_do_root_default}, END_DYNFUNTAB };