xserver: Branch 'master' - 4 commits
Peter Hutterer
whot at kemper.freedesktop.org
Wed Sep 2 18:28:13 PDT 2009
Xi/xiwarppointer.c | 12 +
test/xi2/Makefile.am | 4
test/xi2/protocol-common.c | 18 +-
test/xi2/protocol-common.h | 10 +
test/xi2/protocol-xigetclientpointer.c | 6
test/xi2/protocol-xisetclientpointer.c | 4
test/xi2/protocol-xiwarppointer.c | 216 +++++++++++++++++++++++++++++++++
7 files changed, 258 insertions(+), 12 deletions(-)
New commits:
commit 84eb4c66a4a09c360cef260fb2f35dfb6d8a93c6
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Sep 3 10:00:42 2009 +1000
test: add protocol testing for XIWarpPointer.
TODO: some way to check src_x/y coordinates would be good.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/test/xi2/Makefile.am b/test/xi2/Makefile.am
index 0a2fa08..b8362ca 100644
--- a/test/xi2/Makefile.am
+++ b/test/xi2/Makefile.am
@@ -7,6 +7,7 @@ check_PROGRAMS = \
protocol-xisetclientpointer \
protocol-xigetclientpointer \
protocol-xiquerypointer \
+ protocol-xiwarppointer \
protocol-eventconvert
TESTS=$(check_PROGRAMS)
@@ -23,6 +24,7 @@ protocol_xigetselectedevents_LDADD=$(TEST_LDADD)
protocol_xisetclientpointer_LDADD=$(TEST_LDADD)
protocol_xigetclientpointer_LDADD=$(TEST_LDADD)
protocol_xiquerypointer_LDADD=$(TEST_LDADD)
+protocol_xiwarppointer_LDADD=$(TEST_LDADD)
protocol_eventconvert_LDADD=$(TEST_LDADD)
protocol_xiqueryversion_CFLAGS=$(AM_CFLAGS) -Wl,-wrap,WriteToClient
@@ -32,6 +34,7 @@ protocol_xigetselectedevents_CFLAGS=$(AM_CFLAGS) -Wl,-wrap,WriteToClient -Wl,-wr
protocol_xisetclientpointer_CFLAGS=$(AM_CFLAGS) -Wl,-wrap,dixLookupClient
protocol_xigetclientpointer_CFLAGS=$(AM_CFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupClient
protocol_xiquerypointer_CFLAGS=$(AM_CFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow
+protocol_xiwarppointer_CFLAGS=$(AM_CFLAGS) -Wl,-wrap,WriteToClient -Wl,-wrap,dixLookupWindow
protocol_xiqueryversion_SOURCES=$(COMMON_SOURCES) protocol-xiqueryversion.c
protocol_xiquerydevice_SOURCES=$(COMMON_SOURCES) protocol-xiquerydevice.c
@@ -40,4 +43,5 @@ protocol_xigetselectedevents_SOURCES=$(COMMON_SOURCES) protocol-xigetselectedeve
protocol_xisetclientpointer_SOURCES=$(COMMON_SOURCES) protocol-xisetclientpointer.c
protocol_xigetclientpointer_SOURCES=$(COMMON_SOURCES) protocol-xigetclientpointer.c
protocol_xiquerypointer_SOURCES=$(COMMON_SOURCES) protocol-xiquerypointer.c
+protocol_xiwarppointer_SOURCES=$(COMMON_SOURCES) protocol-xiwarppointer.c
endif
diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c
new file mode 100644
index 0000000..4f8860e
--- /dev/null
+++ b/test/xi2/protocol-xiwarppointer.c
@@ -0,0 +1,216 @@
+/**
+ * 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"
+
+#include "protocol-common.h"
+#include <glib.h>
+
+static int expected_x = SPRITE_X;
+static int expected_y = SPRITE_Y;
+
+/* dixLookupWindow requires a lot of setup not necessary for this test.
+ * Simple wrapper that returns either one of the fake root window or the
+ * fake client window. If the requested ID is neither of those wanted,
+ * return whatever the real dixLookupWindow does.
+ */
+int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
+{
+ if (id == root.drawable.id)
+ {
+ *win = &root;
+ return Success;
+ } else if (id == window.drawable.id)
+ {
+ *win = &window;
+ return Success;
+ }
+
+ return __real_dixLookupWindow(win, id, client, access);
+}
+
+/**
+ * This function overrides the one in the screen rec.
+ */
+static Bool ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr screen,
+ int x, int y, Bool generateEvent)
+{
+ g_assert(x == expected_x);
+ g_assert(y == expected_y);
+ return TRUE;
+}
+
+
+static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req,
+ int error)
+{
+ char n;
+ int rc;
+
+ rc = ProcXIWarpPointer(client);
+ g_assert(rc == error);
+
+ if (rc == BadDevice)
+ g_assert(client->errorValue == req->deviceid);
+ else if (rc == BadWindow)
+ g_assert(client->errorValue == req->dst_win ||
+ client->errorValue == req->src_win);
+
+
+ client->swapped = TRUE;
+
+ swapl(&req->src_win, n);
+ swapl(&req->dst_win, n);
+ swapl(&req->src_x, n);
+ swapl(&req->src_y, n);
+ swapl(&req->dst_x, n);
+ swapl(&req->dst_y, n);
+ swaps(&req->src_width, n);
+ swaps(&req->src_height, n);
+ swaps(&req->deviceid, n);
+
+ rc = SProcXIWarpPointer(client);
+ g_assert(rc == error);
+
+ if (rc == BadDevice)
+ g_assert(client->errorValue == req->deviceid);
+ else if (rc == BadWindow)
+ g_assert(client->errorValue == req->dst_win ||
+ client->errorValue == req->src_win);
+
+ client->swapped = FALSE;
+}
+
+static void test_XIWarpPointer(void)
+{
+ 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);
+
+ devices.mouse->u.master = NULL; /* Float, kind-of */
+ request.deviceid = devices.mouse->id;
+ request_XIWarpPointer(&client_request, &request, Success);
+
+ for (i = devices.kbd->id + 1; i <= 0xFFFF; i++)
+ {
+ 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;
+ request.dst_win = 0xFFFF; /* invalid window */
+ request_XIWarpPointer(&client_request, &request, BadWindow);
+
+ request.src_win = 0xFFFF; /* invalid window */
+ 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 */
+}
+
+int main(int argc, char** argv)
+{
+ g_test_init(&argc, &argv,NULL);
+ g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id=");
+
+ init_simple();
+ screen.SetCursorPosition = ScreenSetCursorPosition;
+
+ g_test_add_func("/xi2/protocol/XIWarpPointer", test_XIWarpPointer);
+
+ return g_test_run();
+}
commit 1b7858e8469aea6d2031039ba41d7191a4b80f28
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Sep 3 10:58:00 2009 +1000
test: expose the default screen to tests, some cleanup work.
Provide common #define for invalid window IDs.
Init the sprite's hotPhys, provide a common #define for the initial sprite
position.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c
index 3307499..2d0bc36 100644
--- a/test/xi2/protocol-common.c
+++ b/test/xi2/protocol-common.c
@@ -32,6 +32,7 @@
#include "protocol-common.h"
struct devices devices;
+ScreenRec screen;
WindowRec root;
WindowRec window;
@@ -49,11 +50,16 @@ static void fake_init_sprite(DeviceIntPtr dev)
sprite->spriteTrace = xcalloc(sprite->spriteTraceSize, sizeof(WindowPtr));
sprite->spriteTraceGood = 1;
sprite->spriteTrace[0] = &root;
- sprite->hot.x = 100;
- sprite->hot.y = 200;
- sprite->hotPhys.x = 100;
- sprite->hotPhys.y = 200;
+ sprite->hot.x = SPRITE_X;
+ sprite->hot.y = SPRITE_Y;
+ sprite->hotPhys.x = sprite->hot.x;
+ sprite->hotPhys.y = sprite->hot.y;
sprite->win = &window;
+ sprite->hotPhys.pScreen = &screen;
+ sprite->physLimits.x1 = 0;
+ sprite->physLimits.y1 = 0;
+ sprite->physLimits.x2 = screen.width;
+ sprite->physLimits.y2 = screen.height;
}
/**
@@ -132,10 +138,9 @@ void init_window(WindowPtr window, WindowPtr parent, int id)
/* Needed for the screen setup, otherwise we crash during sprite initialization */
static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; }
+static Bool set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event) { return TRUE; };
void init_simple(void)
{
- static ScreenRec screen;
-
screenInfo.arraySize = MAXSCREENS;
screenInfo.numScreens = 1;
screenInfo.screens[0] = &screen;
@@ -145,6 +150,7 @@ void init_simple(void)
screen.width = 640;
screen.height = 480;
screen.DeviceCursorInitialize = device_cursor_init;
+ screen.SetCursorPosition = set_cursor_pos;
dixResetPrivates();
XInputExtensionInit();
diff --git a/test/xi2/protocol-common.h b/test/xi2/protocol-common.h
index 1ab35c9..afa0878 100644
--- a/test/xi2/protocol-common.h
+++ b/test/xi2/protocol-common.h
@@ -66,6 +66,12 @@ extern int BadDevice;
#define ROOT_WINDOW_ID 0x10
/* default client window id */
#define CLIENT_WINDOW_ID 0x100001
+/* invalid window ID. use for BadWindow checks. */
+#define INVALID_WINDOW_ID 0x111111
+/* initial fake sprite position */
+#define SPRITE_X 100
+#define SPRITE_Y 200
+
/* Various structs used throughout the tests */
@@ -98,6 +104,10 @@ extern void *userdata;
void (*reply_handler)(ClientPtr client, int len, char *data, void *userdata);
/**
+ * The default screen used for the windows. Initialized by init_simple().
+ */
+extern ScreenRec screen;
+/**
* Semi-initialized root window. initialized by init().
*/
extern WindowRec root;
diff --git a/test/xi2/protocol-xigetclientpointer.c b/test/xi2/protocol-xigetclientpointer.c
index d4923f3..6b4d049 100644
--- a/test/xi2/protocol-xigetclientpointer.c
+++ b/test/xi2/protocol-xigetclientpointer.c
@@ -41,8 +41,6 @@
#include "protocol-common.h"
#include <glib.h>
-#define FAKE_WINDOW_ID 12345
-
struct {
int cp_is_set;
DeviceIntPtr dev;
@@ -123,8 +121,8 @@ static void test_XIGetClientPointer(void)
client_request = init_client(request.length, &request);
- g_test_message("Testing invalid window 12345");
- request.win = FAKE_WINDOW_ID;
+ g_test_message("Testing invalid window");
+ request.win = INVALID_WINDOW_ID;
request_XIGetClientPointer(&client_request, &request, BadWindow);
test_data.cp_is_set = FALSE;
diff --git a/test/xi2/protocol-xisetclientpointer.c b/test/xi2/protocol-xisetclientpointer.c
index e72d016..2e638ee 100644
--- a/test/xi2/protocol-xisetclientpointer.c
+++ b/test/xi2/protocol-xisetclientpointer.c
@@ -127,8 +127,8 @@ static void test_XISetClientPointer(void)
request_XISetClientPointer(&request, Success);
g_assert(client_request.clientPtr->id == 2);
- g_test_message("Testing invalid window 12345");
- request.win = 12345;
+ g_test_message("Testing invalid window");
+ request.win = INVALID_WINDOW_ID;
request.deviceid = devices.vcp->id;
request_XISetClientPointer(&request, BadWindow);
commit 61a6e1f074d9ff75d61446b946aab6c04019c287
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Sep 3 10:00:00 2009 +1000
Xi: return BadDevice for master kbds and attached slaves in XIWarpPointer
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c
index 88ba9fa..7276e6f 100644
--- a/Xi/xiwarppointer.c
+++ b/Xi/xiwarppointer.c
@@ -97,6 +97,13 @@ ProcXIWarpPointer(ClientPtr client)
return rc;
}
+ if ((!IsMaster(pDev) && pDev->u.master) ||
+ (IsMaster(pDev) && !IsPointerDevice(pDev)))
+ {
+ client->errorValue = stuff->deviceid;
+ return BadDevice;
+ }
+
if (stuff->dst_win != None)
{
rc = dixLookupWindow(&dest, stuff->dst_win, client, DixGetAttrAccess);
commit 8939ad2b2aa0385f072d3e1169eaf99289ed737a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu Sep 3 09:44:11 2009 +1000
Xi: return error values to client from XIWarpPointer.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
diff --git a/Xi/xiwarppointer.c b/Xi/xiwarppointer.c
index f659269..88ba9fa 100644
--- a/Xi/xiwarppointer.c
+++ b/Xi/xiwarppointer.c
@@ -92,13 +92,17 @@ ProcXIWarpPointer(ClientPtr client)
rc = dixLookupDevice(&pDev, stuff->deviceid, client, DixWriteAccess);
if (rc != Success)
+ {
+ client->errorValue = stuff->deviceid;
return rc;
+ }
if (stuff->dst_win != None)
{
rc = dixLookupWindow(&dest, stuff->dst_win, client, DixGetAttrAccess);
if (rc != Success)
{
+ client->errorValue = stuff->dst_win;
return rc;
}
}
@@ -120,6 +124,7 @@ ProcXIWarpPointer(ClientPtr client)
rc = dixLookupWindow(&src, stuff->src_win, client, DixGetAttrAccess);
if (rc != Success)
{
+ client->errorValue = stuff->src_win;
return rc;
}
More information about the xorg-commit
mailing list