2 * ion/ioncore/grouppholder.c
4 * Copyright (c) Tuomo Valkonen 2005-2007.
6 * See the included file LICENSE for details.
9 #include <libtu/objp.h>
10 #include <libtu/obj.h>
11 #include <libtu/pointer.h>
13 #include <ioncore/common.h>
15 #include "grouppholder.h"
18 static void group_watch_handler(Watch *watch, Obj *ws);
24 static void group_watch_handler(Watch *watch, Obj *ws)
26 WGroupPHolder *ph=FIELD_TO_STRUCT(WGroupPHolder,
28 pholder_redirect(&(ph->ph), (WRegion*)ws);
32 static WGroupAttachParams dummy_param=GROUPATTACHPARAMS_INIT;
35 bool grouppholder_init(WGroupPHolder *ph, WGroup *ws,
37 const WGroupAttachParams *param)
39 pholder_init(&(ph->ph));
41 watch_init(&(ph->group_watch));
42 watch_init(&(ph->stack_above_watch));
45 if(!watch_setup(&(ph->group_watch), (Obj*)ws,
46 group_watch_handler)){
47 pholder_deinit(&(ph->ph));
56 /* TODO? Just link to the stacking structure to remember
60 ph->param.szplcy_set=TRUE;
61 ph->param.szplcy=st->szplcy;
62 ph->param.level_set=TRUE;
63 ph->param.level=st->level;
66 ph->param.geom_set=TRUE;
67 ph->param.geom=REGION_GEOM(st->reg);
70 if(st->above!=NULL && st->above->reg!=NULL)
71 ph->param.stack_above=st->above->reg;
73 ph->param.bottom=(st==ws->bottom);
78 ph->param.switchto_set=FALSE;
80 if(ph->param.stack_above!=NULL){
81 /* We must move stack_above pointer into a Watch. */
82 watch_setup(&(ph->stack_above_watch),
83 (Obj*)ph->param.stack_above, NULL);
84 ph->param.stack_above=NULL;
91 WGroupPHolder *create_grouppholder(WGroup *ws,
93 const WGroupAttachParams *param)
95 CREATEOBJ_IMPL(WGroupPHolder, grouppholder, (p, ws, st, param));
99 void grouppholder_deinit(WGroupPHolder *ph)
101 watch_reset(&(ph->group_watch));
102 watch_reset(&(ph->stack_above_watch));
103 pholder_deinit(&(ph->ph));
113 WRegion *grouppholder_do_attach(WGroupPHolder *ph, int flags,
114 WRegionAttachData *data)
116 WGroup *ws=(WGroup*)ph->group_watch.obj;
122 ph->param.switchto_set=1;
123 ph->param.switchto=(flags&PHOLDER_ATTACH_SWITCHTO ? 1 : 0);
125 /* Get stack_above from Watch. */
126 ph->param.stack_above=(WRegion*)ph->stack_above_watch.obj;
128 reg=group_do_attach(ws, &ph->param, data);
130 ph->param.stack_above=NULL;
136 bool grouppholder_do_goto(WGroupPHolder *ph)
138 WGroup *ws=(WGroup*)ph->group_watch.obj;
141 return region_goto((WRegion*)ws);
147 WRegion *grouppholder_do_target(WGroupPHolder *ph)
149 return (WRegion*)ph->group_watch.obj;
156 /*{{{ WGroup stuff */
159 WGroupPHolder *group_managed_get_pholder(WGroup *ws, WRegion *mgd)
161 WStacking *st=group_find_stacking(ws, mgd);
166 return create_grouppholder(ws, st, NULL);
173 /*{{{ Class information */
176 static DynFunTab grouppholder_dynfuntab[]={
177 {(DynFun*)pholder_do_attach,
178 (DynFun*)grouppholder_do_attach},
180 {(DynFun*)pholder_do_goto,
181 (DynFun*)grouppholder_do_goto},
183 {(DynFun*)pholder_do_target,
184 (DynFun*)grouppholder_do_target},
189 IMPLCLASS(WGroupPHolder, WPHolder, grouppholder_deinit,
190 grouppholder_dynfuntab);