2 * Copyright © 2009 Red Hat, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #ifdef HAVE_DIX_CONFIG_H
25 #include <dix-config.h>
28 #include "scrnintstr.h"
29 #include "windowstr.h"
33 #ifndef PROTOCOL_COMMON_H
34 #define PROTOCOL_COMMON_H
36 /* Check default values in a reply */
37 #define reply_check_defaults(rep, len, type) \
39 assert((len) >= sz_x##type##Reply); \
40 assert((rep)->repType == X_Reply); \
41 assert((rep)->RepType == X_##type); \
42 assert((rep)->sequenceNumber == CLIENT_SEQUENCE); \
43 assert((rep)->length >= (sz_x##type##Reply - 32)/4); \
46 /* initialise default values for request */
47 #define request_init(req, type) \
49 (req)->reqType = 128; /* doesn't matter */ \
50 (req)->ReqType = X_##type; \
51 (req)->length = (sz_x##type##Req >> 2); \
54 /* Various defines used in the tests. Some tests may use different values
55 * than these defaults */
56 /* default client index */
57 #define CLIENT_INDEX 1
58 /* default client mask for resources and windows */
59 #define CLIENT_MASK ((CLIENT_INDEX) << CLIENTOFFSET)
60 /* default client sequence number for replies */
61 #define CLIENT_SEQUENCE 0x100
62 /* default root window id */
63 #define ROOT_WINDOW_ID 0x10
64 /* default client window id */
65 #define CLIENT_WINDOW_ID 0x100001
66 /* invalid window ID. use for BadWindow checks. */
67 #define INVALID_WINDOW_ID 0x111111
68 /* initial fake sprite position */
72 /* Various structs used throughout the tests */
74 /* The default devices struct, contains one pointer + keyboard and the
75 * matching master devices. Initialize with init_devices() if needed. */
83 int num_master_devices
;
87 * The set of default devices available in all tests if necessary.
89 extern struct devices devices
;
92 * test-specific userdata, passed into the reply handler.
94 extern void *userdata
;
97 * The reply handler called from WriteToClient. Set this handler if you need
98 * to check the reply values.
100 void (*reply_handler
) (ClientPtr client
, int len
, char *data
, void *userdata
);
103 * The default screen used for the windows. Initialized by init_simple().
105 extern ScreenRec screen
;
108 * Semi-initialized root window. initialized by init().
110 extern WindowRec root
;
113 * Semi-initialized top-level window. initialized by init().
115 extern WindowRec window
;
117 /* various simple functions for quick setup */
119 * Initialize the above struct with default devices and return the struct.
120 * Usually not needed if you call ::init_simple.
122 struct devices
init_devices(void);
125 * Init a mostly zeroed out client with default values for index and mask.
127 ClientRec
init_client(int request_len
, void *request_data
);
130 * Init a mostly zeroed out window with the given window ID.
131 * Usually not needed if you call ::init_simple which sets up root and
134 void init_window(WindowPtr window
, WindowPtr parent
, int id
);
137 * Create a very simple setup that provides the minimum values for most
138 * tests, including a screen, the root and client window and the default
141 void init_simple(void);
143 /* Declarations for various overrides in the test files. */
144 void __wrap_WriteToClient(ClientPtr client
, int len
, void *data
);
145 int __wrap_XISetEventMask(DeviceIntPtr dev
, WindowPtr win
, int len
,
146 unsigned char *mask
);
147 int __wrap_dixLookupWindow(WindowPtr
*win
, XID id
, ClientPtr client
,
149 int __real_dixLookupWindow(WindowPtr
*win
, XID id
, ClientPtr client
,
151 Bool
__wrap_AddResource(XID id
, RESTYPE type
, pointer value
);
152 int __wrap_dixLookupClient(ClientPtr
*c
, XID id
, ClientPtr client
, Mask access
);
153 int __real_dixLookupClient(ClientPtr
*c
, XID id
, ClientPtr client
, Mask access
);
155 #endif /* PROTOCOL_COMMON_H */