2 * ion/ioncore/basicpholder.c
4 * Copyright (c) Tuomo Valkonen 2005-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
12 #include <libtu/objp.h>
13 #include <libtu/obj.h>
14 #include <libtu/pointer.h>
16 #include "basicpholder.h"
22 static void basicpholder_watch_handler(Watch *watch, Obj *reg)
24 WBasicPHolder *ph=FIELD_TO_STRUCT(WBasicPHolder, reg_watch, watch);
25 pholder_redirect(&(ph->ph), (WRegion*)reg);
29 bool basicpholder_init(WBasicPHolder *ph, WRegion *reg,
30 WBasicPHolderHandler *hnd)
32 assert(reg!=NULL && hnd!=NULL);
34 pholder_init(&(ph->ph));
36 watch_init(&(ph->reg_watch));
38 if(!watch_setup(&(ph->reg_watch), (Obj*)reg, basicpholder_watch_handler)){
39 pholder_deinit(&(ph->ph));
49 WBasicPHolder *create_basicpholder(WRegion *reg,
50 WBasicPHolderHandler *hnd)
52 CREATEOBJ_IMPL(WBasicPHolder, basicpholder, (p, reg, hnd));
56 void basicpholder_deinit(WBasicPHolder *ph)
58 watch_reset(&(ph->reg_watch));
59 pholder_deinit(&(ph->ph));
69 WRegion *basicpholder_do_attach(WBasicPHolder *ph, int flags,
70 WRegionAttachData *data)
72 WRegion *reg=(WRegion*)ph->reg_watch.obj;
74 if(reg==NULL || ph->hnd==NULL)
77 return ph->hnd(reg, flags, data);
81 bool basicpholder_do_goto(WBasicPHolder *ph)
83 WRegion *reg=(WRegion*)ph->reg_watch.obj;
86 return region_goto((WRegion*)reg);
92 WRegion *basicpholder_do_target(WBasicPHolder *ph)
94 return (WRegion*)ph->reg_watch.obj;
101 /*{{{ Class information */
104 static DynFunTab basicpholder_dynfuntab[]={
105 {(DynFun*)pholder_do_attach,
106 (DynFun*)basicpholder_do_attach},
108 {(DynFun*)pholder_do_goto,
109 (DynFun*)basicpholder_do_goto},
111 {(DynFun*)pholder_do_target,
112 (DynFun*)basicpholder_do_target},
117 IMPLCLASS(WBasicPHolder, WPHolder, basicpholder_deinit,
118 basicpholder_dynfuntab);