4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * See the included file LICENSE for details.
12 #include <libtu/objp.h>
13 #include <libtu/minmax.h>
15 #include <libextl/extl.h>
16 #include <libmainloop/defer.h>
30 #include "frame-pointer.h"
35 #include "mplexpholder.h"
38 #include "sizepolicy.h"
42 #include "groupedpholder.h"
45 #define SUBS_MAY_BE_MAPPED(MPLEX) \
46 (REGION_IS_MAPPED(MPLEX) && !MPLEX_MGD_UNVIEWABLE(MPLEX))
48 #define PASSIVE(ST) ((ST)->level<=STACKING_LEVEL_MODAL1 \
50 || (ST)->reg->flags®ION_SKIP_FOCUS))
52 #define CAN_MANAGE_STDISP(REG) HAS_DYN(REG, region_manage_stdisp)
55 /*{{{ Stacking list stuff */
58 WStacking *mplex_get_stacking(WMPlex *mplex)
60 return window_get_stacking(&mplex->win);
64 WStacking **mplex_get_stackingp(WMPlex *mplex)
66 return window_get_stackingp(&mplex->win);
70 void mplex_iter_init(WMPlexIterTmp *tmp, WMPlex *mplex)
72 stacking_iter_mgr_init(tmp, mplex->mgd, NULL, mplex);
76 WRegion *mplex_iter(WMPlexIterTmp *tmp)
78 return stacking_iter_mgr(tmp);
82 WStacking *mplex_iter_nodes(WMPlexIterTmp *tmp)
84 return stacking_iter_mgr_nodes(tmp);
91 /*{{{ Destroy/create mplex */
94 bool mplex_do_init(WMPlex *mplex, WWindow *parent,
95 const WFitParams *fp, Window win)
100 mplex->mx_current=NULL;
106 watch_init(&(mplex->stdispwatch));
107 mplex->stdispinfo.pos=MPLEX_STDISP_BL;
108 mplex->stdispinfo.fullsize=FALSE;
110 if(!window_do_init((WWindow*)mplex, parent, fp, win))
113 mplex->win.region.flags|=REGION_BINDINGS_ARE_GRABBED;
115 window_select_input(&(mplex->win), IONCORE_EVENTMASK_CWINMGR);
117 region_register((WRegion*)mplex);
119 /* Call this to set MPLEX_MANAGED_UNVIEWABLE if necessary. */
120 mplex_fit_managed(mplex);
126 bool mplex_init(WMPlex *mplex, WWindow *parent, const WFitParams *fp)
128 return mplex_do_init(mplex, parent, fp, None);
132 WMPlex *create_mplex(WWindow *parent, const WFitParams *fp)
134 CREATEOBJ_IMPL(WMPlex, mplex, (p, parent, fp));
138 void mplex_deinit(WMPlex *mplex)
143 FOR_ALL_MANAGED_BY_MPLEX(mplex, reg, tmp){
144 destroy_obj((Obj*)reg);
147 assert(mplex->mgd==NULL);
148 assert(mplex->mx_list==NULL);
150 while(mplex->mx_phs!=NULL){
151 assert(mplexpholder_move(mplex->mx_phs, NULL, NULL, NULL));
154 window_deinit((WWindow*)mplex);
161 /*{{{ Node lookup etc. */
164 WStacking *mplex_find_stacking(WMPlex *mplex, WRegion *reg)
168 /* Some routines that call us expect us to this check. */
169 if(reg==NULL || REGION_MANAGER(reg)!=(WRegion*)mplex)
172 st=ioncore_find_stacking(reg);
174 assert(st==NULL || st->mgr_prev!=NULL);
180 WStacking *mplex_current_node(WMPlex *mplex)
185 reg=REGION_ACTIVE_SUB(mplex);
186 reg=region_managed_within((WRegion*)mplex, reg);
188 st=mplex_find_stacking(mplex, reg);
193 return (mplex->mx_current!=NULL ? mplex->mx_current->st : NULL);
197 WRegion *mplex_current(WMPlex *mplex)
199 WStacking *node=mplex_current_node(mplex);
200 return (node==NULL ? NULL : node->reg);
207 /*{{{ Exclusive list management and exports */
210 * Returns the number of objects on the mutually exclusive list of \var{mplex}.
214 int mplex_mx_count(WMPlex *mplex)
216 return mplex->mx_count;
221 * Returns the managed object currently active within the mutually exclusive
222 * list of \var{mplex}.
226 WRegion *mplex_mx_current(WMPlex *mplex)
228 WLListNode *lnode=mplex->mx_current;
229 return (lnode==NULL ? NULL : lnode->st->reg);
234 * Returns the \var{n}:th object on the mutually exclusive
235 * list of \var{mplex}.
239 WRegion *mplex_mx_nth(WMPlex *mplex, uint n)
241 WLListNode *lnode=llist_nth_node(mplex->mx_list, n);
242 return (lnode==NULL ? NULL : lnode->st->reg);
247 * Iterate over numbered/mutually exclusive region list of \var{mplex}
248 * until \var{iterfn} returns \code{false}.
249 * The function itself returns \code{true} if it reaches the end of list
250 * without this happening.
254 bool mplex_mx_i(WMPlex *mplex, ExtlFn iterfn)
257 llist_iter_init(&tmp, mplex->mx_list);
259 return extl_iter_objlist_(iterfn, (ObjIterator*)llist_iter_regions, &tmp);
264 * Iterate over managed regions of \var{mplex} until \var{iterfn} returns
266 * The function itself returns \code{true} if it reaches the end of list
267 * without this happening.
271 bool mplex_managed_i(WMPlex *mplex, ExtlFn iterfn)
274 mplex_iter_init(&tmp, mplex);
276 return extl_iter_objlist_(iterfn, (ObjIterator*)mplex_iter, &tmp);
281 * Set index of \var{reg} to \var{index} within the mutually exclusive
282 * list of \var{mplex}. Special values for \var{index} are:
283 * \begin{tabularx}{\linewidth}{lX}
285 * $-2$ & After \fnref{WMPlex.mx_current}. \\
289 void mplex_set_index(WMPlex *mplex, WRegion *reg, int index)
291 WLListNode *lnode, *after;
294 node=mplex_find_stacking(mplex, reg);
302 lnode=ALLOC(WLListNode);
312 mplex_move_phs_before(mplex, lnode);
313 llist_unlink(&(mplex->mx_list), lnode);
316 after=llist_index_to_after(mplex->mx_list, mplex->mx_current, index);
317 llist_link_after(&(mplex->mx_list), after, lnode);
318 mplex_managed_changed(mplex, MPLEX_CHANGE_REORDER, FALSE, reg);
323 * Get index of \var{reg} on the mutually exclusive list of \var{mplex}.
324 * The indices begin from zero.. If \var{reg} is not on the list,
329 int mplex_get_index(WMPlex *mplex, WRegion *reg)
335 FOR_ALL_NODES_ON_LLIST(lnode, mplex->mx_list, tmp){
336 if(reg==lnode->st->reg)
346 * Move \var{r} ``right'' within objects managed by \var{mplex} on list 1.
349 void mplex_inc_index(WMPlex *mplex, WRegion *r)
352 r=mplex_mx_current(mplex);
354 mplex_set_index(mplex, r, mplex_get_index(mplex, r)+1);
359 * Move \var{r} ``left'' within objects managed by \var{mplex} on list 1.
362 void mplex_dec_index(WMPlex *mplex, WRegion *r)
365 r=mplex_mx_current(mplex);
367 mplex_set_index(mplex, r, mplex_get_index(mplex, r)-1);
377 static void mplex_map_mgd(WMPlex *mplex)
382 FOR_ALL_NODES_IN_MPLEX(mplex, node, tmp){
383 if(!STACKING_IS_HIDDEN(node))
384 region_map(node->reg);
389 static void mplex_unmap_mgd(WMPlex *mplex)
394 FOR_ALL_NODES_IN_MPLEX(mplex, node, tmp){
395 if(!STACKING_IS_HIDDEN(node))
396 region_unmap(node->reg);
402 void mplex_map(WMPlex *mplex)
404 window_map((WWindow*)mplex);
405 /* A lame requirement of the ICCCM is that client windows should be
406 * unmapped if the parent is unmapped.
408 if(!MPLEX_MGD_UNVIEWABLE(mplex))
409 mplex_map_mgd(mplex);
413 void mplex_unmap(WMPlex *mplex)
415 window_unmap((WWindow*)mplex);
416 /* A lame requirement of the ICCCM is that client windows should be
417 * unmapped if the parent is unmapped.
419 if(!MPLEX_MGD_UNVIEWABLE(mplex))
420 mplex_unmap_mgd(mplex);
427 /*{{{ Resize and reparent */
430 bool mplex_fitrep(WMPlex *mplex, WWindow *par, const WFitParams *fp)
432 bool wchg=(REGION_GEOM(mplex).w!=fp->g.w);
433 bool hchg=(REGION_GEOM(mplex).h!=fp->g.h);
435 window_do_fitrep(&(mplex->win), par, &(fp->g));
438 mplex_fit_managed(mplex);
439 mplex_size_changed(mplex, wchg, hchg);
446 void mplex_do_fit_managed(WMPlex *mplex, WFitParams *fp)
453 if(!MPLEX_MGD_UNVIEWABLE(mplex) && (fp->g.w<=1 || fp->g.h<=1)){
454 mplex->flags|=MPLEX_MANAGED_UNVIEWABLE;
455 if(REGION_IS_MAPPED(mplex))
456 mplex_unmap_mgd(mplex);
457 }else if(MPLEX_MGD_UNVIEWABLE(mplex) && !(fp->g.w<=1 || fp->g.h<=1)){
458 mplex->flags&=~MPLEX_MANAGED_UNVIEWABLE;
459 if(REGION_IS_MAPPED(mplex))
460 mplex_map_mgd(mplex);
463 if(!MPLEX_MGD_UNVIEWABLE(mplex)){
464 FOR_ALL_NODES_IN_MPLEX(mplex, node, tmp){
466 sizepolicy(&node->szplcy, node->reg, NULL, 0, &fp2);
467 region_fitrep(node->reg, NULL, &fp2);
473 void mplex_fit_managed(WMPlex *mplex)
477 fp.mode=REGION_FIT_EXACT;
478 mplex_managed_geom(mplex, &(fp.g));
480 mplex_do_fit_managed(mplex, &fp);
484 static void mplex_managed_rqgeom(WMPlex *mplex, WRegion *sub,
485 const WRQGeomParams *rq,
492 node=mplex_find_stacking(mplex, sub);
496 mplex_managed_geom(mplex, &fp.g);
498 sizepolicy(&node->szplcy, sub, &rq->geom, rq->flags, &fp);
503 if(!(rq->flags®ION_RQGEOM_TRYONLY))
504 region_fitrep(sub, NULL, &fp);
508 void mplex_set_szplcy(WMPlex *mplex, WRegion *sub, WSizePolicy szplcy)
512 node=mplex_find_stacking(mplex, sub);
519 WSizePolicy mplex_get_szplcy(WMPlex *mplex, WRegion *sub)
523 node=mplex_find_stacking(mplex, sub);
525 return (node==NULL ? SIZEPOLICY_DEFAULT : node->szplcy);
544 static WRegion *manager_within(WMPlex *mplex, WStacking *st)
546 return region_managed_within((WRegion*)mplex, st->reg);
550 static WStacking *stacking_within(WMPlex *mplex, WStacking *st)
552 WRegion *reg=manager_within(mplex, st);
558 : ioncore_find_stacking(reg)));
562 /* Mutually exclusive regions can't be pseudomodal */
563 #define IS_PSEUDOMODAL(ST) ((ST)->lnode==NULL && (ST)->pseudomodal)
566 static bool mapped_pseudomodal_include_filt(WStacking *st, void *data_)
568 FiltData *data=(FiltData*)data_;
571 if(st->reg==NULL || !REGION_IS_MAPPED(st->reg))
575 || (data->to_try==NULL && data->group_st==NULL)
576 || st->level<STACKING_LEVEL_MODAL1){
580 /* Ok, modal node in the way. Let's see if it is pseudomodal
584 stw=stacking_within(data->mplex, st);
586 /* This should not happen */
587 if(stw==NULL || stw->reg==NULL)
590 /* The node is within the same group, so it can not be hidden.
591 * Latter case should not happen.
593 if(stw==data->group_st || stw==data->to_try)
596 if(IS_PSEUDOMODAL(stw)){
597 /* Don't insert multiple times. */
598 return !ptrlist_reinsert_first(data->hidelist, stw);
605 static bool mgr_pseudomodal_approve_filt(WStacking *st, void *data_)
607 FiltData *data=(FiltData*)data_;
609 return (data->group_st==NULL || st==data->group_st ||
610 manager_within(data->mplex, st)==data->group_st->reg);
614 WStacking *mplex_find_to_focus(WMPlex *mplex,
619 WStackingFilter *fi=mapped_pseudomodal_include_filt;
620 WStackingFilter *fa=mgr_pseudomodal_approve_filt;
621 WStacking *stacking=mplex_get_stacking(mplex);
628 if(to_try!=NULL && (to_try->reg==NULL || !REGION_IS_MAPPED(to_try->reg)))
633 data.group_st=group_st;
634 data.hidelist=hidelist;
636 st=stacking_find_to_focus(stacking, to_try, fi, fa, &data);
638 if(st==NULL && hidelist!=NULL)
639 ptrlist_clear(hidelist);
645 static WStacking *mplex_do_to_focus(WMPlex *mplex, WStacking *to_try,
648 return mplex_find_to_focus(mplex, to_try, NULL, hidelist);
652 static WStacking *mplex_do_to_focus_on(WMPlex *mplex, WStacking *node,
654 PtrList **hidelist, bool *within)
656 WGroup *grp=OBJ_CAST(node->reg, WGroup);
661 to_try=grp->current_managed;
662 /* Only will return stuff within 'node' */
663 st=mplex_find_to_focus(mplex, to_try, node, hidelist);
671 st=mplex_do_to_focus(mplex, node, hidelist);
673 if(st==node && within!=NULL)
680 static WStacking *maybe_focusable(WRegion *reg)
682 if(reg==NULL || !REGION_IS_MAPPED(reg))
685 return ioncore_find_stacking(reg);
689 static WStacking *has_stacking_within(WMPlex *mplex, WRegion *reg)
691 while(reg!=NULL && REGION_MANAGER(reg)!=(WRegion*)mplex)
692 reg=REGION_MANAGER(reg);
694 return maybe_focusable(reg);
698 static WStacking *mplex_to_focus(WMPlex *mplex)
700 WStacking *to_try=NULL;
704 to_try=maybe_focusable(REGION_ACTIVE_SUB(mplex));
707 /* Search focus history */
708 for(reg=ioncore_g.focus_current; reg!=NULL; reg=reg->active_next){
709 to_try=has_stacking_within(mplex, reg);
715 st=mplex_do_to_focus(mplex, to_try, NULL);
719 : (mplex->mx_current!=NULL
720 ? mplex->mx_current->st
725 void mplex_do_set_focus(WMPlex *mplex, bool warp)
727 if(!MPLEX_MGD_UNVIEWABLE(mplex)){
728 WStacking *st=mplex_to_focus(mplex);
731 region_do_set_focus(st->reg, warp);
736 window_do_set_focus((WWindow*)mplex, warp);
746 static void mplex_do_remanage_stdisp(WMPlex *mplex, WRegion *sub)
748 WRegion *stdisp=(WRegion*)(mplex->stdispwatch.obj);
751 if(sub!=NULL && CAN_MANAGE_STDISP(sub)){
753 WRegion *omgr=REGION_MANAGER(stdisp);
754 if(omgr!=sub && omgr!=NULL){
755 if(CAN_MANAGE_STDISP(omgr))
756 region_unmanage_stdisp(omgr, FALSE, FALSE);
757 region_detach_manager(stdisp);
760 region_manage_stdisp(sub, stdisp,
761 &(mplex->stdispinfo));
763 region_unmanage_stdisp(sub, TRUE, FALSE);
769 void mplex_remanage_stdisp(WMPlex *mplex)
771 mplex_do_remanage_stdisp(mplex, (mplex->mx_current!=NULL
772 ? mplex->mx_current->st->reg
777 static void mplex_do_node_display(WMPlex *mplex, WStacking *node,
780 WRegion *sub=node->reg;
781 WLListNode *mxc=mplex->mx_current;
783 if(!STACKING_IS_HIDDEN(node))
786 if(node->lnode!=NULL && node->lnode!=mxc)
787 mplex_do_remanage_stdisp(mplex, sub);
791 if(SUBS_MAY_BE_MAPPED(mplex))
796 if(node->lnode!=NULL){
798 /* Hide current mx region. We do it after mapping the
799 * new one to avoid flicker.
801 if(REGION_IS_MAPPED(mplex))
802 region_unmap(mxc->st->reg);
803 mxc->st->hidden=TRUE;
806 mplex->mx_current=node->lnode;
809 * Many programs will get upset if the visible, although only
810 * such, client window is not the lowest window in the mplex.
811 * xprop/xwininfo will return the information for the lowest
812 * window. 'netscape -remote' will not work at all if there are
813 * no visible netscape windows.
816 WGroup *grp=(WGroup*)OBJ_CAST(sub, WGroupCW);
818 WRegion *bottom=group_bottom(grp);
820 region_managed_rqorder((WRegion*)grp, bottom,
827 mplex_managed_changed(mplex, MPLEX_CHANGE_SWITCHONLY, TRUE, sub);
832 static bool mplex_refocus(WMPlex *mplex, WStacking *node, bool warp)
838 foc=mplex_do_to_focus_on(mplex, node, NULL, NULL, &within);
840 if(foc==NULL || !within)
841 foc=mplex_to_focus(mplex);
844 region_maybewarp(foc->reg, warp);
850 bool mplex_do_prepare_focus(WMPlex *mplex, WStacking *node,
851 WStacking *sub, int flags,
852 WPrepareFocusResult *res)
854 bool ew=(flags®ION_GOTO_ENTERWINDOW);
855 PtrList *hidelist=NULL;
856 PtrList **hidelistp=(ew ? NULL : &hidelist);
858 /*bool within=FALSE;*/
860 if(sub==NULL && node==NULL)
863 /* Display the node in any case */
864 if(node!=NULL && !ew)
865 mplex_do_node_display(mplex, node, TRUE);
867 if(!region_prepare_focus((WRegion*)mplex, flags, res))
870 foc=mplex_do_to_focus_on(mplex, node, sub, hidelistp, NULL /*&within*/);
873 while(hidelist!=NULL){
874 WStacking *st=(WStacking*)ptrlist_take_first(&hidelist);
876 region_unmap(st->reg);
879 if(ioncore_g.autoraise &&
880 !(flags®ION_GOTO_ENTERWINDOW) &&
881 foc->level>STACKING_LEVEL_BOTTOM){
882 WStacking **stackingp=mplex_get_stackingp(mplex);
883 stacking_restack(stackingp, foc, None, NULL, NULL, FALSE);
889 return (foc==sub || (sub==NULL && foc==node));
896 bool mplex_managed_prepare_focus(WMPlex *mplex, WRegion *disp,
897 int flags, WPrepareFocusResult *res)
899 WStacking *node=mplex_find_stacking(mplex, disp);
904 return mplex_do_prepare_focus(mplex, node, NULL, flags, res);
911 /*{{{ Switch exports */
914 static void do_switch(WMPlex *mplex, WLListNode *lnode)
916 WStacking *node=(lnode!=NULL ? lnode->st : NULL);
919 bool mcf=region_may_control_focus((WRegion*)mplex);
921 mplex_do_node_display(mplex, node, TRUE);
924 mplex_refocus(mplex, node, TRUE);
930 * Have \var{mplex} display the \var{n}:th object managed by it.
933 void mplex_switch_nth(WMPlex *mplex, uint n)
935 do_switch(mplex, llist_nth_node(mplex->mx_list, n));
940 * Have \var{mplex} display next (wrt. currently selected) object managed
944 void mplex_switch_next(WMPlex *mplex)
946 do_switch(mplex, LIST_NEXT_WRAP(mplex->mx_list, mplex->mx_current,
952 * Have \var{mplex} display previous (wrt. currently selected) object
956 void mplex_switch_prev(WMPlex *mplex)
958 do_switch(mplex, LIST_PREV_WRAP(mplex->mx_list, mplex->mx_current,
963 bool mplex_set_hidden(WMPlex *mplex, WRegion *reg, int sp)
965 bool mcf=region_may_control_focus((WRegion*)mplex);
966 WStacking *node=mplex_find_stacking(mplex, reg);
967 bool hidden, nhidden;
972 hidden=STACKING_IS_HIDDEN(node);
973 nhidden=libtu_do_setparam(sp, hidden);
975 if(!hidden && nhidden){
978 if(REGION_IS_MAPPED(mplex) && !MPLEX_MGD_UNVIEWABLE(mplex))
981 /* lnode -> switch next? */
982 }else if(hidden && !nhidden){
983 mplex_do_node_display(mplex, node, TRUE);
986 if(mcf && !PASSIVE(node))
987 mplex_refocus(mplex, (nhidden ? NULL : node), TRUE);
989 return STACKING_IS_HIDDEN(node);
994 * Set the visibility of the region \var{reg} on \var{mplex}
995 * as specified with the parameter \var{how}
996 * (one of \codestr{set}, \codestr{unset}, or \codestr{toggle}).
997 * The resulting state is returned.
999 EXTL_EXPORT_AS(WMPlex, set_hidden)
1000 bool mplex_set_hidden_extl(WMPlex *mplex, WRegion *reg, const char *how)
1002 return mplex_set_hidden(mplex, reg, libtu_string_to_setparam(how));
1007 * Is \var{reg} on within \var{mplex} and hidden?
1011 bool mplex_is_hidden(WMPlex *mplex, WRegion *reg)
1013 WStacking *node=mplex_find_stacking(mplex, reg);
1015 return (node!=NULL && STACKING_IS_HIDDEN(node));
1025 static WStacking *mplex_nxt(WMPlex *mplex, WStacking *st, bool wrap)
1027 return (st->mgr_next!=NULL
1029 : (wrap ? mplex->mgd : NULL));
1033 static WStacking *mplex_prv(WMPlex *mplex, WStacking *st, bool wrap)
1035 return (st!=mplex->mgd
1037 : (wrap ? st->mgr_prev : NULL));
1041 typedef WStacking *NxtFn(WMPlex *mplex, WStacking *st, bool wrap);
1044 static WRegion *do_navi(WMPlex *mplex, WStacking *sti,
1045 NxtFn *fn, WRegionNaviData *data,
1046 bool sti_ok, bool wrap)
1048 WStacking *st, *stacking;
1051 stacking=mplex_get_stacking(mplex);
1054 min_level=stacking_min_level_mapped(stacking);
1058 st=fn(mplex, st, wrap);
1060 if(st==NULL || (st==sti && !sti_ok))
1064 if(OBJ_IS(st->reg, WGroup)){
1065 /* WGroup navigation code should respect modal stuff. */
1066 WRegion *res=region_navi_cont((WRegion*)mplex, st->reg, data);
1067 if(res!=NULL && res!=st->reg)
1070 if(st->level>=min_level && !PASSIVE(st))
1071 return region_navi_cont((WRegion*)mplex, st->reg, data);
1083 WRegion *mplex_navi_first(WMPlex *mplex, WRegionNavi nh,
1084 WRegionNaviData *data)
1086 WStacking *lst=mplex->mgd;
1090 if(nh==REGION_NAVI_ANY){
1094 if(nh==REGION_NAVI_ANY || nh==REGION_NAVI_END ||
1095 nh==REGION_NAVI_BOTTOM || nh==REGION_NAVI_RIGHT){
1096 res=do_navi(mplex, lst, mplex_prv, data, TRUE, TRUE);
1098 res=do_navi(mplex, lst->mgr_prev, mplex_nxt, data, TRUE, TRUE);
1102 return region_navi_cont((WRegion*)mplex, res, data);
1106 WRegion *mplex_navi_next(WMPlex *mplex, WRegion *rel, WRegionNavi nh,
1107 WRegionNaviData *data)
1113 st=mplex_find_stacking(mplex, rel);
1116 }else if(mplex->mx_current!=NULL){
1117 st=mplex->mx_current->st;
1119 return mplex_navi_first(mplex, nh, data);
1122 if(nh==REGION_NAVI_ANY){
1126 if(nh==REGION_NAVI_ANY || nh==REGION_NAVI_END ||
1127 nh==REGION_NAVI_BOTTOM || nh==REGION_NAVI_RIGHT){
1128 res=do_navi(mplex, st, mplex_nxt, data, FALSE, FALSE);
1130 res=do_navi(mplex, st, mplex_prv, data, FALSE, FALSE);
1133 return region_navi_cont((WRegion*)mplex, res, data);
1143 bool mplex_managed_rqorder(WMPlex *mplex, WRegion *reg, WRegionOrder order)
1145 WStacking **stackingp=mplex_get_stackingp(mplex);
1148 if(stackingp==NULL || *stackingp==NULL)
1151 st=mplex_find_stacking(mplex, reg);
1156 stacking_restack(stackingp, st, None, NULL, NULL,
1157 (order!=REGION_ORDER_FRONT));
1169 static bool mplex_stack(WMPlex *mplex, WStacking *st)
1171 WStacking *tmp=NULL;
1172 WStacking **stackingp=mplex_get_stackingp(mplex);
1177 LINK_ITEM_FIRST(tmp, st, next, prev);
1178 stacking_weave(stackingp, &tmp, FALSE);
1185 static void mplex_unstack(WMPlex *mplex, WStacking *st)
1187 WStacking *stacking;
1189 stacking=mplex_get_stacking(mplex);
1191 stacking_unstack(&mplex->win, st);
1195 /* WMPlexWPHolder is used for position marking in order to allow
1196 * WLListNodes be safely removed in the attach handler hnd, that
1197 * could remove something this mplex is managing.
1199 bool mplex_do_attach_final(WMPlex *mplex, WRegion *reg, WMPlexPHolder *ph)
1201 WStacking *node=NULL;
1202 WLListNode *lnode=NULL;
1203 WMPlexAttachParams *param=&ph->param;
1204 bool mx_was_empty, sw, modal, mcf, hidden;
1208 mcf=region_may_control_focus((WRegion*)mplex);
1210 mx_was_empty=(mplex->mx_list==NULL);
1212 szplcy=((param->flags&MPLEX_ATTACH_SIZEPOLICY &&
1213 param->szplcy!=SIZEPOLICY_DEFAULT)
1215 : (param->flags&MPLEX_ATTACH_UNNUMBERED
1216 ? SIZEPOLICY_FULL_BOUNDS
1217 : SIZEPOLICY_FULL_EXACT));
1219 modal=(param->flags&MPLEX_ATTACH_LEVEL
1220 && param->level>=STACKING_LEVEL_MODAL1);
1222 level=(param->flags&MPLEX_ATTACH_LEVEL
1224 : (param->flags&MPLEX_ATTACH_UNNUMBERED
1225 ? STACKING_LEVEL_NORMAL
1226 : STACKING_LEVEL_BOTTOM));
1228 hidden=(param->flags&MPLEX_ATTACH_HIDDEN
1229 && (param->flags&MPLEX_ATTACH_UNNUMBERED
1232 sw=(!hidden && (param->flags&MPLEX_ATTACH_SWITCHTO
1233 || (param->flags&MPLEX_ATTACH_UNNUMBERED
1235 : (mplex_current_node(mplex)==NULL))));
1237 hidden=(hidden || (!sw && !(param->flags&MPLEX_ATTACH_UNNUMBERED)));
1239 node=create_stacking();
1244 if(!(param->flags&MPLEX_ATTACH_UNNUMBERED)){
1245 lnode=ALLOC(WLListNode);
1247 stacking_free(node);
1257 if(!stacking_assoc(node, reg)){
1262 stacking_free(node);
1267 node->szplcy=szplcy;
1269 node->pseudomodal=(param->flags&MPLEX_ATTACH_PSEUDOMODAL ? 1 : 0);
1272 WMPlexPHolder *ph2, *phn, *php;
1274 llist_link_after(&(mplex->mx_list),
1275 (ph!=NULL ? ph->after : NULL),
1280 /* Move placeholders after new node */
1281 for(php=NULL, ph2=ph; ph2!=NULL; php=ph2, ph2=phn){
1283 mplexpholder_move(ph2, mplex, php, lnode);
1287 LINK_ITEM(mplex->mgd, node, mgr_next, mgr_prev);
1289 if(!OBJ_IS(reg, WGroup))
1290 mplex_stack(mplex, node);
1292 region_set_manager(reg, (WRegion*)mplex);
1294 if(param->flags&MPLEX_ATTACH_PASSIVE)
1295 reg->flags|=REGION_SKIP_FOCUS;
1297 if(!(param->flags&MPLEX_ATTACH_WHATEVER)){
1300 mplex_managed_geom(mplex, &(fp.g));
1302 sizepolicy(&node->szplcy, reg,
1303 (param->flags&MPLEX_ATTACH_GEOM ? &(param->geom) : NULL),
1306 if(rectangle_compare(&fp.g, ®ION_GEOM(reg))!=RECTANGLE_SAME)
1307 region_fitrep(reg, NULL, &fp);
1311 mplex_do_node_display(mplex, node, FALSE);
1317 mplex_refocus(mplex, node, FALSE);
1319 (level>=STACKING_LEVEL_MODAL1 || OBJ_IS(reg, WGroup))){
1320 /* New modal regions may require focusing, so try to
1321 * give focus back to currently active object.
1322 * (There seems to be some problem with uncontained
1323 * client windows still..)
1325 mplex_refocus(mplex, NULL, FALSE);
1330 mplex_managed_changed(mplex, MPLEX_CHANGE_ADD, sw, reg);
1336 WRegion *mplex_do_attach_pholder(WMPlex *mplex, WMPlexPHolder *ph,
1337 WRegionAttachData *data)
1339 WMPlexAttachParams *param=&(ph->param);
1342 if(param->flags&MPLEX_ATTACH_GEOM)
1345 mplex_managed_geom(mplex, &(fp.g));
1347 fp.mode=REGION_FIT_WHATEVER|REGION_FIT_BOUNDS;
1349 return region_attach_helper((WRegion*)mplex,
1350 (WWindow*)mplex, &fp,
1351 (WRegionDoAttachFn*)mplex_do_attach_final,
1356 WRegion *mplex_do_attach(WMPlex *mplex, WMPlexAttachParams *param,
1357 WRegionAttachData *data)
1362 ph=create_mplexpholder(mplex, NULL, param);
1367 reg=mplex_do_attach_pholder(mplex, ph, data);
1369 destroy_obj((Obj*)ph);
1375 WRegion *mplex_do_attach_new(WMPlex *mplex, WMPlexAttachParams *param,
1376 WRegionCreateFn *fn, void *fn_param)
1378 WRegionAttachData data;
1380 data.type=REGION_ATTACH_NEW;
1382 data.u.n.param=fn_param;
1384 return mplex_do_attach(mplex, param, &data);
1388 #define MPLEX_ATTACH_SET_FLAGS (MPLEX_ATTACH_GEOM| \
1389 MPLEX_ATTACH_SIZEPOLICY| \
1393 WRegion *mplex_attach_simple(WMPlex *mplex, WRegion *reg, int flags)
1395 WMPlexAttachParams param;
1396 WRegionAttachData data;
1398 param.flags=flags&~MPLEX_ATTACH_SET_FLAGS;
1400 data.type=REGION_ATTACH_REPARENT;
1403 return mplex_do_attach(mplex, ¶m, &data);
1407 static void get_params(WMPlex *mplex, ExtlTab tab, int mask,
1408 WMPlexAttachParams *par)
1414 if(ok&MPLEX_ATTACH_LEVEL){
1415 if(extl_table_gets_i(tab, "level", &tmp)){
1417 par->flags|=MPLEX_ATTACH_LEVEL;
1422 if(extl_table_is_bool_set(tab, "modal"))
1423 par->level=maxof(par->level, STACKING_LEVEL_MODAL1);
1426 if(extl_table_is_bool_set(tab, "unnumbered"))
1427 par->flags|=MPLEX_ATTACH_UNNUMBERED&ok;
1429 if(extl_table_is_bool_set(tab, "switchto"))
1430 par->flags|=MPLEX_ATTACH_SWITCHTO&ok;
1432 if(extl_table_is_bool_set(tab, "hidden"))
1433 par->flags|=MPLEX_ATTACH_HIDDEN&ok;
1435 if(extl_table_is_bool_set(tab, "passive"))
1436 par->flags|=MPLEX_ATTACH_PASSIVE&ok;
1438 if(extl_table_is_bool_set(tab, "pseudomodal"))
1439 par->flags|=MPLEX_ATTACH_PSEUDOMODAL&ok;
1441 if(extl_table_gets_i(tab, "index", &(par->index)))
1442 par->flags|=MPLEX_ATTACH_INDEX&ok;
1444 if(ok&MPLEX_ATTACH_SIZEPOLICY){
1445 if(extl_table_gets_s(tab, "sizepolicy", &tmpstr)){
1447 if(string2sizepolicy(tmpstr, &tmpp)){
1448 par->flags|=MPLEX_ATTACH_SIZEPOLICY;
1452 }else if(extl_table_gets_i(tab, "sizepolicy", &tmp)){
1453 /* Backwards compat. numeric version */
1454 par->flags|=MPLEX_ATTACH_SIZEPOLICY;
1459 if(extl_table_gets_rectangle(tab, "geom", &par->geom))
1460 par->flags|=MPLEX_ATTACH_GEOM&ok;
1465 * Attach and reparent existing region \var{reg} to \var{mplex}.
1466 * The table \var{param} may contain the fields \var{index} and
1467 * \var{switchto} that are interpreted as for \fnref{WMPlex.attach_new}.
1470 WRegion *mplex_attach(WMPlex *mplex, WRegion *reg, ExtlTab param)
1472 WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
1473 WRegionAttachData data;
1478 get_params(mplex, param, 0, &par);
1480 data.type=REGION_ATTACH_REPARENT;
1483 return mplex_do_attach(mplex, &par, &data);
1487 WRegion *mplex_attach_new_(WMPlex *mplex, WMPlexAttachParams *par,
1488 int mask, ExtlTab param)
1490 WRegionAttachData data;
1492 get_params(mplex, param, mask, par);
1494 data.type=REGION_ATTACH_LOAD;
1497 return mplex_do_attach(mplex, par, &data);
1502 * Create a new region to be managed by \var{mplex}. At least the following
1503 * fields in \var{param} are understood (all but \var{type} are optional).
1505 * \begin{tabularx}{\linewidth}{lX}
1506 * \tabhead{Field & Description}
1507 * \var{type} & (string) Class name (a string) of the object to be created. \\
1508 * \var{name} & (string) Name of the object to be created (a string). \\
1509 * \var{switchto} & (boolean) Should the region be switched to (boolean)? \\
1510 * \var{unnumbered} & (boolean) Do not put on the numbered mutually
1511 * exclusive list. \\
1512 * \var{index} & (integer) Index on this list, same as for
1513 * \fnref{WMPlex.set_index}. \\
1514 * \var{level} & (integer) Stacking level. \\
1515 * \var{modal} & (boolean) Shortcut for modal stacking level. \\
1516 * \var{hidden} & (boolean) Attach hidden, if not prevented
1517 * by e.g. the mutually exclusive list being empty.
1518 * This option overrides \var{switchto}. \\
1519 * \var{passive} & (boolean) Skip in certain focusing operations. \\
1520 * \var{pseudomodal} & (boolean) The attached region is ``pseudomodal''
1521 * if the stacking level dictates it to be modal.
1522 * This means that the region may be hidden to display
1523 * regions with lesser stacking levels. \\
1524 * \var{sizepolicy} & (string) Size policy; see Section \ref{sec:sizepolicies}. \\
1525 * \var{geom} & (table) Geometry specification. \\
1528 * In addition parameters to the region to be created are passed in this
1532 WRegion *mplex_attach_new(WMPlex *mplex, ExtlTab param)
1534 WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
1536 return mplex_attach_new_(mplex, &par, 0, param);
1540 static bool mplex_handle_drop(WMPlex *mplex, int x, int y,
1543 WRegion *curr=mplex_mx_current(mplex);
1545 /* This code should handle dropping tabs on floating workspaces. */
1546 if(curr && HAS_DYN(curr, region_handle_drop)){
1548 region_rootpos(curr, &rx, &ry);
1549 if(rectangle_contains(®ION_GEOM(curr), x-rx, y-ry)){
1550 if(region_handle_drop(curr, x, y, dropped))
1555 return (NULL!=mplex_attach_simple(mplex, dropped, MPLEX_ATTACH_SWITCHTO));
1559 WPHolder *mplex_prepare_manage(WMPlex *mplex, const WClientWin *cwin,
1560 const WManageParams *param, int priority)
1562 int cpriority=MANAGE_PRIORITY_SUB(priority, MANAGE_PRIORITY_NORMAL);
1563 WMPlexAttachParams ap;
1568 /* Check current */ {
1569 WStacking *cur=mplex_current_node(mplex);
1572 ph=region_prepare_manage(cur->reg, cwin, param, cpriority);
1577 if(mplex->mx_current!=NULL && mplex->mx_current->st!=cur){
1578 ph=region_prepare_manage(mplex->mx_current->st->reg,
1579 cwin, param, cpriority);
1585 if(!MANAGE_PRIORITY_OK(priority, MANAGE_PRIORITY_NORMAL))
1588 ap.flags=((param->switchto ? MPLEX_ATTACH_SWITCHTO : 0)
1589 |MPLEX_ATTACH_SIZEPOLICY);
1590 ap.szplcy=SIZEPOLICY_FULL_EXACT;
1592 mph=create_mplexpholder(mplex, NULL, &ap);
1595 WGroupedPHolder *gph=create_groupedpholder((WPHolder*)mph);
1597 return (WPHolder*)gph;
1600 return (WPHolder*)mph;
1610 void mplex_managed_remove(WMPlex *mplex, WRegion *sub)
1612 bool mx=FALSE, hadfocus=FALSE, mcf;
1613 WRegion *stdisp=(WRegion*)(mplex->stdispwatch.obj);
1614 WStacking *node, *next=NULL;
1616 mcf=region_may_control_focus((WRegion*)mplex);
1619 if(CAN_MANAGE_STDISP(sub) &&
1620 region_managed_within((WRegion*)mplex, stdisp)==sub){
1621 region_unmanage_stdisp(sub, TRUE, TRUE);
1622 region_detach_manager(stdisp);
1626 node=mplex_find_stacking(mplex, sub);
1631 hadfocus=(mplex_current_node(mplex)==node);
1633 if(node->lnode!=NULL){
1634 if(mplex->mx_current==node->lnode){
1637 mplex->mx_current=NULL;
1638 lnext=LIST_PREV(mplex->mx_list, node->lnode, next, prev);
1640 lnext=LIST_NEXT(mplex->mx_list, node->lnode, next, prev);
1641 if(lnext==node->lnode)
1648 mplex_move_phs_before(mplex, node->lnode);
1649 llist_unlink(&(mplex->mx_list), node->lnode);
1657 UNLINK_ITEM(mplex->mgd, node, mgr_next, mgr_prev);
1659 mplex_unstack(mplex, node);
1661 stacking_unassoc(node);
1662 stacking_free(node);
1664 region_unset_manager(sub, (WRegion*)mplex);
1666 if(OBJ_IS_BEING_DESTROYED(mplex))
1670 mplex_do_node_display(mplex, next, FALSE);
1673 mplex_refocus(mplex, next, FALSE);
1676 mplex_managed_changed(mplex, MPLEX_CHANGE_REMOVE, next!=NULL, sub);
1680 bool mplex_rescue_clientwins(WMPlex *mplex, WRescueInfo *info)
1685 WLListNode *lnode, *was_current=mplex->mx_current;
1687 /* First all mx stuff to move them nicely to another mplex (when that
1688 * is the case), switching to the current region in the target if
1689 * allowed by ph_flags_mask region_rescue.
1691 FOR_ALL_NODES_ON_LLIST(lnode, mplex->mx_list, ltmp){
1692 int sw=(lnode==was_current ? PHOLDER_ATTACH_SWITCHTO : 0);
1693 region_do_rescue_this(lnode->st->reg, info, sw);
1696 /* Then the rest (possibly retrying failed mx stuff).
1698 mplex_iter_init(&tmp, mplex);
1699 ret1=region_rescue_some_clientwins((WRegion*)mplex, info,
1700 (WRegionIterator*)mplex_iter,
1703 ret2=region_rescue_child_clientwins((WRegion*)mplex, info);
1705 return (ret1 && ret2);
1710 void mplex_child_removed(WMPlex *mplex, WRegion *sub)
1712 if(sub!=NULL && sub==(WRegion*)(mplex->stdispwatch.obj)){
1713 watch_reset(&(mplex->stdispwatch));
1714 mplex_set_stdisp(mplex, NULL, NULL);
1722 /*{{{ Status display support */
1725 # define offsetof(T,F) ((size_t)((char*)&((T*)0L)->F-(char*)0L))
1728 #define STRUCTOF(T, F, FADDR) \
1729 ((T*)((char*)(FADDR)-offsetof(T, F)))
1732 static void stdisp_watch_handler(Watch *watch, Obj *obj)
1734 /*WMPlex *mplex=STRUCTOF(WMPlex, stdispinfo,
1735 STRUCTOF(WMPlexSTDispInfo, regwatch, watch));
1736 WMPlexSTDispInfo *di=&(mplex->stdispinfo);
1737 WGenWS *ws=OBJ_CAST(REGION_MANAGER(obj), WGenWS);
1739 if(ioncore_g.opmode!=IONCORE_OPMODE_DEINIT && ws!=NULL)
1740 genws_unmanage_stdisp(ws, TRUE, FALSE);*/
1744 bool mplex_set_stdisp(WMPlex *mplex, WRegion *reg,
1745 const WMPlexSTDispInfo *din)
1747 WRegion *oldstdisp=(WRegion*)(mplex->stdispwatch.obj);
1750 assert(reg==NULL || (reg==oldstdisp) ||
1751 (REGION_MANAGER(reg)==NULL &&
1752 REGION_PARENT(reg)==(WWindow*)mplex));
1754 if(oldstdisp!=NULL){
1755 mgr=region_managed_within((WRegion*)mplex, oldstdisp);
1757 if(!CAN_MANAGE_STDISP(mgr))
1762 mplex->stdispinfo=*din;
1765 watch_reset(&(mplex->stdispwatch));
1768 region_unmanage_stdisp(mgr, TRUE, FALSE);
1770 region_detach_manager(oldstdisp);
1773 watch_setup(&(mplex->stdispwatch), (Obj*)reg, stdisp_watch_handler);
1775 mplex_remanage_stdisp(mplex);
1778 if(oldstdisp!=NULL && oldstdisp!=reg)
1779 mainloop_defer_destroy((Obj*)oldstdisp);
1785 void mplex_get_stdisp(WMPlex *mplex, WRegion **reg, WMPlexSTDispInfo *di)
1787 *di=mplex->stdispinfo;
1788 *reg=(WRegion*)mplex->stdispwatch.obj;
1792 static StringIntMap pos_map[]={
1793 {"tl", MPLEX_STDISP_TL},
1794 {"tr", MPLEX_STDISP_TR},
1795 {"bl", MPLEX_STDISP_BL},
1796 {"br", MPLEX_STDISP_BR},
1801 static bool do_attach_stdisp(WRegion *mplex, WRegion *reg, void *unused)
1803 /* We do not actually manage the stdisp. */
1809 * Set/create status display for \var{mplex}. Table is a standard
1810 * description of the object to be created (as passed to e.g.
1811 * \fnref{WMPlex.attach_new}). In addition, the following fields are
1814 * \begin{tabularx}{\linewidth}{lX}
1815 * \tabhead{Field & Description}
1816 * \var{pos} & (string) The corner of the screen to place the status
1817 * display in: one of \codestr{tl}, \codestr{tr}, \codestr{bl}
1818 * or \codestr{br}. \\
1819 * \var{fullsize} & (boolean) Waste all available space. \\
1820 * \var{action} & (string) If this field is set to \codestr{keep},
1821 * \var{pos} and \var{fullsize} are changed for the existing
1822 * status display. If this field is set to \codestr{remove},
1823 * the existing status display is removed. If this
1824 * field is not set or is set to \codestr{replace}, a
1825 * new status display is created and the old, if any,
1829 EXTL_EXPORT_AS(WMPlex, set_stdisp)
1830 WRegion *mplex_set_stdisp_extl(WMPlex *mplex, ExtlTab t)
1832 WRegion *stdisp=NULL;
1833 WMPlexSTDispInfo din=mplex->stdispinfo;
1836 if(extl_table_gets_s(t, "pos", &s)){
1837 din.pos=stringintmap_value(pos_map, s, -1);
1839 warn(TR("Invalid position setting."));
1844 extl_table_gets_b(t, "fullsize", &(din.fullsize));
1847 extl_table_gets_s(t, "action", &s);
1849 if(s==NULL || strcmp(s, "replace")==0){
1850 WRegionAttachData data;
1856 fp.g.w=REGION_GEOM(mplex).w;
1857 fp.g.h=REGION_GEOM(mplex).h;
1858 fp.mode=REGION_FIT_BOUNDS|REGION_FIT_WHATEVER;
1860 /* Full mplex size is stupid so use saved geometry initially
1863 extl_table_gets_rectangle(t, "geom", &(fp.g));
1865 data.type=REGION_ATTACH_LOAD;
1868 stdisp=region_attach_helper((WRegion*)mplex,
1869 (WWindow*)mplex, &fp,
1870 do_attach_stdisp, NULL,
1876 }else if(strcmp(s, "keep")==0){
1877 stdisp=(WRegion*)(mplex->stdispwatch.obj);
1878 }else if(strcmp(s, "remove")!=0){
1879 warn(TR("Invalid action setting."));
1883 if(!mplex_set_stdisp(mplex, stdisp, &din)){
1884 destroy_obj((Obj*)stdisp);
1892 static ExtlTab mplex_do_get_stdisp_extl(WMPlex *mplex, bool fullconfig)
1894 WRegion *reg=(WRegion*)mplex->stdispwatch.obj;
1898 return extl_table_none();
1901 t=region_get_configuration(reg);
1902 extl_table_sets_rectangle(t, "geom", ®ION_GEOM(reg));
1904 t=extl_create_table();
1905 extl_table_sets_o(t, "reg", (Obj*)reg);
1908 if(t!=extl_table_none()){
1909 WMPlexSTDispInfo *di=&(mplex->stdispinfo);
1910 extl_table_sets_s(t, "pos", stringintmap_key(pos_map, di->pos, NULL));
1911 extl_table_sets_b(t, "fullsize", di->fullsize);
1918 * Get status display information. See \fnref{WMPlex.get_stdisp} for
1919 * information on the fields.
1922 EXTL_EXPORT_AS(WMPlex, get_stdisp)
1923 ExtlTab mplex_get_stdisp_extl(WMPlex *mplex)
1925 return mplex_do_get_stdisp_extl(mplex, FALSE);
1935 void mplex_managed_geom_default(const WMPlex *mplex, WRectangle *geom)
1939 geom->w=REGION_GEOM(mplex).w;
1940 geom->h=REGION_GEOM(mplex).h;
1944 void mplex_managed_geom(const WMPlex *mplex, WRectangle *geom)
1946 CALL_DYN(mplex_managed_geom, mplex, (mplex, geom));
1950 void mplex_size_changed(WMPlex *mplex, bool wchg, bool hchg)
1952 CALL_DYN(mplex_size_changed, mplex, (mplex, wchg, hchg));
1956 void mplex_managed_changed(WMPlex *mplex, int mode, bool sw, WRegion *mgd)
1958 CALL_DYN(mplex_managed_changed, mplex, (mplex, mode, sw, mgd));
1962 int mplex_default_index(WMPlex *mplex)
1964 int idx=LLIST_INDEX_LAST;
1965 CALL_DYN_RET(idx, int, mplex_default_index, mplex, (mplex));
1970 /* For regions managing stdisps */
1972 void region_manage_stdisp(WRegion *reg, WRegion *stdisp,
1973 const WMPlexSTDispInfo *info)
1975 CALL_DYN(region_manage_stdisp, reg, (reg, stdisp, info));
1979 void region_unmanage_stdisp(WRegion *reg, bool permanent, bool nofocus)
1981 CALL_DYN(region_unmanage_stdisp, reg, (reg, permanent, nofocus));
1988 /*{{{ Changed hook helper */
1991 static const char *mode2str(int mode)
1993 if(mode==MPLEX_CHANGE_SWITCHONLY)
1994 return "switchonly";
1995 else if(mode==MPLEX_CHANGE_REORDER)
1997 else if(mode==MPLEX_CHANGE_ADD)
1999 else if(mode==MPLEX_CHANGE_REMOVE)
2005 static bool mrsh_chg(ExtlFn fn, WMPlexChangedParams *p)
2007 ExtlTab t=extl_create_table();
2010 extl_table_sets_o(t, "reg", (Obj*)p->reg);
2011 extl_table_sets_s(t, "mode", mode2str(p->mode));
2012 extl_table_sets_b(t, "sw", p->sw);
2013 extl_table_sets_o(t, "sub", (Obj*)p->sub);
2016 ret=extl_call(fn, "t", NULL, t);
2017 extl_unprotect(NULL);
2019 extl_unref_table(t);
2025 void mplex_call_changed_hook(WMPlex *mplex, WHook *hook,
2026 int mode, bool sw, WRegion *reg)
2028 WMPlexChangedParams p;
2035 hook_call_p(hook, &p, (WHookMarshallExtl*)mrsh_chg);
2045 static void save_node(WMPlex *mplex, ExtlTab subs, int *n,
2046 WStacking *node, bool unnumbered)
2050 st=region_get_configuration(node->reg);
2052 if(st!=extl_table_none()){
2053 if(mplex->mx_current!=NULL && node==mplex->mx_current->st)
2054 extl_table_sets_b(st, "switchto", TRUE);
2055 extl_table_sets_s(st, "sizepolicy",
2056 sizepolicy2string(node->szplcy));
2057 extl_table_sets_i(st, "level", node->level);
2058 g=extl_table_from_rectangle(®ION_GEOM(node->reg));
2059 extl_table_sets_t(st, "geom", g);
2060 extl_unref_table(g);
2061 if(STACKING_IS_HIDDEN(node))
2062 extl_table_sets_b(st, "hidden", TRUE);
2063 if(STACKING_IS_PSEUDOMODAL(node))
2064 extl_table_sets_b(st, "pseudomodal", TRUE);
2066 extl_table_sets_b(st, "unnumbered", TRUE);
2068 extl_table_seti_t(subs, ++(*n), st);
2069 extl_unref_table(st);
2074 ExtlTab mplex_get_configuration(WMPlex *mplex)
2076 ExtlTab tab, subs, stdisptab;
2083 tab=region_get_base_configuration((WRegion*)mplex);
2085 subs=extl_create_table();
2086 extl_table_sets_t(tab, "managed", subs);
2088 /* First the numbered/mutually exclusive nodes */
2089 FOR_ALL_NODES_ON_LLIST(lnode, mplex->mx_list, ltmp){
2090 save_node(mplex, subs, &n, lnode->st, FALSE);
2093 FOR_ALL_NODES_IN_MPLEX(mplex, node, tmp){
2094 if(node->lnode==NULL)
2095 save_node(mplex, subs, &n, node, TRUE);
2098 extl_unref_table(subs);
2100 /*stdisptab=mplex_do_get_stdisp_extl(mplex, TRUE);
2101 if(stdisptab!=extl_table_none()){
2102 extl_table_sets_t(tab, "stdisp", stdisptab);
2103 extl_unref_table(stdisptab);
2110 static WMPlex *tmp_mplex=NULL;
2111 static WMPlexAttachParams *tmp_par=NULL;
2113 static WPHolder *pholder_callback()
2115 assert(tmp_mplex!=NULL);
2116 return (WPHolder*)create_mplexpholder(tmp_mplex, NULL, tmp_par);
2120 void mplex_load_contents(WMPlex *mplex, ExtlTab tab)
2122 ExtlTab substab, subtab;
2125 /*if(extl_table_gets_t(tab, "stdisp", &subtab)){
2126 mplex_set_stdisp_extl(mplex, subtab);
2127 extl_unref_table(subtab);
2130 if(extl_table_gets_t(tab, "managed", &substab) ||
2131 extl_table_gets_t(tab, "subs", &substab)){
2132 n=extl_table_get_n(substab);
2133 for(i=1; i<=n; i++){
2134 if(extl_table_geti_t(substab, i, &subtab)){
2135 /*mplex_attach_new(mplex, subtab);*/
2136 WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
2137 WRegionAttachData data;
2140 get_params(mplex, subtab, 0, &par);
2142 par.flags|=MPLEX_ATTACH_INDEX;
2143 par.index=LLIST_INDEX_LAST;
2148 data.type=REGION_ATTACH_LOAD;
2151 ioncore_set_sm_pholder_callback(pholder_callback);
2153 mplex_do_attach(mplex, &par, &data);
2157 extl_unref_table(subtab);
2160 extl_unref_table(substab);
2165 WRegion *mplex_load(WWindow *par, const WFitParams *fp, ExtlTab tab)
2167 WMPlex *mplex=create_mplex(par, fp);
2169 mplex_load_contents(mplex, tab);
2170 return (WRegion*)mplex;
2177 /*{{{ Dynfuntab and class info */
2180 static DynFunTab mplex_dynfuntab[]={
2181 {region_do_set_focus,
2182 mplex_do_set_focus},
2184 {region_managed_remove,
2185 mplex_managed_remove},
2187 {region_managed_rqgeom,
2188 mplex_managed_rqgeom},
2190 {(DynFun*)region_managed_prepare_focus,
2191 (DynFun*)mplex_managed_prepare_focus},
2193 {(DynFun*)region_handle_drop,
2194 (DynFun*)mplex_handle_drop},
2196 {region_map, mplex_map},
2197 {region_unmap, mplex_unmap},
2199 {(DynFun*)region_prepare_manage,
2200 (DynFun*)mplex_prepare_manage},
2202 {(DynFun*)region_current,
2203 (DynFun*)mplex_current},
2205 {(DynFun*)region_rescue_clientwins,
2206 (DynFun*)mplex_rescue_clientwins},
2208 {(DynFun*)region_get_configuration,
2209 (DynFun*)mplex_get_configuration},
2211 {mplex_managed_geom,
2212 mplex_managed_geom_default},
2214 {(DynFun*)region_fitrep,
2215 (DynFun*)mplex_fitrep},
2217 {region_child_removed,
2218 mplex_child_removed},
2220 {(DynFun*)region_managed_get_pholder,
2221 (DynFun*)mplex_managed_get_pholder},
2223 {(DynFun*)region_get_rescue_pholder_for,
2224 (DynFun*)mplex_get_rescue_pholder_for},
2226 {(DynFun*)region_navi_first,
2227 (DynFun*)mplex_navi_first},
2229 {(DynFun*)region_navi_next,
2230 (DynFun*)mplex_navi_next},
2232 {(DynFun*)region_managed_rqorder,
2233 (DynFun*)mplex_managed_rqorder},
2240 IMPLCLASS(WMPlex, WWindow, mplex_deinit, mplex_dynfuntab);