4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
9 #include <libtu/objp.h>
10 #include <ioncore/common.h>
11 #include <ioncore/mplex.h>
12 #include <ioncore/focus.h>
13 #include <ioncore/return.h>
14 #include <ioncore/group.h>
21 static WRegion
*mkbottom_fn(WWindow
*parent
, const WFitParams
*fp
,
24 WRegion
*reg
=(WRegion
*)param
, *res
;
25 WRegionAttachData data
;
29 fp2
.mode
=REGION_FIT_EXACT
;
32 tiling
=create_tiling(parent
, &fp2
, NULL
, FALSE
);
37 data
.type
=REGION_ATTACH_REPARENT
;
40 /* Warning! Potentially dangerous call to remove a `reg` from the same
41 * group we're being attached to, and from the attach routine of which
42 * this function is called from!
44 res
=region_attach_helper((WRegion
*)tiling
, parent
, &fp2
,
45 (WRegionDoAttachFn
*)tiling_do_attach_initial
,
49 destroy_obj((Obj
*)tiling
);
53 return (WRegion
*)tiling
;
58 * Create a new \type{WTiling} 'bottom' for the group of \var{reg},
59 * consisting of \var{reg}.
62 bool mod_tiling_mkbottom(WRegion
*reg
)
64 WGroup
*grp
=REGION_MANAGER_CHK(reg
, WGroup
);
65 WGroupAttachParams ap
=GROUPATTACHPARAMS_INIT
;
66 WRegionAttachData data
;
69 warn(TR("Not member of a group"));
73 if(group_bottom(grp
)!=NULL
){
74 warn(TR("Manager group already has bottom"));
79 ap
.level
=STACKING_LEVEL_BOTTOM
;
82 ap
.szplcy
=SIZEPOLICY_FULL_EXACT
;
85 ap
.switchto
=region_may_control_focus(reg
);
89 data
.type
=REGION_ATTACH_NEW
;
90 data
.u
.n
.fn
=mkbottom_fn
;
93 /* See the "Warning!" above. */
94 return (group_do_attach(grp
, &ap
, &data
)!=NULL
);
105 * If \var{tiling} is managed by some group, float the frames in
106 * the tiling in that group, and dispose of \var{tiling}.
109 bool mod_tiling_untile(WTiling
*tiling
)
111 WGroup
*grp
=REGION_MANAGER_CHK(tiling
, WGroup
);
112 WGroupAttachParams param
=GROUPATTACHPARAMS_INIT
;
117 warn(TR("Not member of a group"));
121 if(group_bottom(grp
)==(WRegion
*)tiling
)
122 group_set_bottom(grp
, NULL
);
124 /* Setting `batchop` will stop `tiling_managed_remove` from
125 * resizing remaining frames into freed space. It will also
126 * stop the tiling from being destroyed by actions of
127 * `tiling_managed_disposeroot`.
129 tiling
->batchop
=TRUE
;
131 FOR_ALL_MANAGED_BY_TILING(reg
, tiling
, tmp
){
132 WRegionAttachData data
;
134 /* Don't bother with the status display */
135 if(reg
==TILING_STDISP_OF(tiling
))
138 /* Don't bother with regions containing no client windows. */
139 if(!region_rescue_needed(reg
))
142 data
.type
=REGION_ATTACH_REPARENT
;
146 param
.geom
=REGION_GEOM(reg
);
148 reg2
=group_do_attach(grp
, ¶m
, &data
);
151 warn(TR("Unable to move a region from tiling to group."));
154 tiling
->batchop
=FALSE
;
156 region_dispose((WRegion
*)tiling
);