xref: /OK3568_Linux_fs/external/xserver/Xext/geext.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun 
3*4882a593Smuzhiyun Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun Permission to use, copy, modify, distribute, and sell this software and its
6*4882a593Smuzhiyun documentation for any purpose is hereby granted without fee, provided that
7*4882a593Smuzhiyun the above copyright notice appear in all copies and that both that
8*4882a593Smuzhiyun copyright notice and this permission notice appear in supporting
9*4882a593Smuzhiyun documentation.
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun The above copyright notice and this permission notice shall be included
12*4882a593Smuzhiyun in all copies or substantial portions of the Software.
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15*4882a593Smuzhiyun OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16*4882a593Smuzhiyun MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17*4882a593Smuzhiyun IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*4882a593Smuzhiyun OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*4882a593Smuzhiyun ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*4882a593Smuzhiyun OTHER DEALINGS IN THE SOFTWARE.
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun Except as contained in this notice, the name of the author shall
23*4882a593Smuzhiyun not be used in advertising or otherwise to promote the sale, use or
24*4882a593Smuzhiyun other dealings in this Software without prior written authorization
25*4882a593Smuzhiyun from the author.
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun */
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #ifdef HAVE_DIX_CONFIG_H
30*4882a593Smuzhiyun #include <dix-config.h>
31*4882a593Smuzhiyun #endif
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #ifndef _GEEXT_H_
34*4882a593Smuzhiyun #define _GEEXT_H_
35*4882a593Smuzhiyun #include <X11/extensions/geproto.h>
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun /** Struct to keep information about registered extensions */
38*4882a593Smuzhiyun typedef struct _GEExtension {
39*4882a593Smuzhiyun     /** Event swapping routine */
40*4882a593Smuzhiyun     void (*evswap) (xGenericEvent *from, xGenericEvent *to);
41*4882a593Smuzhiyun } GEExtension, *GEExtensionPtr;
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /* All registered extensions and their handling functions. */
44*4882a593Smuzhiyun extern _X_EXPORT GEExtension GEExtensions[MAXEXTENSIONS];
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun /* Typecast to generic event */
47*4882a593Smuzhiyun #define GEV(ev) ((xGenericEvent*)(ev))
48*4882a593Smuzhiyun /* Returns the extension offset from the event */
49*4882a593Smuzhiyun #define GEEXT(ev) (GEV(ev)->extension)
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun /* Return zero-based extension offset (offset - 128). Only for use in arrays */
52*4882a593Smuzhiyun #define GEEXTIDX(ev) (GEEXT(ev) & 0x7F)
53*4882a593Smuzhiyun /* True if mask is set for extension on window */
54*4882a593Smuzhiyun #define GEMaskIsSet(pWin, extension, mask) \
55*4882a593Smuzhiyun     ((pWin)->optional && \
56*4882a593Smuzhiyun      (pWin)->optional->geMasks && \
57*4882a593Smuzhiyun      ((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask)))
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun /* Returns first client */
60*4882a593Smuzhiyun #define GECLIENT(pWin) \
61*4882a593Smuzhiyun     (((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL)
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun /* Returns the event_fill for the given event */
64*4882a593Smuzhiyun #define GEEventFill(ev) \
65*4882a593Smuzhiyun     GEExtensions[GEEXTIDX(ev)].evfill
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun #define GEIsType(ev, ext, ev_type) \
68*4882a593Smuzhiyun         ((GEV(ev)->type == GenericEvent) &&  \
69*4882a593Smuzhiyun          GEEXT(ev) == (ext) && \
70*4882a593Smuzhiyun          GEV(ev)->evtype == (ev_type))
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun /* Interface for other extensions */
73*4882a593Smuzhiyun extern _X_EXPORT void GERegisterExtension(int extension,
74*4882a593Smuzhiyun                                           void (*ev_dispatch) (xGenericEvent
75*4882a593Smuzhiyun                                                                *from,
76*4882a593Smuzhiyun                                                                xGenericEvent
77*4882a593Smuzhiyun                                                                *to));
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun extern _X_EXPORT void GEInitEvent(xGenericEvent *ev, int extension);
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun #endif                          /* _GEEXT_H_ */
82