]> git.decadent.org.uk Git - ion3.git/blob - ioncore/mplex.h
Imported Upstream version 20090110
[ion3.git] / ioncore / mplex.h
1 /*
2  * ion/ioncore/mplex.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2009. 
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  0x0008 /* 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 #define MPLEX_ATTACH_PASSIVE      0x0200 /* sets SKIP_FOCUS */
40
41
42 enum{
43     MPLEX_CHANGE_SWITCHONLY=0,
44     MPLEX_CHANGE_REORDER=1,
45     MPLEX_CHANGE_ADD=2,
46     MPLEX_CHANGE_REMOVE=3
47 };
48
49
50 enum{
51     MPLEX_STDISP_TL,
52     MPLEX_STDISP_TR,
53     MPLEX_STDISP_BL,
54     MPLEX_STDISP_BR
55 };
56
57
58 INTRSTRUCT(WMPlexSTDispInfo);
59 INTRSTRUCT(WMPlexChangedParams);
60 INTRSTRUCT(WMPlexAttachParams);
61
62
63 DECLSTRUCT(WMPlexSTDispInfo){
64     int pos;
65     bool fullsize;
66 };
67
68
69 DECLSTRUCT(WMPlexChangedParams){
70     WMPlex *reg;
71     int mode;
72     bool sw;
73     WRegion *sub;
74 };
75
76
77 #define MPLEXATTACHPARAMS_INIT {0, 0, {0, 0, 0, 0}, 0, 0}
78
79 DECLSTRUCT(WMPlexAttachParams){
80     int flags;
81     int index;
82     WRectangle geom;
83     WSizePolicy szplcy;
84     uint level;
85 };
86
87
88 DECLCLASS(WMPlex){
89     WWindow win;
90     int flags;
91     
92     WStacking *mgd;
93     
94     int mx_count;
95     WLListNode *mx_current;
96     WLListNode *mx_list;
97     WMPlexPHolder *misc_phs;
98     
99     Watch stdispwatch;
100     WMPlexSTDispInfo stdispinfo;
101 };
102
103
104 /* Create/destroy */
105
106 extern WMPlex *create_mplex(WWindow *parent, const WFitParams *fp);
107 extern bool mplex_init(WMPlex *mplex, WWindow *parent,
108                        const WFitParams *fp);
109 extern bool mplex_do_init(WMPlex *mplex, WWindow *parent, 
110                           const WFitParams *fp, Window win);
111 extern void mplex_deinit(WMPlex *mplex);
112
113 /* Resize and reparent */
114
115 extern bool mplex_fitrep(WMPlex *mplex, WWindow *par, const WFitParams *fp);
116 extern void mplex_do_fit_managed(WMPlex *mplex, WFitParams *fp);
117 extern void mplex_fit_managed(WMPlex *mplex);
118
119 /* Mapping */
120
121 extern void mplex_map(WMPlex *mplex);
122 extern void mplex_unmap(WMPlex *mplex);
123
124 /* Attach */
125
126 extern WRegion *mplex_attach_simple(WMPlex *mplex, WRegion *reg, 
127                                     int flags);
128
129 extern WRegion *mplex_attach(WMPlex *mplex, WRegion *reg, ExtlTab param);
130 extern WRegion *mplex_attach_new_(WMPlex *mplex, WMPlexAttachParams *partmpl,
131                                   int mask, ExtlTab param);
132 extern WRegion *mplex_attach_new(WMPlex *mplex, ExtlTab param);
133
134 extern WRegion *mplex_do_attach_pholder(WMPlex *mplex, WMPlexPHolder *ph,
135                                         WRegionAttachData *data);
136 extern WRegion *mplex_do_attach(WMPlex *mplex, WMPlexAttachParams *param,
137                                 WRegionAttachData *data);
138 extern WRegion *mplex_do_attach_new(WMPlex *mplex, WMPlexAttachParams *param,
139                                     WRegionCreateFn *fn, void *fn_param);
140
141 extern void mplex_managed_remove(WMPlex *mplex, WRegion *reg);
142 extern void mplex_child_removed(WMPlex *mplex, WRegion *sub);
143
144 extern bool mplex_rescue_clientwins(WMPlex *mplex, WRescueInfo *info);
145
146 extern WPHolder *mplex_prepare_manage(WMPlex *mplex, const WClientWin *cwin,
147                                       const WManageParams *param, int redir);
148
149 /* Switch */
150
151 extern bool mplex_managed_prepare_focus(WMPlex *mplex, WRegion *sub, 
152                                         int flags, WPrepareFocusResult *res);
153 extern bool mplex_do_prepare_focus(WMPlex *mplex, WStacking *disp, 
154                                    WStacking *sub, int flags, 
155                                    WPrepareFocusResult *res);
156
157 extern void mplex_switch_nth(WMPlex *mplex, uint n);
158 extern void mplex_switch_next(WMPlex *mplex);
159 extern void mplex_switch_prev(WMPlex *mplex);
160 extern bool mplex_is_hidden(WMPlex *mplex, WRegion *reg);
161 extern bool mplex_set_hidden(WMPlex *mplex, WRegion *reg, int sp);
162
163 /* Focus */
164
165 extern void mplex_do_set_focus(WMPlex *mplex, bool warp);
166
167 /* Stacking */
168
169 extern bool mplex_managed_rqorder(WMPlex *mplex, WRegion *sub, 
170                                   WRegionOrder order);
171
172 /* Misc */
173
174 extern WRegion *mplex_current(WMPlex *mplex);
175
176 extern bool mplex_managed_i(WMPlex *mplex, ExtlFn iterfn);
177
178 extern int mplex_mx_count(WMPlex *mplex);
179 extern WRegion *mplex_mx_nth(WMPlex *mplex, uint n);
180 extern bool mplex_mx_i(WMPlex *mplex, ExtlFn iterfn);
181 extern WRegion *mplex_mx_current(WMPlex *mplex);
182
183 extern void mplex_call_changed_hook(WMPlex *mplex, WHook *hook, 
184                                     int mode, bool sw, WRegion *reg);
185
186 extern void mplex_remanage_stdisp(WMPlex *mplex);
187
188 /* Note: only the size policy field is changed; actual geometry is not
189  * yet changed.
190  */
191 extern void mplex_set_szplcy(WMPlex *mplex, WRegion *sub, WSizePolicy szplcy);
192 extern WSizePolicy mplex_get_szplcy(WMPlex *mplex, WRegion *sub);
193
194 /* Dynfuns */
195
196 DYNFUN void mplex_managed_geom(const WMPlex *mplex, WRectangle *geom);
197 DYNFUN void mplex_size_changed(WMPlex *mplex, bool wchg, bool hchg);
198 DYNFUN void mplex_managed_changed(WMPlex *mplex, int what, bool sw,
199                                   WRegion *mgd);
200 DYNFUN int mplex_default_index(WMPlex *mplex);
201
202 /* Save/load */
203
204 extern ExtlTab mplex_get_configuration(WMPlex *mplex);
205 extern WRegion *mplex_load(WWindow *par, const WFitParams *fp, ExtlTab tab);
206 extern void mplex_load_contents(WMPlex *frame, ExtlTab tab);
207
208
209 /* Sticky status display support */
210
211 extern bool mplex_set_stdisp(WMPlex *mplex, WRegion *stdisp, 
212                              const WMPlexSTDispInfo *info);
213 extern void mplex_get_stdisp(WMPlex *mplex, WRegion **stdisp, 
214                              WMPlexSTDispInfo *info);
215
216 extern WRegion *mplex_set_stdisp_extl(WMPlex *mplex, ExtlTab t);
217 extern ExtlTab mplex_get_stdisp_extl(WMPlex *mplex);
218
219 DYNFUN void region_manage_stdisp(WRegion *reg, WRegion *stdisp, 
220                                  const WMPlexSTDispInfo *info);
221 DYNFUN void region_unmanage_stdisp(WRegion *reg, bool permanent, bool nofocus);
222
223 /* Stacking list stuff */
224
225 typedef WStackingIterTmp WMPlexIterTmp;
226
227 extern void mplex_iter_init(WMPlexIterTmp *tmp, WMPlex *ws);
228 extern WRegion *mplex_iter(WMPlexIterTmp *tmp);
229 extern WStacking *mplex_iter_nodes(WMPlexIterTmp *tmp);
230
231 extern WStacking *mplex_get_stacking(WMPlex *ws);
232 extern WStacking **mplex_get_stackingp(WMPlex *ws);
233
234 #define FOR_ALL_MANAGED_BY_MPLEX(MPLEX, VAR, TMP) \
235     for(mplex_iter_init(&(TMP), MPLEX),           \
236          VAR=mplex_iter(&(TMP));                  \
237         VAR!=NULL;                                \
238         VAR=mplex_iter(&(TMP)))
239
240 #define FOR_ALL_NODES_IN_MPLEX(MPLEX, VAR, TMP) \
241     for(mplex_iter_init(&(TMP), MPLEX),         \
242          VAR=mplex_iter_nodes(&(TMP));          \
243         VAR!=NULL;                              \
244         VAR=mplex_iter_nodes(&(TMP)))
245
246 extern WStacking *mplex_find_stacking(WMPlex *mplex, WRegion *reg);
247
248 #endif /* ION_IONCORE_MPLEX_H */