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.
12 #include <libtu/objp.h>
13 #include <ioncore/common.h>
14 #include <ioncore/mplex.h>
15 #include <ioncore/focus.h>
16 #include <ioncore/return.h>
17 #include <ioncore/group.h>
24 static WRegion *mkbottom_fn(WWindow *parent, const WFitParams *fp,
27 WRegion *reg=(WRegion*)param, *res;
28 WRegionAttachData data;
32 fp2.mode=REGION_FIT_EXACT;
35 tiling=create_tiling(parent, &fp2, NULL, FALSE);
40 data.type=REGION_ATTACH_REPARENT;
43 /* Warning! Potentially dangerous call to remove a `reg` from the same
44 * group we're being attached to, and from the attach routine of which
45 * this function is called from!
47 res=region_attach_helper((WRegion*)tiling, parent, &fp2,
48 (WRegionDoAttachFn*)tiling_do_attach_initial,
52 destroy_obj((Obj*)tiling);
56 return (WRegion*)tiling;
61 * Create a new \type{WTiling} 'bottom' for the group of \var{reg},
62 * consisting of \var{reg}.
65 bool mod_tiling_mkbottom(WRegion *reg)
67 WGroup *grp=REGION_MANAGER_CHK(reg, WGroup);
68 WGroupAttachParams ap=GROUPATTACHPARAMS_INIT;
69 WRegionAttachData data;
72 warn(TR("Not member of a group"));
76 if(group_bottom(grp)!=NULL){
77 warn(TR("Manager group already has bottom"));
82 ap.level=STACKING_LEVEL_BOTTOM;
85 ap.szplcy=SIZEPOLICY_FULL_EXACT;
88 ap.switchto=region_may_control_focus(reg);
92 data.type=REGION_ATTACH_NEW;
93 data.u.n.fn=mkbottom_fn;
96 /* See the "Warning!" above. */
97 return (group_do_attach(grp, &ap, &data)!=NULL);
108 * If \var{tiling} is managed by some group, float the frames in
109 * the tiling in that group, and dispose of \var{tiling}.
112 bool mod_tiling_untile(WTiling *tiling)
114 WGroup *grp=REGION_MANAGER_CHK(tiling, WGroup);
115 WGroupAttachParams param=GROUPATTACHPARAMS_INIT;
120 warn(TR("Not member of a group"));
124 if(group_bottom(grp)==(WRegion*)tiling)
125 group_set_bottom(grp, NULL);
127 /* Setting `batchop` will stop `tiling_managed_remove` from
128 * resizing remaining frames into freed space. It will also
129 * stop the tiling from being destroyed by actions of
130 * `tiling_managed_disposeroot`.
132 tiling->batchop=TRUE;
134 FOR_ALL_MANAGED_BY_TILING(reg, tiling, tmp){
135 WRegionAttachData data;
137 /* Don't bother with the status display */
138 if(reg==TILING_STDISP_OF(tiling))
141 /* Don't bother with regions containing no client windows. */
142 if(!region_rescue_needed(reg))
145 data.type=REGION_ATTACH_REPARENT;
149 param.geom=REGION_GEOM(reg);
151 reg2=group_do_attach(grp, ¶m, &data);
154 warn(TR("Unable to move a region from tiling to group."));
157 tiling->batchop=FALSE;
159 region_dispose((WRegion*)tiling);