geext.h revision 35c4bbdf
14642e01fSmrg/* 24642e01fSmrg 34642e01fSmrgCopyright 2007 Peter Hutterer <peter@cs.unisa.edu.au> 44642e01fSmrg 54642e01fSmrgPermission to use, copy, modify, distribute, and sell this software and its 64642e01fSmrgdocumentation for any purpose is hereby granted without fee, provided that 74642e01fSmrgthe above copyright notice appear in all copies and that both that 84642e01fSmrgcopyright notice and this permission notice appear in supporting 94642e01fSmrgdocumentation. 104642e01fSmrg 114642e01fSmrgThe above copyright notice and this permission notice shall be included 124642e01fSmrgin all copies or substantial portions of the Software. 134642e01fSmrg 144642e01fSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 154642e01fSmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 164642e01fSmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 174642e01fSmrgIN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR 184642e01fSmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 194642e01fSmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 204642e01fSmrgOTHER DEALINGS IN THE SOFTWARE. 214642e01fSmrg 224642e01fSmrgExcept as contained in this notice, the name of the author shall 234642e01fSmrgnot be used in advertising or otherwise to promote the sale, use or 244642e01fSmrgother dealings in this Software without prior written authorization 254642e01fSmrgfrom the author. 264642e01fSmrg 274642e01fSmrg*/ 284642e01fSmrg 294642e01fSmrg#ifdef HAVE_DIX_CONFIG_H 304642e01fSmrg#include <dix-config.h> 314642e01fSmrg#endif 324642e01fSmrg 334642e01fSmrg#ifndef _GEEXT_H_ 344642e01fSmrg#define _GEEXT_H_ 354642e01fSmrg#include <X11/extensions/geproto.h> 364642e01fSmrg 376747b715Smrg/** Struct to keep information about registered extensions */ 384642e01fSmrgtypedef struct _GEExtension { 396747b715Smrg /** Event swapping routine */ 4035c4bbdfSmrg void (*evswap) (xGenericEvent *from, xGenericEvent *to); 414642e01fSmrg} GEExtension, *GEExtensionPtr; 424642e01fSmrg 434642e01fSmrg/* All registered extensions and their handling functions. */ 446747b715Smrgextern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS]; 454642e01fSmrg 466747b715Smrg/* Typecast to generic event */ 476747b715Smrg#define GEV(ev) ((xGenericEvent*)(ev)) 484642e01fSmrg/* Returns the extension offset from the event */ 496747b715Smrg#define GEEXT(ev) (GEV(ev)->extension) 504642e01fSmrg 516747b715Smrg/* Return zero-based extension offset (offset - 128). Only for use in arrays */ 524642e01fSmrg#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F) 534642e01fSmrg/* True if mask is set for extension on window */ 544642e01fSmrg#define GEMaskIsSet(pWin, extension, mask) \ 554642e01fSmrg ((pWin)->optional && \ 564642e01fSmrg (pWin)->optional->geMasks && \ 574642e01fSmrg ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask))) 584642e01fSmrg 594642e01fSmrg/* Returns first client */ 604642e01fSmrg#define GECLIENT(pWin) \ 614642e01fSmrg (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL) 624642e01fSmrg 634642e01fSmrg/* Returns the event_fill for the given event */ 644642e01fSmrg#define GEEventFill(ev) \ 656747b715Smrg GEExtensions[GEEXTIDX(ev)].evfill 664642e01fSmrg 674642e01fSmrg#define GEIsType(ev, ext, ev_type) \ 686747b715Smrg ((GEV(ev)->type == GenericEvent) && \ 696747b715Smrg GEEXT(ev) == (ext) && \ 706747b715Smrg GEV(ev)->evtype == (ev_type)) 714642e01fSmrg 724642e01fSmrg/* Interface for other extensions */ 7335c4bbdfSmrgextern _X_EXPORT void GERegisterExtension(int extension, 7435c4bbdfSmrg void (*ev_dispatch) (xGenericEvent 7535c4bbdfSmrg *from, 7635c4bbdfSmrg xGenericEvent 7735c4bbdfSmrg *to)); 784642e01fSmrg 7935c4bbdfSmrgextern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension); 804642e01fSmrg 8135c4bbdfSmrg#endif /* _GEEXT_H_ */ 82