2010-07-27 13:02:24 -06:00
|
|
|
/**
|
|
|
|
* Copyright © 2009 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Protocol testing for XISetClientPointer request.
|
|
|
|
*
|
|
|
|
* Tests include:
|
|
|
|
* BadDevice of all devices except master pointers.
|
|
|
|
* Success for a valid window.
|
|
|
|
* Success for window None.
|
|
|
|
* BadWindow for invalid windows.
|
|
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include <X11/extensions/XI2proto.h>
|
|
|
|
#include "inputstr.h"
|
|
|
|
#include "windowstr.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "extinit.h" /* for XInputExtensionInit */
|
2010-07-27 13:02:24 -06:00
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "xisetclientpointer.h"
|
|
|
|
#include "exevents.h"
|
2013-06-07 11:28:45 -06:00
|
|
|
#include "exglobals.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
#include "protocol-common.h"
|
|
|
|
|
2020-04-13 02:06:58 -06:00
|
|
|
extern ClientRec client_window;
|
2010-07-27 13:02:24 -06:00
|
|
|
static ClientRec client_request;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
request_XISetClientPointer(xXISetClientPointerReq * req, int error)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int rc;
|
2012-06-10 07:21:05 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
client_request = init_client(req->length, req);
|
|
|
|
|
|
|
|
rc = ProcXISetClientPointer(&client_request);
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(rc == error);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (rc == BadDevice)
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(client_request.errorValue == req->deviceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
client_request.swapped = TRUE;
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&req->win);
|
|
|
|
swaps(&req->length);
|
|
|
|
swaps(&req->deviceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
rc = SProcXISetClientPointer(&client_request);
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(rc == error);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
if (rc == BadDevice)
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(client_request.errorValue == req->deviceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
test_XISetClientPointer(void)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
xXISetClientPointerReq request;
|
|
|
|
|
|
|
|
request_init(&request, XISetClientPointer);
|
|
|
|
|
|
|
|
request.win = CLIENT_WINDOW_ID;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
printf("Testing BadDevice error for XIAllDevices and XIMasterDevices.\n");
|
2010-07-27 13:02:24 -06:00
|
|
|
request.deviceid = XIAllDevices;
|
|
|
|
request_XISetClientPointer(&request, BadDevice);
|
|
|
|
|
|
|
|
request.deviceid = XIAllMasterDevices;
|
|
|
|
request_XISetClientPointer(&request, BadDevice);
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
printf("Testing Success for VCP and VCK.\n");
|
2010-07-27 13:02:24 -06:00
|
|
|
request.deviceid = devices.vcp->id; /* 2 */
|
|
|
|
request_XISetClientPointer(&request, Success);
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(client_window.clientPtr->id == 2);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
request.deviceid = devices.vck->id; /* 3 */
|
|
|
|
request_XISetClientPointer(&request, Success);
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(client_window.clientPtr->id == 2);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
printf("Testing BadDevice error for all other devices.\n");
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = 4; i <= 0xFFFF; i++) {
|
2010-07-27 13:02:24 -06:00
|
|
|
request.deviceid = i;
|
|
|
|
request_XISetClientPointer(&request, BadDevice);
|
|
|
|
}
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
printf("Testing window None\n");
|
2010-07-27 13:02:24 -06:00
|
|
|
request.win = None;
|
|
|
|
request.deviceid = devices.vcp->id; /* 2 */
|
|
|
|
request_XISetClientPointer(&request, Success);
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(client_request.clientPtr->id == 2);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
printf("Testing invalid window\n");
|
2010-07-27 13:02:24 -06:00
|
|
|
request.win = INVALID_WINDOW_ID;
|
|
|
|
request.deviceid = devices.vcp->id;
|
|
|
|
request_XISetClientPointer(&request, BadWindow);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
2019-07-27 01:57:06 -06:00
|
|
|
protocol_xisetclientpointer_test(void)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
init_simple();
|
|
|
|
client_window = init_client(0, NULL);
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
test_XISetClientPointer();
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
return 0;
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|