Include mod_xrandr instead of using submodules
[notion/jeffpc.git] / ioncore / basicpholder.c
blob9689ec49b82e00701e6789bca2124c7a328fbe60
1 /*
2 * ion/ioncore/basicpholder.c
4 * Copyright (c) Tuomo Valkonen 2005-2009.
6 * See the included file LICENSE for details.
7 */
9 #include <libtu/objp.h>
10 #include <libtu/obj.h>
11 #include <libtu/pointer.h>
13 #include "basicpholder.h"
16 /*{{{ Init/deinit */
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));
30 return FALSE;
33 ph->hnd=hnd;
35 return TRUE;
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));
53 /*}}}*/
56 /*{{{ Dynfuns */
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)
65 return FALSE;
67 return ph->hnd(reg, flags, data);
71 bool basicpholder_do_goto(WBasicPHolder *ph)
73 WRegion *reg=(WRegion*)ph->reg_watch.obj;
75 if(reg!=NULL)
76 return region_goto((WRegion*)reg);
78 return FALSE;
82 WRegion *basicpholder_do_target(WBasicPHolder *ph)
84 return (WRegion*)ph->reg_watch.obj;
88 /*}}}*/
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},
104 END_DYNFUNTAB
107 IMPLCLASS(WBasicPHolder, WPHolder, basicpholder_deinit,
108 basicpholder_dynfuntab);
111 /*}}}*/