2 * ion/ioncore/basicpholder.c
4 * Copyright (c) Tuomo Valkonen 2005-2009.
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 "basicpholder.h"
19 bool basicpholder_init(WBasicPHolder *ph, WRegion *reg,
20 WBasicPHolderHandler *hnd)
22 assert(reg!=NULL && hnd!=NULL);
24 pholder_init(&(ph->ph));
26 watch_init(&(ph->reg_watch));
28 if(!watch_setup(&(ph->reg_watch), (Obj*)reg, NULL)){
29 pholder_deinit(&(ph->ph));
39 WBasicPHolder *create_basicpholder(WRegion *reg,
40 WBasicPHolderHandler *hnd)
42 CREATEOBJ_IMPL(WBasicPHolder, basicpholder, (p, reg, hnd));
46 void basicpholder_deinit(WBasicPHolder *ph)
48 watch_reset(&(ph->reg_watch));
49 pholder_deinit(&(ph->ph));
59 WRegion *basicpholder_do_attach(WBasicPHolder *ph, int flags,
60 WRegionAttachData *data)
62 WRegion *reg=(WRegion*)ph->reg_watch.obj;
64 if(reg==NULL || ph->hnd==NULL)
67 return ph->hnd(reg, flags, data);
71 bool basicpholder_do_goto(WBasicPHolder *ph)
73 WRegion *reg=(WRegion*)ph->reg_watch.obj;
76 return region_goto((WRegion*)reg);
82 WRegion *basicpholder_do_target(WBasicPHolder *ph)
84 return (WRegion*)ph->reg_watch.obj;
91 /*{{{ Class information */
94 static DynFunTab basicpholder_dynfuntab[]={
95 {(DynFun*)pholder_do_attach,
96 (DynFun*)basicpholder_do_attach},
98 {(DynFun*)pholder_do_goto,
99 (DynFun*)basicpholder_do_goto},
101 {(DynFun*)pholder_do_target,
102 (DynFun*)basicpholder_do_target},
107 IMPLCLASS(WBasicPHolder, WPHolder, basicpholder_deinit,
108 basicpholder_dynfuntab);