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