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 XIWarpPointer request.
|
|
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xproto.h>
|
|
|
|
#include <X11/extensions/XI2proto.h>
|
|
|
|
#include "inputstr.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "xiwarppointer.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"
|
|
|
|
|
|
|
|
static int expected_x = SPRITE_X;
|
|
|
|
static int expected_y = SPRITE_Y;
|
|
|
|
|
2020-04-13 02:06:58 -06:00
|
|
|
extern ClientRec client_window;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This function overrides the one in the screen rec.
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
static Bool
|
2013-06-07 11:28:45 -06:00
|
|
|
ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr scr,
|
2012-06-10 07:21:05 -06:00
|
|
|
int x, int y, Bool generateEvent)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(x == expected_x);
|
|
|
|
assert(y == expected_y);
|
2010-07-27 13:02:24 -06:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq * req, int error)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = ProcXIWarpPointer(client);
|
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->errorValue == req->deviceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rc == BadWindow)
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(client->errorValue == req->dst_win ||
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue == req->src_win);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
client->swapped = TRUE;
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
swapl(&req->src_win);
|
|
|
|
swapl(&req->dst_win);
|
|
|
|
swapl(&req->src_x);
|
|
|
|
swapl(&req->src_y);
|
|
|
|
swapl(&req->dst_x);
|
|
|
|
swapl(&req->dst_y);
|
|
|
|
swaps(&req->src_width);
|
|
|
|
swaps(&req->src_height);
|
|
|
|
swaps(&req->deviceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
rc = SProcXIWarpPointer(client);
|
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->errorValue == req->deviceid);
|
2010-07-27 13:02:24 -06:00
|
|
|
else if (rc == BadWindow)
|
2011-11-05 07:32:40 -06:00
|
|
|
assert(client->errorValue == req->dst_win ||
|
2012-06-10 07:21:05 -06:00
|
|
|
client->errorValue == req->src_win);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
client->swapped = FALSE;
|
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
static void
|
|
|
|
test_XIWarpPointer(void)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
ClientRec client_request;
|
|
|
|
xXIWarpPointerReq request;
|
|
|
|
|
|
|
|
memset(&request, 0, sizeof(request));
|
|
|
|
|
|
|
|
request_init(&request, XIWarpPointer);
|
|
|
|
|
|
|
|
client_request = init_client(request.length, &request);
|
|
|
|
|
|
|
|
request.deviceid = XIAllDevices;
|
|
|
|
request_XIWarpPointer(&client_request, &request, BadDevice);
|
|
|
|
|
|
|
|
request.deviceid = XIAllMasterDevices;
|
|
|
|
request_XIWarpPointer(&client_request, &request, BadDevice);
|
|
|
|
|
|
|
|
request.src_win = root.drawable.id;
|
|
|
|
request.dst_win = root.drawable.id;
|
|
|
|
request.deviceid = devices.vcp->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, Success);
|
|
|
|
request.deviceid = devices.vck->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, BadDevice);
|
|
|
|
request.deviceid = devices.mouse->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, BadDevice);
|
|
|
|
request.deviceid = devices.kbd->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, BadDevice);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
devices.mouse->master = NULL; /* Float, kind-of */
|
2010-07-27 13:02:24 -06:00
|
|
|
request.deviceid = devices.mouse->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, Success);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) {
|
2010-07-27 13:02:24 -06:00
|
|
|
request.deviceid = i;
|
|
|
|
request_XIWarpPointer(&client_request, &request, BadDevice);
|
|
|
|
}
|
|
|
|
|
|
|
|
request.src_win = window.drawable.id;
|
|
|
|
request.deviceid = devices.vcp->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, Success);
|
|
|
|
|
|
|
|
request.deviceid = devices.mouse->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, Success);
|
|
|
|
|
|
|
|
request.src_win = root.drawable.id;
|
2012-06-10 07:21:05 -06:00
|
|
|
request.dst_win = 0xFFFF; /* invalid window */
|
2010-07-27 13:02:24 -06:00
|
|
|
request_XIWarpPointer(&client_request, &request, BadWindow);
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
request.src_win = 0xFFFF; /* invalid window */
|
2010-07-27 13:02:24 -06:00
|
|
|
request.dst_win = root.drawable.id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, BadWindow);
|
|
|
|
|
|
|
|
request.src_win = None;
|
|
|
|
request.dst_win = None;
|
|
|
|
|
|
|
|
request.dst_y = 0;
|
|
|
|
expected_y = SPRITE_Y;
|
|
|
|
|
|
|
|
request.dst_x = 1 << 16;
|
|
|
|
expected_x = SPRITE_X + 1;
|
|
|
|
request.deviceid = devices.vcp->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, Success);
|
|
|
|
|
|
|
|
request.dst_x = -1 << 16;
|
|
|
|
expected_x = SPRITE_X - 1;
|
|
|
|
request.deviceid = devices.vcp->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, Success);
|
|
|
|
|
|
|
|
request.dst_x = 0;
|
|
|
|
expected_x = SPRITE_X;
|
|
|
|
|
|
|
|
request.dst_y = 1 << 16;
|
|
|
|
expected_y = SPRITE_Y + 1;
|
|
|
|
request.deviceid = devices.vcp->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, Success);
|
|
|
|
|
|
|
|
request.dst_y = -1 << 16;
|
|
|
|
expected_y = SPRITE_Y - 1;
|
|
|
|
request.deviceid = devices.vcp->id;
|
|
|
|
request_XIWarpPointer(&client_request, &request, Success);
|
|
|
|
|
|
|
|
/* FIXME: src_x/y checks */
|
2014-12-09 10:58:52 -07:00
|
|
|
|
|
|
|
client_request.req_len -= 2; /* invalid length */
|
|
|
|
request_XIWarpPointer(&client_request, &request, BadLength);
|
2010-07-27 13:02:24 -06:00
|
|
|
}
|
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
int
|
2019-07-27 01:57:06 -06:00
|
|
|
protocol_xiwarppointer_test(void)
|
2010-07-27 13:02:24 -06:00
|
|
|
{
|
|
|
|
init_simple();
|
|
|
|
screen.SetCursorPosition = ScreenSetCursorPosition;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
test_XIWarpPointer();
|
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
|
|
|
}
|