4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
19 #include "clientwin.h"
29 static WRegion *doit_new(WRegion *mgr,
30 WWindow *par, const WFitParams *fp,
31 WRegionDoAttachFn *cont, void *cont_param,
32 WRegionCreateFn *fn, void *fn_param)
34 WRegion *reg=fn(par, fp, fn_param);
39 if(!cont(mgr, reg, cont_param)){
40 destroy_obj((Obj*)reg);
48 static WRegion *doit_reparent(WRegion *mgr,
49 WWindow *par, const WFitParams *fp,
50 WRegionDoAttachFn *cont, void *cont_param,
55 if(!region_attach_reparent_check(mgr, reg))
58 if(fp->mode®ION_FIT_WHATEVER){
59 /* fp->g is not final; substitute size with current to avoid
65 fp2.g.w=REGION_GEOM(reg).w;
66 fp2.g.h=REGION_GEOM(reg).h;
70 if(!region_fitrep(reg, par, fp)){
71 warn(TR("Unable to reparent."));
75 region_detach_manager(reg);
77 if(!cont(mgr, reg, cont_param)){
78 #warning "TODO: What?"
86 static WRegion *wrap_load(WWindow *par, const WFitParams *fp,
89 return create_region_load(par, fp, *tab);
93 WRegion *ioncore_newly_created=NULL;
96 static WRegion *doit_load(WRegion *mgr,
97 WWindow *par, const WFitParams *fp,
98 WRegionDoAttachFn *cont, void *cont_param,
103 if(extl_table_gets_o(tab, "reg", (Obj**)®)){
104 if(!OBJ_IS(reg, WRegion))
106 }/*else if(extl_table_is_bool_set(tab, "reg_use_new")){
107 reg=ioncore_newly_created;
113 return doit_reparent(mgr, par, fp, cont, cont_param, reg);
115 return doit_new(mgr, par, fp, cont, cont_param,
116 (WRegionCreateFn*)wrap_load, &tab);
120 WRegion *region_attach_helper(WRegion *mgr,
121 WWindow *par, const WFitParams *fp,
122 WRegionDoAttachFn *fn, void *fn_param,
123 const WRegionAttachData *data)
125 if(data->type==REGION_ATTACH_NEW){
126 return doit_new(mgr, par, fp, fn, fn_param,
127 data->u.n.fn, data->u.n.param);
128 }else if(data->type==REGION_ATTACH_LOAD){
129 return doit_load(mgr, par, fp, fn, fn_param, data->u.tab);
130 }else if(data->type==REGION_ATTACH_REPARENT){
131 return doit_reparent(mgr, par, fp, fn, fn_param, data->u.reg);
141 /*{{{ Reparent check */
144 bool region_attach_reparent_check(WRegion *mgr, WRegion *reg)
148 /*if(REGION_MANAGER(reg)==mgr){
149 warn(TR("Same manager."));
153 /* Check that reg is not a parent or manager of mgr */
154 for(reg2=mgr; reg2!=NULL; reg2=REGION_MANAGER(reg2)){
159 for(reg2=REGION_PARENT_REG(mgr); reg2!=NULL; reg2=REGION_PARENT_REG(reg2)){
167 warn(TR("Attempt to make region %s manage its ancestor %s."),
168 region_name(mgr), region_name(reg));