4 * Copyright (c) Tuomo Valkonen 1999-2008.
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"
36 #include "grouppholder.h"
39 #include "sizepolicy.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;
101 mplex->misc_phs=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->misc_phs!=NULL){
151 assert(mplexpholder_move(mplex->misc_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 is called in protected mode.
250 * This routine returns \code{true} if it reaches the end of list
251 * without this happening.
255 bool mplex_mx_i(WMPlex *mplex, ExtlFn iterfn)
258 llist_iter_init(&tmp, mplex->mx_list);
260 return extl_iter_objlist_(iterfn, (ObjIterator*)llist_iter_regions, &tmp);
265 * Iterate over managed regions of \var{mplex} until \var{iterfn} returns
267 * The function is called in protected mode.
268 * This routine returns \code{true} if it reaches the end of list
269 * without this happening.
273 bool mplex_managed_i(WMPlex *mplex, ExtlFn iterfn)
276 mplex_iter_init(&tmp, mplex);
278 return extl_iter_objlist_(iterfn, (ObjIterator*)mplex_iter, &tmp);
283 * Set index of \var{reg} to \var{index} within the mutually exclusive
284 * list of \var{mplex}. Special values for \var{index} are:
285 * \begin{tabularx}{\linewidth}{lX}
287 * $-2$ & After \fnref{WMPlex.mx_current}. \\
291 void mplex_set_index(WMPlex *mplex, WRegion *reg, int index)
293 WLListNode *lnode, *after;
296 node=mplex_find_stacking(mplex, reg);
304 lnode=ALLOC(WLListNode);
314 mplex_move_phs_before(mplex, lnode);
315 llist_unlink(&(mplex->mx_list), lnode);
318 after=llist_index_to_after(mplex->mx_list, mplex->mx_current, index);
319 llist_link_after(&(mplex->mx_list), after, lnode);
320 mplex_managed_changed(mplex, MPLEX_CHANGE_REORDER, FALSE, reg);
325 * Get index of \var{reg} on the mutually exclusive list of \var{mplex}.
326 * The indices begin from zero.. If \var{reg} is not on the list,
331 int mplex_get_index(WMPlex *mplex, WRegion *reg)
337 FOR_ALL_NODES_ON_LLIST(lnode, mplex->mx_list, tmp){
338 if(reg==lnode->st->reg)
348 * Move \var{r} ``right'' within objects managed by \var{mplex} on list 1.
351 void mplex_inc_index(WMPlex *mplex, WRegion *r)
354 r=mplex_mx_current(mplex);
356 mplex_set_index(mplex, r, mplex_get_index(mplex, r)+1);
361 * Move \var{r} ``left'' within objects managed by \var{mplex} on list 1.
364 void mplex_dec_index(WMPlex *mplex, WRegion *r)
367 r=mplex_mx_current(mplex);
369 mplex_set_index(mplex, r, mplex_get_index(mplex, r)-1);
379 static void mplex_map_mgd(WMPlex *mplex)
384 FOR_ALL_NODES_IN_MPLEX(mplex, node, tmp){
385 if(!STACKING_IS_HIDDEN(node))
386 region_map(node->reg);
391 static void mplex_unmap_mgd(WMPlex *mplex)
396 FOR_ALL_NODES_IN_MPLEX(mplex, node, tmp){
397 if(!STACKING_IS_HIDDEN(node))
398 region_unmap(node->reg);
404 void mplex_map(WMPlex *mplex)
406 window_map((WWindow*)mplex);
407 /* A lame requirement of the ICCCM is that client windows should be
408 * unmapped if the parent is unmapped.
410 if(!MPLEX_MGD_UNVIEWABLE(mplex))
411 mplex_map_mgd(mplex);
415 void mplex_unmap(WMPlex *mplex)
417 window_unmap((WWindow*)mplex);
418 /* A lame requirement of the ICCCM is that client windows should be
419 * unmapped if the parent is unmapped.
421 if(!MPLEX_MGD_UNVIEWABLE(mplex))
422 mplex_unmap_mgd(mplex);
429 /*{{{ Resize and reparent */
432 bool mplex_fitrep(WMPlex *mplex, WWindow *par, const WFitParams *fp)
434 bool wchg=(REGION_GEOM(mplex).w!=fp->g.w);
435 bool hchg=(REGION_GEOM(mplex).h!=fp->g.h);
437 if(!window_fitrep(&(mplex->win), par, fp))
441 mplex_fit_managed(mplex);
442 mplex_size_changed(mplex, wchg, hchg);
449 void mplex_do_fit_managed(WMPlex *mplex, WFitParams *fp)
456 if(!MPLEX_MGD_UNVIEWABLE(mplex) && (fp->g.w<=1 || fp->g.h<=1)){
457 mplex->flags|=MPLEX_MANAGED_UNVIEWABLE;
458 if(REGION_IS_MAPPED(mplex))
459 mplex_unmap_mgd(mplex);
460 }else if(MPLEX_MGD_UNVIEWABLE(mplex) && !(fp->g.w<=1 || fp->g.h<=1)){
461 mplex->flags&=~MPLEX_MANAGED_UNVIEWABLE;
462 if(REGION_IS_MAPPED(mplex))
463 mplex_map_mgd(mplex);
466 if(!MPLEX_MGD_UNVIEWABLE(mplex)){
467 FOR_ALL_NODES_IN_MPLEX(mplex, node, tmp){
469 sizepolicy(&node->szplcy, node->reg, NULL, 0, &fp2);
470 region_fitrep(node->reg, NULL, &fp2);
476 void mplex_fit_managed(WMPlex *mplex)
480 fp.mode=REGION_FIT_EXACT;
481 mplex_managed_geom(mplex, &(fp.g));
483 mplex_do_fit_managed(mplex, &fp);
487 static void mplex_managed_rqgeom(WMPlex *mplex, WRegion *sub,
488 const WRQGeomParams *rq,
495 node=mplex_find_stacking(mplex, sub);
500 mplex_managed_geom(mplex, &fp.g);
502 sizepolicy(&node->szplcy, sub, &rq->geom, rq->flags, &fp);
507 if(!(rq->flags®ION_RQGEOM_TRYONLY))
508 region_fitrep(sub, NULL, &fp);
512 void mplex_set_szplcy(WMPlex *mplex, WRegion *sub, WSizePolicy szplcy)
516 node=mplex_find_stacking(mplex, sub);
523 WSizePolicy mplex_get_szplcy(WMPlex *mplex, WRegion *sub)
527 node=mplex_find_stacking(mplex, sub);
529 return (node==NULL ? SIZEPOLICY_DEFAULT : node->szplcy);
548 static WRegion *manager_within(WMPlex *mplex, WStacking *st)
550 return region_managed_within((WRegion*)mplex, st->reg);
554 static WStacking *stacking_within(WMPlex *mplex, WStacking *st)
556 WRegion *reg=manager_within(mplex, st);
562 : ioncore_find_stacking(reg)));
566 /* Mutually exclusive regions can't be pseudomodal */
567 #define IS_PSEUDOMODAL(ST) ((ST)->lnode==NULL && (ST)->pseudomodal)
570 static bool mapped_pseudomodal_include_filt(WStacking *st, void *data_)
572 FiltData *data=(FiltData*)data_;
575 if(st->reg==NULL || !REGION_IS_MAPPED(st->reg))
579 || (data->to_try==NULL && data->group_st==NULL)
580 || st->level<STACKING_LEVEL_MODAL1){
584 /* Ok, modal node in the way. Let's see if it is pseudomodal
588 stw=stacking_within(data->mplex, st);
590 /* This should not happen */
591 if(stw==NULL || stw->reg==NULL)
594 /* The node is within the same group, so it can not be hidden.
595 * Latter case should not happen.
597 if(stw==data->group_st || stw==data->to_try)
600 if(IS_PSEUDOMODAL(stw)){
601 /* Don't insert multiple times. */
602 return !ptrlist_reinsert_first(data->hidelist, stw);
609 static bool mgr_pseudomodal_approve_filt(WStacking *st, void *data_)
611 FiltData *data=(FiltData*)data_;
613 return (data->group_st==NULL || st==data->group_st ||
614 manager_within(data->mplex, st)==data->group_st->reg);
618 WStacking *mplex_find_to_focus(WMPlex *mplex,
623 WStackingFilter *fi=mapped_pseudomodal_include_filt;
624 WStackingFilter *fa=mgr_pseudomodal_approve_filt;
625 WStacking *stacking=mplex_get_stacking(mplex);
632 if(to_try!=NULL && (to_try->reg==NULL || !REGION_IS_MAPPED(to_try->reg)))
637 data.group_st=group_st;
638 data.hidelist=hidelist;
640 st=stacking_find_to_focus(stacking, to_try, fi, fa, &data);
642 if(st==NULL && hidelist!=NULL)
643 ptrlist_clear(hidelist);
649 static WStacking *mplex_do_to_focus_on(WMPlex *mplex, WStacking *node,
651 PtrList **hidelist, bool *within)
653 WGroup *grp=OBJ_CAST(node->reg, WGroup);
658 to_try=grp->current_managed;
659 /* Only will return stuff within 'node' */
660 st=mplex_find_to_focus(mplex, to_try, node, hidelist);
668 st=mplex_find_to_focus(mplex, node, NULL, hidelist);
670 if(st==node && within!=NULL)
677 static WStacking *maybe_focusable(WRegion *reg)
679 if(reg==NULL || !REGION_IS_MAPPED(reg))
682 return ioncore_find_stacking(reg);
686 static WStacking *has_stacking_within(WMPlex *mplex, WRegion *reg)
688 while(reg!=NULL && REGION_MANAGER(reg)!=(WRegion*)mplex)
689 reg=REGION_MANAGER(reg);
691 return maybe_focusable(reg);
695 /* 1. Try keep focus in REGION_ACTIVE_SUB.
696 * 2. Try given `node`.
697 * 3. Choose something else, attempting previous in focus history
698 * (unless `node` was set).
700 static WStacking *mplex_to_focus(WMPlex *mplex, WStacking *node)
702 WStacking *foc=NULL, *fallback=NULL;
707 foc=maybe_focusable(REGION_ACTIVE_SUB(mplex));
709 if(foc==NULL && node==NULL){
710 /* Search focus history if no specific attempt set.*/
711 for(reg=ioncore_g.focus_current; reg!=NULL; reg=reg->active_next){
712 foc=has_stacking_within(mplex, reg);
719 /*fallback=mplex_find_to_focus(mplex, foc, NULL, NULL);*/
720 /* In the history search case, 'foc' might point to a group,
721 * since we don't properly try to find a stacking within it...
723 fallback=mplex_do_to_focus_on(mplex, foc, NULL, NULL, NULL);
728 if(foc==NULL && node!=NULL)
729 foc=mplex_do_to_focus_on(mplex, node, NULL, NULL, &within);
731 if(foc==NULL || !within)
738 void mplex_do_set_focus(WMPlex *mplex, bool warp)
740 if(!MPLEX_MGD_UNVIEWABLE(mplex)){
741 WStacking *st=mplex_to_focus(mplex, NULL);
744 st=(mplex->mx_current!=NULL
745 ? mplex->mx_current->st
750 region_do_set_focus(st->reg, warp);
755 window_do_set_focus((WWindow*)mplex, warp);
759 static void mplex_refocus(WMPlex *mplex, WStacking *node, bool warp)
761 WStacking *foc=mplex_to_focus(mplex, node);
764 region_maybewarp(foc->reg, warp);
774 static void mplex_do_remanage_stdisp(WMPlex *mplex, WRegion *sub)
776 WRegion *stdisp=(WRegion*)(mplex->stdispwatch.obj);
779 if(sub!=NULL && CAN_MANAGE_STDISP(sub)){
781 WRegion *omgr=REGION_MANAGER(stdisp);
782 if(omgr!=sub && omgr!=NULL){
783 if(CAN_MANAGE_STDISP(omgr))
784 region_unmanage_stdisp(omgr, FALSE, FALSE);
785 region_detach_manager(stdisp);
788 region_manage_stdisp(sub, stdisp,
789 &(mplex->stdispinfo));
791 region_unmanage_stdisp(sub, TRUE, FALSE);
797 void mplex_remanage_stdisp(WMPlex *mplex)
799 mplex_do_remanage_stdisp(mplex, (mplex->mx_current!=NULL
800 ? mplex->mx_current->st->reg
805 static void mplex_do_node_display(WMPlex *mplex, WStacking *node,
808 WRegion *sub=node->reg;
809 WLListNode *mxc=mplex->mx_current;
811 if(!STACKING_IS_HIDDEN(node))
814 if(node->lnode!=NULL && node->lnode!=mxc)
815 mplex_do_remanage_stdisp(mplex, sub);
819 if(SUBS_MAY_BE_MAPPED(mplex))
824 if(node->lnode!=NULL){
826 /* Hide current mx region. We do it after mapping the
827 * new one to avoid flicker.
829 if(REGION_IS_MAPPED(mplex))
830 region_unmap(mxc->st->reg);
831 mxc->st->hidden=TRUE;
834 mplex->mx_current=node->lnode;
837 * Many programs will get upset if the visible, although only
838 * such, client window is not the lowest window in the mplex.
839 * xprop/xwininfo will return the information for the lowest
840 * window. 'netscape -remote' will not work at all if there are
841 * no visible netscape windows.
844 WGroup *grp=(WGroup*)OBJ_CAST(sub, WGroupCW);
846 WRegion *bottom=group_bottom(grp);
848 region_managed_rqorder((WRegion*)grp, bottom,
855 mplex_managed_changed(mplex, MPLEX_CHANGE_SWITCHONLY, TRUE, sub);
860 bool mplex_do_prepare_focus(WMPlex *mplex, WStacking *node,
861 WStacking *sub, int flags,
862 WPrepareFocusResult *res)
864 bool ew=(flags®ION_GOTO_ENTERWINDOW);
865 PtrList *hidelist=NULL;
866 PtrList **hidelistp=(ew ? NULL : &hidelist);
868 /*bool within=FALSE;*/
870 if(sub==NULL && node==NULL)
873 /* Display the node in any case */
874 if(node!=NULL && !ew)
875 mplex_do_node_display(mplex, node, TRUE);
877 if(!region_prepare_focus((WRegion*)mplex, flags, res))
880 foc=mplex_do_to_focus_on(mplex, node, sub, hidelistp, NULL /*&within*/);
883 while(hidelist!=NULL){
884 WStacking *st=(WStacking*)ptrlist_take_first(&hidelist);
886 region_unmap(st->reg);
889 if(ioncore_g.autoraise &&
890 !(flags®ION_GOTO_ENTERWINDOW) &&
891 foc->level>STACKING_LEVEL_BOTTOM){
892 WStacking **stackingp=mplex_get_stackingp(mplex);
893 stacking_restack(stackingp, foc, None, NULL, NULL, FALSE);
899 return (foc==sub || (sub==NULL && foc==node));
906 bool mplex_managed_prepare_focus(WMPlex *mplex, WRegion *disp,
907 int flags, WPrepareFocusResult *res)
909 WStacking *node=mplex_find_stacking(mplex, disp);
914 return mplex_do_prepare_focus(mplex, node, NULL, flags, res);
921 /*{{{ Switch exports */
924 static void do_switch(WMPlex *mplex, WLListNode *lnode)
926 WStacking *node=(lnode!=NULL ? lnode->st : NULL);
929 bool mcf=region_may_control_focus((WRegion*)mplex);
931 mplex_do_node_display(mplex, node, TRUE);
934 mplex_refocus(mplex, node, TRUE);
940 * Have \var{mplex} display the \var{n}:th object managed by it.
943 void mplex_switch_nth(WMPlex *mplex, uint n)
945 do_switch(mplex, llist_nth_node(mplex->mx_list, n));
950 * Have \var{mplex} display next (wrt. currently selected) object managed
954 void mplex_switch_next(WMPlex *mplex)
956 do_switch(mplex, LIST_NEXT_WRAP(mplex->mx_list, mplex->mx_current,
962 * Have \var{mplex} display previous (wrt. currently selected) object
966 void mplex_switch_prev(WMPlex *mplex)
968 do_switch(mplex, LIST_PREV_WRAP(mplex->mx_list, mplex->mx_current,
973 bool mplex_set_hidden(WMPlex *mplex, WRegion *reg, int sp)
975 bool mcf=region_may_control_focus((WRegion*)mplex);
976 WStacking *node=mplex_find_stacking(mplex, reg);
977 bool hidden, nhidden;
982 hidden=STACKING_IS_HIDDEN(node);
983 nhidden=libtu_do_setparam(sp, hidden);
985 if(!hidden && nhidden){
988 if(REGION_IS_MAPPED(mplex) && !MPLEX_MGD_UNVIEWABLE(mplex))
991 /* lnode -> switch next? */
992 }else if(hidden && !nhidden){
993 mplex_do_node_display(mplex, node, TRUE);
996 if(mcf && !PASSIVE(node))
997 mplex_refocus(mplex, (nhidden ? NULL : node), TRUE);
999 return STACKING_IS_HIDDEN(node);
1004 * Set the visibility of the region \var{reg} on \var{mplex}
1005 * as specified with the parameter \var{how}
1006 * (one of \codestr{set}, \codestr{unset}, or \codestr{toggle}).
1007 * The resulting state is returned.
1009 EXTL_EXPORT_AS(WMPlex, set_hidden)
1010 bool mplex_set_hidden_extl(WMPlex *mplex, WRegion *reg, const char *how)
1012 return mplex_set_hidden(mplex, reg, libtu_string_to_setparam(how));
1017 * Is \var{reg} on within \var{mplex} and hidden?
1021 bool mplex_is_hidden(WMPlex *mplex, WRegion *reg)
1023 WStacking *node=mplex_find_stacking(mplex, reg);
1025 return (node!=NULL && STACKING_IS_HIDDEN(node));
1035 static WStacking *mplex_nxt(WMPlex *mplex, WStacking *st, bool wrap)
1037 return (st->mgr_next!=NULL
1039 : (wrap ? mplex->mgd : NULL));
1043 static WStacking *mplex_prv(WMPlex *mplex, WStacking *st, bool wrap)
1045 return (st!=mplex->mgd
1047 : (wrap ? st->mgr_prev : NULL));
1051 typedef WStacking *NxtFn(WMPlex *mplex, WStacking *st, bool wrap);
1054 static WRegion *do_navi(WMPlex *mplex, WStacking *sti,
1055 NxtFn *fn, WRegionNaviData *data,
1056 bool sti_ok, bool wrap)
1058 WStacking *st, *stacking;
1061 stacking=mplex_get_stacking(mplex);
1064 min_level=stacking_min_level_mapped(stacking);
1068 st=fn(mplex, st, wrap);
1070 if(st==NULL || (st==sti && !sti_ok))
1074 if(OBJ_IS(st->reg, WGroup)){
1075 /* WGroup navigation code should respect modal stuff. */
1076 WRegion *res=region_navi_cont((WRegion*)mplex, st->reg, data);
1077 if(res!=NULL && res!=st->reg)
1080 if(st->level>=min_level && !PASSIVE(st))
1081 return region_navi_cont((WRegion*)mplex, st->reg, data);
1093 WRegion *mplex_navi_first(WMPlex *mplex, WRegionNavi nh,
1094 WRegionNaviData *data)
1096 WStacking *lst=mplex->mgd;
1100 if(nh==REGION_NAVI_ANY){
1104 if(nh==REGION_NAVI_ANY || nh==REGION_NAVI_END ||
1105 nh==REGION_NAVI_BOTTOM || nh==REGION_NAVI_RIGHT){
1106 res=do_navi(mplex, lst, mplex_prv, data, TRUE, TRUE);
1108 res=do_navi(mplex, lst->mgr_prev, mplex_nxt, data, TRUE, TRUE);
1112 return region_navi_cont((WRegion*)mplex, res, data);
1116 WRegion *mplex_navi_next(WMPlex *mplex, WRegion *rel, WRegionNavi nh,
1117 WRegionNaviData *data)
1123 st=mplex_find_stacking(mplex, rel);
1126 }else if(mplex->mx_current!=NULL){
1127 st=mplex->mx_current->st;
1129 return mplex_navi_first(mplex, nh, data);
1132 if(nh==REGION_NAVI_ANY){
1136 if(nh==REGION_NAVI_ANY || nh==REGION_NAVI_END ||
1137 nh==REGION_NAVI_BOTTOM || nh==REGION_NAVI_RIGHT){
1138 res=do_navi(mplex, st, mplex_nxt, data, FALSE, FALSE);
1140 res=do_navi(mplex, st, mplex_prv, data, FALSE, FALSE);
1143 return region_navi_cont((WRegion*)mplex, res, data);
1153 bool mplex_managed_rqorder(WMPlex *mplex, WRegion *reg, WRegionOrder order)
1155 WStacking **stackingp=mplex_get_stackingp(mplex);
1158 if(stackingp==NULL || *stackingp==NULL)
1161 st=mplex_find_stacking(mplex, reg);
1166 stacking_restack(stackingp, st, None, NULL, NULL,
1167 (order!=REGION_ORDER_FRONT));
1179 static bool mplex_stack(WMPlex *mplex, WStacking *st)
1181 WStacking *tmp=NULL;
1182 WStacking **stackingp=mplex_get_stackingp(mplex);
1187 LINK_ITEM_FIRST(tmp, st, next, prev);
1188 stacking_weave(stackingp, &tmp, FALSE);
1195 static void mplex_unstack(WMPlex *mplex, WStacking *st)
1197 WStacking *stacking;
1199 stacking=mplex_get_stacking(mplex);
1201 stacking_unstack(&mplex->win, st);
1205 /* WMPlexWPHolder is used for position marking in order to allow
1206 * WLListNodes be safely removed in the attach handler hnd, that
1207 * could remove something this mplex is managing.
1209 bool mplex_do_attach_final(WMPlex *mplex, WRegion *reg, WMPlexPHolder *ph)
1211 WStacking *node=NULL;
1212 WLListNode *lnode=NULL;
1213 WMPlexAttachParams *param=&ph->param;
1214 bool mx_was_empty, sw, modal, mcf, hidden;
1218 mcf=region_may_control_focus((WRegion*)mplex);
1220 mx_was_empty=(mplex->mx_list==NULL);
1222 szplcy=((param->flags&MPLEX_ATTACH_SIZEPOLICY &&
1223 param->szplcy!=SIZEPOLICY_DEFAULT)
1225 : (param->flags&MPLEX_ATTACH_UNNUMBERED
1226 ? SIZEPOLICY_FULL_BOUNDS
1227 : SIZEPOLICY_FULL_EXACT));
1229 modal=(param->flags&MPLEX_ATTACH_LEVEL
1230 && param->level>=STACKING_LEVEL_MODAL1);
1232 level=(param->flags&MPLEX_ATTACH_LEVEL
1234 : (param->flags&MPLEX_ATTACH_UNNUMBERED
1235 ? STACKING_LEVEL_NORMAL
1236 : STACKING_LEVEL_BOTTOM));
1238 hidden=(param->flags&MPLEX_ATTACH_HIDDEN
1239 && (param->flags&MPLEX_ATTACH_UNNUMBERED
1242 sw=(!hidden && (param->flags&MPLEX_ATTACH_SWITCHTO
1243 || (param->flags&MPLEX_ATTACH_UNNUMBERED
1245 : (mplex_current_node(mplex)==NULL))));
1247 hidden=(hidden || (!sw && !(param->flags&MPLEX_ATTACH_UNNUMBERED)));
1249 node=create_stacking();
1254 if(!(param->flags&MPLEX_ATTACH_UNNUMBERED)){
1255 lnode=ALLOC(WLListNode);
1257 stacking_free(node);
1267 if(!stacking_assoc(node, reg)){
1272 stacking_free(node);
1277 node->szplcy=szplcy;
1279 node->pseudomodal=(param->flags&MPLEX_ATTACH_PSEUDOMODAL ? 1 : 0);
1282 WMPlexPHolder *ph2, *phn, *php;
1284 llist_link_after(&(mplex->mx_list),
1285 (ph!=NULL ? ph->after : NULL),
1290 /* Move placeholders after new node */
1291 for(php=NULL, ph2=ph; ph2!=NULL; php=ph2, ph2=phn){
1293 mplexpholder_move(ph2, mplex, php, lnode);
1297 LINK_ITEM(mplex->mgd, node, mgr_next, mgr_prev);
1299 if(!OBJ_IS(reg, WGroup))
1300 mplex_stack(mplex, node);
1302 region_set_manager(reg, (WRegion*)mplex);
1304 if(param->flags&MPLEX_ATTACH_PASSIVE)
1305 reg->flags|=REGION_SKIP_FOCUS;
1307 if(!(param->flags&MPLEX_ATTACH_WHATEVER)){
1311 mplex_managed_geom(mplex, &(fp.g));
1313 sizepolicy(&node->szplcy, reg,
1314 (param->flags&MPLEX_ATTACH_GEOM ? &(param->geom) : NULL),
1317 if(rectangle_compare(&fp.g, ®ION_GEOM(reg))!=RECTANGLE_SAME)
1318 region_fitrep(reg, NULL, &fp);
1322 mplex_do_node_display(mplex, node, FALSE);
1328 mplex_refocus(mplex, node, FALSE);
1330 (level>=STACKING_LEVEL_MODAL1 || OBJ_IS(reg, WGroup))){
1331 /* New modal regions may require focusing, so try to
1332 * give focus back to currently active object.
1333 * (There seems to be some problem with uncontained
1334 * client windows still..)
1336 mplex_refocus(mplex, NULL, FALSE);
1338 region_pointer_focus_hack(reg);
1341 region_pointer_focus_hack(reg);
1345 mplex_managed_changed(mplex, MPLEX_CHANGE_ADD, sw, reg);
1351 static void mplex_attach_fp(WMPlex *mplex, const WMPlexAttachParams *param,
1354 if(param->flags&MPLEX_ATTACH_GEOM)
1357 mplex_managed_geom(mplex, &(fp->g));
1359 fp->mode=REGION_FIT_WHATEVER|REGION_FIT_BOUNDS;
1363 WRegion *mplex_do_attach_pholder(WMPlex *mplex, WMPlexPHolder *ph,
1364 WRegionAttachData *data)
1368 mplex_attach_fp(mplex, &ph->param, &fp);
1370 return region_attach_helper((WRegion*)mplex,
1371 (WWindow*)mplex, &fp,
1372 (WRegionDoAttachFn*)mplex_do_attach_final,
1377 WRegion *mplex_do_attach(WMPlex *mplex, WMPlexAttachParams *param,
1378 WRegionAttachData *data)
1383 ph=create_mplexpholder(mplex, NULL, param);
1388 reg=mplex_do_attach_pholder(mplex, ph, data);
1390 destroy_obj((Obj*)ph);
1396 WRegion *mplex_do_attach_new(WMPlex *mplex, WMPlexAttachParams *param,
1397 WRegionCreateFn *fn, void *fn_param)
1399 WRegionAttachData data;
1401 data.type=REGION_ATTACH_NEW;
1403 data.u.n.param=fn_param;
1405 return mplex_do_attach(mplex, param, &data);
1409 #define MPLEX_ATTACH_SET_FLAGS (MPLEX_ATTACH_GEOM| \
1410 MPLEX_ATTACH_SIZEPOLICY| \
1414 WRegion *mplex_attach_simple(WMPlex *mplex, WRegion *reg, int flags)
1416 WMPlexAttachParams param;
1417 WRegionAttachData data;
1419 param.flags=flags&~MPLEX_ATTACH_SET_FLAGS;
1421 data.type=REGION_ATTACH_REPARENT;
1424 return mplex_do_attach(mplex, ¶m, &data);
1428 static void get_params(WMPlex *mplex, ExtlTab tab, int mask,
1429 WMPlexAttachParams *par)
1435 if(ok&MPLEX_ATTACH_LEVEL){
1436 if(extl_table_gets_i(tab, "level", &tmp)){
1438 par->flags|=MPLEX_ATTACH_LEVEL;
1443 if(extl_table_is_bool_set(tab, "modal"))
1444 par->level=maxof(par->level, STACKING_LEVEL_MODAL1);
1447 if(extl_table_is_bool_set(tab, "unnumbered"))
1448 par->flags|=MPLEX_ATTACH_UNNUMBERED&ok;
1450 if(extl_table_is_bool_set(tab, "switchto"))
1451 par->flags|=MPLEX_ATTACH_SWITCHTO&ok;
1453 if(extl_table_is_bool_set(tab, "hidden"))
1454 par->flags|=MPLEX_ATTACH_HIDDEN&ok;
1456 if(extl_table_is_bool_set(tab, "passive"))
1457 par->flags|=MPLEX_ATTACH_PASSIVE&ok;
1459 if(extl_table_is_bool_set(tab, "pseudomodal"))
1460 par->flags|=MPLEX_ATTACH_PSEUDOMODAL&ok;
1462 if(extl_table_gets_i(tab, "index", &(par->index)))
1463 par->flags|=MPLEX_ATTACH_INDEX&ok;
1465 if(ok&MPLEX_ATTACH_SIZEPOLICY){
1466 if(extl_table_gets_s(tab, "sizepolicy", &tmpstr)){
1468 if(string2sizepolicy(tmpstr, &tmpp)){
1469 par->flags|=MPLEX_ATTACH_SIZEPOLICY;
1473 }else if(extl_table_gets_i(tab, "sizepolicy", &tmp)){
1474 /* Backwards compat. numeric version */
1475 par->flags|=MPLEX_ATTACH_SIZEPOLICY;
1480 if(extl_table_gets_rectangle(tab, "geom", &par->geom))
1481 par->flags|=MPLEX_ATTACH_GEOM&ok;
1486 * Attach and reparent existing region \var{reg} to \var{mplex}.
1487 * The table \var{param} may contain the fields \var{index} and
1488 * \var{switchto} that are interpreted as for \fnref{WMPlex.attach_new}.
1491 WRegion *mplex_attach(WMPlex *mplex, WRegion *reg, ExtlTab param)
1493 WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
1494 WRegionAttachData data;
1499 get_params(mplex, param, 0, &par);
1501 data.type=REGION_ATTACH_REPARENT;
1504 return mplex_do_attach(mplex, &par, &data);
1508 WRegion *mplex_attach_new_(WMPlex *mplex, WMPlexAttachParams *par,
1509 int mask, ExtlTab param)
1511 WRegionAttachData data;
1513 get_params(mplex, param, mask, par);
1515 data.type=REGION_ATTACH_LOAD;
1518 return mplex_do_attach(mplex, par, &data);
1523 * Create a new region to be managed by \var{mplex}. At least the following
1524 * fields in \var{param} are understood (all but \var{type} are optional).
1526 * \begin{tabularx}{\linewidth}{lX}
1527 * \tabhead{Field & Description}
1528 * \var{type} & (string) Class name (a string) of the object to be created. \\
1529 * \var{name} & (string) Name of the object to be created (a string). \\
1530 * \var{switchto} & (boolean) Should the region be switched to (boolean)? \\
1531 * \var{unnumbered} & (boolean) Do not put on the numbered mutually
1532 * exclusive list. \\
1533 * \var{index} & (integer) Index on this list, same as for
1534 * \fnref{WMPlex.set_index}. \\
1535 * \var{level} & (integer) Stacking level. \\
1536 * \var{modal} & (boolean) Shortcut for modal stacking level. \\
1537 * \var{hidden} & (boolean) Attach hidden, if not prevented
1538 * by e.g. the mutually exclusive list being empty.
1539 * This option overrides \var{switchto}. \\
1540 * \var{passive} & (boolean) Skip in certain focusing operations. \\
1541 * \var{pseudomodal} & (boolean) The attached region is ``pseudomodal''
1542 * if the stacking level dictates it to be modal.
1543 * This means that the region may be hidden to display
1544 * regions with lesser stacking levels. \\
1545 * \var{sizepolicy} & (string) Size policy; see Section \ref{sec:sizepolicies}. \\
1546 * \var{geom} & (table) Geometry specification. \\
1549 * In addition parameters to the region to be created are passed in this
1553 WRegion *mplex_attach_new(WMPlex *mplex, ExtlTab param)
1555 WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
1557 return mplex_attach_new_(mplex, &par, 0, param);
1561 static bool mplex_handle_drop(WMPlex *mplex, int x, int y,
1564 WRegion *curr=mplex_mx_current(mplex);
1566 /* This code should handle dropping tabs on floating workspaces. */
1567 if(curr && HAS_DYN(curr, region_handle_drop)){
1569 region_rootpos(curr, &rx, &ry);
1570 if(rectangle_contains(®ION_GEOM(curr), x-rx, y-ry)){
1571 if(region_handle_drop(curr, x, y, dropped))
1576 return (NULL!=mplex_attach_simple(mplex, dropped, MPLEX_ATTACH_SWITCHTO));
1580 WPHolder *mplex_prepare_manage(WMPlex *mplex, const WClientWin *cwin,
1581 const WManageParams *param, int priority)
1583 int cpriority=MANAGE_PRIORITY_SUB(priority, MANAGE_PRIORITY_NORMAL);
1584 WMPlexAttachParams ap;
1589 /* Check current */ {
1590 WStacking *cur=mplex_current_node(mplex);
1593 ph=region_prepare_manage(cur->reg, cwin, param, cpriority);
1598 if(mplex->mx_current!=NULL && mplex->mx_current->st!=cur){
1599 ph=region_prepare_manage(mplex->mx_current->st->reg,
1600 cwin, param, cpriority);
1606 if(!MANAGE_PRIORITY_OK(priority, MANAGE_PRIORITY_NORMAL))
1609 ap.flags=((param->switchto ? MPLEX_ATTACH_SWITCHTO : 0)
1610 |MPLEX_ATTACH_SIZEPOLICY);
1611 ap.szplcy=SIZEPOLICY_FULL_EXACT;
1613 mph=create_mplexpholder(mplex, NULL, &ap);
1617 WGroupAttachParams gp=GROUPATTACHPARAMS_INIT;
1623 gph=create_grouppholder(NULL, NULL, &gp);
1626 gph->recreate_pholder=(WPHolder*)mph;
1627 return (WPHolder*)gph;
1631 return (WPHolder*)mph;
1641 void mplex_managed_remove(WMPlex *mplex, WRegion *sub)
1643 bool mx=FALSE, hadfocus=FALSE, mcf;
1644 WRegion *stdisp=(WRegion*)(mplex->stdispwatch.obj);
1645 WStacking *node, *next=NULL;
1647 mcf=region_may_control_focus((WRegion*)mplex);
1650 if(CAN_MANAGE_STDISP(sub) &&
1651 region_managed_within((WRegion*)mplex, stdisp)==sub){
1652 region_unmanage_stdisp(sub, TRUE, TRUE);
1653 region_detach_manager(stdisp);
1657 node=mplex_find_stacking(mplex, sub);
1662 hadfocus=(mplex_current_node(mplex)==node);
1664 if(node->lnode!=NULL){
1665 if(mplex->mx_current==node->lnode){
1668 mplex->mx_current=NULL;
1669 lnext=LIST_PREV(mplex->mx_list, node->lnode, next, prev);
1671 lnext=LIST_NEXT(mplex->mx_list, node->lnode, next, prev);
1672 if(lnext==node->lnode)
1679 mplex_move_phs_before(mplex, node->lnode);
1680 llist_unlink(&(mplex->mx_list), node->lnode);
1688 UNLINK_ITEM(mplex->mgd, node, mgr_next, mgr_prev);
1690 mplex_unstack(mplex, node);
1692 stacking_unassoc(node);
1693 stacking_free(node);
1695 region_unset_manager(sub, (WRegion*)mplex);
1697 if(OBJ_IS_BEING_DESTROYED(mplex))
1701 mplex_do_node_display(mplex, next, FALSE);
1704 mplex_refocus(mplex, next, FALSE);
1707 mplex_managed_changed(mplex, MPLEX_CHANGE_REMOVE, next!=NULL, sub);
1711 void mplex_child_removed(WMPlex *mplex, WRegion *sub)
1713 if(sub!=NULL && sub==(WRegion*)(mplex->stdispwatch.obj)){
1714 watch_reset(&(mplex->stdispwatch));
1715 mplex_set_stdisp(mplex, NULL, NULL);
1726 bool mplex_rescue_clientwins(WMPlex *mplex, WRescueInfo *info)
1731 WLListNode *lnode, *was_current=mplex->mx_current;
1734 /* First all mx stuff to move them nicely to another mplex (when that
1735 * is the case), switching to the current region in the target if
1736 * allowed by ph_flags_mask region_rescue.
1738 FOR_ALL_NODES_ON_LLIST(lnode, mplex->mx_list, ltmp){
1739 int sw=(lnode==was_current ? PHOLDER_ATTACH_SWITCHTO : 0);
1740 region_do_rescue_this(lnode->st->reg, info, sw);
1743 /* Then the rest (possibly retrying failed mx stuff).
1745 mplex_iter_init(&tmp, mplex);
1746 ret1=region_rescue_some_clientwins((WRegion*)mplex, info,
1747 (WRegionIterator*)mplex_iter,
1750 ret2=region_rescue_child_clientwins((WRegion*)mplex, info);
1752 return (ret1 && ret2);
1759 /*{{{ Status display support */
1762 bool mplex_set_stdisp(WMPlex *mplex, WRegion *reg,
1763 const WMPlexSTDispInfo *din)
1765 WRegion *oldstdisp=(WRegion*)(mplex->stdispwatch.obj);
1768 assert(reg==NULL || (reg==oldstdisp) ||
1769 (REGION_MANAGER(reg)==NULL &&
1770 REGION_PARENT(reg)==(WWindow*)mplex));
1772 if(oldstdisp!=NULL){
1773 mgr=region_managed_within((WRegion*)mplex, oldstdisp);
1775 if(!CAN_MANAGE_STDISP(mgr))
1780 mplex->stdispinfo=*din;
1783 watch_reset(&(mplex->stdispwatch));
1786 region_unmanage_stdisp(mgr, TRUE, FALSE);
1788 region_detach_manager(oldstdisp);
1791 watch_setup(&(mplex->stdispwatch), (Obj*)reg, NULL);
1793 mplex_remanage_stdisp(mplex);
1796 if(oldstdisp!=NULL && oldstdisp!=reg)
1797 mainloop_defer_destroy((Obj*)oldstdisp);
1803 void mplex_get_stdisp(WMPlex *mplex, WRegion **reg, WMPlexSTDispInfo *di)
1805 *di=mplex->stdispinfo;
1806 *reg=(WRegion*)mplex->stdispwatch.obj;
1810 static StringIntMap pos_map[]={
1811 {"tl", MPLEX_STDISP_TL},
1812 {"tr", MPLEX_STDISP_TR},
1813 {"bl", MPLEX_STDISP_BL},
1814 {"br", MPLEX_STDISP_BR},
1819 static bool do_attach_stdisp(WRegion *mplex, WRegion *reg, void *unused)
1821 /* We do not actually manage the stdisp. */
1827 * Set/create status display for \var{mplex}. Table is a standard
1828 * description of the object to be created (as passed to e.g.
1829 * \fnref{WMPlex.attach_new}). In addition, the following fields are
1832 * \begin{tabularx}{\linewidth}{lX}
1833 * \tabhead{Field & Description}
1834 * \var{pos} & (string) The corner of the screen to place the status
1835 * display in: one of \codestr{tl}, \codestr{tr}, \codestr{bl}
1836 * or \codestr{br}. \\
1837 * \var{fullsize} & (boolean) Waste all available space. \\
1838 * \var{action} & (string) If this field is set to \codestr{keep},
1839 * \var{pos} and \var{fullsize} are changed for the existing
1840 * status display. If this field is set to \codestr{remove},
1841 * the existing status display is removed. If this
1842 * field is not set or is set to \codestr{replace}, a
1843 * new status display is created and the old, if any,
1847 EXTL_EXPORT_AS(WMPlex, set_stdisp)
1848 WRegion *mplex_set_stdisp_extl(WMPlex *mplex, ExtlTab t)
1850 WRegion *stdisp=NULL;
1851 WMPlexSTDispInfo din=mplex->stdispinfo;
1854 if(extl_table_gets_s(t, "pos", &s)){
1855 din.pos=stringintmap_value(pos_map, s, -1);
1857 warn(TR("Invalid position setting."));
1862 extl_table_gets_b(t, "fullsize", &(din.fullsize));
1865 extl_table_gets_s(t, "action", &s);
1867 if(s==NULL || strcmp(s, "replace")==0){
1868 WRegionAttachData data;
1874 fp.g.w=REGION_GEOM(mplex).w;
1875 fp.g.h=REGION_GEOM(mplex).h;
1876 fp.mode=REGION_FIT_BOUNDS|REGION_FIT_WHATEVER;
1878 /* Full mplex size is stupid so use saved geometry initially
1881 extl_table_gets_rectangle(t, "geom", &(fp.g));
1883 data.type=REGION_ATTACH_LOAD;
1886 stdisp=region_attach_helper((WRegion*)mplex,
1887 (WWindow*)mplex, &fp,
1888 do_attach_stdisp, NULL,
1894 }else if(strcmp(s, "keep")==0){
1895 stdisp=(WRegion*)(mplex->stdispwatch.obj);
1896 }else if(strcmp(s, "remove")!=0){
1897 warn(TR("Invalid action setting."));
1901 if(!mplex_set_stdisp(mplex, stdisp, &din)){
1902 destroy_obj((Obj*)stdisp);
1910 static ExtlTab mplex_do_get_stdisp_extl(WMPlex *mplex, bool fullconfig)
1912 WRegion *reg=(WRegion*)mplex->stdispwatch.obj;
1916 return extl_table_none();
1919 t=region_get_configuration(reg);
1920 extl_table_sets_rectangle(t, "geom", ®ION_GEOM(reg));
1922 t=extl_create_table();
1923 extl_table_sets_o(t, "reg", (Obj*)reg);
1926 if(t!=extl_table_none()){
1927 WMPlexSTDispInfo *di=&(mplex->stdispinfo);
1928 extl_table_sets_s(t, "pos", stringintmap_key(pos_map, di->pos, NULL));
1929 extl_table_sets_b(t, "fullsize", di->fullsize);
1936 * Get status display information. See \fnref{WMPlex.get_stdisp} for
1937 * information on the fields.
1940 EXTL_EXPORT_AS(WMPlex, get_stdisp)
1941 ExtlTab mplex_get_stdisp_extl(WMPlex *mplex)
1943 return mplex_do_get_stdisp_extl(mplex, FALSE);
1953 void mplex_managed_geom_default(const WMPlex *mplex, WRectangle *geom)
1957 geom->w=REGION_GEOM(mplex).w;
1958 geom->h=REGION_GEOM(mplex).h;
1962 void mplex_managed_geom(const WMPlex *mplex, WRectangle *geom)
1964 CALL_DYN(mplex_managed_geom, mplex, (mplex, geom));
1968 void mplex_size_changed(WMPlex *mplex, bool wchg, bool hchg)
1970 CALL_DYN(mplex_size_changed, mplex, (mplex, wchg, hchg));
1974 void mplex_managed_changed(WMPlex *mplex, int mode, bool sw, WRegion *mgd)
1976 CALL_DYN(mplex_managed_changed, mplex, (mplex, mode, sw, mgd));
1980 int mplex_default_index(WMPlex *mplex)
1982 int idx=LLIST_INDEX_LAST;
1983 CALL_DYN_RET(idx, int, mplex_default_index, mplex, (mplex));
1988 /* For regions managing stdisps */
1990 void region_manage_stdisp(WRegion *reg, WRegion *stdisp,
1991 const WMPlexSTDispInfo *info)
1993 CALL_DYN(region_manage_stdisp, reg, (reg, stdisp, info));
1997 void region_unmanage_stdisp(WRegion *reg, bool permanent, bool nofocus)
1999 CALL_DYN(region_unmanage_stdisp, reg, (reg, permanent, nofocus));
2006 /*{{{ Changed hook helper */
2009 static const char *mode2str(int mode)
2011 if(mode==MPLEX_CHANGE_SWITCHONLY)
2012 return "switchonly";
2013 else if(mode==MPLEX_CHANGE_REORDER)
2015 else if(mode==MPLEX_CHANGE_ADD)
2017 else if(mode==MPLEX_CHANGE_REMOVE)
2023 static bool mrsh_chg(ExtlFn fn, WMPlexChangedParams *p)
2025 ExtlTab t=extl_create_table();
2028 extl_table_sets_o(t, "reg", (Obj*)p->reg);
2029 extl_table_sets_s(t, "mode", mode2str(p->mode));
2030 extl_table_sets_b(t, "sw", p->sw);
2031 extl_table_sets_o(t, "sub", (Obj*)p->sub);
2034 ret=extl_call(fn, "t", NULL, t);
2035 extl_unprotect(NULL);
2037 extl_unref_table(t);
2043 void mplex_call_changed_hook(WMPlex *mplex, WHook *hook,
2044 int mode, bool sw, WRegion *reg)
2046 WMPlexChangedParams p;
2053 hook_call_p(hook, &p, (WHookMarshallExtl*)mrsh_chg);
2063 static void save_node(WMPlex *mplex, ExtlTab subs, int *n,
2064 WStacking *node, bool unnumbered)
2068 st=region_get_configuration(node->reg);
2070 if(st!=extl_table_none()){
2071 if(mplex->mx_current!=NULL && node==mplex->mx_current->st)
2072 extl_table_sets_b(st, "switchto", TRUE);
2073 extl_table_sets_s(st, "sizepolicy",
2074 sizepolicy2string(node->szplcy));
2075 extl_table_sets_i(st, "level", node->level);
2076 g=extl_table_from_rectangle(®ION_GEOM(node->reg));
2077 extl_table_sets_t(st, "geom", g);
2078 extl_unref_table(g);
2079 if(STACKING_IS_HIDDEN(node))
2080 extl_table_sets_b(st, "hidden", TRUE);
2081 if(STACKING_IS_PSEUDOMODAL(node))
2082 extl_table_sets_b(st, "pseudomodal", TRUE);
2084 extl_table_sets_b(st, "unnumbered", TRUE);
2086 extl_table_seti_t(subs, ++(*n), st);
2087 extl_unref_table(st);
2092 ExtlTab mplex_get_configuration(WMPlex *mplex)
2094 ExtlTab tab, subs, stdisptab;
2101 tab=region_get_base_configuration((WRegion*)mplex);
2103 subs=extl_create_table();
2104 extl_table_sets_t(tab, "managed", subs);
2106 /* First the numbered/mutually exclusive nodes */
2107 FOR_ALL_NODES_ON_LLIST(lnode, mplex->mx_list, ltmp){
2108 save_node(mplex, subs, &n, lnode->st, FALSE);
2111 FOR_ALL_NODES_IN_MPLEX(mplex, node, tmp){
2112 if(node->lnode==NULL)
2113 save_node(mplex, subs, &n, node, TRUE);
2116 extl_unref_table(subs);
2118 /*stdisptab=mplex_do_get_stdisp_extl(mplex, TRUE);
2119 if(stdisptab!=extl_table_none()){
2120 extl_table_sets_t(tab, "stdisp", stdisptab);
2121 extl_unref_table(stdisptab);
2128 void mplex_load_contents(WMPlex *mplex, ExtlTab tab)
2130 ExtlTab substab, subtab;
2133 /*if(extl_table_gets_t(tab, "stdisp", &subtab)){
2134 mplex_set_stdisp_extl(mplex, subtab);
2135 extl_unref_table(subtab);
2138 if(extl_table_gets_t(tab, "managed", &substab) ||
2139 extl_table_gets_t(tab, "subs", &substab)){
2140 n=extl_table_get_n(substab);
2141 for(i=1; i<=n; i++){
2142 if(extl_table_geti_t(substab, i, &subtab)){
2143 WMPlexAttachParams par=MPLEXATTACHPARAMS_INIT;
2147 get_params(mplex, subtab, 0, &par);
2148 mplex_attach_fp(mplex, &par, &fp);
2150 par.flags|=MPLEX_ATTACH_INDEX;
2151 par.index=LLIST_INDEX_LAST;
2153 ph=(WPHolder*)create_mplexpholder(mplex, NULL, &par);
2156 region_attach_load_helper((WRegion*)mplex, (WWindow*)mplex, &fp,
2157 (WRegionDoAttachFn*)mplex_do_attach_final,
2158 (void*)ph, subtab, &ph);
2161 destroy_obj((Obj*)ph);
2164 extl_unref_table(subtab);
2167 extl_unref_table(substab);
2172 WRegion *mplex_load(WWindow *par, const WFitParams *fp, ExtlTab tab)
2174 WMPlex *mplex=create_mplex(par, fp);
2176 mplex_load_contents(mplex, tab);
2177 return (WRegion*)mplex;
2184 /*{{{ Dynfuntab and class info */
2187 static DynFunTab mplex_dynfuntab[]={
2188 {region_do_set_focus,
2189 mplex_do_set_focus},
2191 {region_managed_remove,
2192 mplex_managed_remove},
2194 {region_managed_rqgeom,
2195 mplex_managed_rqgeom},
2197 {(DynFun*)region_managed_prepare_focus,
2198 (DynFun*)mplex_managed_prepare_focus},
2200 {(DynFun*)region_handle_drop,
2201 (DynFun*)mplex_handle_drop},
2203 {region_map, mplex_map},
2204 {region_unmap, mplex_unmap},
2206 {(DynFun*)region_prepare_manage,
2207 (DynFun*)mplex_prepare_manage},
2209 {(DynFun*)region_current,
2210 (DynFun*)mplex_current},
2212 {(DynFun*)region_rescue_clientwins,
2213 (DynFun*)mplex_rescue_clientwins},
2215 {(DynFun*)region_get_configuration,
2216 (DynFun*)mplex_get_configuration},
2218 {mplex_managed_geom,
2219 mplex_managed_geom_default},
2221 {(DynFun*)region_fitrep,
2222 (DynFun*)mplex_fitrep},
2224 {region_child_removed,
2225 mplex_child_removed},
2227 {(DynFun*)region_managed_get_pholder,
2228 (DynFun*)mplex_managed_get_pholder},
2230 {(DynFun*)region_get_rescue_pholder_for,
2231 (DynFun*)mplex_get_rescue_pholder_for},
2233 {(DynFun*)region_navi_first,
2234 (DynFun*)mplex_navi_first},
2236 {(DynFun*)region_navi_next,
2237 (DynFun*)mplex_navi_next},
2239 {(DynFun*)region_managed_rqorder,
2240 (DynFun*)mplex_managed_rqorder},
2247 IMPLCLASS(WMPlex, WWindow, mplex_deinit, mplex_dynfuntab);