]> git.decadent.org.uk Git - ion3.git/blob - ioncore/mplex.h
[svn-upgrade] Integrating new upstream version, ion3 (20070506)
[ion3.git] / ioncore / mplex.h
1 /*
2  * ion/ioncore/mplex.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  * 
6  * See the included file LICENSE for details.
7  */
8
9 #ifndef ION_IONCORE_MPLEX_H
10 #define ION_IONCORE_MPLEX_H
11
12 #include <libextl/extl.h>
13 #include <libmainloop/hooks.h>
14 #include "common.h"
15 #include "window.h"
16 #include "attach.h"
17 #include "manage.h"
18 #include "rectangle.h"
19 #include "pholder.h"
20 #include "sizepolicy.h"
21
22
23 #define MPLEX_ADD_TO_END 0x0001
24 #define MPLEX_MANAGED_UNVIEWABLE 0x0002
25
26 #define MPLEX_MGD_UNVIEWABLE(MPLEX) \
27     ((MPLEX)->flags&MPLEX_MANAGED_UNVIEWABLE)
28
29
30 #define MPLEX_ATTACH_SWITCHTO     0x0001 /* switch to region */
31 #define MPLEX_ATTACH_UNNUMBERED   0x0002 /* do not put on mut.ex list */
32 #define MPLEX_ATTACH_HIDDEN       0x0004 /* should be hidden */
33 #define MPLEX_ATTACH_PSEUDOMODAL  0x0004 /* pseudomodal (if modal) */
34 #define MPLEX_ATTACH_LEVEL        0x0010 /* level field set */
35 #define MPLEX_ATTACH_GEOM         0x0020 /* geometry field is set */
36 #define MPLEX_ATTACH_SIZEPOLICY   0x0040 /* size policy field is set */
37 #define MPLEX_ATTACH_INDEX        0x0080 /* index field is set */
38 #define MPLEX_ATTACH_WHATEVER     0x0100 /* set REGION_FIT_WHATEVER */
39
40
41 enum{
42     MPLEX_CHANGE_SWITCHONLY=0,
43     MPLEX_CHANGE_REORDER=1,
44     MPLEX_CHANGE_ADD=2,
45     MPLEX_CHANGE_REMOVE=3
46 };
47
48
49 enum{
50     MPLEX_STDISP_TL,
51     MPLEX_STDISP_TR,
52     MPLEX_STDISP_BL,
53     MPLEX_STDISP_BR
54 };
55
56
57 INTRSTRUCT(WMPlexSTDispInfo);
58 INTRSTRUCT(WMPlexChangedParams);
59 INTRSTRUCT(WMPlexAttachParams);
60
61
62 DECLSTRUCT(WMPlexSTDispInfo){
63     int pos;
64     bool fullsize;
65 };
66
67
68 DECLSTRUCT(WMPlexChangedParams){
69     WMPlex *reg;
70     int mode;
71     bool sw;
72     WRegion *sub;
73 };
74
75
76 #define MPLEXATTACHPARAMS_INIT {0, 0, {0, 0, 0, 0}, 0, 0}
77
78 DECLSTRUCT(WMPlexAttachParams){
79     int flags;
80     int index;
81     WRectangle geom;
82     WSizePolicy szplcy;
83     uint level;
84 };
85
86
87 DECLCLASS(WMPlex){
88     WWindow win;
89     int flags;
90     
91     WStacking *mgd;
92     
93     int mx_count;
94     WLListNode *mx_current;
95     WLListNode *mx_list;
96     WMPlexPHolder *mx_phs;
97     
98     Watch stdispwatch;
99     WMPlexSTDispInfo stdispinfo;
100 };
101
102
103 /* Create/destroy */
104
105 extern WMPlex *create_mplex(WWindow *parent, const WFitParams *fp);
106 extern bool mplex_init(WMPlex *mplex, WWindow *parent,
107                        const WFitParams *fp);
108 extern bool mplex_do_init(WMPlex *mplex, WWindow *parent, 
109                           const WFitParams *fp, Window win);
110 extern void mplex_deinit(WMPlex *mplex);
111
112 /* Resize and reparent */
113
114 extern bool mplex_fitrep(WMPlex *mplex, WWindow *par, const WFitParams *fp);
115 extern void mplex_do_fit_managed(WMPlex *mplex, WFitParams *fp);
116 extern void mplex_fit_managed(WMPlex *mplex);
117
118 /* Mapping */
119
120 extern void mplex_map(WMPlex *mplex);
121 extern void mplex_unmap(WMPlex *mplex);
122
123 /* Attach */
124
125 extern WRegion *mplex_attach_simple(WMPlex *mplex, WRegion *reg, 
126                                     int flags);
127
128 extern WRegion *mplex_attach(WMPlex *mplex, WRegion *reg, ExtlTab param);
129 extern WRegion *mplex_attach_new_(WMPlex *mplex, WMPlexAttachParams *partmpl,
130                                   int mask, ExtlTab param);
131 extern WRegion *mplex_attach_new(WMPlex *mplex, ExtlTab param);
132
133 extern WRegion *mplex_do_attach_pholder(WMPlex *mplex, WMPlexPHolder *ph,
134                                         WRegionAttachData *data);
135 extern WRegion *mplex_do_attach(WMPlex *mplex, WMPlexAttachParams *param,
136                                 WRegionAttachData *data);
137 extern WRegion *mplex_do_attach_new(WMPlex *mplex, WMPlexAttachParams *param,
138                                     WRegionCreateFn *fn, void *fn_param);
139
140 extern void mplex_managed_remove(WMPlex *mplex, WRegion *reg);
141 extern void mplex_child_removed(WMPlex *mplex, WRegion *sub);
142
143 extern bool mplex_rescue_clientwins(WMPlex *mplex, WRescueInfo *info);
144
145 extern WPHolder *mplex_prepare_manage(WMPlex *mplex, const WClientWin *cwin,
146                                       const WManageParams *param, int redir);
147
148 /* Switch */
149
150 extern bool mplex_managed_prepare_focus(WMPlex *mplex, WRegion *sub, 
151                                         int flags, WPrepareFocusResult *res);
152 extern bool mplex_do_prepare_focus(WMPlex *mplex, WStacking *disp, 
153                                    WStacking *sub, int flags, 
154                                    WPrepareFocusResult *res);
155
156 extern void mplex_switch_nth(WMPlex *mplex, uint n);
157 extern void mplex_switch_next(WMPlex *mplex);
158 extern void mplex_switch_prev(WMPlex *mplex);
159 extern bool mplex_is_hidden(WMPlex *mplex, WRegion *reg);
160 extern bool mplex_set_hidden(WMPlex *mplex, WRegion *reg, int sp);
161
162 /* Focus */
163
164 extern void mplex_do_set_focus(WMPlex *mplex, bool warp);
165
166 /* Stacking */
167
168 extern bool mplex_managed_rqorder(WMPlex *mplex, WRegion *sub, 
169                                   WRegionOrder order);
170
171 /* Misc */
172
173 extern WRegion *mplex_current(WMPlex *mplex);
174
175 extern bool mplex_managed_i(WMPlex *mplex, ExtlFn iterfn);
176
177 extern int mplex_mx_count(WMPlex *mplex);
178 extern WRegion *mplex_mx_nth(WMPlex *mplex, uint n);
179 extern bool mplex_mx_i(WMPlex *mplex, ExtlFn iterfn);
180 extern WRegion *mplex_mx_current(WMPlex *mplex);
181
182 extern void mplex_call_changed_hook(WMPlex *mplex, WHook *hook, 
183                                     int mode, bool sw, WRegion *reg);
184
185 extern void mplex_remanage_stdisp(WMPlex *mplex);
186
187 /* Dynfuns */
188
189 DYNFUN void mplex_managed_geom(const WMPlex *mplex, WRectangle *geom);
190 DYNFUN void mplex_size_changed(WMPlex *mplex, bool wchg, bool hchg);
191 DYNFUN void mplex_managed_changed(WMPlex *mplex, int what, bool sw,
192                                   WRegion *mgd);
193 DYNFUN int mplex_default_index(WMPlex *mplex);
194
195 /* Save/load */
196
197 extern ExtlTab mplex_get_configuration(WMPlex *mplex);
198 extern WRegion *mplex_load(WWindow *par, const WFitParams *fp, ExtlTab tab);
199 extern void mplex_load_contents(WMPlex *frame, ExtlTab tab);
200
201
202 /* Sticky status display support */
203
204 extern bool mplex_set_stdisp(WMPlex *mplex, WRegion *stdisp, 
205                              const WMPlexSTDispInfo *info);
206 extern void mplex_get_stdisp(WMPlex *mplex, WRegion **stdisp, 
207                              WMPlexSTDispInfo *info);
208
209 extern WRegion *mplex_set_stdisp_extl(WMPlex *mplex, ExtlTab t);
210 extern ExtlTab mplex_get_stdisp_extl(WMPlex *mplex);
211
212 DYNFUN void region_manage_stdisp(WRegion *reg, WRegion *stdisp, 
213                                  const WMPlexSTDispInfo *info);
214 DYNFUN void region_unmanage_stdisp(WRegion *reg, bool permanent, bool nofocus);
215
216 /* Stacking list stuff */
217
218 typedef WStackingIterTmp WMPlexIterTmp;
219
220 extern void mplex_iter_init(WMPlexIterTmp *tmp, WMPlex *ws);
221 extern WRegion *mplex_iter(WMPlexIterTmp *tmp);
222 extern WStacking *mplex_iter_nodes(WMPlexIterTmp *tmp);
223
224 extern WStacking *mplex_get_stacking(WMPlex *ws);
225 extern WStacking **mplex_get_stackingp(WMPlex *ws);
226
227 #define FOR_ALL_MANAGED_BY_MPLEX(MPLEX, VAR, TMP) \
228     for(mplex_iter_init(&(TMP), MPLEX),           \
229          VAR=mplex_iter(&(TMP));                  \
230         VAR!=NULL;                                \
231         VAR=mplex_iter(&(TMP)))
232
233 #define FOR_ALL_NODES_IN_MPLEX(MPLEX, VAR, TMP) \
234     for(mplex_iter_init(&(TMP), MPLEX),         \
235          VAR=mplex_iter_nodes(&(TMP));          \
236         VAR!=NULL;                              \
237         VAR=mplex_iter_nodes(&(TMP)))
238
239 extern WStacking *mplex_find_stacking(WMPlex *mplex, WRegion *reg);
240
241 #endif /* ION_IONCORE_MPLEX_H */