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