From ecdbe817fd7eb53fd1e7485c0492355f7f002d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Tue, 22 Jun 2010 19:45:26 +0200 Subject: [PATCH 01/14] XF86CONFIGDIR is undefined when built with --disable-xorg (#28672) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 10-evdev.conf file gets installed as /usr/share/X11/10-evdev.conf on platforms that built the server with --disable-xorg like s390/s390x. The definition/installation should be guarded with "if XORG" because it makes sense only when built with xorg. X.Org Bug 28672 Signed-off-by: Dan Horák Acked-by: Julien Cristau Signed-off-by: Peter Hutterer --- config/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) 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 From a6b9e8f1e5d5d0b3b0f121a6f677eeca7aab1950 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 25 Aug 2010 11:06:38 -0400 Subject: [PATCH 02/14] linux: Fix CPU usage bug in console fd flushing If the vt gets a vhangup from under us, then the tty will appear ready in select(), but trying to tcflush() it will return -EIO, so we'll spin around at 100% CPU for no reason. Notice this condition and unregister the handler if it happens. Signed-off-by: Adam Jackson Reviewed-by: Mikhail Gusarov Reviewed-by: Julien Cristau Signed-off-by: Peter Hutterer --- hw/xfree86/os-support/linux/lnx_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 From 463841f45aafd1227bac652965c9ea337dd527fa Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Mon, 15 Nov 2010 11:42:11 -0500 Subject: [PATCH 03/14] Fix GPE Y axis scaling Signed-off-by: Chase Douglas Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- dix/getevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/getevents.c b/dix/getevents.c index 9553728c7..bc5841fed 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1139,7 +1139,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); From 31737fff08ec19b394837341d5e358ec401f5cd8 Mon Sep 17 00:00:00 2001 From: Chase Douglas Date: Mon, 15 Nov 2010 11:42:12 -0500 Subject: [PATCH 04/14] Fix transformAbsolute transformAbsolute must use old values if valuator mask doesn't have new ones, and it must only set new values if there was a change. Signed-off-by: Chase Douglas Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- dix/getevents.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index bc5841fed..a288e36d7 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -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])); } /** From b31df0439fe336a43a2355e2f1fb223d86045a05 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 22 Nov 2010 15:14:02 +1000 Subject: [PATCH 05/14] xfree86: add missing linebreak in error message. Signed-off-by: Peter Hutterer Reviewed-by: Magnus Kessler --- hw/xfree86/common/xf86Xinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From f49ee9074a66883a3c525b0d6e71589123288465 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 5 Feb 2010 10:59:52 +1000 Subject: [PATCH 06/14] test: compare byte padding macros against the expected bytes. We calculate the expected bytes for each value, let's use it. Signed-off-by: Peter Hutterer Reviewed-by: Julien Cristau --- test/input.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/input.c b/test/input.c index f8ce4b2df..13a441e9f 100644 --- a/test/input.c +++ b/test/input.c @@ -696,6 +696,7 @@ static void include_byte_padding_macros(void) 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()"); @@ -706,6 +707,7 @@ static void include_byte_padding_macros(void) g_assert(bytes_to_int32(i) <= i); g_assert((bytes_to_int32(i) * 4) - i <= 3); + g_assert(expected_4byte == bytes_to_int32(i)); } g_test_message("Testing pad_to_int32"); @@ -717,6 +719,7 @@ static void include_byte_padding_macros(void) g_assert(pad_to_int32(i) >= i); g_assert(pad_to_int32(i) - i <= 3); + g_assert(expected_bytes == pad_to_int32(i)); } } From d435e1ecb86e2fe6292b5945262956644f979bbb Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 5 Feb 2010 11:08:27 +1000 Subject: [PATCH 07/14] test: reduce range of byte-padding macro tests. Byte padding and conversion is interesting for the rage of 0-8 bytes, and then interesting towards the end of the valid range (INT_MAX - 7 and INT_MAX - 3). Note: this changes the upper range for pad_to_int32() and bytes_to_int32() from the previous (INT_MAX - 4) to (INT_MAX - 3). Signed-off-by: Peter Hutterer Reviewed-by: Julien Cristau --- test/input.c | 71 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/test/input.c b/test/input.c index 13a441e9f..4ccfaff1e 100644 --- a/test/input.c +++ b/test/input.c @@ -683,45 +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_assert(expected_4byte == bytes_to_int32(i)); - } +} - g_test_message("Testing pad_to_int32"); - - 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) From ebe3ddaf284ad388835da9cbaa6ad61fa21ce6dd Mon Sep 17 00:00:00 2001 From: Simon Thum Date: Fri, 19 Nov 2010 11:09:21 +1000 Subject: [PATCH 08/14] dix: fix up valuators passed to acceleration code. Signed-off-by: Peter Hutterer Reviewed-by: Simon Thum Reviewed-by: Chase Douglas --- dix/getevents.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dix/getevents.c b/dix/getevents.c index a288e36d7..06a0da014 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1159,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]; From 6f12934d4ea52f17ac7b21e92f4f929db165f83d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Nov 2010 10:58:32 +1000 Subject: [PATCH 09/14] dix: replace a manual valuator check with valuator_get_mode(). This check was missing the OutOfProximity mask and resulted in the wrong bits being set in InternalEvents. Signed-off-by: Peter Hutterer Reviewed-by: Jeremy Huddleston --- dix/getevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/getevents.c b/dix/getevents.c index 06a0da014..5f4fb66c8 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] = From 4f3e670fd28fceec384ff0d4ca7c1ff8d7a872ad Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Nov 2010 10:59:52 +1000 Subject: [PATCH 10/14] dix: when comparing axis modes, compare the bits, not the bytes. The DeviceEvent's mode field is a set of bits for each valuator, not bytes. Signed-off-by: Peter Hutterer Reviewed-by: Jeremy Huddleston --- dix/eventconvert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/eventconvert.c b/dix/eventconvert.c index 46eb4ffd8..b92169ee3 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -327,7 +327,7 @@ countValuators(DeviceEvent *ev, int *first) /* 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]) + if (BitIsOn(ev->valuators.mode, i) != BitIsOn(ev->valuators.mode, 0)) break; if (BitIsOn(ev->valuators.mask, i)) From 048e93593e3f7a99a7d2a219e1ce2bdc9d407807 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Nov 2010 11:15:52 +1000 Subject: [PATCH 11/14] dix: when converting to XI 1.x events, use the first_valuator's device mode Don't stop processing events when a valuator's mode doesn't match the 0th valuator's mode. Instead, start with the first_valuator in the event and keep stacking them on until the first valuator with a different mode is hit. Signed-off-by: Peter Hutterer Reviewed-by: Jeremy Huddleston --- dix/eventconvert.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dix/eventconvert.c b/dix/eventconvert.c index b92169ee3..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 (BitIsOn(ev->valuators.mode, i) != BitIsOn(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; From 45131bb67f9eacb3b55de4bcd3730fb9bb028e8a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Nov 2010 12:55:50 +1000 Subject: [PATCH 12/14] dix: GetProximityEvents needs to check up to the last valuator valuator_mask_size() returns the highest valuator set as opposed to the number of set bits (which obviously changes as we unset valuators). Signed-off-by: Peter Hutterer Reviewed-by: Jeremy Huddleston --- dix/getevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/getevents.c b/dix/getevents.c index 5f4fb66c8..f80e87ce9 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1248,7 +1248,7 @@ 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) From 0aca9e8424d8b978053a29c4468f800fc2e7238c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Nov 2010 13:04:19 +1000 Subject: [PATCH 13/14] dix: fix typo, set the second valuator with the y-axis data. Signed-off-by: Peter Hutterer Tested-by: Jeremy Huddleston Reviewed-by: Jeremy Huddleston --- dix/getevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dix/getevents.c b/dix/getevents.c index f80e87ce9..f19c99194 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1186,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); From 639600fa7ebad7a4953d0b632abeff2d339a49c6 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Nov 2010 13:30:05 +1000 Subject: [PATCH 14/14] dix: add a fixme about a corner-case that should probably be fixed. Signed-off-by: Peter Hutterer Reviewed-by: Jeremy Huddleston --- dix/getevents.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dix/getevents.c b/dix/getevents.c index f19c99194..0d5929073 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1255,6 +1255,10 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const Valuato 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;