]> git.decadent.org.uk Git - ion3.git/blob - mod_tiling/ops.c
[svn-upgrade] Integrating new upstream version, ion3 (20070203)
[ion3.git] / mod_tiling / ops.c
1 /*
2  * ion/mod_tiling/ops.c
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
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.
10  */
11
12 #include <ioncore/common.h>
13 #include <ioncore/mplex.h>
14 #include <ioncore/focus.h>
15 #include <ioncore/return.h>
16 #include <ioncore/group.h>
17 #include "tiling.h"
18
19
20 static WRegion *mkbottom_fn(WWindow *parent, const WFitParams *fp, 
21                             void *param)
22 {
23     WRegion *reg=(WRegion*)param;
24     WTiling *tiling;
25     WSplitRegion *node=NULL;
26     
27     if(!region_fitrep(reg, parent, fp))
28         return NULL;
29     
30     tiling=create_tiling(parent, fp, NULL, FALSE);
31     
32     if(tiling==NULL)
33         return NULL;
34     
35     node=create_splitregion(&REGION_GEOM(tiling), reg);
36     if(node!=NULL){
37         tiling->split_tree=(WSplit*)node;
38         tiling->split_tree->ws_if_root=tiling;
39         
40         region_detach_manager(reg);
41         
42         if(tiling_managed_add(tiling, reg))
43             return (WRegion*)tiling;
44         
45         #warning "TODO: reattach?"
46         
47         destroy_obj((Obj*)tiling->split_tree);
48         tiling->split_tree=NULL;
49     }
50     
51     destroy_obj((Obj*)tiling);
52     return NULL;
53 }
54
55
56 /*EXTL_DOC
57  * Create a new \type{WTiling} 'bottom' for the group of \var{reg},
58  * consisting of \var{reg}.
59  */
60 EXTL_EXPORT
61 bool mod_tiling_mkbottom(WRegion *reg)
62 {
63     WGroup *grp=REGION_MANAGER_CHK(reg, WGroup);
64     WGroupAttachParams ap=GROUPATTACHPARAMS_INIT;
65     WRegionAttachData data;
66     WRegion *tiling;
67     
68     if(grp==NULL){
69         warn(TR("Not member of a group"));
70         return FALSE;
71     }
72     
73     if(grp->bottom!=NULL){
74         warn(TR("Manager group already has bottom"));
75         return FALSE;
76     }
77     
78     ap.level_set=TRUE;
79     ap.level=STACKING_LEVEL_BOTTOM;
80     
81     ap.szplcy_set=TRUE;
82     ap.szplcy=SIZEPOLICY_FULL_EXACT;
83     
84     ap.switchto_set=TRUE;
85     ap.switchto=region_may_control_focus(reg);
86     
87     ap.bottom=TRUE;
88
89     data.type=REGION_ATTACH_NEW;
90     data.u.n.fn=mkbottom_fn;
91     data.u.n.param=reg;
92     
93     /* kele... poisto samalla kuin attach */
94     return (group_do_attach(grp, &ap, &data)!=NULL);
95 }