1 | /**
|
---|
2 | * Copyright © 2009 Red Hat, Inc.
|
---|
3 | *
|
---|
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:
|
---|
10 | *
|
---|
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
|
---|
13 | * Software.
|
---|
14 | *
|
---|
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.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #ifdef HAVE_DIX_CONFIG_H
|
---|
25 | #include <dix-config.h>
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #include "scrnintstr.h"
|
---|
29 | #include "windowstr.h"
|
---|
30 | #include "scrnintstr.h"
|
---|
31 | #include "exevents.h"
|
---|
32 |
|
---|
33 | #ifndef PROTOCOL_COMMON_H
|
---|
34 | #define PROTOCOL_COMMON_H
|
---|
35 |
|
---|
36 | extern int BadDevice;
|
---|
37 |
|
---|
38 | /* Check default values in a reply */
|
---|
39 | #define reply_check_defaults(rep, len, type) \
|
---|
40 | { \
|
---|
41 | g_assert((len) >= sz_x##type##Reply); \
|
---|
42 | g_assert((rep)->repType == X_Reply); \
|
---|
43 | g_assert((rep)->RepType == X_##type); \
|
---|
44 | g_assert((rep)->sequenceNumber == CLIENT_SEQUENCE); \
|
---|
45 | g_assert((rep)->length >= (sz_x##type##Reply - 32)/4); \
|
---|
46 | }
|
---|
47 |
|
---|
48 | /* initialise default values for request */
|
---|
49 | #define request_init(req, type) \
|
---|
50 | { \
|
---|
51 | (req)->reqType = 128; /* doesn't matter */ \
|
---|
52 | (req)->ReqType = X_##type; \
|
---|
53 | (req)->length = (sz_x##type##Req >> 2); \
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | /* Various defines used in the tests. Some tests may use different values
|
---|
58 | * than these defaults */
|
---|
59 | /* default client index */
|
---|
60 | #define CLIENT_INDEX 1
|
---|
61 | /* default client mask for resources and windows */
|
---|
62 | #define CLIENT_MASK ((CLIENT_INDEX) << CLIENTOFFSET)
|
---|
63 | /* default client sequence number for replies */
|
---|
64 | #define CLIENT_SEQUENCE 0x100
|
---|
65 | /* default root window id */
|
---|
66 | #define ROOT_WINDOW_ID 0x10
|
---|
67 | /* default client window id */
|
---|
68 | #define CLIENT_WINDOW_ID 0x100001
|
---|
69 |
|
---|
70 | /* Various structs used throughout the tests */
|
---|
71 |
|
---|
72 |
|
---|
73 | /* The default devices struct, contains one pointer + keyboard and the
|
---|
74 | * matching master devices. Initialize with init_devices() if needed. */
|
---|
75 | struct devices {
|
---|
76 | DeviceIntPtr vcp;
|
---|
77 | DeviceIntPtr vck;
|
---|
78 | DeviceIntPtr mouse;
|
---|
79 | DeviceIntPtr kbd;
|
---|
80 |
|
---|
81 | int num_devices;
|
---|
82 | int num_master_devices;
|
---|
83 | } devices;
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * The set of default devices available in all tests if necessary.
|
---|
87 | */
|
---|
88 | extern struct devices devices;
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * test-specific userdata, passed into the reply handler.
|
---|
92 | */
|
---|
93 | extern void *userdata;
|
---|
94 | /**
|
---|
95 | * The reply handler called from WriteToClient. Set this handler if you need
|
---|
96 | * to check the reply values.
|
---|
97 | */
|
---|
98 | void (*reply_handler)(ClientPtr client, int len, char *data, void *userdata);
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Semi-initialized root window. initialized by init().
|
---|
102 | */
|
---|
103 | extern WindowRec root;
|
---|
104 | /**
|
---|
105 | * Semi-initialized top-level window. initialized by init().
|
---|
106 | */
|
---|
107 | extern WindowRec window;
|
---|
108 |
|
---|
109 | /* various simple functions for quick setup */
|
---|
110 | /**
|
---|
111 | * Initialize the above struct with default devices and return the struct.
|
---|
112 | * Usually not needed if you call ::init_simple.
|
---|
113 | */
|
---|
114 | struct devices init_devices(void);
|
---|
115 | /**
|
---|
116 | * Init a mostly zeroed out client with default values for index and mask.
|
---|
117 | */
|
---|
118 | ClientRec init_client(int request_len, void *request_data);
|
---|
119 | /**
|
---|
120 | * Init a mostly zeroed out window with the given window ID.
|
---|
121 | * Usually not needed if you call ::init_simple which sets up root and
|
---|
122 | * window.
|
---|
123 | */
|
---|
124 | void init_window(WindowPtr window, WindowPtr parent, int id);
|
---|
125 | /**
|
---|
126 | * Create a very simple setup that provides the minimum values for most
|
---|
127 | * tests, including a screen, the root and client window and the default
|
---|
128 | * device setup.
|
---|
129 | */
|
---|
130 | void init_simple(void);
|
---|
131 |
|
---|
132 | /* Declarations for various overrides in the test files. */
|
---|
133 | void __wrap_WriteToClient(ClientPtr client, int len, void *data);
|
---|
134 | void __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask);
|
---|
135 | int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
|
---|
136 | int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
|
---|
137 | Bool __wrap_AddResource(XID id, RESTYPE type, pointer value);
|
---|
138 | int __wrap_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
|
---|
139 | int __real_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
|
---|
140 |
|
---|
141 |
|
---|
142 | #endif /* PROTOCOL_COMMON_H */
|
---|
143 |
|
---|