Imported Upstream version 1.15.1
[deb_xorg-server.git] / Xext / geext.h
CommitLineData
a09e091a
JB
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/** Struct to keep information about registered extensions */
38typedef struct _GEExtension {
39 /** Event swapping routine */
40 void (*evswap) (xGenericEvent *from, xGenericEvent *to);
41} GEExtension, *GEExtensionPtr;
42
43/* All registered extensions and their handling functions. */
44extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS];
45
46/* Typecast to generic event */
47#define GEV(ev) ((xGenericEvent*)(ev))
48/* Returns the extension offset from the event */
49#define GEEXT(ev) (GEV(ev)->extension)
50
51/* Return zero-based extension offset (offset - 128). Only for use in arrays */
52#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F)
53/* True if mask is set for extension on window */
54#define GEMaskIsSet(pWin, extension, mask) \
55 ((pWin)->optional && \
56 (pWin)->optional->geMasks && \
57 ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask)))
58
59/* Returns first client */
60#define GECLIENT(pWin) \
61 (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL)
62
63/* Returns the event_fill for the given event */
64#define GEEventFill(ev) \
65 GEExtensions[GEEXTIDX(ev)].evfill
66
67#define GEIsType(ev, ext, ev_type) \
68 ((GEV(ev)->type == GenericEvent) && \
69 GEEXT(ev) == (ext) && \
70 GEV(ev)->evtype == (ev_type))
71
72/* Interface for other extensions */
73extern _X_EXPORT void GERegisterExtension(int extension,
74 void (*ev_dispatch) (xGenericEvent
75 *from,
76 xGenericEvent
77 *to));
78
79extern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension);
80
81#endif /* _GEEXT_H_ */