]> git.decadent.org.uk Git - ion3.git/blob - ioncore/region.h
Imported Upstream version 20090110
[ion3.git] / ioncore / region.h
1 /*
2  * ion/ioncore/region.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2009. 
5  *
6  * See the included file LICENSE for details.
7  */
8
9 #ifndef ION_IONCORE_REGION_H
10 #define ION_IONCORE_REGION_H
11
12 #include <libtu/obj.h>
13 #include <libtu/stringstore.h>
14 #include <libmainloop/hooks.h>
15 #include "common.h"
16 #include "rectangle.h"
17
18 #define REGION_MAPPED               0x0001
19 #define REGION_ACTIVE               0x0002
20 #define REGION_HAS_GRABS            0x0004
21 #define REGION_TAGGED               0x0008
22 #define REGION_PSEUDOACTIVE         0x0010
23 #define REGION_BINDINGS_ARE_GRABBED 0x0020
24 #define REGION_GRAB_ON_PARENT       0x0040
25 #define REGION_ACTIVITY             0x0100
26 #define REGION_SKIP_FOCUS           0x0200
27 #define REGION_CWINS_BEING_RESCUED  0x0400
28 #define REGION_PLEASE_WARP          0x0800
29 #define REGION_BINDING_UPDATE_SCHEDULED 0x1000
30
31 #define REGION_GOTO_FOCUS           0x0001
32 #define REGION_GOTO_NOWARP          0x0002
33 #define REGION_GOTO_ENTERWINDOW     0x0004
34
35 /* Use region_is_fully_mapped instead for most cases. */
36 #define REGION_IS_MAPPED(R)     (((WRegion*)(R))->flags&REGION_MAPPED)
37 #define REGION_MARK_MAPPED(R)   (((WRegion*)(R))->flags|=REGION_MAPPED)
38 #define REGION_MARK_UNMAPPED(R) (((WRegion*)(R))->flags&=~REGION_MAPPED)
39 #define REGION_IS_ACTIVE(R)     (((WRegion*)(R))->flags&REGION_ACTIVE)
40 #define REGION_IS_PSEUDOACTIVE(R) (((WRegion*)(R))->flags&REGION_PSEUDOACTIVE)
41 #define REGION_IS_TAGGED(R)     (((WRegion*)(R))->flags&REGION_TAGGED)
42 #define REGION_IS_URGENT(R)     (((WRegion*)(R))->flags&REGION_URGENT)
43 #define REGION_GEOM(R)          (((WRegion*)(R))->geom)
44 #define REGION_ACTIVE_SUB(R)    (((WRegion*)(R))->active_sub)
45
46 #define REGION_MANAGER(R)       (((WRegion*)(R))->manager)
47 #define REGION_MANAGER_CHK(R, TYPE) OBJ_CAST(REGION_MANAGER(R), TYPE)
48
49 #define REGION_PARENT(REG)      (((WRegion*)(REG))->parent)
50 #define REGION_PARENT_REG(REG)  ((WRegion*)REGION_PARENT(REG))
51
52 #define REGION_FIT_BOUNDS    0x0001 /* Geometry is maximum bounds */
53 #define REGION_FIT_ROTATE    0x0002 /* for Xrandr */
54 #define REGION_FIT_WHATEVER  0x0004 /* for attach routines; g is not final */
55 #define REGION_FIT_GRAVITY   0x0008 /* just a hint; for use with BOUNDS */
56 #define REGION_FIT_EXACT     0x0000 /* No flags; exact fit */
57
58
59 typedef int WRegionFitMode;
60
61 typedef StringId WRegionNotify;
62
63
64 typedef enum{
65     REGION_ORDER_FRONT,
66     REGION_ORDER_BACK
67 } WRegionOrder;
68
69
70 INTRSTRUCT(WFitParams);
71 DECLSTRUCT(WFitParams){
72     WRectangle g;
73     WRegionFitMode mode;
74     int gravity;
75     int rotation;
76 };
77
78
79 INTRSTRUCT(WRegionNameInfo);
80 DECLSTRUCT(WRegionNameInfo){
81     char *name;
82     int inst_off;
83     void *node;
84 };
85
86
87 INTRSTRUCT(WPrepareFocusResult);
88 DECLSTRUCT(WPrepareFocusResult){
89     WRegion *reg;
90     int flags;
91 };
92
93
94 DECLCLASS(WRegion){
95     Obj obj;
96     
97     WRectangle geom;
98     void *rootwin;
99     bool flags;
100
101     WWindow *parent;
102     WRegion *children;
103     WRegion *p_next, *p_prev;
104     
105     void *bindings;
106     WSubmapState *submapstat;
107     
108     WRegion *active_sub;
109     WRegion *active_prev, *active_next;
110     
111     WRegionNameInfo ni;
112     
113     WRegion *manager;
114     
115     int mgd_activity;
116 };
117
118
119
120
121 extern void region_init(WRegion *reg, WWindow *par, const WFitParams *fp);
122 extern void region_deinit(WRegion *reg);
123
124 DYNFUN bool region_fitrep(WRegion *reg, WWindow *par, const WFitParams *fp);
125 DYNFUN void region_map(WRegion *reg);
126 DYNFUN void region_unmap(WRegion *reg);
127 DYNFUN Window region_xwindow(const WRegion *reg);
128 DYNFUN void region_activated(WRegion *reg);
129 DYNFUN void region_inactivated(WRegion *reg);
130 DYNFUN void region_updategr(WRegion *reg);
131 DYNFUN void region_rqclose(WRegion *reg, bool relocate);
132 DYNFUN WRegion *region_rqclose_propagate(WRegion *reg, WRegion *maybe_sub);
133 DYNFUN WRegion *region_current(WRegion *mgr);
134 DYNFUN void region_notify_rootpos(WRegion *reg, int x, int y);
135 DYNFUN bool region_may_dispose(WRegion *reg);
136 DYNFUN WRegion *region_managed_control_focus(WRegion *mgr, WRegion *reg);
137 DYNFUN void region_managed_remove(WRegion *reg, WRegion *sub);
138 DYNFUN bool region_managed_prepare_focus(WRegion *reg, WRegion *sub, 
139                                          int flags, WPrepareFocusResult *res);
140 DYNFUN void region_managed_notify(WRegion *reg, WRegion *sub, WRegionNotify how);
141 DYNFUN WRegion *region_managed_disposeroot(WRegion *mgr, WRegion *reg);
142 DYNFUN bool region_managed_rqorder(WRegion *reg, WRegion *sub, 
143                                    WRegionOrder order);
144
145 DYNFUN void region_child_removed(WRegion *reg, WRegion *sub);
146
147 DYNFUN void region_restack(WRegion *reg, Window other, int mode);
148 DYNFUN void region_stacking(WRegion *reg, Window *bottomret, Window *topret);
149
150 DYNFUN bool region_handle_drop(WRegion *reg, int x, int y, WRegion *dropped);
151
152 extern bool region_rqorder(WRegion *reg, WRegionOrder order);
153
154 extern bool region_prepare_focus(WRegion *reg, int flags,
155                                  WPrepareFocusResult *res);
156
157 extern void region_fit(WRegion *reg, const WRectangle *geom, 
158                        WRegionFitMode mode);
159 extern bool region_reparent(WRegion *reg, WWindow *target, 
160                             const WRectangle *geom, WRegionFitMode mode);
161
162 extern void region_updategr_default(WRegion *reg);
163
164 extern void region_rootpos(WRegion *reg, int *xret, int *yret);
165 extern void region_notify_change(WRegion *reg, WRegionNotify how);
166
167 extern bool region_goto(WRegion *reg);
168 extern bool region_goto_flags(WRegion *reg, int flags);
169
170 extern bool region_is_fully_mapped(WRegion *reg);
171
172 extern void region_detach_manager(WRegion *reg);
173
174 extern WRegion *region_disposeroot(WRegion *reg);
175
176 extern bool region_dispose(WRegion *reg);
177 extern bool region_rqdispose(WRegion *reg);
178 extern void region_defer_rqdispose(WRegion *reg);
179
180 extern WWindow *region_parent(WRegion *reg);
181 extern WRegion *region_manager(WRegion *reg);
182 extern WRegion *region_manager_or_parent(WRegion *reg);
183 extern void region_set_parent(WRegion *reg, WWindow *par);
184 extern void region_set_manager(WRegion *reg, WRegion *mgr);
185 extern void region_unset_manager(WRegion *reg, WRegion *mgr);
186 extern void region_unset_parent(WRegion *reg);
187
188 extern WRootWin *region_rootwin_of(const WRegion *reg);
189 extern Window region_root_of(const WRegion *reg);
190 extern WScreen *region_screen_of(WRegion *reg);
191 extern bool region_same_rootwin(const WRegion *reg1, const WRegion *reg2);
192
193 extern WRegion *region_managed_within(WRegion *reg, WRegion *mgd);
194
195 extern void region_set_manager_pseudoactivity(WRegion *reg);
196 extern void region_unset_manager_pseudoactivity(WRegion *reg);
197
198 extern WHook *region_notify_hook;
199
200 #endif /* ION_IONCORE_REGION_H */