From 01fe35482ab03d20e0dad1095ed9fe57ea17d633 Mon Sep 17 00:00:00 2001 From: Hongbo Min Date: Wed, 7 Aug 2013 14:39:21 +0800 Subject: [PATCH 1/2] Fix touch support issue on Tizen 2.1 On Tizen 2.1, the multi-touch support is different from the XInput2.2 approach. It extends the older Input2.1 spec to use multiple touch devices for multiple touch points, one touch device for one touch points. The device type name for this purpose is MULTITOUCHSCREEN which is not defined by XInput extension. This fix is to make Crosswalk be able to handle the new extension to XInput2.1 by introducing a new build option 'enable_xi21_mt'. It should be turned on for Tizen 2.1, and is exclusive to 'use_xi2_mt' option. --- build/common.gypi | 8 ++++++++ ui/base/touch/touch_factory_x11.cc | 13 ++++++++++++- ui/base/x/events_x.cc | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/build/common.gypi b/build/common.gypi index 6452ffa936f45..f4eae226cc558 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -374,6 +374,10 @@ # For example, use_xi2_mt=2 means XI2.2 or above version is required. 'use_xi2_mt%': 0, + # Enable multi-touch support based on XInput2.1 in which one touch screen + # device for one touch point. + 'enable_xi21_mt%': 0, + # Use of precompiled headers on Windows. # # This variable may be explicitly set to 1 (enabled) or 0 @@ -760,6 +764,7 @@ 'enable_hidpi%': '<(enable_hidpi)', 'enable_touch_ui%': '<(enable_touch_ui)', 'use_xi2_mt%':'<(use_xi2_mt)', + 'enable_xi21_mt%':'<(enable_xi21_mt)', 'file_manager_extension%': '<(file_manager_extension)', 'image_loader_extension%': '<(image_loader_extension)', 'inside_chromium_build%': '<(inside_chromium_build)', @@ -1911,6 +1916,9 @@ ['use_xi2_mt!=0', { 'defines': ['USE_XI2_MT=<(use_xi2_mt)'], }], + ['enable_xi21_mt==1', { + 'defines': ['ENABLE_XI21_MT=1'], + }], ['file_manager_extension==1', { 'defines': ['FILE_MANAGER_EXTENSION=1'], }], diff --git a/ui/base/touch/touch_factory_x11.cc b/ui/base/touch/touch_factory_x11.cc index 94191a8ad4245..06f1affe2ab2f 100644 --- a/ui/base/touch/touch_factory_x11.cc +++ b/ui/base/touch/touch_factory_x11.cc @@ -93,14 +93,25 @@ void TouchFactory::UpdateDeviceList(Display* display) { // old version of query function (XListInputDevices) is used instead. // If XInput2 is not supported, this will return null (with count of -1) so // we assume there cannot be any touch devices. - // With XI2.1 or older, we allow only single touch devices. + // With XI2.1 or older, we allow only single touch devices unless + // |enable_xi2_mt| is turned on. XDeviceList dev_list = DeviceListCacheX::GetInstance()->GetXDeviceList(display); for (int i = 0; i < dev_list.count; i++) { if (dev_list[i].type) { XScopedString devtype(XGetAtomName(display, dev_list[i].type)); +#if !defined(ENABLE_XI21_MT) if (devtype.string() && !strcmp(devtype.string(), XI_TOUCHSCREEN)) { +#else + // If XInput2.1 based multi-touch is enabled, the device type name is + // "MULTITOUCHSCREEN", which is specific to Tizen 2.1 case, not defined + // by XInput extension. + if (devtype.string() && !strcmp(devtype.string(), "MULTITOUCHSCREEN")) { +#endif touch_device_lookup_[dev_list[i].id] = true; + // We still think it as a single touch device although it is of + // 'MULTITOUCHSCREEN' device type since one touch screen device is + // only for one touch point. touch_device_list_[dev_list[i].id] = false; touch_device_available_ = true; } diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc index d890d65c577d9..65350d69430df 100644 --- a/ui/base/x/events_x.cc +++ b/ui/base/x/events_x.cc @@ -1006,6 +1006,11 @@ int GetTouchId(const base::NativeEvent& xev) { float slot = 0; ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); XIDeviceEvent* xievent = static_cast(xev->xcookie.data); +#if defined(ENABLE_XI21_MT) + // If using XInput2.1 for multi-touch support, the slot is tracked by the + // source id of each device event. + slot = xievent->sourceid; +#endif if (!factory->IsMultiTouchDevice(xievent->sourceid)) { // TODO(sad): Come up with a way to generate touch-ids for multi-touch // events when touch-events are generated from a single-touch device. From af6fd1f012112283fac34f462d7d4fd15114b5ae Mon Sep 17 00:00:00 2001 From: Hongbo Min Date: Wed, 7 Aug 2013 22:23:02 +0800 Subject: [PATCH 2/2] Polish the comments for enable_xi21_mt usage. --- build/common.gypi | 10 ++++++++-- ui/base/touch/touch_factory_x11.cc | 5 ++--- ui/base/x/events_x.cc | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/build/common.gypi b/build/common.gypi index f4eae226cc558..2aefde3418a68 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -374,8 +374,14 @@ # For example, use_xi2_mt=2 means XI2.2 or above version is required. 'use_xi2_mt%': 0, - # Enable multi-touch support based on XInput2.1 in which one touch screen - # device for one touch point. + # Enable multitouch support with XInput2.1. When it is enabled, unlike + # XInput2.2, there are no XI_TouchBegin, XI_TouchUpdate and XI_TouchEnd + # raw touch events emitted from touch device. Instead, the touch event is + # simulated by a normal mouse event, since X server maintains multiple + # virtual touch screen devices as floating device, each of them can + # simulate a touch event tracked by the device id of event source, as a + # result, multi-touch support works with these simulated touch events + # dispatched from floating device. 'enable_xi21_mt%': 0, # Use of precompiled headers on Windows. diff --git a/ui/base/touch/touch_factory_x11.cc b/ui/base/touch/touch_factory_x11.cc index 06f1affe2ab2f..c5235385fa20f 100644 --- a/ui/base/touch/touch_factory_x11.cc +++ b/ui/base/touch/touch_factory_x11.cc @@ -103,9 +103,8 @@ void TouchFactory::UpdateDeviceList(Display* display) { #if !defined(ENABLE_XI21_MT) if (devtype.string() && !strcmp(devtype.string(), XI_TOUCHSCREEN)) { #else - // If XInput2.1 based multi-touch is enabled, the device type name is - // "MULTITOUCHSCREEN", which is specific to Tizen 2.1 case, not defined - // by XInput extension. + // Certain Samsung and Intel devices support multi-touch with XInput2.1 + // using the device type "MULTITOUCHSCREEN". if (devtype.string() && !strcmp(devtype.string(), "MULTITOUCHSCREEN")) { #endif touch_device_lookup_[dev_list[i].id] = true; diff --git a/ui/base/x/events_x.cc b/ui/base/x/events_x.cc index 65350d69430df..fad2028f4b39d 100644 --- a/ui/base/x/events_x.cc +++ b/ui/base/x/events_x.cc @@ -1007,7 +1007,7 @@ int GetTouchId(const base::NativeEvent& xev) { ui::TouchFactory* factory = ui::TouchFactory::GetInstance(); XIDeviceEvent* xievent = static_cast(xev->xcookie.data); #if defined(ENABLE_XI21_MT) - // If using XInput2.1 for multi-touch support, the slot is tracked by the + // When using XInput2.1 multi-touch support, the slot is tracked by the // source id of each device event. slot = xievent->sourceid; #endif