| 1 | /* |
| 2 | |
| 3 | Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au> |
| 4 | |
| 5 | Permission to use, copy, modify, distribute, and sell this software and its |
| 6 | documentation for any purpose is hereby granted without fee, provided that |
| 7 | the above copyright notice appear in all copies and that both that |
| 8 | copyright notice and this permission notice appear in supporting |
| 9 | documentation. |
| 10 | |
| 11 | The above copyright notice and this permission notice shall be included |
| 12 | in all copies or substantial portions of the Software. |
| 13 | |
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 17 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | OTHER DEALINGS IN THE SOFTWARE. |
| 21 | |
| 22 | Except as contained in this notice, the name of the author shall |
| 23 | not be used in advertising or otherwise to promote the sale, use or |
| 24 | other dealings in this Software without prior written authorization |
| 25 | from the author. |
| 26 | |
| 27 | */ |
| 28 | |
| 29 | #ifdef HAVE_DIX_CONFIG_H |
| 30 | #include <dix-config.h> |
| 31 | #endif |
| 32 | |
| 33 | #ifndef _GEEXT_H_ |
| 34 | #define _GEEXT_H_ |
| 35 | #include <X11/extensions/geproto.h> |
| 36 | |
| 37 | /** Struct to keep information about registered extensions */ |
| 38 | typedef struct _GEExtension { |
| 39 | /** Event swapping routine */ |
| 40 | void (*evswap) (xGenericEvent *from, xGenericEvent *to); |
| 41 | } GEExtension, *GEExtensionPtr; |
| 42 | |
| 43 | /* All registered extensions and their handling functions. */ |
| 44 | extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS]; |
| 45 | |
| 46 | /* Typecast to generic event */ |
| 47 | #define GEV(ev) ((xGenericEvent*)(ev)) |
| 48 | /* Returns the extension offset from the event */ |
| 49 | #define GEEXT(ev) (GEV(ev)->extension) |
| 50 | |
| 51 | /* Return zero-based extension offset (offset - 128). Only for use in arrays */ |
| 52 | #define GEEXTIDX(ev) (GEEXT(ev) & 0x7F) |
| 53 | /* True if mask is set for extension on window */ |
| 54 | #define GEMaskIsSet(pWin, extension, mask) \ |
| 55 | ((pWin)->optional && \ |
| 56 | (pWin)->optional->geMasks && \ |
| 57 | ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask))) |
| 58 | |
| 59 | /* Returns first client */ |
| 60 | #define GECLIENT(pWin) \ |
| 61 | (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL) |
| 62 | |
| 63 | /* Returns the event_fill for the given event */ |
| 64 | #define GEEventFill(ev) \ |
| 65 | GEExtensions[GEEXTIDX(ev)].evfill |
| 66 | |
| 67 | #define GEIsType(ev, ext, ev_type) \ |
| 68 | ((GEV(ev)->type == GenericEvent) && \ |
| 69 | GEEXT(ev) == (ext) && \ |
| 70 | GEV(ev)->evtype == (ev_type)) |
| 71 | |
| 72 | /* Interface for other extensions */ |
| 73 | extern _X_EXPORT void GERegisterExtension(int extension, |
| 74 | void (*ev_dispatch) (xGenericEvent |
| 75 | *from, |
| 76 | xGenericEvent |
| 77 | *to)); |
| 78 | |
| 79 | extern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension); |
| 80 | |
| 81 | #endif /* _GEEXT_H_ */ |