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