2 * ion/ioncore/basicpholder.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 "basicpholder.h"
19 static void basicpholder_watch_handler(Watch *watch, Obj *reg)
21 WBasicPHolder *ph=FIELD_TO_STRUCT(WBasicPHolder, reg_watch, watch);
22 pholder_redirect(&(ph->ph), (WRegion*)reg);
26 bool basicpholder_init(WBasicPHolder *ph, WRegion *reg,
27 WBasicPHolderHandler *hnd)
29 assert(reg!=NULL && hnd!=NULL);
31 pholder_init(&(ph->ph));
33 watch_init(&(ph->reg_watch));
35 if(!watch_setup(&(ph->reg_watch), (Obj*)reg, basicpholder_watch_handler)){
36 pholder_deinit(&(ph->ph));
46 WBasicPHolder *create_basicpholder(WRegion *reg,
47 WBasicPHolderHandler *hnd)
49 CREATEOBJ_IMPL(WBasicPHolder, basicpholder, (p, reg, hnd));
53 void basicpholder_deinit(WBasicPHolder *ph)
55 watch_reset(&(ph->reg_watch));
56 pholder_deinit(&(ph->ph));
66 WRegion *basicpholder_do_attach(WBasicPHolder *ph, int flags,
67 WRegionAttachData *data)
69 WRegion *reg=(WRegion*)ph->reg_watch.obj;
71 if(reg==NULL || ph->hnd==NULL)
74 return ph->hnd(reg, flags, data);
78 bool basicpholder_do_goto(WBasicPHolder *ph)
80 WRegion *reg=(WRegion*)ph->reg_watch.obj;
83 return region_goto((WRegion*)reg);
89 WRegion *basicpholder_do_target(WBasicPHolder *ph)
91 return (WRegion*)ph->reg_watch.obj;
98 /*{{{ Class information */
101 static DynFunTab basicpholder_dynfuntab[]={
102 {(DynFun*)pholder_do_attach,
103 (DynFun*)basicpholder_do_attach},
105 {(DynFun*)pholder_do_goto,
106 (DynFun*)basicpholder_do_goto},
108 {(DynFun*)pholder_do_target,
109 (DynFun*)basicpholder_do_target},
114 IMPLCLASS(WBasicPHolder, WPHolder, basicpholder_deinit,
115 basicpholder_dynfuntab);