aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/test/xi2
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
committermarha <marha@users.sourceforge.net>2012-03-23 10:05:55 +0100
commit0f834b91a4768673833ab4917e87d86c237bb1a6 (patch)
tree363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/test/xi2
parentfc72edebf875378459368c5383d9023730cbca54 (diff)
downloadvcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2
vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/test/xi2')
-rw-r--r--xorg-server/test/xi2/protocol-common.c92
-rw-r--r--xorg-server/test/xi2/protocol-common.h24
-rw-r--r--xorg-server/test/xi2/protocol-eventconvert.c453
-rw-r--r--xorg-server/test/xi2/protocol-xigetclientpointer.c27
-rw-r--r--xorg-server/test/xi2/protocol-xigetselectedevents.c88
-rw-r--r--xorg-server/test/xi2/protocol-xipassivegrabdevice.c91
-rw-r--r--xorg-server/test/xi2/protocol-xiquerydevice.c339
-rw-r--r--xorg-server/test/xi2/protocol-xiquerypointer.c45
-rw-r--r--xorg-server/test/xi2/protocol-xiqueryversion.c27
-rw-r--r--xorg-server/test/xi2/protocol-xiselectevents.c130
-rw-r--r--xorg-server/test/xi2/protocol-xisetclientpointer.c23
-rw-r--r--xorg-server/test/xi2/protocol-xiwarppointer.c40
-rw-r--r--xorg-server/test/xi2/xi2.c16
13 files changed, 706 insertions, 689 deletions
diff --git a/xorg-server/test/xi2/protocol-common.c b/xorg-server/test/xi2/protocol-common.c
index 27edfe516..32c056797 100644
--- a/xorg-server/test/xi2/protocol-common.c
+++ b/xorg-server/test/xi2/protocol-common.c
@@ -26,9 +26,9 @@
#endif
#include <stdint.h>
-#include "extinit.h" /* for XInputExtensionInit */
+#include "extinit.h" /* for XInputExtensionInit */
#include "exglobals.h"
-#include "xkbsrv.h" /* for XkbInitPrivates */
+#include "xkbsrv.h" /* for XkbInitPrivates */
#include "xserver-properties.h"
#include <X11/extensions/XI2.h>
@@ -44,9 +44,11 @@ void *userdata;
extern int CorePointerProc(DeviceIntPtr pDev, int what);
extern int CoreKeyboardProc(DeviceIntPtr pDev, int what);
-static void fake_init_sprite(DeviceIntPtr dev)
+static void
+fake_init_sprite(DeviceIntPtr dev)
{
SpritePtr sprite;
+
sprite = dev->spriteInfo->sprite;
sprite->spriteTraceSize = 10;
@@ -73,32 +75,32 @@ TestPointerProc(DeviceIntPtr pDev, int what)
#define NAXES 4
BYTE map[NBUTTONS + 1];
int i = 0;
- Atom btn_labels[NBUTTONS] = {0};
- Atom axes_labels[NAXES] = {0};
+ Atom btn_labels[NBUTTONS] = { 0 };
+ Atom axes_labels[NAXES] = { 0 };
switch (what) {
case DEVICE_INIT:
for (i = 1; i <= NBUTTONS; i++)
map[i] = i;
- btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
- btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
- /* don't know about the rest */
-
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
- axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
- axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
-
- if (!InitPointerDeviceStruct((DevicePtr)pDev, map, NBUTTONS, btn_labels,
- (PtrCtrlProcPtr)NoopDDA,
- GetMotionHistorySize(), NAXES, axes_labels))
- {
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ /* don't know about the rest */
+
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
+
+ if (!InitPointerDeviceStruct
+ ((DevicePtr) pDev, map, NBUTTONS, btn_labels,
+ (PtrCtrlProcPtr) NoopDDA, GetMotionHistorySize(), NAXES,
+ axes_labels)) {
ErrorF("Could not initialize device '%s'. Out of memory.\n",
pDev->name);
return BadAlloc;
@@ -110,7 +112,8 @@ TestPointerProc(DeviceIntPtr pDev, int what)
/* protocol-xiquerydevice.c relies on these increment */
SetScrollValuator(pDev, 2, SCROLL_TYPE_VERTICAL, 2.4, SCROLL_FLAG_NONE);
- SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5, SCROLL_FLAG_PREFERRED);
+ SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5,
+ SCROLL_FLAG_PREFERRED);
break;
case DEVICE_CLOSE:
@@ -125,11 +128,13 @@ TestPointerProc(DeviceIntPtr pDev, int what)
#undef NBUTTONS
#undef NAXES
}
+
/**
* Create and init 2 master devices (VCP + VCK) and two slave devices, one
* default mouse, one default keyboard.
*/
-struct devices init_devices(void)
+struct devices
+init_devices(void)
{
ClientRec client;
struct devices devices;
@@ -139,6 +144,7 @@ struct devices init_devices(void)
AllocDevicePair(&client, "Virtual core", &devices.vcp, &devices.vck,
CorePointerProc, CoreKeyboardProc, TRUE);
inputInfo.pointer = devices.vcp;
+
inputInfo.keyboard = devices.vck;
ActivateDevice(devices.vcp, FALSE);
ActivateDevice(devices.vck, FALSE);
@@ -161,9 +167,9 @@ struct devices init_devices(void)
return devices;
}
-
/* Create minimal client, with the given buffer and len as request buffer */
-ClientRec init_client(int len, void *data)
+ClientRec
+init_client(int len, void *data)
{
ClientRec client = { 0 };
@@ -181,13 +187,13 @@ ClientRec init_client(int len, void *data)
return client;
}
-void init_window(WindowPtr window, WindowPtr parent, int id)
+void
+init_window(WindowPtr window, WindowPtr parent, int id)
{
memset(window, 0, sizeof(*window));
window->drawable.id = id;
- if (parent)
- {
+ if (parent) {
window->drawable.x = 30;
window->drawable.y = 50;
window->drawable.width = 100;
@@ -202,9 +208,20 @@ extern DevPrivateKeyRec miPointerScreenKeyRec;
extern DevPrivateKeyRec miPointerPrivKeyRec;
/* 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 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)
{
screenInfo.numScreens = 1;
screenInfo.screens[0] = &screen;
@@ -219,7 +236,8 @@ void init_simple(void)
dixResetPrivates();
InitAtoms();
XkbInitPrivates();
- dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec));
+ dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT,
+ sizeof(XIClientRec));
dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0);
dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0);
XInputExtensionInit();
@@ -230,10 +248,10 @@ void init_simple(void)
devices = init_devices();
}
-void __wrap_WriteToClient(ClientPtr client, int len, void *data)
+void
+__wrap_WriteToClient(ClientPtr client, int len, void *data)
{
assert(reply_handler != NULL);
- (*reply_handler)(client, len, data, userdata);
+ (*reply_handler) (client, len, data, userdata);
}
-
diff --git a/xorg-server/test/xi2/protocol-common.h b/xorg-server/test/xi2/protocol-common.h
index b55f57c05..04a1e8990 100644
--- a/xorg-server/test/xi2/protocol-common.h
+++ b/xorg-server/test/xi2/protocol-common.h
@@ -53,7 +53,6 @@ extern int BadDevice;
(req)->length = (sz_x##type##Req >> 2); \
}
-
/* Various defines used in the tests. Some tests may use different values
* than these defaults */
/* default client index */
@@ -72,10 +71,8 @@ extern int BadDevice;
#define SPRITE_X 100
#define SPRITE_Y 200
-
/* Various structs used throughout the tests */
-
/* The default devices struct, contains one pointer + keyboard and the
* matching master devices. Initialize with init_devices() if needed. */
struct devices {
@@ -97,20 +94,23 @@ extern struct devices devices;
* test-specific userdata, passed into the reply handler.
*/
extern void *userdata;
+
/**
* The reply handler called from WriteToClient. Set this handler if you need
* to check the reply values.
*/
-void (*reply_handler)(ClientPtr client, int len, char *data, 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;
+
/**
* Semi-initialized top-level window. initialized by init().
*/
@@ -122,16 +122,19 @@ extern WindowRec window;
* Usually not needed if you call ::init_simple.
*/
struct devices init_devices(void);
+
/**
* Init a mostly zeroed out client with default values for index and mask.
*/
ClientRec init_client(int request_len, void *request_data);
+
/**
* Init a mostly zeroed out window with the given window ID.
* Usually not needed if you call ::init_simple which sets up root and
* window.
*/
void init_window(WindowPtr window, WindowPtr parent, int id);
+
/**
* Create a very simple setup that provides the minimum values for most
* tests, including a screen, the root and client window and the default
@@ -141,13 +144,14 @@ void init_simple(void);
/* Declarations for various overrides in the test files. */
void __wrap_WriteToClient(ClientPtr client, int len, void *data);
-int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask);
-int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
-int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access);
+int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len,
+ unsigned char *mask);
+int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client,
+ Mask access);
+int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client,
+ Mask access);
Bool __wrap_AddResource(XID id, RESTYPE type, pointer value);
int __wrap_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
int __real_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access);
-
-#endif /* PROTOCOL_COMMON_H */
-
+#endif /* PROTOCOL_COMMON_H */
diff --git a/xorg-server/test/xi2/protocol-eventconvert.c b/xorg-server/test/xi2/protocol-eventconvert.c
index bf1493c05..1188e8b25 100644
--- a/xorg-server/test/xi2/protocol-eventconvert.c
+++ b/xorg-server/test/xi2/protocol-eventconvert.c
@@ -33,8 +33,8 @@
#include "inpututils.h"
#include <X11/extensions/XI2proto.h>
-static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
- BOOL swap)
+static void
+test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent * out, BOOL swap)
{
int i;
unsigned char *ptr;
@@ -44,8 +44,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
int len;
uint32_t flagmask = 0;
- if (swap)
- {
+ if (swap) {
swaps(&out->sequenceNumber);
swapl(&out->length);
swaps(&out->evtype);
@@ -56,14 +55,14 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
swapl(&out->flags);
}
-
assert(out->type == GenericEvent);
- assert(out->extension == 0); /* IReqCode defaults to 0 */
+ assert(out->extension == 0); /* IReqCode defaults to 0 */
assert(out->evtype == GetXI2Type(in->type));
assert(out->time == in->time);
assert(out->detail == in->detail.button);
assert(out->deviceid == in->deviceid);
- assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(sizeof(in->valuators.mask))));
+ assert(out->valuators_len >=
+ bytes_to_int32(bits_to_bytes(sizeof(in->valuators.mask))));
switch (in->type) {
case ET_RawMotion:
@@ -76,14 +75,13 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
}
assert((out->flags & ~flagmask) == 0);
- ptr = (unsigned char*)&out[1];
+ ptr = (unsigned char *) &out[1];
bits_set = 0;
- for (i = 0; out->valuators_len && i < sizeof(in->valuators.mask) * 8; i++)
- {
+ for (i = 0; out->valuators_len && i < sizeof(in->valuators.mask) * 8; i++) {
if (i >= MAX_VALUATORS)
- assert (!XIMaskIsSet(in->valuators.mask, i));
- assert (XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i));
+ assert(!XIMaskIsSet(in->valuators.mask, i));
+ assert(XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i));
if (XIMaskIsSet(in->valuators.mask, i))
bits_set++;
}
@@ -96,21 +94,21 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
nvals = 0;
- for (i = 0; out->valuators_len && i < MAX_VALUATORS; i++)
- {
- assert (XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i));
- if (XIMaskIsSet(in->valuators.mask, i))
- {
+ for (i = 0; out->valuators_len && i < MAX_VALUATORS; i++) {
+ assert(XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i));
+ if (XIMaskIsSet(in->valuators.mask, i)) {
FP3232 vi, vo;
- value = (FP3232*)(((unsigned char*)&out[1]) + out->valuators_len * 4);
+
+ value =
+ (FP3232 *) (((unsigned char *) &out[1]) +
+ out->valuators_len * 4);
value += nvals;
vi = double_to_fp3232(in->valuators.data[i]);
vo.integral = value->integral;
vo.frac = value->frac;
- if (swap)
- {
+ if (swap) {
swapl(&vo.integral);
swapl(&vo.frac);
}
@@ -124,8 +122,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
vo.integral = raw_value->integral;
vo.frac = raw_value->frac;
- if (swap)
- {
+ if (swap) {
swapl(&vo.integral);
swapl(&vo.frac);
}
@@ -138,25 +135,27 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
}
}
-static void test_XIRawEvent(RawDeviceEvent *in)
+static void
+test_XIRawEvent(RawDeviceEvent *in)
{
xXIRawEvent *out, *swapped;
int rc;
- rc = EventToXI2((InternalEvent*)in, (xEvent**)&out);
+ rc = EventToXI2((InternalEvent *) in, (xEvent **) &out);
assert(rc == Success);
test_values_XIRawEvent(in, out, FALSE);
swapped = calloc(1, sizeof(xEvent) + out->length * 4);
- XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped);
+ XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped);
test_values_XIRawEvent(in, swapped, TRUE);
free(out);
free(swapped);
}
-static void test_convert_XIFocusEvent(void)
+static void
+test_convert_XIFocusEvent(void)
{
xEvent *out;
DeviceEvent in;
@@ -164,29 +163,29 @@ static void test_convert_XIFocusEvent(void)
in.header = ET_Internal;
in.type = ET_Enter;
- rc = EventToXI2((InternalEvent*)&in, &out);
+ rc = EventToXI2((InternalEvent *) &in, &out);
assert(rc == Success);
assert(out == NULL);
in.header = ET_Internal;
in.type = ET_FocusIn;
- rc = EventToXI2((InternalEvent*)&in, &out);
+ rc = EventToXI2((InternalEvent *) &in, &out);
assert(rc == Success);
assert(out == NULL);
in.header = ET_Internal;
in.type = ET_FocusOut;
- rc = EventToXI2((InternalEvent*)&in, &out);
+ rc = EventToXI2((InternalEvent *) &in, &out);
assert(rc == BadImplementation);
in.header = ET_Internal;
in.type = ET_Leave;
- rc = EventToXI2((InternalEvent*)&in, &out);
+ rc = EventToXI2((InternalEvent *) &in, &out);
assert(rc == BadImplementation);
}
-
-static void test_convert_XIRawEvent(void)
+static void
+test_convert_XIRawEvent(void)
{
RawDeviceEvent in;
int i;
@@ -244,15 +243,13 @@ static void test_convert_XIRawEvent(void)
in.deviceid = ~0 & 0xFF;
test_XIRawEvent(&in);
- for (i = 0; i < MAX_VALUATORS; i++)
- {
+ for (i = 0; i < MAX_VALUATORS; i++) {
XISetMask(in.valuators.mask, i);
test_XIRawEvent(&in);
XIClearMask(in.valuators.mask, i);
}
- for (i = 0; i < MAX_VALUATORS; i++)
- {
+ for (i = 0; i < MAX_VALUATORS; i++) {
XISetMask(in.valuators.mask, i);
in.valuators.data[i] = i + (i * 0.0010);
@@ -261,15 +258,14 @@ static void test_convert_XIRawEvent(void)
XIClearMask(in.valuators.mask, i);
}
- for (i = 0; i < MAX_VALUATORS; i++)
- {
+ for (i = 0; i < MAX_VALUATORS; i++) {
XISetMask(in.valuators.mask, i);
test_XIRawEvent(&in);
}
}
-static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
- BOOL swap)
+static void
+test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent * out, BOOL swap)
{
int buttons, valuators;
int i;
@@ -301,7 +297,7 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
swapl(&out->flags);
}
- assert(out->extension == 0); /* IReqCode defaults to 0 */
+ assert(out->extension == 0); /* IReqCode defaults to 0 */
assert(out->evtype == GetXI2Type(in->type));
assert(out->time == in->time);
assert(out->detail == in->detail.button);
@@ -311,17 +307,17 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
assert(out->sourceid == in->sourceid);
switch (in->type) {
- case ET_ButtonPress:
- case ET_Motion:
- case ET_ButtonRelease:
- flagmask = XIPointerEmulated;
- break;
- case ET_KeyPress:
- flagmask = XIKeyRepeat;
- break;
- default:
- flagmask = 0;
- break;
+ case ET_ButtonPress:
+ case ET_Motion:
+ case ET_ButtonRelease:
+ flagmask = XIPointerEmulated;
+ break;
+ case ET_KeyPress:
+ flagmask = XIKeyRepeat;
+ break;
+ default:
+ flagmask = 0;
+ break;
}
assert((out->flags & ~flagmask) == 0);
@@ -339,27 +335,24 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
assert(out->group.locked_group == in->group.locked);
assert(out->group.effective_group == in->group.effective);
- assert(out->event_x == 0); /* set in FixUpEventFromWindow */
- assert(out->event_y == 0); /* set in FixUpEventFromWindow */
+ assert(out->event_x == 0); /* set in FixUpEventFromWindow */
+ assert(out->event_y == 0); /* set in FixUpEventFromWindow */
assert(out->root_x == FP1616(in->root_x, in->root_x_frac));
assert(out->root_y == FP1616(in->root_y, in->root_y_frac));
buttons = 0;
- for (i = 0; i < bits_to_bytes(sizeof(in->buttons)); i++)
- {
- if (XIMaskIsSet(in->buttons, i))
- {
+ for (i = 0; i < bits_to_bytes(sizeof(in->buttons)); i++) {
+ if (XIMaskIsSet(in->buttons, i)) {
assert(out->buttons_len >= bytes_to_int32(bits_to_bytes(i)));
buttons++;
}
}
- ptr = (unsigned char*)&out[1];
+ ptr = (unsigned char *) &out[1];
for (i = 0; i < sizeof(in->buttons) * 8; i++)
assert(XIMaskIsSet(in->buttons, i) == XIMaskIsSet(ptr, i));
-
valuators = 0;
for (i = 0; i < MAX_VALUATORS; i++)
if (XIMaskIsSet(in->valuators.mask, i))
@@ -368,10 +361,9 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(valuators)));
ptr += out->buttons_len * 4;
- values = (FP3232*)(ptr + out->valuators_len * 4);
+ values = (FP3232 *) (ptr + out->valuators_len * 4);
for (i = 0; i < sizeof(in->valuators.mask) * 8 ||
- i < (out->valuators_len * 4) * 8; i++)
- {
+ i < (out->valuators_len * 4) * 8; i++) {
if (i >= MAX_VALUATORS)
assert(!XIMaskIsSet(in->valuators.mask, i) && !XIMaskIsSet(ptr, i));
else if (i > sizeof(in->valuators.mask) * 8)
@@ -379,23 +371,19 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
else if (i > out->valuators_len * 4 * 8)
assert(!XIMaskIsSet(in->valuators.mask, i));
else {
- assert(XIMaskIsSet(in->valuators.mask, i) ==
- XIMaskIsSet(ptr, i));
+ assert(XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i));
- if (XIMaskIsSet(ptr, i))
- {
+ if (XIMaskIsSet(ptr, i)) {
FP3232 vi, vo;
vi = double_to_fp3232(in->valuators.data[i]);
vo = *values;
- if (swap)
- {
+ if (swap) {
swapl(&vo.integral);
swapl(&vo.frac);
}
-
assert(vi.integral == vo.integral);
assert(vi.frac == vo.frac);
values++;
@@ -404,25 +392,27 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
}
}
-static void test_XIDeviceEvent(DeviceEvent *in)
+static void
+test_XIDeviceEvent(DeviceEvent *in)
{
xXIDeviceEvent *out, *swapped;
int rc;
- rc = EventToXI2((InternalEvent*)in, (xEvent**)&out);
+ rc = EventToXI2((InternalEvent *) in, (xEvent **) &out);
assert(rc == Success);
test_values_XIDeviceEvent(in, out, FALSE);
swapped = calloc(1, sizeof(xEvent) + out->length * 4);
- XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped);
+ XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped);
test_values_XIDeviceEvent(in, swapped, TRUE);
free(out);
free(swapped);
}
-static void test_convert_XIDeviceEvent(void)
+static void
+test_convert_XIDeviceEvent(void)
{
DeviceEvent in;
int i;
@@ -432,23 +422,23 @@ static void test_convert_XIDeviceEvent(void)
in.header = ET_Internal;
in.type = ET_Motion;
in.length = sizeof(DeviceEvent);
- in.time = 0;
- in.deviceid = 1;
- in.sourceid = 2;
- in.root = 3;
- in.root_x = 4;
- in.root_x_frac = 5;
- in.root_y = 6;
- in.root_y_frac = 7;
- in.detail.button = 8;
- in.mods.base = 9;
- in.mods.latched = 10;
- in.mods.locked = 11;
- in.mods.effective = 11;
- in.group.base = 12;
- in.group.latched = 13;
- in.group.locked = 14;
- in.group.effective = 15;
+ in.time = 0;
+ in.deviceid = 1;
+ in.sourceid = 2;
+ in.root = 3;
+ in.root_x = 4;
+ in.root_x_frac = 5;
+ in.root_y = 6;
+ in.root_y_frac = 7;
+ in.detail.button = 8;
+ in.mods.base = 9;
+ in.mods.latched = 10;
+ in.mods.locked = 11;
+ in.mods.effective = 11;
+ in.group.base = 12;
+ in.group.latched = 13;
+ in.group.locked = 14;
+ in.group.effective = 15;
test_XIDeviceEvent(&in);
@@ -599,28 +589,24 @@ static void test_convert_XIDeviceEvent(void)
in.mods.effective = ~0 & 0xFF;
test_XIDeviceEvent(&in);
- for (i = 0; i < sizeof(in.buttons) * 8; i++)
- {
+ for (i = 0; i < sizeof(in.buttons) * 8; i++) {
XISetMask(in.buttons, i);
test_XIDeviceEvent(&in);
XIClearMask(in.buttons, i);
}
- for (i = 0; i < sizeof(in.buttons) * 8; i++)
- {
+ for (i = 0; i < sizeof(in.buttons) * 8; i++) {
XISetMask(in.buttons, i);
test_XIDeviceEvent(&in);
}
- for (i = 0; i < MAX_VALUATORS; i++)
- {
+ for (i = 0; i < MAX_VALUATORS; i++) {
XISetMask(in.valuators.mask, i);
test_XIDeviceEvent(&in);
XIClearMask(in.valuators.mask, i);
}
- for (i = 0; i < MAX_VALUATORS; i++)
- {
+ for (i = 0; i < MAX_VALUATORS; i++) {
XISetMask(in.valuators.mask, i);
in.valuators.data[i] = i + (i * 0.0020);
@@ -628,22 +614,20 @@ static void test_convert_XIDeviceEvent(void)
XIClearMask(in.valuators.mask, i);
}
- for (i = 0; i < MAX_VALUATORS; i++)
- {
+ for (i = 0; i < MAX_VALUATORS; i++) {
XISetMask(in.valuators.mask, i);
test_XIDeviceEvent(&in);
}
}
-static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
- xXIDeviceChangedEvent *out,
- BOOL swap)
+static void
+test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
+ xXIDeviceChangedEvent * out, BOOL swap)
{
int i, j;
unsigned char *ptr;
- if (swap)
- {
+ if (swap) {
swaps(&out->sequenceNumber);
swapl(&out->length);
swaps(&out->evtype);
@@ -654,114 +638,106 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
}
assert(out->type == GenericEvent);
- assert(out->extension == 0); /* IReqCode defaults to 0 */
+ assert(out->extension == 0); /* IReqCode defaults to 0 */
assert(out->evtype == GetXI2Type(in->type));
assert(out->time == in->time);
assert(out->deviceid == in->deviceid);
assert(out->sourceid == in->sourceid);
- ptr = (unsigned char*)&out[1];
- for (i = 0; i < out->num_classes; i++)
- {
- xXIAnyInfo* any = (xXIAnyInfo*)ptr;
+ ptr = (unsigned char *) &out[1];
+ for (i = 0; i < out->num_classes; i++) {
+ xXIAnyInfo *any = (xXIAnyInfo *) ptr;
- if (swap)
- {
+ if (swap) {
swaps(&any->length);
swaps(&any->type);
swaps(&any->sourceid);
}
- switch(any->type)
+ switch (any->type) {
+ case XIButtonClass:
{
- case XIButtonClass:
- {
- xXIButtonInfo *b = (xXIButtonInfo*)any;
- Atom *names;
-
- if (swap)
- {
- swaps(&b->num_buttons);
- }
-
- assert(b->length ==
- bytes_to_int32(sizeof(xXIButtonInfo)) +
- bytes_to_int32(bits_to_bytes(b->num_buttons)) +
- b->num_buttons);
- assert(b->num_buttons == in->buttons.num_buttons);
-
- names = (Atom*)((char*)&b[1] +
- pad_to_int32(bits_to_bytes(b->num_buttons)));
- for (j = 0; j < b->num_buttons; j++)
- {
- if (swap)
- {
- swapl(&names[j]);
- }
- assert(names[j] == in->buttons.names[j]);
- }
- }
- break;
- case XIKeyClass:
- {
- xXIKeyInfo *k = (xXIKeyInfo*)any;
- uint32_t *kc;
-
- if (swap)
- {
- swaps(&k->num_keycodes);
- }
-
- assert(k->length ==
- bytes_to_int32(sizeof(xXIKeyInfo)) +
- k->num_keycodes);
- assert(k->num_keycodes == in->keys.max_keycode -
- in->keys.min_keycode + 1);
-
- kc = (uint32_t*)&k[1];
- for (j = 0; j < k->num_keycodes; j++)
- {
- if (swap)
- {
- swapl(&kc[j]);
- }
- assert(kc[j] >= in->keys.min_keycode);
- assert(kc[j] <= in->keys.max_keycode);
- }
+ xXIButtonInfo *b = (xXIButtonInfo *) any;
+ Atom *names;
+
+ if (swap) {
+ swaps(&b->num_buttons);
+ }
+
+ assert(b->length ==
+ bytes_to_int32(sizeof(xXIButtonInfo)) +
+ bytes_to_int32(bits_to_bytes(b->num_buttons)) +
+ b->num_buttons);
+ assert(b->num_buttons == in->buttons.num_buttons);
+
+ names = (Atom *) ((char *) &b[1] +
+ pad_to_int32(bits_to_bytes(b->num_buttons)));
+ for (j = 0; j < b->num_buttons; j++) {
+ if (swap) {
+ swapl(&names[j]);
}
- break;
- case XIValuatorClass:
- {
- xXIValuatorInfo *v = (xXIValuatorInfo*)any;
- assert(v->length ==
- bytes_to_int32(sizeof(xXIValuatorInfo)));
+ assert(names[j] == in->buttons.names[j]);
+ }
+ }
+ break;
+ case XIKeyClass:
+ {
+ xXIKeyInfo *k = (xXIKeyInfo *) any;
+ uint32_t *kc;
+ if (swap) {
+ swaps(&k->num_keycodes);
+ }
+
+ assert(k->length ==
+ bytes_to_int32(sizeof(xXIKeyInfo)) + k->num_keycodes);
+ assert(k->num_keycodes == in->keys.max_keycode -
+ in->keys.min_keycode + 1);
+
+ kc = (uint32_t *) & k[1];
+ for (j = 0; j < k->num_keycodes; j++) {
+ if (swap) {
+ swapl(&kc[j]);
}
+ assert(kc[j] >= in->keys.min_keycode);
+ assert(kc[j] <= in->keys.max_keycode);
+ }
+ }
+ break;
+ case XIValuatorClass:
+ {
+ xXIValuatorInfo *v = (xXIValuatorInfo *) any;
+
+ assert(v->length == bytes_to_int32(sizeof(xXIValuatorInfo)));
+
+ }
+ break;
+ case XIScrollClass:
+ {
+ xXIScrollInfo *s = (xXIScrollInfo *) any;
+
+ assert(s->length == bytes_to_int32(sizeof(xXIScrollInfo)));
+
+ assert(s->sourceid == in->sourceid);
+ assert(s->number < in->num_valuators);
+ switch (s->type) {
+ case XIScrollTypeVertical:
+ assert(in->valuators[s->number].scroll.type ==
+ SCROLL_TYPE_VERTICAL);
break;
- case XIScrollClass:
- {
- xXIScrollInfo *s = (xXIScrollInfo*)any;
- assert(s->length ==
- bytes_to_int32(sizeof(xXIScrollInfo)));
-
- assert(s->sourceid == in->sourceid);
- assert(s->number < in->num_valuators);
- switch(s->type)
- {
- case XIScrollTypeVertical:
- assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_VERTICAL);
- break;
- case XIScrollTypeHorizontal:
- assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_HORIZONTAL);
- break;
- }
- if (s->flags & XIScrollFlagPreferred)
- assert(in->valuators[s->number].scroll.flags & SCROLL_FLAG_PREFERRED);
- }
- default:
- printf("Invalid class type.\n\n");
- assert(1);
+ case XIScrollTypeHorizontal:
+ assert(in->valuators[s->number].scroll.type ==
+ SCROLL_TYPE_HORIZONTAL);
break;
+ }
+ if (s->flags & XIScrollFlagPreferred)
+ assert(in->valuators[s->number].scroll.
+ flags & SCROLL_FLAG_PREFERRED);
+ }
+ default:
+ printf("Invalid class type.\n\n");
+ assert(1);
+ break;
}
ptr += any->length * 4;
@@ -769,25 +745,27 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
}
-static void test_XIDeviceChangedEvent(DeviceChangedEvent *in)
+static void
+test_XIDeviceChangedEvent(DeviceChangedEvent *in)
{
xXIDeviceChangedEvent *out, *swapped;
int rc;
- rc = EventToXI2((InternalEvent*)in, (xEvent**)&out);
+ rc = EventToXI2((InternalEvent *) in, (xEvent **) &out);
assert(rc == Success);
test_values_XIDeviceChangedEvent(in, out, FALSE);
swapped = calloc(1, sizeof(xEvent) + out->length * 4);
- XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped);
+ XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped);
test_values_XIDeviceChangedEvent(in, swapped, TRUE);
free(out);
free(swapped);
}
-static void test_convert_XIDeviceChangedEvent(void)
+static void
+test_convert_XIDeviceChangedEvent(void)
{
DeviceChangedEvent in;
int i;
@@ -796,12 +774,14 @@ static void test_convert_XIDeviceChangedEvent(void)
in.header = ET_Internal;
in.type = ET_DeviceChanged;
in.length = sizeof(DeviceChangedEvent);
- in.time = 0;
- in.deviceid = 1;
- in.sourceid = 2;
- in.masterid = 3;
- in.num_valuators = 4;
- in.flags = DEVCHANGE_SLAVE_SWITCH | DEVCHANGE_POINTER_EVENT | DEVCHANGE_KEYBOARD_EVENT;
+ in.time = 0;
+ in.deviceid = 1;
+ in.sourceid = 2;
+ in.masterid = 3;
+ in.num_valuators = 4;
+ in.flags =
+ DEVCHANGE_SLAVE_SWITCH | DEVCHANGE_POINTER_EVENT |
+ DEVCHANGE_KEYBOARD_EVENT;
for (i = 0; i < MAX_BUTTONS; i++)
in.buttons.names[i] = i + 10;
@@ -859,8 +839,8 @@ static void test_convert_XIDeviceChangedEvent(void)
in.keys.max_keycode = 1 << 8;
test_XIDeviceChangedEvent(&in);
- in.keys.max_keycode = 0xFFFC; /* highest range, above that the length
- field gives up */
+ in.keys.max_keycode = 0xFFFC; /* highest range, above that the length
+ field gives up */
test_XIDeviceChangedEvent(&in);
in.keys.min_keycode = 1 << 8;
@@ -880,8 +860,7 @@ static void test_convert_XIDeviceChangedEvent(void)
in.num_valuators = MAX_VALUATORS;
test_XIDeviceChangedEvent(&in);
- for (i = 0; i < MAX_VALUATORS; i++)
- {
+ for (i = 0; i < MAX_VALUATORS; i++) {
in.valuators[i].min = 0;
in.valuators[i].max = 0;
test_XIDeviceChangedEvent(&in);
@@ -917,11 +896,9 @@ static void test_convert_XIDeviceChangedEvent(void)
static void
test_values_XITouchOwnershipEvent(TouchOwnershipEvent *in,
- xXITouchOwnershipEvent *out,
- BOOL swap)
+ xXITouchOwnershipEvent * out, BOOL swap)
{
- if (swap)
- {
+ if (swap) {
swaps(&out->sequenceNumber);
swapl(&out->length);
swaps(&out->evtype);
@@ -936,7 +913,7 @@ test_values_XITouchOwnershipEvent(TouchOwnershipEvent *in,
}
assert(out->type == GenericEvent);
- assert(out->extension == 0); /* IReqCode defaults to 0 */
+ assert(out->extension == 0); /* IReqCode defaults to 0 */
assert(out->evtype == GetXI2Type(in->type));
assert(out->time == in->time);
assert(out->deviceid == in->deviceid);
@@ -951,13 +928,13 @@ test_XITouchOwnershipEvent(TouchOwnershipEvent *in)
xXITouchOwnershipEvent *out, *swapped;
int rc;
- rc = EventToXI2((InternalEvent*)in, (xEvent**)&out);
+ rc = EventToXI2((InternalEvent *) in, (xEvent **) &out);
assert(rc == Success);
test_values_XITouchOwnershipEvent(in, out, FALSE);
swapped = calloc(1, sizeof(xEvent) + out->length * 4);
- XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped);
+ XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped);
test_values_XITouchOwnershipEvent(in, swapped, TRUE);
free(out);
free(swapped);
@@ -970,47 +947,45 @@ test_convert_XITouchOwnershipEvent(void)
long i;
memset(&in, 0, sizeof(in));
- in.header = ET_Internal;
- in.type = ET_TouchOwnership;
- in.length = sizeof(in);
- in.time = 0;
- in.deviceid = 1;
- in.sourceid = 2;
- in.touchid = 0;
- in.reason = 0;
- in.resource = 0;
- in.flags = 0;
+ in.header = ET_Internal;
+ in.type = ET_TouchOwnership;
+ in.length = sizeof(in);
+ in.time = 0;
+ in.deviceid = 1;
+ in.sourceid = 2;
+ in.touchid = 0;
+ in.reason = 0;
+ in.resource = 0;
+ in.flags = 0;
test_XITouchOwnershipEvent(&in);
- in.flags = XIAcceptTouch;
+ in.flags = XIAcceptTouch;
test_XITouchOwnershipEvent(&in);
- in.flags = XIRejectTouch;
+ in.flags = XIRejectTouch;
test_XITouchOwnershipEvent(&in);
- for (i = 1; i <= 0xFFFF; i <<= 1)
- {
+ for (i = 1; i <= 0xFFFF; i <<= 1) {
in.deviceid = i;
test_XITouchOwnershipEvent(&in);
}
- for (i = 1; i <= 0xFFFF; i <<= 1)
- {
+ for (i = 1; i <= 0xFFFF; i <<= 1) {
in.sourceid = i;
test_XITouchOwnershipEvent(&in);
}
- for (i = 1; ; i <<= 1)
- {
+ for (i = 1;; i <<= 1) {
in.touchid = i;
test_XITouchOwnershipEvent(&in);
- if (i == ((long)1 << 31))
- break;
+ if (i == ((long) 1 << 31))
+ break;
}
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
test_convert_XIRawEvent();
test_convert_XIFocusEvent();
diff --git a/xorg-server/test/xi2/protocol-xigetclientpointer.c b/xorg-server/test/xi2/protocol-xigetclientpointer.c
index aec58908d..28eb8d32a 100644
--- a/xorg-server/test/xi2/protocol-xigetclientpointer.c
+++ b/xorg-server/test/xi2/protocol-xigetclientpointer.c
@@ -49,13 +49,14 @@ struct {
static ClientRec client_window;
static ClientRec client_request;
-int __wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
+int
+__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client,
+ Mask access)
{
if (rid == ROOT_WINDOW_ID)
return BadWindow;
- if (rid == CLIENT_WINDOW_ID)
- {
+ if (rid == CLIENT_WINDOW_ID) {
*pClient = &client_window;
return Success;
}
@@ -63,13 +64,12 @@ int __wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask a
return __real_dixLookupClient(pClient, rid, client, access);
}
-
-static void reply_XIGetClientPointer(ClientPtr client, int len, char *data, void *userdata)
+static void
+reply_XIGetClientPointer(ClientPtr client, int len, char *data, void *userdata)
{
- xXIGetClientPointerReply *rep = (xXIGetClientPointerReply*)data;
+ xXIGetClientPointerReply *rep = (xXIGetClientPointerReply *) data;
- if (client->swapped)
- {
+ if (client->swapped) {
swapl(&rep->length);
swaps(&rep->sequenceNumber);
swaps(&rep->deviceid);
@@ -82,7 +82,9 @@ static void reply_XIGetClientPointer(ClientPtr client, int len, char *data, void
assert(rep->deviceid == test_data.dev->id);
}
-static void request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq* req, int error)
+static void
+request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq * req,
+ int error)
{
int rc;
@@ -105,7 +107,8 @@ static void request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq*
}
-static void test_XIGetClientPointer(void)
+static void
+test_XIGetClientPointer(void)
{
xXIGetClientPointerReq request;
@@ -113,7 +116,6 @@ static void test_XIGetClientPointer(void)
request.win = CLIENT_WINDOW_ID;
-
reply_handler = reply_XIGetClientPointer;
client_request = init_client(request.length, &request);
@@ -149,7 +151,8 @@ static void test_XIGetClientPointer(void)
request_XIGetClientPointer(&client_request, &request, Success);
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
client_window = init_client(0, NULL);
diff --git a/xorg-server/test/xi2/protocol-xigetselectedevents.c b/xorg-server/test/xi2/protocol-xigetselectedevents.c
index a78fb2655..fc33aa554 100644
--- a/xorg-server/test/xi2/protocol-xigetselectedevents.c
+++ b/xorg-server/test/xi2/protocol-xigetselectedevents.c
@@ -42,20 +42,21 @@
#include <X11/extensions/XI2proto.h>
#include "inputstr.h"
#include "windowstr.h"
-#include "extinit.h" /* for XInputExtensionInit */
+#include "extinit.h" /* for XInputExtensionInit */
#include "scrnintstr.h"
#include "xiselectev.h"
#include "exevents.h"
#include "protocol-common.h"
-static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, void *userdata);
-static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data, void *userdata);
-
+static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data,
+ void *userdata);
+static void reply_XIGetSelectedEvents_data(ClientPtr client, int len,
+ char *data, void *userdata);
struct {
int num_masks_expected;
- unsigned char mask[MAXDEVICES][XI2LASTEVENT]; /* intentionally bigger */
+ unsigned char mask[MAXDEVICES][XI2LASTEVENT]; /* intentionally bigger */
int mask_len;
} test_data;
@@ -64,14 +65,14 @@ struct {
* 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)
+int
+__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
{
- if (id == root.drawable.id)
- {
+ if (id == root.drawable.id) {
*win = &root;
return Success;
- } else if (id == window.drawable.id)
- {
+ }
+ else if (id == window.drawable.id) {
*win = &window;
return Success;
}
@@ -80,17 +81,18 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access
}
/* AddResource is called from XISetSEventMask, we don't need this */
-Bool __wrap_AddResource(XID id, RESTYPE type, pointer value)
+Bool
+__wrap_AddResource(XID id, RESTYPE type, pointer value)
{
return TRUE;
}
-static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, void *userdata)
+static void
+reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, void *userdata)
{
- xXIGetSelectedEventsReply *rep = (xXIGetSelectedEventsReply*)data;
+ xXIGetSelectedEventsReply *rep = (xXIGetSelectedEventsReply *) data;
- if (client->swapped)
- {
+ if (client->swapped) {
swapl(&rep->length);
swaps(&rep->sequenceNumber);
swaps(&rep->num_masks);
@@ -103,39 +105,41 @@ static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, voi
reply_handler = reply_XIGetSelectedEvents_data;
}
-static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data, void *userdata)
+static void
+reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data,
+ void *userdata)
{
int i;
xXIEventMask *mask;
unsigned char *bitmask;
- mask = (xXIEventMask*)data;
- for (i = 0; i < test_data.num_masks_expected; i++)
- {
- if (client->swapped)
- {
+ mask = (xXIEventMask *) data;
+ for (i = 0; i < test_data.num_masks_expected; i++) {
+ if (client->swapped) {
swaps(&mask->deviceid);
swaps(&mask->mask_len);
}
assert(mask->deviceid < 6);
- assert(mask->mask_len <= (((XI2LASTEVENT + 8)/8) + 3)/4) ;
+ assert(mask->mask_len <= (((XI2LASTEVENT + 8) / 8) + 3) / 4);
- bitmask = (unsigned char*)&mask[1];
+ bitmask = (unsigned char *) &mask[1];
assert(memcmp(bitmask,
- test_data.mask[mask->deviceid],
- mask->mask_len * 4) == 0);
+ test_data.mask[mask->deviceid], mask->mask_len * 4) == 0);
- mask = (xXIEventMask*)((char*)mask + mask->mask_len * 4 + sizeof(xXIEventMask));
+ mask =
+ (xXIEventMask *) ((char *) mask + mask->mask_len * 4 +
+ sizeof(xXIEventMask));
}
-
}
-static void request_XIGetSelectedEvents(xXIGetSelectedEventsReq* req, int error)
+static void
+request_XIGetSelectedEvents(xXIGetSelectedEventsReq * req, int error)
{
int rc;
ClientRec client;
+
client = init_client(req->length, req);
reply_handler = reply_XIGetSelectedEvents;
@@ -151,7 +155,8 @@ static void request_XIGetSelectedEvents(xXIGetSelectedEventsReq* req, int error)
assert(rc == error);
}
-static void test_XIGetSelectedEvents(void)
+static void
+test_XIGetSelectedEvents(void)
{
int i, j;
xXIGetSelectedEventsReq request;
@@ -174,42 +179,37 @@ static void test_XIGetSelectedEvents(void)
request.win = CLIENT_WINDOW_ID;
request_XIGetSelectedEvents(&request, Success);
- memset(test_data.mask, 0,
- sizeof(test_data.mask));
+ memset(test_data.mask, 0, sizeof(test_data.mask));
printf("Testing for valid masks\n");
- memset(&dev, 0, sizeof(dev)); /* dev->id is enough for XISetEventMask */
+ memset(&dev, 0, sizeof(dev)); /* dev->id is enough for XISetEventMask */
request.win = ROOT_WINDOW_ID;
/* devices 6 - MAXDEVICES don't exist, they mustn't be included in the
* reply even if a mask is set */
- for (j = 0; j < MAXDEVICES; j++)
- {
+ for (j = 0; j < MAXDEVICES; j++) {
test_data.num_masks_expected = min(j + 1, devices.num_devices + 2);
dev.id = j;
mask = test_data.mask[j];
/* bits one-by-one */
- for (i = 0; i < XI2LASTEVENT; i++)
- {
+ for (i = 0; i < XI2LASTEVENT; i++) {
SetBit(mask, i);
- XISetEventMask(&dev, &root, &client, (i + 8)/8, mask);
+ XISetEventMask(&dev, &root, &client, (i + 8) / 8, mask);
request_XIGetSelectedEvents(&request, Success);
ClearBit(mask, i);
}
/* all valid mask bits */
- for (i = 0; i < XI2LASTEVENT; i++)
- {
+ for (i = 0; i < XI2LASTEVENT; i++) {
SetBit(mask, i);
- XISetEventMask(&dev, &root, &client, (i + 8)/8, mask);
+ XISetEventMask(&dev, &root, &client, (i + 8) / 8, mask);
request_XIGetSelectedEvents(&request, Success);
}
}
printf("Testing removing all masks\n");
/* Unset all masks one-by-one */
- for (j = MAXDEVICES - 1; j >= 0; j--)
- {
+ for (j = MAXDEVICES - 1; j >= 0; j--) {
if (j < devices.num_devices + 2)
test_data.num_masks_expected--;
@@ -223,7 +223,8 @@ static void test_XIGetSelectedEvents(void)
}
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
@@ -231,4 +232,3 @@ int main(int argc, char** argv)
return 0;
}
-
diff --git a/xorg-server/test/xi2/protocol-xipassivegrabdevice.c b/xorg-server/test/xi2/protocol-xipassivegrabdevice.c
index b405556be..53c65bda6 100644
--- a/xorg-server/test/xi2/protocol-xipassivegrabdevice.c
+++ b/xorg-server/test/xi2/protocol-xipassivegrabdevice.c
@@ -41,26 +41,29 @@
#include "protocol-common.h"
static ClientRec client_request;
+
#define N_MODS 7
-static uint32_t modifiers[N_MODS] = {1, 2, 3, 4, 5, 6, 7};
+static uint32_t modifiers[N_MODS] = { 1, 2, 3, 4, 5, 6, 7 };
struct test_data {
int num_modifiers;
} testdata;
-int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
- int button, GrabParameters *param, enum InputLevel grabtype,
+int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
+ DeviceIntPtr modifier_device, int button,
+ GrabParameters *param, enum InputLevel grabtype,
GrabMask *mask);
-static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data, void *userdata);
+static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len,
+ char *data, void *userdata);
-int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
+int
+__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
{
- if (id == root.drawable.id)
- {
+ if (id == root.drawable.id) {
*win = &root;
return Success;
- } else if (id == window.drawable.id)
- {
+ }
+ else if (id == window.drawable.id) {
*win = &window;
return Success;
}
@@ -68,9 +71,11 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access
return __real_dixLookupWindow(win, id, client, access);
}
-int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
- int button, GrabParameters *param, enum InputLevel grabtype,
- GrabMask *mask)
+int
+__wrap_GrabButton(ClientPtr client, DeviceIntPtr dev,
+ DeviceIntPtr modifier_device, int button,
+ GrabParameters *param, enum InputLevel grabtype,
+ GrabMask *mask)
{
/* Fail every odd modifier */
if (param->modifiers % 2)
@@ -79,12 +84,12 @@ int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_
return Success;
}
-static void reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *userdata)
+static void
+reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *userdata)
{
- xXIPassiveGrabDeviceReply *rep = (xXIPassiveGrabDeviceReply*)data;
+ xXIPassiveGrabDeviceReply *rep = (xXIPassiveGrabDeviceReply *) data;
- if (client->swapped)
- {
+ if (client->swapped) {
swaps(&rep->sequenceNumber);
swapl(&rep->length);
swaps(&rep->num_modifiers);
@@ -100,14 +105,15 @@ static void reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, voi
reply_handler = reply_XIPassiveGrabDevice_data;
}
-static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data, void *userdata)
+static void
+reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data,
+ void *userdata)
{
int i;
- xXIGrabModifierInfo *mods = (xXIGrabModifierInfo*)data;
+ xXIGrabModifierInfo *mods = (xXIGrabModifierInfo *) data;
- for (i = 0; i < testdata.num_modifiers; i++, mods++)
- {
+ for (i = 0; i < testdata.num_modifiers; i++, mods++) {
if (client->swapped)
swapl(&mods->modifiers);
@@ -115,7 +121,7 @@ static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data
* above */
assert(mods->modifiers > 0);
assert(mods->modifiers <= 7);
- assert(mods->modifiers % 2 == 1); /* because we fail odd ones */
+ assert(mods->modifiers % 2 == 1); /* because we fail odd ones */
assert(mods->status != Success);
assert(mods->pad0 == 0);
assert(mods->pad1 == 0);
@@ -124,7 +130,9 @@ static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data
reply_handler = reply_XIPassiveGrabDevice;
}
-static void request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq* req, int error, int errval)
+static void
+request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req,
+ int error, int errval)
{
int rc;
int modifiers;
@@ -146,9 +154,9 @@ static void request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceRe
swaps(&req->num_modifiers);
swaps(&req->mask_len);
- while(modifiers--)
- {
- CARD32 *mod = ((CARD32*)(req + 1)) + modifiers;
+ while (modifiers--) {
+ CARD32 *mod = ((CARD32 *) (req + 1)) + modifiers;
+
swapl(mod);
}
@@ -159,11 +167,12 @@ static void request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceRe
assert(client_request.errorValue == errval);
}
-static unsigned char *data[4096]; /* the request buffer */
-static void test_XIPassiveGrabDevice(void)
+static unsigned char *data[4096]; /* the request buffer */
+static void
+test_XIPassiveGrabDevice(void)
{
int i;
- xXIPassiveGrabDeviceReq *request = (xXIPassiveGrabDeviceReq*)data;
+ xXIPassiveGrabDeviceReq *request = (xXIPassiveGrabDeviceReq *) data;
unsigned char *mask;
request_init(request, XIPassiveGrabDevice);
@@ -175,34 +184,38 @@ static void test_XIPassiveGrabDevice(void)
printf("Testing invalid device\n");
request->deviceid = 12;
- request_XIPassiveGrabDevice(&client_request, request, BadDevice, request->deviceid);
+ request_XIPassiveGrabDevice(&client_request, request, BadDevice,
+ request->deviceid);
request->deviceid = XIAllMasterDevices;
printf("Testing invalid grab types\n");
- for (i = XIGrabtypeTouchBegin + 1; i < 0xFF; i++)
- {
+ for (i = XIGrabtypeTouchBegin + 1; i < 0xFF; i++) {
request->grab_type = i;
- request_XIPassiveGrabDevice(&client_request, request, BadValue, request->grab_type);
+ request_XIPassiveGrabDevice(&client_request, request, BadValue,
+ request->grab_type);
}
printf("Testing invalid grab type + detail combinations\n");
request->grab_type = XIGrabtypeEnter;
request->detail = 1;
- request_XIPassiveGrabDevice(&client_request, request, BadValue, request->detail);
+ request_XIPassiveGrabDevice(&client_request, request, BadValue,
+ request->detail);
request->grab_type = XIGrabtypeFocusIn;
- request_XIPassiveGrabDevice(&client_request, request, BadValue, request->detail);
+ request_XIPassiveGrabDevice(&client_request, request, BadValue,
+ request->detail);
request->detail = 0;
printf("Testing invalid masks\n");
- mask = (unsigned char*)&request[1];
+ mask = (unsigned char *) &request[1];
request->mask_len = bytes_to_int32(XI2LASTEVENT + 1);
request->length += request->mask_len;
SetBit(mask, XI2LASTEVENT + 1);
- request_XIPassiveGrabDevice(&client_request, request, BadValue, XI2LASTEVENT + 1);
+ request_XIPassiveGrabDevice(&client_request, request, BadValue,
+ XI2LASTEVENT + 1);
ClearBit(mask, XI2LASTEVENT + 1);
@@ -217,11 +230,13 @@ static void test_XIPassiveGrabDevice(void)
/* some modifiers */
request->num_modifiers = N_MODS;
request->length += N_MODS;
- memcpy((uint32_t*)(request + 1) + request->mask_len, modifiers, sizeof(modifiers));
+ memcpy((uint32_t *) (request + 1) + request->mask_len, modifiers,
+ sizeof(modifiers));
request_XIPassiveGrabDevice(&client_request, request, Success, 0);
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
diff --git a/xorg-server/test/xi2/protocol-xiquerydevice.c b/xorg-server/test/xi2/protocol-xiquerydevice.c
index 569aea93a..5e59e8084 100644
--- a/xorg-server/test/xi2/protocol-xiquerydevice.c
+++ b/xorg-server/test/xi2/protocol-xiquerydevice.c
@@ -53,17 +53,19 @@ struct test_data {
int num_devices_in_reply;
};
-static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *userdata);
-static void reply_XIQueryDevice(ClientPtr client, int len, char* data, void *userdata);
+static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data,
+ void *userdata);
+static void reply_XIQueryDevice(ClientPtr client, int len, char *data,
+ void *userdata);
/* reply handling for the first bytes that constitute the reply */
-static void reply_XIQueryDevice(ClientPtr client, int len, char* data, void *userdata)
+static void
+reply_XIQueryDevice(ClientPtr client, int len, char *data, void *userdata)
{
- xXIQueryDeviceReply *rep = (xXIQueryDeviceReply*)data;
- struct test_data *querydata = (struct test_data*)userdata;
+ xXIQueryDeviceReply *rep = (xXIQueryDeviceReply *) data;
+ struct test_data *querydata = (struct test_data *) userdata;
- if (client->swapped)
- {
+ if (client->swapped) {
swapl(&rep->length);
swaps(&rep->sequenceNumber);
swaps(&rep->num_devices);
@@ -83,19 +85,18 @@ static void reply_XIQueryDevice(ClientPtr client, int len, char* data, void *use
}
/* reply handling for the trailing bytes that constitute the device info */
-static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *userdata)
+static void
+reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *userdata)
{
int i, j;
- struct test_data *querydata = (struct test_data*)userdata;
+ struct test_data *querydata = (struct test_data *) userdata;
DeviceIntPtr dev;
- xXIDeviceInfo *info = (xXIDeviceInfo*)data;
+ xXIDeviceInfo *info = (xXIDeviceInfo *) data;
xXIAnyInfo *any;
- for (i = 0; i < querydata->num_devices_in_reply; i++)
- {
- if (client->swapped)
- {
+ for (i = 0; i < querydata->num_devices_in_reply; i++) {
+ if (client->swapped) {
swaps(&info->deviceid);
swaps(&info->attachment);
swaps(&info->use);
@@ -106,179 +107,173 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void
if (querydata->which_device > XIAllMasterDevices)
assert(info->deviceid == querydata->which_device);
- assert(info->deviceid >= 2); /* 0 and 1 is reserved */
-
-
- switch(info->deviceid)
- {
- case 2: /* VCP */
- dev = devices.vcp;
- assert(info->use == XIMasterPointer);
- assert(info->attachment == devices.vck->id);
- assert(info->num_classes == 3); /* 2 axes + button */
- break;
- case 3: /* VCK */
- dev = devices.vck;
- assert(info->use == XIMasterKeyboard);
- assert(info->attachment == devices.vcp->id);
- assert(info->num_classes == 1);
- break;
- case 4: /* mouse */
- dev = devices.mouse;
- assert(info->use == XISlavePointer);
- assert(info->attachment == devices.vcp->id);
- assert(info->num_classes == 7); /* 4 axes + button + 2 scroll*/
- break;
- case 5: /* keyboard */
- dev = devices.kbd;
- assert(info->use == XISlaveKeyboard);
- assert(info->attachment == devices.vck->id);
- assert(info->num_classes == 1);
- break;
-
- default:
- /* We shouldn't get here */
- assert(0);
- break;
+ assert(info->deviceid >= 2); /* 0 and 1 is reserved */
+
+ switch (info->deviceid) {
+ case 2: /* VCP */
+ dev = devices.vcp;
+ assert(info->use == XIMasterPointer);
+ assert(info->attachment == devices.vck->id);
+ assert(info->num_classes == 3); /* 2 axes + button */
+ break;
+ case 3: /* VCK */
+ dev = devices.vck;
+ assert(info->use == XIMasterKeyboard);
+ assert(info->attachment == devices.vcp->id);
+ assert(info->num_classes == 1);
+ break;
+ case 4: /* mouse */
+ dev = devices.mouse;
+ assert(info->use == XISlavePointer);
+ assert(info->attachment == devices.vcp->id);
+ assert(info->num_classes == 7); /* 4 axes + button + 2 scroll */
+ break;
+ case 5: /* keyboard */
+ dev = devices.kbd;
+ assert(info->use == XISlaveKeyboard);
+ assert(info->attachment == devices.vck->id);
+ assert(info->num_classes == 1);
+ break;
+
+ default:
+ /* We shouldn't get here */
+ assert(0);
+ break;
}
assert(info->enabled == dev->enabled);
assert(info->name_len == strlen(dev->name));
- assert(strncmp((char*)&info[1], dev->name, info->name_len) == 0);
+ assert(strncmp((char *) &info[1], dev->name, info->name_len) == 0);
- any = (xXIAnyInfo*)((char*)&info[1] + ((info->name_len + 3)/4) * 4);
- for (j = 0; j < info->num_classes; j++)
- {
- if (client->swapped)
- {
+ any =
+ (xXIAnyInfo *) ((char *) &info[1] + ((info->name_len + 3) / 4) * 4);
+ for (j = 0; j < info->num_classes; j++) {
+ if (client->swapped) {
swaps(&any->type);
swaps(&any->length);
swaps(&any->sourceid);
}
- switch(info->deviceid)
+ switch (info->deviceid) {
+ case 3: /* VCK and kbd have the same properties */
+ case 5:
+ {
+ int k;
+ xXIKeyInfo *ki = (xXIKeyInfo *) any;
+ XkbDescPtr xkb = devices.vck->key->xkbInfo->desc;
+ uint32_t *kc;
+
+ if (client->swapped)
+ swaps(&ki->num_keycodes);
+
+ assert(any->type == XIKeyClass);
+ assert(ki->num_keycodes ==
+ (xkb->max_key_code - xkb->min_key_code + 1));
+ assert(any->length == (2 + ki->num_keycodes));
+
+ kc = (uint32_t *) & ki[1];
+ for (k = 0; k < ki->num_keycodes; k++, kc++) {
+ if (client->swapped)
+ swapl(kc);
+
+ assert(*kc >= xkb->min_key_code);
+ assert(*kc <= xkb->max_key_code);
+ }
+ break;
+ }
+ case 4:
{
- case 3: /* VCK and kbd have the same properties */
- case 5:
- {
- int k;
- xXIKeyInfo *ki = (xXIKeyInfo*)any;
- XkbDescPtr xkb = devices.vck->key->xkbInfo->desc;
- uint32_t *kc;
-
- if (client->swapped)
- swaps(&ki->num_keycodes);
-
- assert(any->type == XIKeyClass);
- assert(ki->num_keycodes == (xkb->max_key_code - xkb->min_key_code + 1));
- assert(any->length == (2 + ki->num_keycodes));
-
- kc = (uint32_t*)&ki[1];
- for (k = 0; k < ki->num_keycodes; k++, kc++)
- {
- if (client->swapped)
- swapl(kc);
-
- assert(*kc >= xkb->min_key_code);
- assert(*kc <= xkb->max_key_code);
- }
- break;
+ assert(any->type == XIButtonClass ||
+ any->type == XIValuatorClass ||
+ any->type == XIScrollClass);
+
+ if (any->type == XIScrollClass) {
+ xXIScrollInfo *si = (xXIScrollInfo *) any;
+
+ if (client->swapped) {
+ swaps(&si->number);
+ swaps(&si->scroll_type);
+ swapl(&si->increment.integral);
+ swapl(&si->increment.frac);
}
- case 4:
- {
- assert(any->type == XIButtonClass ||
- any->type == XIValuatorClass ||
- any->type == XIScrollClass);
-
- if (any->type == XIScrollClass)
- {
- xXIScrollInfo *si = (xXIScrollInfo*)any;
-
- if (client->swapped)
- {
- swaps(&si->number);
- swaps(&si->scroll_type);
- swapl(&si->increment.integral);
- swapl(&si->increment.frac);
- }
- assert(si->length == 6);
- assert(si->number == 2 || si->number == 3);
- if (si->number == 2) {
- assert(si->scroll_type == XIScrollTypeVertical);
- assert(!si->flags);
- }
- if (si->number == 3) {
- assert(si->scroll_type == XIScrollTypeHorizontal);
- assert(si->flags & XIScrollFlagPreferred);
- assert(!(si->flags & ~XIScrollFlagPreferred));
- }
-
- assert(si->increment.integral == si->number);
- /* protocol-common.c sets up increments of 2.4 and 3.5 */
- assert(si->increment.frac > 0.3 * (1ULL << 32));
- assert(si->increment.frac < 0.6 * (1ULL << 32));
- }
-
+ assert(si->length == 6);
+ assert(si->number == 2 || si->number == 3);
+ if (si->number == 2) {
+ assert(si->scroll_type == XIScrollTypeVertical);
+ assert(!si->flags);
}
- /* fall through */
- case 2: /* VCP and mouse have the same properties except for scroll */
- {
- if (info->deviceid == 2 ) /* VCP */
- assert(any->type == XIButtonClass ||
- any->type == XIValuatorClass);
-
- if (any->type == XIButtonClass)
- {
- int len;
- xXIButtonInfo *bi = (xXIButtonInfo*)any;
-
- if (client->swapped)
- swaps(&bi->num_buttons);
-
- assert(bi->num_buttons == devices.vcp->button->numButtons);
-
- len = 2 + bi->num_buttons + bytes_to_int32(bits_to_bytes(bi->num_buttons));
- assert(bi->length == len);
- } else if (any->type == XIValuatorClass)
- {
- xXIValuatorInfo *vi = (xXIValuatorInfo*)any;
-
- if (client->swapped)
- {
- swaps(&vi->number);
- swapl(&vi->label);
- swapl(&vi->min.integral);
- swapl(&vi->min.frac);
- swapl(&vi->max.integral);
- swapl(&vi->max.frac);
- swapl(&vi->resolution);
- }
-
- assert(vi->length == 11);
- assert(vi->number >= 0 && vi->number < 4);
- if (info->deviceid == 2) /* VCP */
- assert(vi->number < 2);
-
- assert(vi->mode == XIModeRelative);
- /* device was set up as relative, so standard
- * values here. */
- assert(vi->min.integral == -1);
- assert(vi->min.frac == 0);
- assert(vi->max.integral == -1);
- assert(vi->max.frac == 0);
- assert(vi->resolution == 0);
- }
+ if (si->number == 3) {
+ assert(si->scroll_type == XIScrollTypeHorizontal);
+ assert(si->flags & XIScrollFlagPreferred);
+ assert(!(si->flags & ~XIScrollFlagPreferred));
}
- break;
+
+ assert(si->increment.integral == si->number);
+ /* protocol-common.c sets up increments of 2.4 and 3.5 */
+ assert(si->increment.frac > 0.3 * (1ULL << 32));
+ assert(si->increment.frac < 0.6 * (1ULL << 32));
+ }
+
}
- any = (xXIAnyInfo*)(((char*)any) + any->length * 4);
+ /* fall through */
+ case 2: /* VCP and mouse have the same properties except for scroll */
+ {
+ if (info->deviceid == 2) /* VCP */
+ assert(any->type == XIButtonClass ||
+ any->type == XIValuatorClass);
+
+ if (any->type == XIButtonClass) {
+ int len;
+ xXIButtonInfo *bi = (xXIButtonInfo *) any;
+
+ if (client->swapped)
+ swaps(&bi->num_buttons);
+
+ assert(bi->num_buttons == devices.vcp->button->numButtons);
+
+ len =
+ 2 + bi->num_buttons +
+ bytes_to_int32(bits_to_bytes(bi->num_buttons));
+ assert(bi->length == len);
+ }
+ else if (any->type == XIValuatorClass) {
+ xXIValuatorInfo *vi = (xXIValuatorInfo *) any;
+
+ if (client->swapped) {
+ swaps(&vi->number);
+ swapl(&vi->label);
+ swapl(&vi->min.integral);
+ swapl(&vi->min.frac);
+ swapl(&vi->max.integral);
+ swapl(&vi->max.frac);
+ swapl(&vi->resolution);
+ }
+
+ assert(vi->length == 11);
+ assert(vi->number >= 0 && vi->number < 4);
+ if (info->deviceid == 2) /* VCP */
+ assert(vi->number < 2);
+
+ assert(vi->mode == XIModeRelative);
+ /* device was set up as relative, so standard
+ * values here. */
+ assert(vi->min.integral == -1);
+ assert(vi->min.frac == 0);
+ assert(vi->max.integral == -1);
+ assert(vi->max.frac == 0);
+ assert(vi->resolution == 0);
+ }
+ }
+ break;
+ }
+ any = (xXIAnyInfo *) (((char *) any) + any->length * 4);
}
- info = (xXIDeviceInfo*)any;
+ info = (xXIDeviceInfo *) any;
}
}
-static void request_XIQueryDevice(struct test_data *querydata,
- int deviceid, int error)
+static void
+request_XIQueryDevice(struct test_data *querydata, int deviceid, int error)
{
int rc;
ClientRec client;
@@ -309,7 +304,8 @@ static void request_XIQueryDevice(struct test_data *querydata,
assert(client.errorValue == deviceid);
}
-static void test_XIQueryDevice(void)
+static void
+test_XIQueryDevice(void)
{
int i;
xXIQueryDeviceReq request;
@@ -332,12 +328,12 @@ static void test_XIQueryDevice(void)
for (i = 6; i <= 0xFFFF; i++)
request_XIQueryDevice(&data, i, BadDevice);
-
reply_handler = NULL;
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
@@ -345,4 +341,3 @@ int main(int argc, char** argv)
return 0;
}
-
diff --git a/xorg-server/test/xi2/protocol-xiquerypointer.c b/xorg-server/test/xi2/protocol-xiquerypointer.c
index 65346ab5d..4756a6b2e 100644
--- a/xorg-server/test/xi2/protocol-xiquerypointer.c
+++ b/xorg-server/test/xi2/protocol-xiquerypointer.c
@@ -49,20 +49,19 @@ static struct {
WindowPtr win;
} test_data;
-
/* 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)
+int
+__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
{
- if (id == root.drawable.id)
- {
+ if (id == root.drawable.id) {
*win = &root;
return Success;
- } else if (id == window.drawable.id)
- {
+ }
+ else if (id == window.drawable.id) {
*win = &window;
return Success;
}
@@ -70,17 +69,16 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access
return __real_dixLookupWindow(win, id, client, access);
}
-static void reply_XIQueryPointer(ClientPtr client, int len, char *data,
- void *userdata)
+static void
+reply_XIQueryPointer(ClientPtr client, int len, char *data, void *userdata)
{
- xXIQueryPointerReply *rep = (xXIQueryPointerReply*)data;
+ xXIQueryPointerReply *rep = (xXIQueryPointerReply *) data;
SpritePtr sprite;
if (!rep->repType)
return;
- if (client->swapped)
- {
+ if (client->swapped) {
swapl(&rep->length);
swaps(&rep->sequenceNumber);
swapl(&rep->root);
@@ -101,13 +99,12 @@ static void reply_XIQueryPointer(ClientPtr client, int len, char *data,
assert((rep->root_x >> 16) == sprite->hot.x);
assert((rep->root_y >> 16) == sprite->hot.y);
- if (test_data.win == &root)
- {
+ if (test_data.win == &root) {
assert(rep->root_x == rep->win_x);
assert(rep->root_y == rep->win_y);
assert(rep->child == window.drawable.id);
- } else
- {
+ }
+ else {
int x, y;
x = sprite->hot.x - window.drawable.x;
@@ -118,18 +115,19 @@ static void reply_XIQueryPointer(ClientPtr client, int len, char *data,
assert(rep->child == None);
}
-
assert(rep->same_screen == xTrue);
reply_handler = reply_XIQueryPointer_data;
}
-static void reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *userdata)
+static void
+reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *userdata)
{
reply_handler = reply_XIQueryPointer;
}
-static void request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq* req, int error)
+static void
+request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq * req, int error)
{
int rc;
@@ -149,7 +147,8 @@ static void request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq* req, in
assert(client_request.errorValue == req->deviceid);
}
-static void test_XIQueryPointer(void)
+static void
+test_XIQueryPointer(void)
{
int i;
xXIQueryPointerReq request;
@@ -182,12 +181,11 @@ static void test_XIQueryPointer(void)
request_XIQueryPointer(&client_request, &request, BadDevice);
test_data.dev = devices.mouse;
- devices.mouse->master = NULL; /* Float, kind-of */
+ devices.mouse->master = NULL; /* Float, kind-of */
request.deviceid = devices.mouse->id;
request_XIQueryPointer(&client_request, &request, Success);
- for (i = devices.kbd->id + 1; i <= 0xFFFF; i++)
- {
+ for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) {
request.deviceid = i;
request_XIQueryPointer(&client_request, &request, BadDevice);
}
@@ -204,7 +202,8 @@ static void test_XIQueryPointer(void)
request_XIQueryPointer(&client_request, &request, Success);
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
diff --git a/xorg-server/test/xi2/protocol-xiqueryversion.c b/xorg-server/test/xi2/protocol-xiqueryversion.c
index d60d16b9d..3d50fa888 100644
--- a/xorg-server/test/xi2/protocol-xiqueryversion.c
+++ b/xorg-server/test/xi2/protocol-xiqueryversion.c
@@ -41,7 +41,7 @@
#include <X11/Xproto.h>
#include <X11/extensions/XI2proto.h>
#include "inputstr.h"
-#include "extinit.h" /* for XInputExtensionInit */
+#include "extinit.h" /* for XInputExtensionInit */
#include "scrnintstr.h"
#include "xiqueryversion.h"
@@ -56,14 +56,14 @@ struct test_data {
int minor_server;
};
-static void reply_XIQueryVersion(ClientPtr client, int len, char* data, void *userdata)
+static void
+reply_XIQueryVersion(ClientPtr client, int len, char *data, void *userdata)
{
- xXIQueryVersionReply *rep = (xXIQueryVersionReply*)data;
- struct test_data *versions = (struct test_data*)userdata;
+ xXIQueryVersionReply *rep = (xXIQueryVersionReply *) data;
+ struct test_data *versions = (struct test_data *) userdata;
unsigned int sver, cver, ver;
- if (client->swapped)
- {
+ if (client->swapped) {
swapl(&rep->length);
swaps(&rep->sequenceNumber);
swaps(&rep->major_version);
@@ -88,7 +88,8 @@ static void reply_XIQueryVersion(ClientPtr client, int len, char* data, void *us
*
* Test is run normal, then for a swapped client.
*/
-static void request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int error)
+static void
+request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int error)
{
int rc;
struct test_data versions;
@@ -97,7 +98,7 @@ static void request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int e
request_init(&request, XIQueryVersion);
client = init_client(request.length, &request);
- userdata = (void*)&versions;
+ userdata = (void *) &versions;
/* Change the server to support smaj.smin */
XIVersion.major_version = smaj;
@@ -126,7 +127,8 @@ static void request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int e
/* Client version less than 2.0 must return BadValue, all other combinations
* Success */
-static void test_XIQueryVersion(void)
+static void
+test_XIQueryVersion(void)
{
reply_handler = reply_XIQueryVersion;
@@ -159,9 +161,9 @@ static void test_XIQueryVersion(void)
for (smaj = 2; smaj <= 0xFFFF; smaj++)
for (smin = 0; smin <= 0xFFFF; smin++)
for (cmin = 0; cmin <= 0xFFFF; cmin++)
- for (cmaj = 0; cmaj <= 0xFFFF; cmaj++)
- {
+ for (cmaj = 0; cmaj <= 0xFFFF; cmaj++) {
int error = (cmaj < 2) ? BadValue : Success;
+
request_XIQueryVersion(smaj, smin, cmaj, cmin, error);
}
@@ -170,7 +172,8 @@ static void test_XIQueryVersion(void)
reply_handler = NULL;
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
diff --git a/xorg-server/test/xi2/protocol-xiselectevents.c b/xorg-server/test/xi2/protocol-xiselectevents.c
index 0390858b1..4daba8775 100644
--- a/xorg-server/test/xi2/protocol-xiselectevents.c
+++ b/xorg-server/test/xi2/protocol-xiselectevents.c
@@ -53,15 +53,17 @@
#include <X11/extensions/XI2proto.h>
#include "inputstr.h"
#include "windowstr.h"
-#include "extinit.h" /* for XInputExtensionInit */
+#include "extinit.h" /* for XInputExtensionInit */
#include "scrnintstr.h"
#include "xiselectev.h"
#include "protocol-common.h"
-static unsigned char *data[4096 * 20]; /* the request data buffer */
+static unsigned char *data[4096 * 20]; /* the request data buffer */
-int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask)
+int
+__wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len,
+ unsigned char *mask)
{
return Success;
}
@@ -71,14 +73,14 @@ int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned cha
* 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)
+int
+__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
{
- if (id == root.drawable.id)
- {
+ if (id == root.drawable.id) {
*win = &root;
return Success;
- } else if (id == window.drawable.id)
- {
+ }
+ else if (id == window.drawable.id) {
*win = &window;
return Success;
}
@@ -86,20 +88,19 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access
return __real_dixLookupWindow(win, id, client, access);
}
-
-static void request_XISelectEvent(xXISelectEventsReq *req, int error)
+static void
+request_XISelectEvent(xXISelectEventsReq * req, int error)
{
int i;
int rc;
ClientRec client;
xXIEventMask *mask, *next;
- req->length = (sz_xXISelectEventsReq/4);
- mask = (xXIEventMask*)&req[1];
- for (i = 0; i < req->num_masks; i++)
- {
- req->length += sizeof(xXIEventMask)/4 + mask->mask_len;
- mask = (xXIEventMask*)((char*)&mask[1] + mask->mask_len * 4);
+ req->length = (sz_xXISelectEventsReq / 4);
+ mask = (xXIEventMask *) & req[1];
+ for (i = 0; i < req->num_masks; i++) {
+ req->length += sizeof(xXIEventMask) / 4 + mask->mask_len;
+ mask = (xXIEventMask *) ((char *) &mask[1] + mask->mask_len * 4);
}
client = init_client(req->length, req);
@@ -109,10 +110,9 @@ static void request_XISelectEvent(xXISelectEventsReq *req, int error)
client.swapped = TRUE;
- mask = (xXIEventMask*)&req[1];
- for (i = 0; i < req->num_masks; i++)
- {
- next = (xXIEventMask*)((char*)&mask[1] + mask->mask_len * 4);
+ mask = (xXIEventMask *) & req[1];
+ for (i = 0; i < req->num_masks; i++) {
+ next = (xXIEventMask *) ((char *) &mask[1] + mask->mask_len * 4);
swaps(&mask->deviceid);
swaps(&mask->mask_len);
mask = next;
@@ -125,41 +125,41 @@ static void request_XISelectEvent(xXISelectEventsReq *req, int error)
assert(rc == error);
}
-static void _set_bit(unsigned char *bits, int bit)
+static void
+_set_bit(unsigned char *bits, int bit)
{
SetBit(bits, bit);
- if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership)
- {
+ if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership) {
SetBit(bits, XI_TouchBegin);
SetBit(bits, XI_TouchUpdate);
SetBit(bits, XI_TouchEnd);
}
}
-static void _clear_bit(unsigned char *bits, int bit)
+static void
+_clear_bit(unsigned char *bits, int bit)
{
ClearBit(bits, bit);
- if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership)
- {
+ if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership) {
ClearBit(bits, XI_TouchBegin);
ClearBit(bits, XI_TouchUpdate);
ClearBit(bits, XI_TouchEnd);
}
}
-static void request_XISelectEvents_masks(xXISelectEventsReq *req)
+static void
+request_XISelectEvents_masks(xXISelectEventsReq * req)
{
int i, j;
xXIEventMask *mask;
- int nmasks = (XI2LASTEVENT + 7)/8;
+ int nmasks = (XI2LASTEVENT + 7) / 8;
unsigned char *bits;
- mask = (xXIEventMask*)&req[1];
+ mask = (xXIEventMask *) & req[1];
req->win = ROOT_WINDOW_ID;
/* if a clients submits more than 100 masks, consider it insane and untested */
- for (i = 1; i <= 1000; i++)
- {
+ for (i = 1; i <= 1000; i++) {
req->num_masks = i;
mask->deviceid = XIAllDevices;
@@ -174,11 +174,10 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
* Test setting each valid mask bit, while leaving unneeded bits 0.
* -> Success
*/
- bits = (unsigned char*)&mask[1];
- mask->mask_len = (nmasks + 3)/4 * 10;
+ bits = (unsigned char *) &mask[1];
+ mask->mask_len = (nmasks + 3) / 4 * 10;
memset(bits, 0, mask->mask_len * 4);
- for (j = 0; j <= XI2LASTEVENT; j++)
- {
+ for (j = 0; j <= XI2LASTEVENT; j++) {
_set_bit(bits, j);
request_XISelectEvent(req, Success);
_clear_bit(bits, j);
@@ -189,12 +188,11 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
* Test setting all valid mask bits, while leaving unneeded bits 0.
* -> Success
*/
- bits = (unsigned char*)&mask[1];
- mask->mask_len = (nmasks + 3)/4 * 10;
+ bits = (unsigned char *) &mask[1];
+ mask->mask_len = (nmasks + 3) / 4 * 10;
memset(bits, 0, mask->mask_len * 4);
- for (j = 0; j <= XI2LASTEVENT; j++)
- {
+ for (j = 0; j <= XI2LASTEVENT; j++) {
_set_bit(bits, j);
request_XISelectEvent(req, Success);
}
@@ -203,12 +201,11 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
* mask is larger than needed for XI2LASTEVENT. If any unneeded bit
* is set -> BadValue
*/
- bits = (unsigned char*)&mask[1];
- mask->mask_len = (nmasks + 3)/4 * 10;
+ bits = (unsigned char *) &mask[1];
+ mask->mask_len = (nmasks + 3) / 4 * 10;
memset(bits, 0, mask->mask_len * 4);
- for (j = XI2LASTEVENT + 1; j < mask->mask_len * 4; j++)
- {
+ for (j = XI2LASTEVENT + 1; j < mask->mask_len * 4; j++) {
_set_bit(bits, j);
request_XISelectEvent(req, BadValue);
_clear_bit(bits, j);
@@ -217,11 +214,10 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
/* Test 4:
* Mask len is a sensible length, only valid bits are set -> Success
*/
- bits = (unsigned char*)&mask[1];
- mask->mask_len = (nmasks + 3)/4;
+ bits = (unsigned char *) &mask[1];
+ mask->mask_len = (nmasks + 3) / 4;
memset(bits, 0, mask->mask_len * 4);
- for (j = 0; j <= XI2LASTEVENT; j++)
- {
+ for (j = 0; j <= XI2LASTEVENT; j++) {
_set_bit(bits, j);
request_XISelectEvent(req, Success);
}
@@ -230,14 +226,13 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
* HierarchyChanged bit is BadValue for devices other than
* XIAllDevices
*/
- bits = (unsigned char*)&mask[1];
- mask->mask_len = (nmasks + 3)/4;
+ bits = (unsigned char *) &mask[1];
+ mask->mask_len = (nmasks + 3) / 4;
memset(bits, 0, mask->mask_len * 4);
SetBit(bits, XI_HierarchyChanged);
mask->deviceid = XIAllDevices;
request_XISelectEvent(req, Success);
- for (j = 1; j < devices.num_devices; j++)
- {
+ for (j = 1; j < devices.num_devices; j++) {
mask->deviceid = j;
request_XISelectEvent(req, BadValue);
}
@@ -245,28 +240,31 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req)
/* Test 6:
* All bits set minus hierarchy changed bit -> Success
*/
- bits = (unsigned char*)&mask[1];
- mask->mask_len = (nmasks + 3)/4;
+ bits = (unsigned char *) &mask[1];
+ mask->mask_len = (nmasks + 3) / 4;
memset(bits, 0, mask->mask_len * 4);
for (j = 0; j <= XI2LASTEVENT; j++)
_set_bit(bits, j);
_clear_bit(bits, XI_HierarchyChanged);
- for (j = 1; j < 6; j++)
- {
+ for (j = 1; j < 6; j++) {
mask->deviceid = j;
request_XISelectEvent(req, Success);
}
- mask = (xXIEventMask*)((char*)mask + sizeof(xXIEventMask) + mask->mask_len * 4);
+ mask =
+ (xXIEventMask *) ((char *) mask + sizeof(xXIEventMask) +
+ mask->mask_len * 4);
}
}
-static void test_XISelectEvents(void)
+static void
+test_XISelectEvents(void)
{
int i;
xXIEventMask *mask;
xXISelectEventsReq *req;
- req = (xXISelectEventsReq*)data;
+
+ req = (xXISelectEventsReq *) data;
request_init(req, XISelectEvents);
@@ -313,16 +311,15 @@ static void test_XISelectEvents(void)
req->num_masks = 1;
printf("Triggering bogus mask length error\n");
- mask = (xXIEventMask*)&req[1];
+ mask = (xXIEventMask *) & req[1];
mask->deviceid = 0;
mask->mask_len = 0xFFFF;
request_XISelectEvent(req, BadLength);
/* testing various device ids */
printf("Testing existing device ids.\n");
- for (i = 0; i < 6; i++)
- {
- mask = (xXIEventMask*)&req[1];
+ for (i = 0; i < 6; i++) {
+ mask = (xXIEventMask *) & req[1];
mask->deviceid = i;
mask->mask_len = 1;
req->win = ROOT_WINDOW_ID;
@@ -331,11 +328,10 @@ static void test_XISelectEvents(void)
}
printf("Testing non-existing device ids.\n");
- for (i = 6; i <= 0xFFFF; i++)
- {
+ for (i = 6; i <= 0xFFFF; i++) {
req->win = ROOT_WINDOW_ID;
req->num_masks = 1;
- mask = (xXIEventMask*)&req[1];
+ mask = (xXIEventMask *) & req[1];
mask->deviceid = i;
mask->mask_len = 1;
request_XISelectEvent(req, BadDevice);
@@ -344,7 +340,8 @@ static void test_XISelectEvents(void)
request_XISelectEvents_masks(req);
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
@@ -352,4 +349,3 @@ int main(int argc, char** argv)
return 0;
}
-
diff --git a/xorg-server/test/xi2/protocol-xisetclientpointer.c b/xorg-server/test/xi2/protocol-xisetclientpointer.c
index d9620e336..51db4ac69 100644
--- a/xorg-server/test/xi2/protocol-xisetclientpointer.c
+++ b/xorg-server/test/xi2/protocol-xisetclientpointer.c
@@ -40,7 +40,7 @@
#include <X11/extensions/XI2proto.h>
#include "inputstr.h"
#include "windowstr.h"
-#include "extinit.h" /* for XInputExtensionInit */
+#include "extinit.h" /* for XInputExtensionInit */
#include "scrnintstr.h"
#include "xisetclientpointer.h"
#include "exevents.h"
@@ -50,13 +50,14 @@
static ClientRec client_window;
static ClientRec client_request;
-int __wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access)
+int
+__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client,
+ Mask access)
{
if (rid == ROOT_WINDOW_ID)
return BadWindow;
- if (rid == CLIENT_WINDOW_ID)
- {
+ if (rid == CLIENT_WINDOW_ID) {
*pClient = &client_window;
return Success;
}
@@ -64,9 +65,11 @@ int __wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask a
return __real_dixLookupClient(pClient, rid, client, access);
}
-static void request_XISetClientPointer(xXISetClientPointerReq* req, int error)
+static void
+request_XISetClientPointer(xXISetClientPointerReq * req, int error)
{
int rc;
+
client_request = init_client(req->length, req);
rc = ProcXISetClientPointer(&client_request);
@@ -87,7 +90,8 @@ static void request_XISetClientPointer(xXISetClientPointerReq* req, int error)
}
-static void test_XISetClientPointer(void)
+static void
+test_XISetClientPointer(void)
{
int i;
xXISetClientPointerReq request;
@@ -113,8 +117,7 @@ static void test_XISetClientPointer(void)
assert(client_window.clientPtr->id == 2);
printf("Testing BadDevice error for all other devices.\n");
- for (i = 4; i <= 0xFFFF; i++)
- {
+ for (i = 4; i <= 0xFFFF; i++) {
request.deviceid = i;
request_XISetClientPointer(&request, BadDevice);
}
@@ -132,8 +135,8 @@ static void test_XISetClientPointer(void)
}
-
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
client_window = init_client(0, NULL);
diff --git a/xorg-server/test/xi2/protocol-xiwarppointer.c b/xorg-server/test/xi2/protocol-xiwarppointer.c
index 2b40f63f9..c279ac413 100644
--- a/xorg-server/test/xi2/protocol-xiwarppointer.c
+++ b/xorg-server/test/xi2/protocol-xiwarppointer.c
@@ -48,14 +48,14 @@ static int expected_y = SPRITE_Y;
* 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)
+int
+__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access)
{
- if (id == root.drawable.id)
- {
+ if (id == root.drawable.id) {
*win = &root;
return Success;
- } else if (id == window.drawable.id)
- {
+ }
+ else if (id == window.drawable.id) {
*win = &window;
return Success;
}
@@ -66,17 +66,17 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access
/**
* This function overrides the one in the screen rec.
*/
-static Bool ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr screen,
- int x, int y, Bool generateEvent)
+static Bool
+ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr screen,
+ int x, int y, Bool generateEvent)
{
assert(x == expected_x);
assert(y == expected_y);
return TRUE;
}
-
-static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req,
- int error)
+static void
+request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq * req, int error)
{
int rc;
@@ -87,8 +87,7 @@ static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req,
assert(client->errorValue == req->deviceid);
else if (rc == BadWindow)
assert(client->errorValue == req->dst_win ||
- client->errorValue == req->src_win);
-
+ client->errorValue == req->src_win);
client->swapped = TRUE;
@@ -109,12 +108,13 @@ static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req,
assert(client->errorValue == req->deviceid);
else if (rc == BadWindow)
assert(client->errorValue == req->dst_win ||
- client->errorValue == req->src_win);
+ client->errorValue == req->src_win);
client->swapped = FALSE;
}
-static void test_XIWarpPointer(void)
+static void
+test_XIWarpPointer(void)
{
int i;
ClientRec client_request;
@@ -143,12 +143,11 @@ static void test_XIWarpPointer(void)
request.deviceid = devices.kbd->id;
request_XIWarpPointer(&client_request, &request, BadDevice);
- devices.mouse->master = NULL; /* Float, kind-of */
+ devices.mouse->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++)
- {
+ for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) {
request.deviceid = i;
request_XIWarpPointer(&client_request, &request, BadDevice);
}
@@ -161,10 +160,10 @@ static void test_XIWarpPointer(void)
request_XIWarpPointer(&client_request, &request, Success);
request.src_win = root.drawable.id;
- request.dst_win = 0xFFFF; /* invalid window */
+ request.dst_win = 0xFFFF; /* invalid window */
request_XIWarpPointer(&client_request, &request, BadWindow);
- request.src_win = 0xFFFF; /* invalid window */
+ request.src_win = 0xFFFF; /* invalid window */
request.dst_win = root.drawable.id;
request_XIWarpPointer(&client_request, &request, BadWindow);
@@ -200,7 +199,8 @@ static void test_XIWarpPointer(void)
/* FIXME: src_x/y checks */
}
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
init_simple();
screen.SetCursorPosition = ScreenSetCursorPosition;
diff --git a/xorg-server/test/xi2/xi2.c b/xorg-server/test/xi2/xi2.c
index 5143caff8..6ee705293 100644
--- a/xorg-server/test/xi2/xi2.c
+++ b/xorg-server/test/xi2/xi2.c
@@ -30,10 +30,10 @@
#include "inputstr.h"
#include "assert.h"
-static void xi2mask_test(void)
+static void
+xi2mask_test(void)
{
- XI2Mask *xi2mask = NULL,
- *mergemask = NULL;
+ XI2Mask *xi2mask = NULL, *mergemask = NULL;
unsigned char *mask;
DeviceIntRec dev;
int i;
@@ -51,12 +51,14 @@ static void xi2mask_test(void)
/* ensure zeros */
for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
+
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
}
/* set various bits */
for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
const unsigned char *m;
+
xi2mask_set(xi2mask, i, i);
dev.id = i;
@@ -71,6 +73,7 @@ static void xi2mask_test(void)
/* ensure zeros one-by-one */
for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
+
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) != 0);
xi2mask_zero(xi2mask, i);
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
@@ -83,11 +86,13 @@ static void xi2mask_test(void)
for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
+
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
}
for (i = 0; i < xi2mask_num_masks(xi2mask); i++) {
const unsigned char *m;
+
SetBit(mask, i);
xi2mask_set_one_mask(xi2mask, i, mask, xi2mask_mask_size(xi2mask));
m = xi2mask_get_one_mask(xi2mask, i);
@@ -105,6 +110,7 @@ static void xi2mask_test(void)
xi2mask_merge(xi2mask, mergemask);
for (i = 0; i < xi2mask_num_masks(mergemask); i++) {
const unsigned char *m = xi2mask_get_one_mask(xi2mask, i);
+
SetBit(mask, i);
SetBit(mask, i * 2);
assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0);
@@ -120,8 +126,8 @@ static void xi2mask_test(void)
free(mask);
}
-
-int main(int argc, char** argv)
+int
+main(int argc, char **argv)
{
xi2mask_test();