65fea56f17cd614bc8908264df980a62e1931468vboxsync/*
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncCopyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncPermission to use, copy, modify, distribute, and sell this software and its
65fea56f17cd614bc8908264df980a62e1931468vboxsyncdocumentation for any purpose is hereby granted without fee, provided that
65fea56f17cd614bc8908264df980a62e1931468vboxsyncthe above copyright notice appear in all copies and that both that
65fea56f17cd614bc8908264df980a62e1931468vboxsynccopyright notice and this permission notice appear in supporting
65fea56f17cd614bc8908264df980a62e1931468vboxsyncdocumentation.
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncThe above copyright notice and this permission notice shall be included
65fea56f17cd614bc8908264df980a62e1931468vboxsyncin all copies or substantial portions of the Software.
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
65fea56f17cd614bc8908264df980a62e1931468vboxsyncOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
65fea56f17cd614bc8908264df980a62e1931468vboxsyncMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
65fea56f17cd614bc8908264df980a62e1931468vboxsyncIN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
65fea56f17cd614bc8908264df980a62e1931468vboxsyncOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
65fea56f17cd614bc8908264df980a62e1931468vboxsyncARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
65fea56f17cd614bc8908264df980a62e1931468vboxsyncOTHER DEALINGS IN THE SOFTWARE.
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncExcept as contained in this notice, the name of the author shall
65fea56f17cd614bc8908264df980a62e1931468vboxsyncnot be used in advertising or otherwise to promote the sale, use or
65fea56f17cd614bc8908264df980a62e1931468vboxsyncother dealings in this Software without prior written authorization
65fea56f17cd614bc8908264df980a62e1931468vboxsyncfrom the author.
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync*/
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifdef HAVE_DIX_CONFIG_H
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <dix-config.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#ifndef _GEEXT_H_
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define _GEEXT_H_
65fea56f17cd614bc8908264df980a62e1931468vboxsync#include <X11/extensions/geproto.h>
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/** Struct to keep information about registered extensions */
65fea56f17cd614bc8908264df980a62e1931468vboxsynctypedef struct _GEExtension {
65fea56f17cd614bc8908264df980a62e1931468vboxsync /** Event swapping routine */
65fea56f17cd614bc8908264df980a62e1931468vboxsync void (*evswap) (xGenericEvent *from, xGenericEvent *to);
65fea56f17cd614bc8908264df980a62e1931468vboxsync} GEExtension, *GEExtensionPtr;
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* All registered extensions and their handling functions. */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS];
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Typecast to generic event */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define GEV(ev) ((xGenericEvent*)(ev))
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Returns the extension offset from the event */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define GEEXT(ev) (GEV(ev)->extension)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Return zero-based extension offset (offset - 128). Only for use in arrays */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F)
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* True if mask is set for extension on window */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define GEMaskIsSet(pWin, extension, mask) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync ((pWin)->optional && \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (pWin)->optional->geMasks && \
65fea56f17cd614bc8908264df980a62e1931468vboxsync ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask)))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Returns first client */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define GECLIENT(pWin) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL)
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Returns the event_fill for the given event */
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define GEEventFill(ev) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync GEExtensions[GEEXTIDX(ev)].evfill
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#define GEIsType(ev, ext, ev_type) \
65fea56f17cd614bc8908264df980a62e1931468vboxsync ((GEV(ev)->type == GenericEvent) && \
65fea56f17cd614bc8908264df980a62e1931468vboxsync GEEXT(ev) == (ext) && \
65fea56f17cd614bc8908264df980a62e1931468vboxsync GEV(ev)->evtype == (ev_type))
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync/* Interface for other extensions */
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void GERegisterExtension(int extension,
65fea56f17cd614bc8908264df980a62e1931468vboxsync void (*ev_dispatch) (xGenericEvent
65fea56f17cd614bc8908264df980a62e1931468vboxsync *from,
65fea56f17cd614bc8908264df980a62e1931468vboxsync xGenericEvent
65fea56f17cd614bc8908264df980a62e1931468vboxsync *to));
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsyncextern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension);
65fea56f17cd614bc8908264df980a62e1931468vboxsync
65fea56f17cd614bc8908264df980a62e1931468vboxsync#endif /* _GEEXT_H_ */