No longer trap fatal signals
[notion/jeffpc.git] / ioncore / pholder.c
blobd62da21ff9e2e8cb5e7b37b6edda4450b270c4c0
1 /*
2 * ion/ioncore/pholder.c
4 * Copyright (c) Tuomo Valkonen 2005-2009.
6 * See the included file LICENSE for details.
7 */
9 #include <libtu/objp.h>
10 #include "common.h"
11 #include "attach.h"
12 #include "pholder.h"
13 #include "focus.h"
16 bool pholder_init(WPHolder *ph)
18 return TRUE;
22 void pholder_deinit(WPHolder *ph)
27 WRegion *pholder_do_attach(WPHolder *ph, int flags,
28 WRegionAttachData *data)
31 WRegion *ret=NULL;
32 CALL_DYN_RET(ret, WRegion*, pholder_do_attach, ph, (ph, flags, data));
33 return ret;
37 bool pholder_attach(WPHolder *ph, int flags, WRegion *reg)
39 WRegionAttachData data;
41 data.type=REGION_ATTACH_REPARENT;
42 data.u.reg=reg;
44 return (pholder_do_attach(ph, flags, &data)!=NULL);
48 bool pholder_attach_mcfgoto(WPHolder *ph, int flags, WRegion *reg)
50 bool cf=region_may_control_focus(reg);
52 if(!pholder_attach(ph, flags, reg))
53 return FALSE;
55 if(cf)
56 region_goto(reg);
58 return TRUE;
62 WRegion *pholder_do_target(WPHolder *ph)
64 WRegion *ret=NULL;
65 CALL_DYN_RET(ret, WRegion*, pholder_do_target, ph, (ph));
66 return ret;
70 WRegion *pholder_target(WPHolder *ph)
72 return pholder_do_target(ph);
76 static bool pholder_do_check_reparent_default(WPHolder *ph, WRegion *reg)
78 WRegion *target=pholder_do_target(ph);
80 return (target==NULL
81 ? FALSE
82 : region_ancestor_check(target, reg));
86 DYNFUN bool pholder_do_check_reparent(WPHolder *ph, WRegion *reg)
88 bool ret=FALSE;
89 CALL_DYN_RET(ret, bool, pholder_do_check_reparent, ph, (ph, reg));
90 return ret;
94 bool pholder_check_reparent(WPHolder *ph, WRegion *reg)
96 return pholder_do_check_reparent(ph, reg);
100 bool pholder_do_goto(WPHolder *ph)
102 bool ret=FALSE;
103 CALL_DYN_RET(ret, bool, pholder_do_goto, ph, (ph));
104 return ret;
108 bool pholder_goto(WPHolder *ph)
110 return pholder_do_goto(ph);
114 bool pholder_stale_default(WPHolder *ph)
116 return (pholder_target(ph)==NULL);
120 bool pholder_stale(WPHolder *ph)
122 bool ret=TRUE;
123 CALL_DYN_RET(ret, bool, pholder_stale, ph, (ph));
124 return ret;
128 WPHolder *region_managed_get_pholder(WRegion *reg, WRegion *mgd)
130 WPHolder *ret=NULL;
131 CALL_DYN_RET(ret, WPHolder*, region_managed_get_pholder,
132 reg, (reg, mgd));
133 return ret;
137 WPHolder *region_get_rescue_pholder_for(WRegion *reg, WRegion *mgd)
139 if(OBJ_IS_BEING_DESTROYED(reg) || reg->flags&REGION_CWINS_BEING_RESCUED){
140 return FALSE;
141 }else{
142 WPHolder *ret=NULL;
144 CALL_DYN_RET(ret, WPHolder*, region_get_rescue_pholder_for,
145 reg, (reg, mgd));
146 return ret;
151 WPHolder *region_get_rescue_pholder(WRegion *reg)
153 WRegion *mgr;
154 WPHolder *ph=NULL;
156 while(1){
157 mgr=region_manager_or_parent(reg);
158 if(mgr==NULL)
159 break;
160 ph=region_get_rescue_pholder_for(mgr, reg);
161 if(ph!=NULL)
162 break;
163 reg=mgr;
166 return ph;
170 WPHolder *pholder_either(WPHolder *a, WPHolder *b)
172 return (a!=NULL ? a : b);
176 static DynFunTab pholder_dynfuntab[]={
177 {(DynFun*)pholder_do_check_reparent,
178 (DynFun*)pholder_do_check_reparent_default},
180 {(DynFun*)pholder_stale,
181 (DynFun*)pholder_stale_default},
183 END_DYNFUNTAB
187 IMPLCLASS(WPHolder, Obj, pholder_deinit, pholder_dynfuntab);