summaryrefslogtreecommitdiffstats
path: root/ui/events/devices
diff options
context:
space:
mode:
authorkpschoedel <kpschoedel@chromium.org>2015-04-14 07:36:26 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-14 14:36:37 +0000
commita824971547acc92c86a302e442c385f94d63a3fb (patch)
tree72134e5073207a0c9a997890ef88ff6fbe1b6fa6 /ui/events/devices
parent1f3cf686b7e5ffcbf867b3f3775ba83b79fbf504 (diff)
downloadchromium_src-a824971547acc92c86a302e442c385f94d63a3fb.zip
chromium_src-a824971547acc92c86a302e442c385f94d63a3fb.tar.gz
chromium_src-a824971547acc92c86a302e442c385f94d63a3fb.tar.bz2
Change device IDs from unsigned to signed.
Change ui::InputDevice::id and ash::DisplayInfo::touch_device_id_ from 'unsigned int' to 'int' in accordance with the coding style guide. Review URL: https://codereview.chromium.org/1071193002 Cr-Commit-Position: refs/heads/master@{#325042}
Diffstat (limited to 'ui/events/devices')
-rw-r--r--ui/events/devices/device_data_manager.cc12
-rw-r--r--ui/events/devices/device_data_manager.h12
-rw-r--r--ui/events/devices/input_device.cc4
-rw-r--r--ui/events/devices/input_device.h6
-rw-r--r--ui/events/devices/touchscreen_device.cc2
-rw-r--r--ui/events/devices/touchscreen_device.h2
-rw-r--r--ui/events/devices/x11/device_data_manager_x11.cc36
-rw-r--r--ui/events/devices/x11/device_data_manager_x11.h16
-rw-r--r--ui/events/devices/x11/device_data_manager_x11_unittest.cc30
-rw-r--r--ui/events/devices/x11/touch_factory_x11.cc40
-rw-r--r--ui/events/devices/x11/touch_factory_x11.h13
11 files changed, 92 insertions, 81 deletions
diff --git a/ui/events/devices/device_data_manager.cc b/ui/events/devices/device_data_manager.cc
index 2bdbac9..628813a 100644
--- a/ui/events/devices/device_data_manager.cc
+++ b/ui/events/devices/device_data_manager.cc
@@ -70,13 +70,13 @@ void DeviceDataManager::ClearTouchDeviceAssociations() {
}
bool DeviceDataManager::IsTouchDeviceIdValid(
- unsigned int touch_device_id) const {
+ int touch_device_id) const {
return (touch_device_id > 0 && touch_device_id < kMaxDeviceNum);
}
void DeviceDataManager::UpdateTouchInfoForDisplay(
int64_t target_display_id,
- unsigned int touch_device_id,
+ int touch_device_id,
const gfx::Transform& touch_transformer) {
if (IsTouchDeviceIdValid(touch_device_id)) {
touch_device_to_target_display_map_[touch_device_id] = target_display_id;
@@ -84,19 +84,19 @@ void DeviceDataManager::UpdateTouchInfoForDisplay(
}
}
-void DeviceDataManager::UpdateTouchRadiusScale(unsigned int touch_device_id,
+void DeviceDataManager::UpdateTouchRadiusScale(int touch_device_id,
double scale) {
if (IsTouchDeviceIdValid(touch_device_id))
touch_radius_scale_map_[touch_device_id] = scale;
}
-void DeviceDataManager::ApplyTouchRadiusScale(unsigned int touch_device_id,
+void DeviceDataManager::ApplyTouchRadiusScale(int touch_device_id,
double* radius) {
if (IsTouchDeviceIdValid(touch_device_id))
*radius = (*radius) * touch_radius_scale_map_[touch_device_id];
}
-void DeviceDataManager::ApplyTouchTransformer(unsigned int touch_device_id,
+void DeviceDataManager::ApplyTouchTransformer(int touch_device_id,
float* x,
float* y) {
if (IsTouchDeviceIdValid(touch_device_id)) {
@@ -110,7 +110,7 @@ void DeviceDataManager::ApplyTouchTransformer(unsigned int touch_device_id,
}
int64_t DeviceDataManager::GetTargetDisplayForTouchDevice(
- unsigned int touch_device_id) const {
+ int touch_device_id) const {
if (IsTouchDeviceIdValid(touch_device_id))
return touch_device_to_target_display_map_[touch_device_id];
return gfx::Display::kInvalidDisplayID;
diff --git a/ui/events/devices/device_data_manager.h b/ui/events/devices/device_data_manager.h
index f58350f..674676e 100644
--- a/ui/events/devices/device_data_manager.h
+++ b/ui/events/devices/device_data_manager.h
@@ -35,15 +35,15 @@ class EVENTS_DEVICES_EXPORT DeviceDataManager
void ClearTouchDeviceAssociations();
void UpdateTouchInfoForDisplay(int64_t target_display_id,
- unsigned int touch_device_id,
+ int touch_device_id,
const gfx::Transform& touch_transformer);
- void ApplyTouchTransformer(unsigned int touch_device_id, float* x, float* y);
+ void ApplyTouchTransformer(int touch_device_id, float* x, float* y);
// Gets the display that touches from |touch_device_id| should be sent to.
- int64_t GetTargetDisplayForTouchDevice(unsigned int touch_device_id) const;
+ int64_t GetTargetDisplayForTouchDevice(int touch_device_id) const;
- void UpdateTouchRadiusScale(unsigned int touch_device_id, double scale);
- void ApplyTouchRadiusScale(unsigned int touch_device_id, double* radius);
+ void UpdateTouchRadiusScale(int touch_device_id, double scale);
+ void ApplyTouchRadiusScale(int touch_device_id, double* radius);
const std::vector<TouchscreenDevice>& touchscreen_devices() const {
return touchscreen_devices_;
@@ -74,7 +74,7 @@ class EVENTS_DEVICES_EXPORT DeviceDataManager
private:
static DeviceDataManager* instance_;
- bool IsTouchDeviceIdValid(unsigned int touch_device_id) const;
+ bool IsTouchDeviceIdValid(int touch_device_id) const;
double touch_radius_scale_map_[kMaxDeviceNum];
diff --git a/ui/events/devices/input_device.cc b/ui/events/devices/input_device.cc
index d57af43..d08aa51 100644
--- a/ui/events/devices/input_device.cc
+++ b/ui/events/devices/input_device.cc
@@ -9,13 +9,13 @@
namespace ui {
// static
-const unsigned int InputDevice::kInvalidId = 0;
+const int InputDevice::kInvalidId = 0;
InputDevice::InputDevice()
: id(kInvalidId), type(InputDeviceType::INPUT_DEVICE_UNKNOWN) {
}
-InputDevice::InputDevice(unsigned int id, InputDeviceType type)
+InputDevice::InputDevice(int id, InputDeviceType type)
: id(id), type(type) {
}
diff --git a/ui/events/devices/input_device.h b/ui/events/devices/input_device.h
index 70ae192..ee493ea 100644
--- a/ui/events/devices/input_device.h
+++ b/ui/events/devices/input_device.h
@@ -19,16 +19,16 @@ enum InputDeviceType {
// Represents an input device state.
struct EVENTS_DEVICES_EXPORT InputDevice {
- static const unsigned int kInvalidId;
+ static const int kInvalidId;
// Creates an invalid input device.
InputDevice();
- InputDevice(unsigned int id, InputDeviceType type);
+ InputDevice(int id, InputDeviceType type);
virtual ~InputDevice();
// ID of the device. This ID is unique between all input devices.
- unsigned int id;
+ int id;
// The type of the input device.
InputDeviceType type;
diff --git a/ui/events/devices/touchscreen_device.cc b/ui/events/devices/touchscreen_device.cc
index 3725c78..c5a0570 100644
--- a/ui/events/devices/touchscreen_device.cc
+++ b/ui/events/devices/touchscreen_device.cc
@@ -13,7 +13,7 @@ namespace ui {
TouchscreenDevice::TouchscreenDevice() : touch_points(0) {
}
-TouchscreenDevice::TouchscreenDevice(unsigned int id,
+TouchscreenDevice::TouchscreenDevice(int id,
InputDeviceType type,
const gfx::Size& size,
int touch_points)
diff --git a/ui/events/devices/touchscreen_device.h b/ui/events/devices/touchscreen_device.h
index 8c14545..7502f68 100644
--- a/ui/events/devices/touchscreen_device.h
+++ b/ui/events/devices/touchscreen_device.h
@@ -18,7 +18,7 @@ struct EVENTS_DEVICES_EXPORT TouchscreenDevice : public InputDevice {
// Creates an invalid touchscreen device.
TouchscreenDevice();
- TouchscreenDevice(unsigned int id,
+ TouchscreenDevice(int id,
InputDeviceType type,
const gfx::Size& size,
int touch_points);
diff --git a/ui/events/devices/x11/device_data_manager_x11.cc b/ui/events/devices/x11/device_data_manager_x11.cc
index f7b3b12..8570443 100644
--- a/ui/events/devices/x11/device_data_manager_x11.cc
+++ b/ui/events/devices/x11/device_data_manager_x11.cc
@@ -111,7 +111,7 @@ namespace ui {
namespace {
-bool DeviceHasId(const ui::InputDevice input_device, unsigned int id) {
+bool DeviceHasId(const ui::InputDevice input_device, int id) {
return input_device.id == id;
}
@@ -301,6 +301,8 @@ void DeviceDataManagerX11::GetEventRawData(const XEvent& xev, EventData* data) {
return;
XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data);
+ CHECK(xiev->sourceid >= 0);
+ CHECK(xiev->deviceid >= 0);
if (xiev->sourceid >= kMaxDeviceNum || xiev->deviceid >= kMaxDeviceNum)
return;
data->clear();
@@ -328,6 +330,8 @@ bool DeviceDataManagerX11::GetEventData(const XEvent& xev,
return false;
XIDeviceEvent* xiev = static_cast<XIDeviceEvent*>(xev.xcookie.data);
+ CHECK(xiev->sourceid >= 0);
+ CHECK(xiev->deviceid >= 0);
if (xiev->sourceid >= kMaxDeviceNum || xiev->deviceid >= kMaxDeviceNum)
return false;
const int sourceid = xiev->sourceid;
@@ -386,6 +390,7 @@ bool DeviceDataManagerX11::IsTouchpadXInputEvent(
XIDeviceEvent* xievent =
static_cast<XIDeviceEvent*>(native_event->xcookie.data);
+ CHECK(xievent->sourceid >= 0);
if (xievent->sourceid >= kMaxDeviceNum)
return false;
return touchpads_[xievent->sourceid];
@@ -398,6 +403,7 @@ bool DeviceDataManagerX11::IsCMTDeviceEvent(
XIDeviceEvent* xievent =
static_cast<XIDeviceEvent*>(native_event->xcookie.data);
+ CHECK(xievent->sourceid >= 0);
if (xievent->sourceid >= kMaxDeviceNum)
return false;
return cmt_devices_[xievent->sourceid];
@@ -570,7 +576,7 @@ void DeviceDataManagerX11::GetGestureTimes(
*end_time = data[DT_CMT_END_TIME];
}
-bool DeviceDataManagerX11::NormalizeData(unsigned int deviceid,
+bool DeviceDataManagerX11::NormalizeData(int deviceid,
const DataType type,
double* value) {
double max_value;
@@ -583,11 +589,12 @@ bool DeviceDataManagerX11::NormalizeData(unsigned int deviceid,
return false;
}
-bool DeviceDataManagerX11::GetDataRange(unsigned int deviceid,
+bool DeviceDataManagerX11::GetDataRange(int deviceid,
const DataType type,
double* min,
double* max) {
- if (deviceid >= static_cast<unsigned int>(kMaxDeviceNum))
+ CHECK(deviceid >= 0);
+ if (deviceid >= kMaxDeviceNum)
return false;
if (valuator_lookup_[deviceid][type] >= 0) {
*min = valuator_min_[deviceid][type];
@@ -598,8 +605,8 @@ bool DeviceDataManagerX11::GetDataRange(unsigned int deviceid,
}
void DeviceDataManagerX11::SetDeviceListForTest(
- const std::vector<unsigned int>& touchscreen,
- const std::vector<unsigned int>& cmt_devices) {
+ const std::vector<int>& touchscreen,
+ const std::vector<int>& cmt_devices) {
for (int i = 0; i < kMaxDeviceNum; ++i) {
valuator_count_[i] = 0;
valuator_lookup_[i].clear();
@@ -611,14 +618,14 @@ void DeviceDataManagerX11::SetDeviceListForTest(
}
for (size_t i = 0; i < touchscreen.size(); i++) {
- unsigned int deviceid = touchscreen[i];
+ int deviceid = touchscreen[i];
InitializeValuatorsForTest(deviceid, kTouchDataTypeStart, kTouchDataTypeEnd,
0, 1000);
}
cmt_devices_.reset();
for (size_t i = 0; i < cmt_devices.size(); ++i) {
- unsigned int deviceid = cmt_devices[i];
+ int deviceid = cmt_devices[i];
cmt_devices_[deviceid] = true;
touchpads_[deviceid] = true;
InitializeValuatorsForTest(deviceid, kCMTDataTypeStart, kCMTDataTypeEnd,
@@ -665,8 +672,7 @@ void DeviceDataManagerX11::InitializeValuatorsForTest(int deviceid,
}
}
-bool DeviceDataManagerX11::TouchEventNeedsCalibrate(
- unsigned int touch_device_id) const {
+bool DeviceDataManagerX11::TouchEventNeedsCalibrate(int touch_device_id) const {
#if defined(OS_CHROMEOS)
if (!base::SysInfo::IsRunningOnChromeOS())
return false;
@@ -688,7 +694,7 @@ void DeviceDataManagerX11::SetDisabledKeyboardAllowedKeys(
blocked_keyboard_allowed_keys_ = excepted_keys.Pass();
}
-void DeviceDataManagerX11::DisableDevice(unsigned int deviceid) {
+void DeviceDataManagerX11::DisableDevice(int deviceid) {
blocked_devices_.set(deviceid, true);
// TODO(rsadam@): Support blocking touchscreen devices.
std::vector<KeyboardDevice> keyboards = keyboard_devices();
@@ -698,15 +704,15 @@ void DeviceDataManagerX11::DisableDevice(unsigned int deviceid) {
std::bind2nd(std::ptr_fun(&DeviceHasId), deviceid));
if (it != std::end(keyboards)) {
blocked_keyboards_.insert(
- std::pair<unsigned int, KeyboardDevice>(deviceid, *it));
+ std::pair<int, KeyboardDevice>(deviceid, *it));
keyboards.erase(it);
DeviceDataManager::OnKeyboardDevicesUpdated(keyboards);
}
}
-void DeviceDataManagerX11::EnableDevice(unsigned int deviceid) {
+void DeviceDataManagerX11::EnableDevice(int deviceid) {
blocked_devices_.set(deviceid, false);
- std::map<unsigned int, KeyboardDevice>::iterator it =
+ std::map<int, KeyboardDevice>::iterator it =
blocked_keyboards_.find(deviceid);
if (it != blocked_keyboards_.end()) {
std::vector<KeyboardDevice> devices = keyboard_devices();
@@ -740,7 +746,7 @@ bool DeviceDataManagerX11::IsEventBlocked(
void DeviceDataManagerX11::OnKeyboardDevicesUpdated(
const std::vector<KeyboardDevice>& devices) {
std::vector<KeyboardDevice> keyboards(devices);
- for (std::map<unsigned int, KeyboardDevice>::iterator blocked_iter =
+ for (std::map<int, KeyboardDevice>::iterator blocked_iter =
blocked_keyboards_.begin();
blocked_iter != blocked_keyboards_.end();) {
// Check if the blocked device still exists in list of devices.
diff --git a/ui/events/devices/x11/device_data_manager_x11.h b/ui/events/devices/x11/device_data_manager_x11.h
index bb5fa15..38cb781 100644
--- a/ui/events/devices/x11/device_data_manager_x11.h
+++ b/ui/events/devices/x11/device_data_manager_x11.h
@@ -204,13 +204,13 @@ class EVENTS_DEVICES_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
// *value = (*value - min_value_of_tp) / (max_value_of_tp - min_value_of_tp)
// Returns true and sets the normalized value in|value| if normalization is
// successful. Returns false and |value| is unchanged otherwise.
- bool NormalizeData(unsigned int deviceid,
+ bool NormalizeData(int deviceid,
const DataType type,
double* value);
// Extract the range of the data type. Return true if the range is available
// and written into min & max, false if the range is not available.
- bool GetDataRange(unsigned int deviceid,
+ bool GetDataRange(int deviceid,
const DataType type,
double* min,
double* max);
@@ -219,22 +219,22 @@ class EVENTS_DEVICES_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
// This function is only for test purpose. It does not query the X server for
// the actual device info, but rather inits the relevant valuator structures
// to have safe default values for testing.
- void SetDeviceListForTest(const std::vector<unsigned int>& touchscreen,
- const std::vector<unsigned int>& cmt_devices);
+ void SetDeviceListForTest(const std::vector<int>& touchscreen,
+ const std::vector<int>& cmt_devices);
void SetValuatorDataForTest(XIDeviceEvent* xievent,
DataType type,
double value);
- bool TouchEventNeedsCalibrate(unsigned int touch_device_id) const;
+ bool TouchEventNeedsCalibrate(int touch_device_id) const;
// Sets the keys which are still allowed on a disabled keyboard device.
void SetDisabledKeyboardAllowedKeys(
scoped_ptr<std::set<KeyboardCode> > excepted_keys);
// Disables and enables events from devices by device id.
- void DisableDevice(unsigned int deviceid);
- void EnableDevice(unsigned int deviceid);
+ void DisableDevice(int deviceid);
+ void EnableDevice(int deviceid);
// Returns true if |native_event| should be blocked.
bool IsEventBlocked(const base::NativeEvent& native_event);
@@ -315,7 +315,7 @@ class EVENTS_DEVICES_EXPORT DeviceDataManagerX11 : public DeviceDataManager {
// Map that stores meta-data for blocked keyboards. This is needed to restore
// devices when they are re-enabled.
- std::map<unsigned int, ui::KeyboardDevice> blocked_keyboards_;
+ std::map<int, ui::KeyboardDevice> blocked_keyboards_;
// X11 atoms cache.
X11AtomCache atom_cache_;
diff --git a/ui/events/devices/x11/device_data_manager_x11_unittest.cc b/ui/events/devices/x11/device_data_manager_x11_unittest.cc
index 444611f..3cce253f 100644
--- a/ui/events/devices/x11/device_data_manager_x11_unittest.cc
+++ b/ui/events/devices/x11/device_data_manager_x11_unittest.cc
@@ -78,9 +78,9 @@ TEST_F(DeviceDataManagerX11Test, NotifyOnDisable) {
TestInputDeviceObserver observer(manager);
std::vector<ui::KeyboardDevice> keyboards;
keyboards.push_back(
- ui::KeyboardDevice(1u, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
+ ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
keyboards.push_back(
- ui::KeyboardDevice(2u, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
+ ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
SetKeyboardDevices(keyboards);
EXPECT_TRUE(observer.change_notified());
std::vector<KeyboardDevice> devices = manager->keyboard_devices();
@@ -88,16 +88,16 @@ TEST_F(DeviceDataManagerX11Test, NotifyOnDisable) {
observer.Reset();
// Disable the device, should be notified that the device list contains one
// less device.
- manager->DisableDevice(2u);
+ manager->DisableDevice(2);
EXPECT_TRUE(observer.change_notified());
devices = manager->keyboard_devices();
EXPECT_EQ(1u, devices.size());
KeyboardDevice device = devices.front();
- EXPECT_EQ(1u, device.id);
+ EXPECT_EQ(1, device.id);
observer.Reset();
// Reenable the device, should be notified that the device list contains one
// more device.
- manager->EnableDevice(2u);
+ manager->EnableDevice(2);
EXPECT_TRUE(observer.change_notified());
devices = manager->keyboard_devices();
EXPECT_EQ(keyboards.size(), devices.size());
@@ -109,9 +109,9 @@ TEST_F(DeviceDataManagerX11Test, TestMultipleDisable) {
TestInputDeviceObserver observer(manager);
std::vector<ui::KeyboardDevice> keyboards;
keyboards.push_back(
- ui::KeyboardDevice(1u, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
+ ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
keyboards.push_back(
- ui::KeyboardDevice(2u, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
+ ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
SetKeyboardDevices(keyboards);
EXPECT_TRUE(observer.change_notified());
std::vector<KeyboardDevice> devices = manager->keyboard_devices();
@@ -119,25 +119,25 @@ TEST_F(DeviceDataManagerX11Test, TestMultipleDisable) {
observer.Reset();
// Disable the device, should be notified that the device list contains one
// less device.
- manager->DisableDevice(1u);
+ manager->DisableDevice(1);
EXPECT_TRUE(observer.change_notified());
devices = manager->keyboard_devices();
EXPECT_EQ(1u, devices.size());
observer.Reset();
// Disable the second device, should be notified that the device list empty.
- manager->DisableDevice(2u);
+ manager->DisableDevice(2);
EXPECT_TRUE(observer.change_notified());
devices = manager->keyboard_devices();
EXPECT_EQ(0u, devices.size());
observer.Reset();
// Enable the first device, should be notified that one device present.
- manager->EnableDevice(1u);
+ manager->EnableDevice(1);
EXPECT_TRUE(observer.change_notified());
devices = manager->keyboard_devices();
EXPECT_EQ(1u, devices.size());
observer.Reset();
// Enable the second device, should be notified that both devices present.
- manager->EnableDevice(2u);
+ manager->EnableDevice(2);
EXPECT_TRUE(observer.change_notified());
devices = manager->keyboard_devices();
EXPECT_EQ(2u, devices.size());
@@ -148,16 +148,16 @@ TEST_F(DeviceDataManagerX11Test, UnblockOnDeviceUnplugged) {
TestInputDeviceObserver observer(manager);
std::vector<ui::KeyboardDevice> all_keyboards;
all_keyboards.push_back(
- ui::KeyboardDevice(1u, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
+ ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
all_keyboards.push_back(
- ui::KeyboardDevice(2u, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
+ ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
SetKeyboardDevices(all_keyboards);
EXPECT_TRUE(observer.change_notified());
std::vector<KeyboardDevice> devices = manager->keyboard_devices();
EXPECT_EQ(all_keyboards.size(), devices.size());
observer.Reset();
// Expect to be notified that the device is no longer available.
- manager->DisableDevice(2u);
+ manager->DisableDevice(2);
EXPECT_TRUE(observer.change_notified());
devices = manager->keyboard_devices();
EXPECT_EQ(1u, devices.size());
@@ -166,7 +166,7 @@ TEST_F(DeviceDataManagerX11Test, UnblockOnDeviceUnplugged) {
// did not change.
std::vector<ui::KeyboardDevice> subset_keyboards;
subset_keyboards.push_back(
- ui::KeyboardDevice(1u, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
+ ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
SetKeyboardDevices(subset_keyboards);
EXPECT_FALSE(observer.change_notified());
// Replug in the first device. Should be notified of the new device.
diff --git a/ui/events/devices/x11/touch_factory_x11.cc b/ui/events/devices/x11/touch_factory_x11.cc
index 3d04235..40c5624 100644
--- a/ui/events/devices/x11/touch_factory_x11.cc
+++ b/ui/events/devices/x11/touch_factory_x11.cc
@@ -63,8 +63,8 @@ void TouchFactory::SetTouchDeviceListFromCommandLine() {
if (!touch_devices.empty()) {
std::vector<std::string> devs;
- std::vector<unsigned int> device_ids;
- unsigned int devid;
+ std::vector<int> device_ids;
+ int devid;
base::SplitString(touch_devices, ',', &devs);
for (std::vector<std::string>::iterator iter = devs.begin();
iter != devs.end(); ++iter) {
@@ -216,28 +216,30 @@ void TouchFactory::SetupXI2ForXWindow(Window window) {
XFlush(display);
}
-void TouchFactory::SetTouchDeviceList(
- const std::vector<unsigned int>& devices) {
+void TouchFactory::SetTouchDeviceList(const std::vector<int>& devices) {
touch_device_lookup_.reset();
touch_device_list_.clear();
- for (std::vector<unsigned int>::const_iterator iter = devices.begin();
+ for (std::vector<int>::const_iterator iter = devices.begin();
iter != devices.end(); ++iter) {
- DCHECK(*iter < touch_device_lookup_.size());
+ DCHECK(IsValidDevice(*iter));
touch_device_lookup_[*iter] = true;
touch_device_list_[*iter] = false;
}
}
-bool TouchFactory::IsTouchDevice(unsigned deviceid) const {
- return deviceid < touch_device_lookup_.size() ?
- touch_device_lookup_[deviceid] : false;
+bool TouchFactory::IsValidDevice(int deviceid) const {
+ return (deviceid >= 0) &&
+ (static_cast<size_t>(deviceid) < touch_device_lookup_.size());
}
-bool TouchFactory::IsMultiTouchDevice(unsigned int deviceid) const {
- return (deviceid < touch_device_lookup_.size() &&
- touch_device_lookup_[deviceid]) ?
- touch_device_list_.find(deviceid)->second :
- false;
+bool TouchFactory::IsTouchDevice(int deviceid) const {
+ return IsValidDevice(deviceid) ? touch_device_lookup_[deviceid] : false;
+}
+
+bool TouchFactory::IsMultiTouchDevice(int deviceid) const {
+ return (IsValidDevice(deviceid) && touch_device_lookup_[deviceid])
+ ? touch_device_list_.find(deviceid)->second
+ : false;
}
bool TouchFactory::QuerySlotForTrackingID(uint32 tracking_id, int* slot) {
@@ -269,12 +271,12 @@ void TouchFactory::ResetForTest() {
}
void TouchFactory::SetTouchDeviceForTest(
- const std::vector<unsigned int>& devices) {
+ const std::vector<int>& devices) {
touch_device_lookup_.reset();
touch_device_list_.clear();
- for (std::vector<unsigned int>::const_iterator iter = devices.begin();
+ for (std::vector<int>::const_iterator iter = devices.begin();
iter != devices.end(); ++iter) {
- DCHECK(*iter < touch_device_lookup_.size());
+ DCHECK(IsValidDevice(*iter));
touch_device_lookup_[*iter] = true;
touch_device_list_[*iter] = true;
}
@@ -282,9 +284,9 @@ void TouchFactory::SetTouchDeviceForTest(
}
void TouchFactory::SetPointerDeviceForTest(
- const std::vector<unsigned int>& devices) {
+ const std::vector<int>& devices) {
pointer_device_lookup_.reset();
- for (std::vector<unsigned int>::const_iterator iter = devices.begin();
+ for (std::vector<int>::const_iterator iter = devices.begin();
iter != devices.end(); ++iter) {
pointer_device_lookup_[*iter] = true;
}
diff --git a/ui/events/devices/x11/touch_factory_x11.h b/ui/events/devices/x11/touch_factory_x11.h
index 775b4966..146b2a6 100644
--- a/ui/events/devices/x11/touch_factory_x11.h
+++ b/ui/events/devices/x11/touch_factory_x11.h
@@ -49,14 +49,17 @@ class EVENTS_DEVICES_EXPORT TouchFactory {
// Keeps a list of touch devices so that it is possible to determine if a
// pointer event is a touch-event or a mouse-event. The list is reset each
// time this is called.
- void SetTouchDeviceList(const std::vector<unsigned int>& devices);
+ void SetTouchDeviceList(const std::vector<int>& devices);
+
+ // Is the device ID valid?
+ bool IsValidDevice(int deviceid) const;
// Is the device a touch-device?
- bool IsTouchDevice(unsigned int deviceid) const;
+ bool IsTouchDevice(int deviceid) const;
// Is the device a real multi-touch-device? (see doc. for |touch_device_list_|
// below for more explanation.)
- bool IsMultiTouchDevice(unsigned int deviceid) const;
+ bool IsMultiTouchDevice(int deviceid) const;
// Tries to find an existing slot ID mapping to tracking ID. Returns true
// if the slot is found and it is saved in |slot|, false if no such slot
@@ -84,12 +87,12 @@ class EVENTS_DEVICES_EXPORT TouchFactory {
// Sets up the device id in the list |devices| as multi-touch capable
// devices and enables touch events processing. This function is only
// for test purpose, and it does not query from X server.
- void SetTouchDeviceForTest(const std::vector<unsigned int>& devices);
+ void SetTouchDeviceForTest(const std::vector<int>& devices);
// Sets up the device id in the list |devices| as pointer devices.
// This function is only for test purpose, and it does not query from
// X server.
- void SetPointerDeviceForTest(const std::vector<unsigned int>& devices);
+ void SetPointerDeviceForTest(const std::vector<int>& devices);
private:
// Requirement for Singleton