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>
29 * Protocol testing for XIQueryPointer request.
33 #include <X11/Xproto.h>
34 #include <X11/extensions/XI2proto.h>
36 #include "windowstr.h"
37 #include "scrnintstr.h"
38 #include "xiquerypointer.h"
40 #include "exglobals.h"
42 #include "protocol-common.h"
44 static ClientRec client_request
;
45 static void reply_XIQueryPointer_data(ClientPtr client
, int len
,
46 char *data
, void *closure
);
53 /* dixLookupWindow requires a lot of setup not necessary for this test.
54 * Simple wrapper that returns either one of the fake root window or the
55 * fake client window. If the requested ID is neither of those wanted,
56 * return whatever the real dixLookupWindow does.
59 __wrap_dixLookupWindow(WindowPtr
*win
, XID id
, ClientPtr client
, Mask access
)
61 if (id
== root
.drawable
.id
) {
65 else if (id
== window
.drawable
.id
) {
70 return __real_dixLookupWindow(win
, id
, client
, access
);
74 reply_XIQueryPointer(ClientPtr client
, int len
, char *data
, void *closure
)
76 xXIQueryPointerReply
*rep
= (xXIQueryPointerReply
*) data
;
82 if (client
->swapped
) {
84 swaps(&rep
->sequenceNumber
);
91 swaps(&rep
->buttons_len
);
94 reply_check_defaults(rep
, len
, XIQueryPointer
);
96 assert(rep
->root
== root
.drawable
.id
);
97 assert(rep
->same_screen
== xTrue
);
99 sprite
= test_data
.dev
->spriteInfo
->sprite
;
100 assert((rep
->root_x
>> 16) == sprite
->hot
.x
);
101 assert((rep
->root_y
>> 16) == sprite
->hot
.y
);
103 if (test_data
.win
== &root
) {
104 assert(rep
->root_x
== rep
->win_x
);
105 assert(rep
->root_y
== rep
->win_y
);
106 assert(rep
->child
== window
.drawable
.id
);
111 x
= sprite
->hot
.x
- window
.drawable
.x
;
112 y
= sprite
->hot
.y
- window
.drawable
.y
;
114 assert((rep
->win_x
>> 16) == x
);
115 assert((rep
->win_y
>> 16) == y
);
116 assert(rep
->child
== None
);
119 assert(rep
->same_screen
== xTrue
);
121 reply_handler
= reply_XIQueryPointer_data
;
125 reply_XIQueryPointer_data(ClientPtr client
, int len
, char *data
, void *closure
)
127 reply_handler
= reply_XIQueryPointer
;
131 request_XIQueryPointer(ClientPtr client
, xXIQueryPointerReq
* req
, int error
)
135 rc
= ProcXIQueryPointer(&client_request
);
139 assert(client_request
.errorValue
== req
->deviceid
);
141 client_request
.swapped
= TRUE
;
142 swaps(&req
->deviceid
);
144 rc
= SProcXIQueryPointer(&client_request
);
148 assert(client_request
.errorValue
== req
->deviceid
);
152 test_XIQueryPointer(void)
155 xXIQueryPointerReq request
;
157 memset(&request
, 0, sizeof(request
));
159 request_init(&request
, XIQueryPointer
);
161 reply_handler
= reply_XIQueryPointer
;
163 client_request
= init_client(request
.length
, &request
);
165 request
.deviceid
= XIAllDevices
;
166 request_XIQueryPointer(&client_request
, &request
, BadDevice
);
168 request
.deviceid
= XIAllMasterDevices
;
169 request_XIQueryPointer(&client_request
, &request
, BadDevice
);
171 request
.win
= root
.drawable
.id
;
172 test_data
.win
= &root
;
174 test_data
.dev
= devices
.vcp
;
175 request
.deviceid
= devices
.vcp
->id
;
176 request_XIQueryPointer(&client_request
, &request
, Success
);
177 request
.deviceid
= devices
.vck
->id
;
178 request_XIQueryPointer(&client_request
, &request
, BadDevice
);
179 request
.deviceid
= devices
.mouse
->id
;
180 request_XIQueryPointer(&client_request
, &request
, BadDevice
);
181 request
.deviceid
= devices
.kbd
->id
;
182 request_XIQueryPointer(&client_request
, &request
, BadDevice
);
184 test_data
.dev
= devices
.mouse
;
185 devices
.mouse
->master
= NULL
; /* Float, kind-of */
186 request
.deviceid
= devices
.mouse
->id
;
187 request_XIQueryPointer(&client_request
, &request
, Success
);
189 for (i
= devices
.kbd
->id
+ 1; i
<= 0xFFFF; i
++) {
190 request
.deviceid
= i
;
191 request_XIQueryPointer(&client_request
, &request
, BadDevice
);
194 request
.win
= window
.drawable
.id
;
196 test_data
.dev
= devices
.vcp
;
197 test_data
.win
= &window
;
198 request
.deviceid
= devices
.vcp
->id
;
199 request_XIQueryPointer(&client_request
, &request
, Success
);
201 test_data
.dev
= devices
.mouse
;
202 request
.deviceid
= devices
.mouse
->id
;
203 request_XIQueryPointer(&client_request
, &request
, Success
);
207 main(int argc
, char **argv
)
211 test_XIQueryPointer();