1 /* 2 * Copyright (C) 2004-2021 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 Animator *animations; /* list of pending animations */ 64 }; 65 66 #define EOBJ_TYPE_EWIN 0 67 #define EOBJ_TYPE_BUTTON 1 68 #define EOBJ_TYPE_DESK 2 69 #define EOBJ_TYPE_MISC 3 70 #define EOBJ_TYPE_EVENT 4 /* Unredirected */ 71 #define EOBJ_TYPE_EXT 5 72 #define EOBJ_TYPE_MISC_NR 6 /* Unredirected */ 73 #define EOBJ_TYPE_ROOT_BG 7 74 #define EOBJ_TYPE_GLX 8 75 76 #define EobjGetWin(eo) ((eo)->win) 77 #define EobjGetParent(eo) WinGetParent(EobjGetWin(eo)) 78 #define EobjGetXwin(eo) WinGetXwin(EobjGetWin(eo)) 79 #define EobjGetX(eo) WinGetX(EobjGetWin(eo)) 80 #define EobjGetY(eo) WinGetY(EobjGetWin(eo)) 81 #define EobjGetW(eo) WinGetW(EobjGetWin(eo)) 82 #define EobjGetH(eo) WinGetH(EobjGetWin(eo)) 83 #define EobjGetBW(eo) WinGetBorderWidth(EobjGetWin(eo)) 84 #define EoIsMapped(eo) WinIsMapped(EoGetWin(eo)) 85 #define EobjHasEmptyShape(eo) (WinGetNumRect(EobjGetWin(eo)) < 0) 86 87 #define EobjGetType(eo) ((eo)->type) 88 #define EobjGetDesk(eo) ((eo)->desk) 89 #define EobjGetName(eo) ((eo)->icccm.wm_name) 90 #define EobjGetCName(eo) ((eo)->icccm.wm_res_name) 91 #define EobjGetClass(eo) ((eo)->icccm.wm_res_class) 92 93 #define EoObj(eo) (&((eo)->o)) 94 #define EoGetWin(eo) EobjGetWin(EoObj(eo)) 95 #define EoGetParent(eo) EobjGetParent(EoObj(eo)) 96 #define EoGetXwin(eo) EobjGetXwin(EoObj(eo)) 97 #define EoGetType(eo) EobjGetType(EoObj(eo)) 98 #define EoGetDesk(eo) EobjGetDesk(EoObj(eo)) 99 #define EoGetName(eo) EobjGetName(EoObj(eo)) 100 #define EoGetNameSafe(eo) EobjGetNameSafe(EoObj(eo)) 101 #define EoGetCName(eo) EobjGetCName(EoObj(eo)) 102 #define EoGetClass(eo) EobjGetClass(EoObj(eo)) 103 #define EoGetX(eo) EobjGetX(EoObj(eo)) 104 #define EoGetY(eo) EobjGetY(EoObj(eo)) 105 #define EoGetW(eo) EobjGetW(EoObj(eo)) 106 #define EoGetH(eo) EobjGetH(EoObj(eo)) 107 #define EoIsGone(eo) (EoObj(eo)->gone) 108 #define EoIsSticky(eo) (EoObj(eo)->sticky) 109 #define EoIsFloating(eo) (EoObj(eo)->floating) 110 #define EoIsShown(eo) (EoObj(eo)->shown) 111 #define EoGetDeskNum(eo) (EoGetDesk(eo)->num) 112 #define EoGetLayer(eo) (EoObj(eo)->layer) 113 #define EoGetPixmap(eo) EobjGetPixmap(EoObj(eo)) 114 115 #define EoSetGone(eo) EoObj(eo)->gone = 1 116 #define EoSetSticky(eo, _x) EoObj(eo)->sticky = ((_x)?1:0) 117 #define EoSetFloating(eo, _f) EobjSetFloating(EoObj(eo), (_f)) 118 #define EoSetDesk(eo, _x) EoObj(eo)->desk = (_x) 119 #define EoSetLayer(eo, _l) EobjSetLayer(EoObj(eo), (_l)) 120 #define EoChangeOpacity(eo, _o) EobjChangeOpacity(EoObj(eo), _o) 121 #define EoSetFade(eo, _x) EoObj(eo)->fade = (_x) 122 #define EoSetNoRedirect(eo, _x) EoObj(eo)->noredir = (_x) 123 #define EoSetOpacity(eo, _o) EoObj(eo)->opacity = (_o) 124 #define EoSetShadow(eo, _x) EoObj(eo)->shadow = (_x) 125 #if USE_COMPOSITE 126 #define EoGetOpacity(eo) (EoObj(eo)->opacity) 127 #define EoGetFade(eo) (EoObj(eo)->fade) 128 #define EoChangeShadow(eo, _x) EobjChangeShadow(EoObj(eo), _x) 129 #define EoGetShadow(eo) (EoObj(eo)->shadow) 130 #define EoGetNoRedirect(eo) (EoObj(eo)->noredir) 131 #define EoGetSerial(eo) (EoObj(eo)->serial) 132 #else 133 #define EoGetOpacity(eo) 0xffffffff 134 #define EoGetSerial(eo) 0 135 #endif 136 137 #define EoInit(eo, type, win, x, y, w, h, su, name) \ 138 EobjInit(EoObj(eo), type, win, x, y, w, h, su, name) 139 #define EoFini(eo) EobjFini(EoObj(eo)); 140 #define EoMap(eo, raise) EobjMap(EoObj(eo), raise) 141 #define EoUnmap(eo) EobjUnmap(EoObj(eo)) 142 #define EoMove(eo, x, y) EobjMove(EoObj(eo), x, y) 143 #define EoResize(eo, w, h) EobjResize(EoObj(eo), w, h) 144 #define EoMoveResize(eo, x, y, w, h) EobjMoveResize(EoObj(eo), x, y, w, h) 145 #define EoReparent(eo, d, x, y) EobjReparent(EoObj(eo), d, x, y) 146 #define EoRaise(eo) EobjRaise(EoObj(eo)) 147 #define EoLower(eo) EobjLower(EoObj(eo)) 148 #define EoShapeUpdate(eo, p) EobjShapeUpdate(EoObj(eo), p) 149 150 /* eobj.c */ 151 void EobjInit(EObj * eo, int type, Win win, int x, int y, 152 int w, int h, int su, const char *name); 153 void EobjFini(EObj * eo); 154 void EobjDestroy(EObj * eo); 155 const char *EobjGetNameSafe(const EObj * eo); 156 157 EObj *EobjWindowCreate(int type, int x, int y, int w, int h, 158 int su, const char *name); 159 void EobjWindowDestroy(EObj * eo); 160 161 EObj *EobjRegisterOR(EX_Window xwin, XWindowAttributes * pxwa, 162 int mapped); 163 void EobjUnregister(EObj * eo); 164 165 void EobjMap(EObj * eo, int raise); 166 void EobjUnmap(EObj * eo); 167 void EobjMove(EObj * eo, int x, int y); 168 void EobjResize(EObj * eo, int w, int h); 169 void EobjMoveResize(EObj * eo, int x, int y, int w, int h); 170 void EobjDamage(EObj * eo); 171 void EobjReparent(EObj * eo, EObj * dst, int x, int y); 172 int EobjRaise(EObj * eo); 173 int EobjLower(EObj * eo); 174 void EobjShapeUpdate(EObj * eo, int propagate); 175 void EobjsRepaint(void); 176 EX_Pixmap EobjGetPixmap(const EObj * eo); 177 178 #if USE_GLX 179 void EobjTextureCreate(EObj * eo); 180 void EobjTextureDestroy(EObj * eo); 181 void EobjTextureInvalidate(EObj * eo); 182 struct _glhook *EobjGetTexture(EObj * eo); 183 #endif 184 void EobjChangeOpacityNow(EObj * eo, unsigned int opacity); 185 void EobjChangeOpacity(EObj * eo, unsigned int opacity); 186 void EobjChangeShadow(EObj * eo, int shadow); 187 void EobjSetLayer(EObj * eo, int layer); 188 void EobjSetFloating(EObj * eo, int floating); 189 int EobjIsShaped(const EObj * eo); 190 191 void EobjsOpacityUpdate(int op_or); 192 193 /* stacking.c */ 194 void EobjListStackAdd(EObj * eo, int ontop); 195 void EobjListStackDel(EObj * eo); 196 int EobjListStackRaise(EObj * eo, int test); 197 int EobjListStackLower(EObj * eo, int test); 198 int EobjListStackCheck(EObj * eo); 199 EObj *EobjListStackFind(EX_Window win); 200 EObj *const *EobjListStackGet(int *num); 201 EObj *const *EobjListStackGetForDesk(int *num, Desk * dsk); 202 void EobjListFocusAdd(EObj * eo, int ontop); 203 void EobjListFocusDel(EObj * eo); 204 int EobjListFocusRaise(EObj * eo); 205 void EobjListOrderAdd(EObj * eo); 206 void EobjListOrderDel(EObj * eo); 207 208 /* Hmmm. */ 209 int OpacityFix(int op, int op_0); 210 unsigned int OpacityFromPercent(int op); 211 int OpacityToPercent(unsigned int opacity); 212 213 #endif /* _EOBJ_H_ */ 214