1 | /*
|
---|
2 |
|
---|
3 | Copyright 2007 Peter Hutterer <[email protected]>
|
---|
4 |
|
---|
5 | Permission to use, copy, modify, distribute, and sell this software and its
|
---|
6 | documentation for any purpose is hereby granted without fee, provided that
|
---|
7 | the above copyright notice appear in all copies and that both that
|
---|
8 | copyright notice and this permission notice appear in supporting
|
---|
9 | documentation.
|
---|
10 |
|
---|
11 | The above copyright notice and this permission notice shall be included
|
---|
12 | in all copies or substantial portions of the Software.
|
---|
13 |
|
---|
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
15 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
---|
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
---|
17 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
18 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
19 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
20 | OTHER DEALINGS IN THE SOFTWARE.
|
---|
21 |
|
---|
22 | Except as contained in this notice, the name of the author shall
|
---|
23 | not be used in advertising or otherwise to promote the sale, use or
|
---|
24 | other dealings in this Software without prior written authorization
|
---|
25 | from 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 | */
|
---|
45 | typedef 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 | */
|
---|
58 | typedef 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. */
|
---|
69 | extern 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 */
|
---|
98 | void GEWindowSetMask(ClientPtr pClient, DeviceIntPtr pDev,
|
---|
99 | WindowPtr pWin, int extension, Mask mask);
|
---|
100 |
|
---|
101 | void 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 |
|
---|
108 | void GEInitEvent(xGenericEvent* ev, int extension);
|
---|
109 | BOOL GEDeviceMaskIsSet(WindowPtr pWin, DeviceIntPtr pDev,
|
---|
110 | int extension, Mask mask);
|
---|
111 |
|
---|
112 | void GEExtensionInit(void);
|
---|
113 |
|
---|
114 | #endif /* _GEEXT_H_ */
|
---|