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