X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fpholder.c;h=d62da21ff9e2e8cb5e7b37b6edda4450b270c4c0;hp=4aed2ccd05159bcf58cb4e5801290355d5b22c0c;hb=HEAD;hpb=8366314611bf30a0f31d25bf5f5023186fa87692 diff --git a/ioncore/pholder.c b/ioncore/pholder.c index 4aed2cc..d62da21 100644 --- a/ioncore/pholder.c +++ b/ioncore/pholder.c @@ -1,31 +1,26 @@ /* * ion/ioncore/pholder.c * - * Copyright (c) Tuomo Valkonen 2005-2006. + * Copyright (c) Tuomo Valkonen 2005-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 #include "common.h" #include "attach.h" #include "pholder.h" +#include "focus.h" bool pholder_init(WPHolder *ph) { - ph->redirect=NULL; return TRUE; } void pholder_deinit(WPHolder *ph) { - if(ph->redirect!=NULL) - destroy_obj((Obj*)ph->redirect); } @@ -39,27 +34,6 @@ 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); -} - - bool pholder_attach(WPHolder *ph, int flags, WRegion *reg) { WRegionAttachData data; @@ -67,7 +41,21 @@ bool pholder_attach(WPHolder *ph, int flags, WRegion *reg) data.type=REGION_ATTACH_REPARENT; data.u.reg=reg; - return (pholder_attach_(ph, flags, &data)!=NULL); + return (pholder_do_attach(ph, flags, &data)!=NULL); +} + + +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; } @@ -81,10 +69,7 @@ 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 pholder_do_target(ph); } @@ -92,10 +77,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)); } @@ -109,10 +93,7 @@ DYNFUN bool pholder_do_check_reparent(WPHolder *ph, WRegion *reg) bool pholder_check_reparent(WPHolder *ph, WRegion *reg) { - if(ph->redirect!=NULL) - return pholder_check_reparent(ph->redirect, reg); - else - return pholder_do_check_reparent(ph, reg); + return pholder_do_check_reparent(ph, reg); } @@ -126,27 +107,21 @@ 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 pholder_do_goto(ph); } - -bool pholder_redirect(WPHolder *ph, WRegion *old_target) +bool pholder_stale_default(WPHolder *ph) { - WPHolder *ph2=region_get_rescue_pholder(old_target); - - if(ph2==NULL) - return FALSE; - - if(ph->redirect!=NULL) - destroy_obj((Obj*)ph->redirect); + return (pholder_target(ph)==NULL); +} - ph->redirect=ph2; - - return TRUE; + +bool pholder_stale(WPHolder *ph) +{ + bool ret=TRUE; + CALL_DYN_RET(ret, bool, pholder_stale, ph, (ph)); + return ret; } @@ -201,6 +176,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_stale, + (DynFun*)pholder_stale_default}, END_DYNFUNTAB };