Add fake-xinerama, create test that tests spurious screens are removed
[notion/jeffpc.git] / mod_tiling / ops.c
blobf09d5029287606c85736c02055518abb4408223e
1 /*
2 * ion/mod_tiling/ops.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
7 */
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>
15 #include "tiling.h"
18 /*{{{ mkbottom */
21 static WRegion *mkbottom_fn(WWindow *parent, const WFitParams *fp,
22 void *param)
24 WRegion *reg=(WRegion*)param, *res;
25 WRegionAttachData data;
26 WTiling *tiling;
27 WFitParams fp2;
29 fp2.mode=REGION_FIT_EXACT;
30 fp2.g=fp->g;
32 tiling=create_tiling(parent, &fp2, NULL, FALSE);
34 if(tiling==NULL)
35 return NULL;
37 data.type=REGION_ATTACH_REPARENT;
38 data.u.reg=reg;
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,
46 NULL, &data);
48 if(res==NULL){
49 destroy_obj((Obj*)tiling);
50 return NULL;
53 return (WRegion*)tiling;
57 /*EXTL_DOC
58 * Create a new \type{WTiling} 'bottom' for the group of \var{reg},
59 * consisting of \var{reg}.
61 EXTL_EXPORT
62 bool mod_tiling_mkbottom(WRegion *reg)
64 WGroup *grp=REGION_MANAGER_CHK(reg, WGroup);
65 WGroupAttachParams ap=GROUPATTACHPARAMS_INIT;
66 WRegionAttachData data;
68 if(grp==NULL){
69 warn(TR("Not member of a group"));
70 return FALSE;
73 if(group_bottom(grp)!=NULL){
74 warn(TR("Manager group already has bottom"));
75 return FALSE;
78 ap.level_set=TRUE;
79 ap.level=STACKING_LEVEL_BOTTOM;
81 ap.szplcy_set=TRUE;
82 ap.szplcy=SIZEPOLICY_FULL_EXACT;
84 ap.switchto_set=TRUE;
85 ap.switchto=region_may_control_focus(reg);
87 ap.bottom=TRUE;
89 data.type=REGION_ATTACH_NEW;
90 data.u.n.fn=mkbottom_fn;
91 data.u.n.param=reg;
93 /* See the "Warning!" above. */
94 return (group_do_attach(grp, &ap, &data)!=NULL);
98 /*}}}*/
101 /*{{{ untile */
104 /*EXTL_DOC
105 * If \var{tiling} is managed by some group, float the frames in
106 * the tiling in that group, and dispose of \var{tiling}.
108 EXTL_EXPORT
109 bool mod_tiling_untile(WTiling *tiling)
111 WGroup *grp=REGION_MANAGER_CHK(tiling, WGroup);
112 WGroupAttachParams param=GROUPATTACHPARAMS_INIT;
113 WTilingIterTmp tmp;
114 WRegion *reg, *reg2;
116 if(grp==NULL){
117 warn(TR("Not member of a group"));
118 return FALSE;
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))
136 continue;
138 /* Don't bother with regions containing no client windows. */
139 if(!region_rescue_needed(reg))
140 continue;
142 data.type=REGION_ATTACH_REPARENT;
143 data.u.reg=reg;
145 param.geom_set=TRUE;
146 param.geom=REGION_GEOM(reg);
148 reg2=group_do_attach(grp, &param, &data);
150 if(reg2==NULL)
151 warn(TR("Unable to move a region from tiling to group."));
154 tiling->batchop=FALSE;
156 region_dispose((WRegion*)tiling);
158 return TRUE;
162 /*}}}*/