geext.h revision 4642e01f
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 38/** 39 * This struct is used both in the window and by grabs to determine the event 40 * mask for a client. 41 * A window will have a linked list of these structs, with one entry per 42 * client per device, null-terminated. 43 * A grab has only one instance of this struct. 44 */ 45typedef struct _GenericMaskRec { 46 struct _GenericMaskRec* next; 47 XID resource; /* id for the resource manager */ 48 DeviceIntPtr dev; 49 Mask eventMask[MAXEXTENSIONS]; /* one mask per extension */ 50} GenericMaskRec, *GenericMaskPtr; 51 52 53/* Struct to keep information about registered extensions 54 * 55 * evswap ... use to swap event fields for different byte ordered clients. 56 * evfill ... use to fill various event fields from the given parameters. 57 */ 58typedef struct _GEExtension { 59 void (*evswap)(xGenericEvent* from, xGenericEvent* to); 60 void (*evfill)(xGenericEvent* ev, 61 DeviceIntPtr pDev, /* device */ 62 WindowPtr pWin, /* event window */ 63 GrabPtr pGrab /* current grab, may be NULL */ 64 ); 65} GEExtension, *GEExtensionPtr; 66 67 68/* All registered extensions and their handling functions. */ 69extern GEExtension GEExtensions[MAXEXTENSIONS]; 70 71/* Returns the extension offset from the event */ 72#define GEEXT(ev) (((xGenericEvent*)(ev))->extension) 73 74#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F) 75/* Typecast to generic event */ 76#define GEV(ev) ((xGenericEvent*)(ev)) 77/* True if mask is set for extension on window */ 78#define GEMaskIsSet(pWin, extension, mask) \ 79 ((pWin)->optional && \ 80 (pWin)->optional->geMasks && \ 81 ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask))) 82 83/* Returns first client */ 84#define GECLIENT(pWin) \ 85 (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL) 86 87/* Returns the event_fill for the given event */ 88#define GEEventFill(ev) \ 89 GEExtensions[GEEXTIDX(xE)].evfill 90 91#define GEIsType(ev, ext, ev_type) \ 92 ((ev->u.u.type == GenericEvent) && \ 93 ((xGenericEvent*)(ev))->extension == ext && \ 94 ((xGenericEvent*)(ev))->evtype == ev_type) 95 96 97/* Interface for other extensions */ 98void GEWindowSetMask(ClientPtr pClient, DeviceIntPtr pDev, 99 WindowPtr pWin, int extension, Mask mask); 100 101void GERegisterExtension( 102 int extension, 103 void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to), 104 void (*ev_fill)(xGenericEvent* ev, DeviceIntPtr pDev, 105 WindowPtr pWin, GrabPtr pGrab) 106 ); 107 108void GEInitEvent(xGenericEvent* ev, int extension); 109BOOL GEDeviceMaskIsSet(WindowPtr pWin, DeviceIntPtr pDev, 110 int extension, Mask mask); 111 112void GEExtensionInit(void); 113 114#endif /* _GEEXT_H_ */ 115