1706f2543Smrg/* 2706f2543Smrg 3706f2543SmrgCopyright 2007 Peter Hutterer <peter@cs.unisa.edu.au> 4706f2543Smrg 5706f2543SmrgPermission to use, copy, modify, distribute, and sell this software and its 6706f2543Smrgdocumentation for any purpose is hereby granted without fee, provided that 7706f2543Smrgthe above copyright notice appear in all copies and that both that 8706f2543Smrgcopyright notice and this permission notice appear in supporting 9706f2543Smrgdocumentation. 10706f2543Smrg 11706f2543SmrgThe above copyright notice and this permission notice shall be included 12706f2543Smrgin all copies or substantial portions of the Software. 13706f2543Smrg 14706f2543SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15706f2543SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16706f2543SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17706f2543SmrgIN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR 18706f2543SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19706f2543SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20706f2543SmrgOTHER DEALINGS IN THE SOFTWARE. 21706f2543Smrg 22706f2543SmrgExcept as contained in this notice, the name of the author shall 23706f2543Smrgnot be used in advertising or otherwise to promote the sale, use or 24706f2543Smrgother dealings in this Software without prior written authorization 25706f2543Smrgfrom the author. 26706f2543Smrg 27706f2543Smrg*/ 28706f2543Smrg 29706f2543Smrg#ifdef HAVE_DIX_CONFIG_H 30706f2543Smrg#include <dix-config.h> 31706f2543Smrg#endif 32706f2543Smrg 33706f2543Smrg#ifndef _GEEXT_H_ 34706f2543Smrg#define _GEEXT_H_ 35706f2543Smrg#include <X11/extensions/geproto.h> 36706f2543Smrg 37706f2543Smrg/** Struct to keep information about registered extensions */ 38706f2543Smrgtypedef struct _GEExtension { 39706f2543Smrg /** Event swapping routine */ 40706f2543Smrg void (*evswap)(xGenericEvent* from, xGenericEvent* to); 41706f2543Smrg} GEExtension, *GEExtensionPtr; 42706f2543Smrg 43706f2543Smrg 44706f2543Smrg/* All registered extensions and their handling functions. */ 45706f2543Smrgextern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS]; 46706f2543Smrg 47706f2543Smrg/* Typecast to generic event */ 48706f2543Smrg#define GEV(ev) ((xGenericEvent*)(ev)) 49706f2543Smrg/* Returns the extension offset from the event */ 50706f2543Smrg#define GEEXT(ev) (GEV(ev)->extension) 51706f2543Smrg 52706f2543Smrg/* Return zero-based extension offset (offset - 128). Only for use in arrays */ 53706f2543Smrg#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F) 54706f2543Smrg/* True if mask is set for extension on window */ 55706f2543Smrg#define GEMaskIsSet(pWin, extension, mask) \ 56706f2543Smrg ((pWin)->optional && \ 57706f2543Smrg (pWin)->optional->geMasks && \ 58706f2543Smrg ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask))) 59706f2543Smrg 60706f2543Smrg/* Returns first client */ 61706f2543Smrg#define GECLIENT(pWin) \ 62706f2543Smrg (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL) 63706f2543Smrg 64706f2543Smrg/* Returns the event_fill for the given event */ 65706f2543Smrg#define GEEventFill(ev) \ 66706f2543Smrg GEExtensions[GEEXTIDX(ev)].evfill 67706f2543Smrg 68706f2543Smrg#define GEIsType(ev, ext, ev_type) \ 69706f2543Smrg ((GEV(ev)->type == GenericEvent) && \ 70706f2543Smrg GEEXT(ev) == (ext) && \ 71706f2543Smrg GEV(ev)->evtype == (ev_type)) 72706f2543Smrg 73706f2543Smrg 74706f2543Smrg/* Interface for other extensions */ 75706f2543Smrgextern _X_EXPORT void GERegisterExtension( 76706f2543Smrg int extension, 77706f2543Smrg void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to)); 78706f2543Smrg 79706f2543Smrgextern _X_EXPORT void GEInitEvent(xGenericEvent* ev, int extension); 80706f2543Smrg 81706f2543Smrgextern _X_EXPORT void GEExtensionInit(void); 82706f2543Smrg 83706f2543Smrg#endif /* _GEEXT_H_ */ 84