chiark / gitweb /
Imported Debian patch 1.0.0-5
[e16] / src / eobj.h
1 /*
2  * Copyright (C) 2004-2008 Kim Woelders
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies of the Software, its documentation and marketing & publicity
13  * materials, and acknowledgment shall be given in the documentation, materials
14  * and software packages that this Software was used.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 #ifndef _EOBJ_H_
24 #define _EOBJ_H_
25
26 #include "etypes.h"
27 #include "xwin.h"
28
29 typedef struct _eobj EObj;
30
31 struct _eobj {
32    Win                 win;     /* The top level window */
33    short               type;    /* Ewin, button, other, ... */
34    short               ilayer;  /* Internal stacking layer */
35    short               layer;   /* Stacking layer */
36    signed char         stacked;
37    signed char         shaped;
38    Desk               *desk;    /* Belongs on desk */
39    char                sticky;
40    char                floating;
41    unsigned            external:1;
42    unsigned            inputonly:1;
43    unsigned            shown:1;
44    unsigned            gone:1;
45    unsigned            noredir:1;       /* Do not redirect */
46    unsigned            shadow:1;        /* Enable shadows */
47    unsigned            fade:1;  /* Enable fading */
48    unsigned            fading:1;        /* Is fading */
49    unsigned            ghost:1; /* Ghost window */
50    struct {
51       char               *wm_name;
52       char               *wm_res_name;
53       char               *wm_res_class;
54    } icccm;
55 #if USE_COMPOSITE
56    unsigned int        serial;
57    unsigned int        opacity;
58    struct _cmhook     *cmhook;
59 #endif
60 #if USE_GLX
61    struct _glhook     *glhook;
62 #endif
63 };
64
65 #define EOBJ_TYPE_EWIN      0
66 #define EOBJ_TYPE_BUTTON    1
67 #define EOBJ_TYPE_DESK      2
68 #define EOBJ_TYPE_MISC      3
69 #define EOBJ_TYPE_EVENT     4   /* Unredirected */
70 #define EOBJ_TYPE_EXT       5
71 #define EOBJ_TYPE_MISC_NR   6   /* Unredirected */
72 #define EOBJ_TYPE_ROOT_BG   7
73 #define EOBJ_TYPE_GLX       8
74
75 #define EobjGetWin(eo)          ((eo)->win)
76 #define EobjGetXwin(eo)         WinGetXwin(EobjGetWin(eo))
77 #define EobjGetX(eo)            WinGetX(EobjGetWin(eo))
78 #define EobjGetY(eo)            WinGetY(EobjGetWin(eo))
79 #define EobjGetW(eo)            WinGetW(EobjGetWin(eo))
80 #define EobjGetH(eo)            WinGetH(EobjGetWin(eo))
81 #define EobjGetBW(eo)           WinGetBorderWidth(EobjGetWin(eo))
82 #define EobjGetType(eo)         ((eo)->type)
83 #define EobjGetDesk(eo)         ((eo)->desk)
84 #define EobjGetName(eo)         ((eo)->icccm.wm_name)
85 #define EobjGetCName(eo)        ((eo)->icccm.wm_res_name)
86 #define EobjGetClass(eo)        ((eo)->icccm.wm_res_class)
87
88 #define EoObj(eo)               (&((eo)->o))
89 #define EoGetWin(eo)            EobjGetWin(EoObj(eo))
90 #define EoGetXwin(eo)           EobjGetXwin(EoObj(eo))
91 #define EoGetType(eo)           EobjGetType(EoObj(eo))
92 #define EoGetDesk(eo)           EobjGetDesk(EoObj(eo))
93 #define EoGetName(eo)           EobjGetName(EoObj(eo))
94 #define EoGetCName(eo)          EobjGetCName(EoObj(eo))
95 #define EoGetClass(eo)          EobjGetClass(EoObj(eo))
96 #define EoGetX(eo)              EobjGetX(EoObj(eo))
97 #define EoGetY(eo)              EobjGetY(EoObj(eo))
98 #define EoGetW(eo)              EobjGetW(EoObj(eo))
99 #define EoGetH(eo)              EobjGetH(EoObj(eo))
100 #define EoIsGone(eo)            (EoObj(eo)->gone)
101 #define EoIsSticky(eo)          (EoObj(eo)->sticky)
102 #define EoIsFloating(eo)        (EoObj(eo)->floating)
103 #define EoIsShown(eo)           (EoObj(eo)->shown)
104 #define EoGetDeskNum(eo)        (EoGetDesk(eo)->num)
105 #define EoGetLayer(eo)          (EoObj(eo)->layer)
106 #define EoGetPixmap(eo)         EobjGetPixmap(EoObj(eo))
107
108 #define EoSetGone(eo)           EoObj(eo)->gone = 1
109 #define EoSetSticky(eo, _x)     EoObj(eo)->sticky = ((_x)?1:0)
110 #define EoSetFloating(eo, _f)   EobjSetFloating(EoObj(eo), (_f))
111 #define EoSetDesk(eo, _x)       EoObj(eo)->desk = (_x)
112 #define EoSetLayer(eo, _l)      EobjSetLayer(EoObj(eo), (_l))
113 #define EoChangeOpacity(eo, _o) EobjChangeOpacity(EoObj(eo), _o)
114 #define EoSetFade(eo, _x)       EoObj(eo)->fade = (_x)
115 #define EoSetNoRedirect(eo, _x) EoObj(eo)->noredir = (_x)
116 #define EoSetOpacity(eo, _o)    EoObj(eo)->opacity = (_o)
117 #define EoSetShadow(eo, _x)     EoObj(eo)->shadow = (_x)
118 #if USE_COMPOSITE
119 #define EoGetOpacity(eo)        (EoObj(eo)->opacity)
120 #define EoGetFade(eo)           (EoObj(eo)->fade)
121 #define EoChangeShadow(eo, _x)  EobjChangeShadow(EoObj(eo), _x)
122 #define EoGetShadow(eo)         (EoObj(eo)->shadow)
123 #define EoGetNoRedirect(eo)     (EoObj(eo)->noredir)
124 #define EoGetSerial(eo)         (EoObj(eo)->serial)
125 #else
126 #define EoGetSerial(eo)         0
127 #endif
128
129 #define EoInit(eo, type, win, x, y, w, h, su, name) \
130                                         EobjInit(EoObj(eo), type, win, x, y, w, h, su, name)
131 #define EoFini(eo)                      EobjFini(EoObj(eo));
132 #define EoMap(eo, raise)                EobjMap(EoObj(eo), raise)
133 #define EoUnmap(eo)                     EobjUnmap(EoObj(eo))
134 #define EoMove(eo, x, y)                EobjMove(EoObj(eo), x, y)
135 #define EoResize(eo, w, h)              EobjResize(EoObj(eo), w, h)
136 #define EoMoveResize(eo, x, y, w, h)    EobjMoveResize(EoObj(eo), x, y, w, h)
137 #define EoReparent(eo, d, x, y)         EobjReparent(EoObj(eo), d, x, y)
138 #define EoRaise(eo)                     EobjRaise(EoObj(eo))
139 #define EoLower(eo)                     EobjLower(EoObj(eo))
140 #define EoShapeUpdate(eo, p)            EobjShapeUpdate(EoObj(eo), p)
141
142 /* eobj.c */
143 void                EobjInit(EObj * eo, int type, Win win, int x, int y,
144                              int w, int h, int su, const char *name);
145 void                EobjFini(EObj * eo);
146 void                EobjDestroy(EObj * eo);
147
148 EObj               *EobjWindowCreate(int type, int x, int y, int w, int h,
149                                      int su, const char *name);
150 void                EobjWindowDestroy(EObj * eo);
151
152 EObj               *EobjRegister(Window win, int type);
153 void                EobjUnregister(EObj * eo);
154
155 void                EobjMap(EObj * eo, int raise);
156 void                EobjUnmap(EObj * eo);
157 void                EobjMove(EObj * eo, int x, int y);
158 void                EobjResize(EObj * eo, int w, int h);
159 void                EobjMoveResize(EObj * eo, int x, int y, int w, int h);
160 void                EobjDamage(EObj * eo);
161 void                EobjReparent(EObj * eo, EObj * dst, int x, int y);
162 int                 EobjRaise(EObj * eo);
163 int                 EobjLower(EObj * eo);
164 void                EobjShapeUpdate(EObj * eo, int propagate);
165 void                EobjsRepaint(void);
166 Pixmap              EobjGetPixmap(const EObj * eo);
167
168 #if USE_GLX
169 struct _etexture   *EobjGetTexture(EObj * eo);
170 struct _etexture   *EobjTextureCreate(EObj * eo);
171 void                EobjTextureDestroy(EObj * eo);
172 void                EobjTextureInvalidate(EObj * eo);
173 #endif
174 void                EobjChangeOpacity(EObj * eo, unsigned int opacity);
175 void                EobjChangeShadow(EObj * eo, int shadow);
176 void                EobjSetLayer(EObj * eo, int layer);
177 void                EobjSetFloating(EObj * eo, int floating);
178 int                 EobjIsShaped(const EObj * eo);
179 void                EobjSlideTo(EObj * eo, int fx, int fy, int tx, int ty,
180                                 int speed);
181 void                EobjsSlideBy(EObj ** peo, int num, int dx, int dy,
182                                  int speed);
183 void                EobjSlideSizeTo(EObj * eo, int fx, int fy, int tx, int ty,
184                                     int fw, int fh, int tw, int th, int speed);
185
186 void                EobjsOpacityUpdate(int op_or);
187
188 /* stacking.c */
189 void                EobjListStackAdd(EObj * eo, int ontop);
190 void                EobjListStackDel(EObj * eo);
191 int                 EobjListStackRaise(EObj * eo, int test);
192 int                 EobjListStackLower(EObj * eo, int test);
193 int                 EobjListStackCheck(EObj * eo);
194 EObj               *EobjListStackFind(Window win);
195 EObj               *const *EobjListStackGet(int *num);
196 EObj               *const *EobjListStackGetForDesk(int *num, Desk * dsk);
197 void                EobjListFocusAdd(EObj * eo, int ontop);
198 void                EobjListFocusDel(EObj * eo);
199 int                 EobjListFocusRaise(EObj * eo);
200 void                EobjListOrderAdd(EObj * eo);
201 void                EobjListOrderDel(EObj * eo);
202
203 /* Hmmm. */
204 int                 OpacityFix(int op, int op_0);
205 unsigned int        OpacityFromPercent(int op);
206 int                 OpacityToPercent(unsigned int opacity);
207
208 #endif /* _EOBJ_H_ */