summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-11-24 11:47:33 -0800
committerKeith Packard <keithp@keithp.com>2010-11-24 11:47:33 -0800
commit4e0f8f666e61390206c42ad2087477a912525bc7 (patch)
tree8fc8414b45d5f3e2de02ebea5b0860a8b482a748
parent400ddf2f58ce673c74d4e8ee829729cd3c75f8c9 (diff)
parent639600fa7ebad7a4953d0b632abeff2d339a49c6 (diff)
Merge remote branch 'whot/for-keith'
-rw-r--r--config/Makefile.am2
-rw-r--r--dix/eventconvert.c14
-rw-r--r--dix/getevents.c33
-rw-r--r--hw/xfree86/common/xf86Xinput.c2
-rw-r--r--hw/xfree86/os-support/linux/lnx_init.c6
-rw-r--r--test/input.c74
6 files changed, 96 insertions, 35 deletions
diff --git a/config/Makefile.am b/config/Makefile.am
index e1f1c4e16..4a2e873db 100644
--- a/config/Makefile.am
+++ b/config/Makefile.am
@@ -9,8 +9,10 @@ AM_CFLAGS += $(UDEV_CFLAGS)
libconfig_la_SOURCES += udev.c
libconfig_la_LIBADD = $(UDEV_LIBS)
+if XORG
xorgconfddir = $(datadir)/X11/$(XF86CONFIGDIR)
xorgconfd_DATA = 10-evdev.conf
+endif
else
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 46eb4ffd8..dd17898b7 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -324,14 +324,16 @@ countValuators(DeviceEvent *ev, int *first)
for (i = 0; i < sizeof(ev->valuators.mask) * 8; i++)
{
- /* Assume mode of 0th valuator matches XI1 device mode. Stop when the
- * event mode changes since XI1 can't handle mixed mode devices.
- */
- if (ev->valuators.mode[i] != ev->valuators.mode[0])
- break;
-
if (BitIsOn(ev->valuators.mask, i))
{
+ /* Assume mode of first_valuator matches XI1 device mode. Stop when the
+ * event mode changes since XI1 can't handle mixed mode devices.
+ */
+ if (first_valuator > -1 &&
+ BitIsOn(ev->valuators.mode, i) !=
+ BitIsOn(ev->valuators.mode, first_valuator))
+ break;
+
if (first_valuator == -1)
first_valuator = i;
last_valuator = i;
diff --git a/dix/getevents.c b/dix/getevents.c
index 9553728c7..0d5929073 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -210,7 +210,7 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask)
if (valuator_mask_isset(mask, i))
{
SetBit(event->valuators.mask, i);
- if (dev->valuator->axes[i].mode == Absolute)
+ if (valuator_get_mode(dev, i) == Absolute)
SetBit(event->valuators.mode, i);
event->valuators.data[i] = valuator_mask_get(mask, i);
event->valuators.data_frac[i] =
@@ -1057,14 +1057,18 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
struct pixman_f_vector p;
/* p' = M * p in homogeneous coordinates */
- p.v[0] = valuator_mask_get(mask, 0);
- p.v[1] = valuator_mask_get(mask, 1);
+ p.v[0] = (valuator_mask_isset(mask, 0) ? valuator_mask_get(mask, 0) :
+ dev->last.valuators[0]);
+ p.v[1] = (valuator_mask_isset(mask, 1) ? valuator_mask_get(mask, 1) :
+ dev->last.valuators[1]);
p.v[2] = 1.0;
pixman_f_transform_point(&dev->transform, &p);
- valuator_mask_set(mask, 0, lround(p.v[0]));
- valuator_mask_set(mask, 1, lround(p.v[1]));
+ if (lround(p.v[0]) != dev->last.valuators[0])
+ valuator_mask_set(mask, 0, lround(p.v[0]));
+ if (lround(p.v[1]) != dev->last.valuators[1])
+ valuator_mask_set(mask, 1, lround(p.v[1]));
}
/**
@@ -1139,7 +1143,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
}
if (valuator_mask_isset(&mask, 1))
{
- scaled = rescaleValuatorAxis(valuator_mask_get(&mask, 0),
+ scaled = rescaleValuatorAxis(valuator_mask_get(&mask, 1),
0.0, &y_frac, NULL,
pDev->valuator->axes + 1,
scr->height);
@@ -1155,11 +1159,16 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
* should be converted to masked valuators. */
int vals[2];
vals[0] = valuator_mask_isset(&mask, 0) ?
- valuator_mask_get(&mask, 0) : pDev->last.valuators[0];
+ valuator_mask_get(&mask, 0) : 0;
vals[1] = valuator_mask_isset(&mask, 1) ?
- valuator_mask_get(&mask, 1) : pDev->last.valuators[1];
+ valuator_mask_get(&mask, 1) : 0;
accelPointer(pDev, 0, 2, vals, ms);
+ if (valuator_mask_isset(&mask, 0))
+ valuator_mask_set(&mask, 0, vals[0]);
+ if (valuator_mask_isset(&mask, 1))
+ valuator_mask_set(&mask, 1, vals[1]);
+
/* The pointer acceleration code modifies the fractional part
* in-place, so we need to extract this information first */
x_frac = pDev->last.remainder[0];
@@ -1177,7 +1186,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
if (valuator_mask_isset(&mask, 0))
valuator_mask_set(&mask, 0, x);
if (valuator_mask_isset(&mask, 1))
- valuator_mask_set(&mask, 0, y);
+ valuator_mask_set(&mask, 1, y);
clipValuators(pDev, &mask);
@@ -1239,13 +1248,17 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const Valuato
valuator_mask_copy(&mask, mask_in);
/* ignore relative axes for proximity. */
- for (i = 0; i < valuator_mask_num_valuators(&mask); i++)
+ for (i = 0; i < valuator_mask_size(&mask); i++)
{
if (valuator_mask_isset(&mask, i) &&
valuator_get_mode(pDev, i) == Relative)
valuator_mask_unset(&mask, i);
}
+ /* FIXME: posting proximity events with relative valuators only results
+ * in an empty event, EventToXI() will fail to convert → no event sent
+ * to client. */
+
events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
event = (DeviceEvent *) events->event;
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 3664d46fb..81bb7070d 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1296,7 +1296,7 @@ xf86ScaleAxis(int Cx,
}
else {
X = 0;
- ErrorF ("Divide by Zero in xf86ScaleAxis");
+ ErrorF ("Divide by Zero in xf86ScaleAxis\n");
}
if (X > to_max)
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index bf61ceb65..7ee9046b2 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -85,7 +85,11 @@ static void *console_handler;
static void
drain_console(int fd, void *closure)
{
- tcflush(fd, TCIOFLUSH);
+ errno = 0;
+ if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) {
+ xf86RemoveGeneralHandler(console_handler);
+ console_handler = NULL;
+ }
}
void
diff --git a/test/input.c b/test/input.c
index f8ce4b2df..4ccfaff1e 100644
--- a/test/input.c
+++ b/test/input.c
@@ -683,42 +683,82 @@ static void dix_grab_matching(void)
g_assert(rc == TRUE);
}
-static void include_byte_padding_macros(void)
+static void test_bits_to_byte(int i)
{
- int i;
- g_test_message("Testing bits_to_bytes()");
-
- /* the macros don't provide overflow protection */
- for (i = 0; i < INT_MAX - 7; i++)
- {
int expected_bytes;
expected_bytes = (i + 7)/8;
g_assert(bits_to_bytes(i) >= i/8);
g_assert((bits_to_bytes(i) * 8) - i <= 7);
- }
+ g_assert(expected_bytes == bits_to_bytes(i));
+}
- g_test_message("Testing bytes_to_int32()");
- for (i = 0; i < INT_MAX - 3; i++)
- {
+static void test_bytes_to_int32(int i)
+{
int expected_4byte;
expected_4byte = (i + 3)/4;
g_assert(bytes_to_int32(i) <= i);
g_assert((bytes_to_int32(i) * 4) - i <= 3);
- }
-
- g_test_message("Testing pad_to_int32");
+ g_assert(expected_4byte == bytes_to_int32(i));
+}
- for (i = 0; i < INT_MAX - 3; i++)
- {
+static void test_pad_to_int32(int i)
+{
int expected_bytes;
expected_bytes = ((i + 3)/4) * 4;
g_assert(pad_to_int32(i) >= i);
g_assert(pad_to_int32(i) - i <= 3);
- }
+ g_assert(expected_bytes == pad_to_int32(i));
+}
+static void include_byte_padding_macros(void)
+{
+ g_test_message("Testing bits_to_bytes()");
+
+ /* the macros don't provide overflow protection */
+ test_bits_to_byte(0);
+ test_bits_to_byte(1);
+ test_bits_to_byte(2);
+ test_bits_to_byte(7);
+ test_bits_to_byte(8);
+ test_bits_to_byte(0xFF);
+ test_bits_to_byte(0x100);
+ test_bits_to_byte(INT_MAX - 9);
+ test_bits_to_byte(INT_MAX - 8);
+
+ g_test_message("Testing bytes_to_int32()");
+
+ test_bytes_to_int32(0);
+ test_bytes_to_int32(1);
+ test_bytes_to_int32(2);
+ test_bytes_to_int32(7);
+ test_bytes_to_int32(8);
+ test_bytes_to_int32(0xFF);
+ test_bytes_to_int32(0x100);
+ test_bytes_to_int32(0xFFFF);
+ test_bytes_to_int32(0x10000);
+ test_bytes_to_int32(0xFFFFFF);
+ test_bytes_to_int32(0x1000000);
+ test_bytes_to_int32(INT_MAX - 4);
+ test_bytes_to_int32(INT_MAX - 3);
+
+ g_test_message("Testing pad_to_int32");
+ test_pad_to_int32(0);
+ test_pad_to_int32(0);
+ test_pad_to_int32(1);
+ test_pad_to_int32(2);
+ test_pad_to_int32(7);
+ test_pad_to_int32(8);
+ test_pad_to_int32(0xFF);
+ test_pad_to_int32(0x100);
+ test_pad_to_int32(0xFFFF);
+ test_pad_to_int32(0x10000);
+ test_pad_to_int32(0xFFFFFF);
+ test_pad_to_int32(0x1000000);
+ test_pad_to_int32(INT_MAX - 4);
+ test_pad_to_int32(INT_MAX - 3);
}
static void xi_unregister_handlers(void)