Consistency fixes
[notion.git] / ioncore / mplex.h
blob4efd9d76d7486f98c05ad6f266fe6bc859e86a54
1 /*
2 * ion/ioncore/mplex.h
4 * Copyright (c) Tuomo Valkonen 1999-2009.
5 *
6 * See the included file LICENSE for details.
7 */
9 #ifndef ION_IONCORE_MPLEX_H
10 #define ION_IONCORE_MPLEX_H
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"
23 #define MPLEX_ADD_TO_END 0x0001
24 #define MPLEX_MANAGED_UNVIEWABLE 0x0002
26 #define MPLEX_MGD_UNVIEWABLE(MPLEX) \
27 ((MPLEX)->flags&MPLEX_MANAGED_UNVIEWABLE)
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 */
42 enum{
43 MPLEX_CHANGE_SWITCHONLY=0,
44 MPLEX_CHANGE_REORDER=1,
45 MPLEX_CHANGE_ADD=2,
46 MPLEX_CHANGE_REMOVE=3
50 enum{
51 MPLEX_STDISP_TL,
52 MPLEX_STDISP_TR,
53 MPLEX_STDISP_BL,
54 MPLEX_STDISP_BR
58 INTRSTRUCT(WMPlexSTDispInfo);
59 INTRSTRUCT(WMPlexChangedParams);
60 INTRSTRUCT(WMPlexAttachParams);
63 DECLSTRUCT(WMPlexSTDispInfo){
64 int pos;
65 bool fullsize;
69 DECLSTRUCT(WMPlexChangedParams){
70 WMPlex *reg;
71 int mode;
72 bool sw;
73 WRegion *sub;
77 #define MPLEXATTACHPARAMS_INIT {0, 0, {0, 0, 0, 0}, 0, 0}
79 DECLSTRUCT(WMPlexAttachParams){
80 int flags;
81 int index;
82 WRectangle geom;
83 WSizePolicy szplcy;
84 uint level;
88 DECLCLASS(WMPlex){
89 WWindow win;
90 int flags;
92 WStacking *mgd;
94 int mx_count;
95 WLListNode *mx_current;
96 WLListNode *mx_list;
97 WMPlexPHolder *misc_phs;
99 Watch stdispwatch;
100 WMPlexSTDispInfo stdispinfo;
104 /* Create/destroy */
106 extern WMPlex *create_mplex(WWindow *parent, const WFitParams *fp, const char *name);
107 extern bool mplex_init(WMPlex *mplex, WWindow *parent,
108 const WFitParams *fp, const char *name);
109 extern bool mplex_do_init(WMPlex *mplex, WWindow *parent,
110 const WFitParams *fp, Window win, const char *name);
111 extern void mplex_deinit(WMPlex *mplex);
113 /* Resize and reparent */
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);
119 /* Mapping */
121 extern void mplex_map(WMPlex *mplex);
122 extern void mplex_unmap(WMPlex *mplex);
124 /* Attach */
126 extern WRegion *mplex_attach_simple(WMPlex *mplex, WRegion *reg,
127 int flags);
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);
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);
141 extern void mplex_managed_remove(WMPlex *mplex, WRegion *reg);
142 extern void mplex_child_removed(WMPlex *mplex, WRegion *sub);
144 extern bool mplex_rescue_clientwins(WMPlex *mplex, WRescueInfo *info);
146 extern WPHolder *mplex_prepare_manage(WMPlex *mplex, const WClientWin *cwin,
147 const WManageParams *param, int redir);
149 /* Switch */
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);
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 void mplex_switch_to(WMPlex *mplex, WRegion *reg);
161 extern bool mplex_is_hidden(WMPlex *mplex, WRegion *reg);
162 extern bool mplex_set_hidden(WMPlex *mplex, WRegion *reg, int sp);
164 /* Focus */
166 extern void mplex_do_set_focus(WMPlex *mplex, bool warp);
168 /* Stacking */
170 extern bool mplex_managed_rqorder(WMPlex *mplex, WRegion *sub,
171 WRegionOrder order);
173 /* Misc */
175 extern WRegion *mplex_current(WMPlex *mplex);
177 extern bool mplex_managed_i(WMPlex *mplex, ExtlFn iterfn);
179 extern int mplex_mx_count(WMPlex *mplex);
180 extern WRegion *mplex_mx_nth(WMPlex *mplex, uint n);
181 extern bool mplex_mx_i(WMPlex *mplex, ExtlFn iterfn);
182 extern WRegion *mplex_mx_current(WMPlex *mplex);
184 extern void mplex_call_changed_hook(WMPlex *mplex, WHook *hook,
185 int mode, bool sw, WRegion *reg);
187 extern void mplex_remanage_stdisp(WMPlex *mplex);
189 /* Note: only the size policy field is changed; actual geometry is not
190 * yet changed.
192 extern void mplex_set_szplcy(WMPlex *mplex, WRegion *sub, WSizePolicy szplcy);
193 extern WSizePolicy mplex_get_szplcy(WMPlex *mplex, WRegion *sub);
195 /* Dynfuns */
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);
203 /* Save/load */
205 extern ExtlTab mplex_get_configuration(WMPlex *mplex);
206 extern WRegion *mplex_load(WWindow *par, const WFitParams *fp, ExtlTab tab,
207 const char *name);
208 extern void mplex_load_contents(WMPlex *frame, ExtlTab tab);
211 /* Sticky status display support */
213 extern bool mplex_set_stdisp(WMPlex *mplex, WRegion *stdisp,
214 const WMPlexSTDispInfo *info);
215 extern void mplex_get_stdisp(WMPlex *mplex, WRegion **stdisp,
216 WMPlexSTDispInfo *info);
218 extern WRegion *mplex_set_stdisp_extl(WMPlex *mplex, ExtlTab t);
219 extern ExtlTab mplex_get_stdisp_extl(WMPlex *mplex);
221 DYNFUN void region_manage_stdisp(WRegion *reg, WRegion *stdisp,
222 const WMPlexSTDispInfo *info);
223 DYNFUN void region_unmanage_stdisp(WRegion *reg, bool permanent, bool nofocus);
225 /* Stacking list stuff */
227 typedef WStackingIterTmp WMPlexIterTmp;
229 extern void mplex_iter_init(WMPlexIterTmp *tmp, WMPlex *ws);
230 extern WRegion *mplex_iter(WMPlexIterTmp *tmp);
231 extern WStacking *mplex_iter_nodes(WMPlexIterTmp *tmp);
233 extern WStacking *mplex_get_stacking(WMPlex *ws);
234 extern WStacking **mplex_get_stackingp(WMPlex *ws);
236 #define FOR_ALL_MANAGED_BY_MPLEX(MPLEX, VAR, TMP) \
237 for(mplex_iter_init(&(TMP), MPLEX), \
238 VAR=mplex_iter(&(TMP)); \
239 VAR!=NULL; \
240 VAR=mplex_iter(&(TMP)))
242 #define FOR_ALL_NODES_IN_MPLEX(MPLEX, VAR, TMP) \
243 for(mplex_iter_init(&(TMP), MPLEX), \
244 VAR=mplex_iter_nodes(&(TMP)); \
245 VAR!=NULL; \
246 VAR=mplex_iter_nodes(&(TMP)))
248 extern WStacking *mplex_find_stacking(WMPlex *mplex, WRegion *reg);
250 #endif /* ION_IONCORE_MPLEX_H */