summaryrefslogtreecommitdiffstats
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
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}
-rw-r--r--ash/display/display_info.h6
-rw-r--r--ash/host/ash_window_tree_host_x11_unittest.cc4
-rw-r--r--ash/touch/touch_transformer_controller.cc2
-rw-r--r--ash/touch/touchscreen_util_unittest.cc18
-rw-r--r--chrome/browser/chromeos/events/event_rewriter_unittest.cc6
-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
-rw-r--r--ui/events/test/events_test_utils_x11.cc10
-rw-r--r--ui/events/test/events_test_utils_x11.h4
-rw-r--r--ui/events/x/events_x_unittest.cc18
-rw-r--r--ui/ozone/platform/egltest/ozone_platform_egltest.cc2
-rw-r--r--ui/views/controls/menu/menu_controller_unittest.cc2
-rw-r--r--ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc2
22 files changed, 129 insertions, 118 deletions
diff --git a/ash/display/display_info.h b/ash/display/display_info.h
index c01d137..427355b 100644
--- a/ash/display/display_info.h
+++ b/ash/display/display_info.h
@@ -111,8 +111,8 @@ class ASH_EXPORT DisplayInfo {
}
gfx::Display::TouchSupport touch_support() const { return touch_support_; }
- void set_touch_device_id(unsigned int id) { touch_device_id_ = id; }
- unsigned int touch_device_id() const { return touch_device_id_; }
+ void set_touch_device_id(int id) { touch_device_id_ = id; }
+ int touch_device_id() const { return touch_device_id_; }
// Gets/Sets the device scale factor of the display.
float device_scale_factor() const { return device_scale_factor_; }
@@ -236,7 +236,7 @@ class ASH_EXPORT DisplayInfo {
// If the display is also a touch device, it will have a positive
// |touch_device_id_|. Otherwise |touch_device_id_| is 0.
- unsigned int touch_device_id_;
+ int touch_device_id_;
// This specifies the device's pixel density. (For example, a
// display whose DPI is higher than the threshold is considered to have
diff --git a/ash/host/ash_window_tree_host_x11_unittest.cc b/ash/host/ash_window_tree_host_x11_unittest.cc
index 442cbbf..803a87c 100644
--- a/ash/host/ash_window_tree_host_x11_unittest.cc
+++ b/ash/host/ash_window_tree_host_x11_unittest.cc
@@ -92,7 +92,7 @@ TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToOneRootWindow) {
scoped_ptr<RootWindowEventHandler> handler(
new RootWindowEventHandler(window_tree_host.get()));
- std::vector<unsigned int> devices;
+ std::vector<int> devices;
devices.push_back(0);
ui::SetUpTouchDevicesForTest(devices);
std::vector<ui::Valuator> valuators;
@@ -155,7 +155,7 @@ TEST_F(AshWindowTreeHostX11Test, DispatchTouchEventToTwoRootWindow) {
scoped_ptr<RootWindowEventHandler> handler2(
new RootWindowEventHandler(window_tree_host2.get()));
- std::vector<unsigned int> devices;
+ std::vector<int> devices;
devices.push_back(0);
ui::SetUpTouchDevicesForTest(devices);
std::vector<ui::Valuator> valuators;
diff --git a/ash/touch/touch_transformer_controller.cc b/ash/touch/touch_transformer_controller.cc
index 9d7caa7..8adb644 100644
--- a/ash/touch/touch_transformer_controller.cc
+++ b/ash/touch/touch_transformer_controller.cc
@@ -22,7 +22,7 @@ DisplayManager* GetDisplayManager() {
return Shell::GetInstance()->display_manager();
}
-ui::TouchscreenDevice FindTouchscreenById(unsigned int id) {
+ui::TouchscreenDevice FindTouchscreenById(int id) {
const std::vector<ui::TouchscreenDevice>& touchscreens =
ui::DeviceDataManager::GetInstance()->touchscreen_devices();
for (const auto& touchscreen : touchscreens) {
diff --git a/ash/touch/touchscreen_util_unittest.cc b/ash/touch/touchscreen_util_unittest.cc
index 4993093..ea88753 100644
--- a/ash/touch/touchscreen_util_unittest.cc
+++ b/ash/touch/touchscreen_util_unittest.cc
@@ -84,9 +84,9 @@ TEST_F(TouchscreenUtilTest, OneToOneMapping) {
AssociateTouchscreens(&displays_, devices);
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
- EXPECT_EQ(1u, displays_[1].touch_device_id());
+ EXPECT_EQ(1, displays_[1].touch_device_id());
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
- EXPECT_EQ(2u, displays_[3].touch_device_id());
+ EXPECT_EQ(2, displays_[3].touch_device_id());
}
TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) {
@@ -99,7 +99,7 @@ TEST_F(TouchscreenUtilTest, MapToCorrectDisplaySize) {
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[1].touch_device_id());
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
- EXPECT_EQ(2u, displays_[3].touch_device_id());
+ EXPECT_EQ(2, displays_[3].touch_device_id());
}
TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) {
@@ -112,9 +112,9 @@ TEST_F(TouchscreenUtilTest, MapWhenSizeDiffersByOne) {
AssociateTouchscreens(&displays_, devices);
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
- EXPECT_EQ(1u, displays_[1].touch_device_id());
+ EXPECT_EQ(1, displays_[1].touch_device_id());
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
- EXPECT_EQ(2u, displays_[3].touch_device_id());
+ EXPECT_EQ(2, displays_[3].touch_device_id());
}
TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) {
@@ -127,9 +127,9 @@ TEST_F(TouchscreenUtilTest, MapWhenSizesDoNotMatch) {
AssociateTouchscreens(&displays_, devices);
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[0].touch_device_id());
- EXPECT_EQ(1u, displays_[1].touch_device_id());
+ EXPECT_EQ(1, displays_[1].touch_device_id());
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
- EXPECT_EQ(2u, displays_[3].touch_device_id());
+ EXPECT_EQ(2, displays_[3].touch_device_id());
}
TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) {
@@ -142,8 +142,8 @@ TEST_F(TouchscreenUtilTest, MapInternalTouchscreen) {
AssociateTouchscreens(&displays_, devices);
// Internal touchscreen is always mapped to internal display.
- EXPECT_EQ(2u, displays_[0].touch_device_id());
- EXPECT_EQ(1u, displays_[1].touch_device_id());
+ EXPECT_EQ(2, displays_[0].touch_device_id());
+ EXPECT_EQ(1, displays_[1].touch_device_id());
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[2].touch_device_id());
EXPECT_EQ(ui::TouchscreenDevice::kInvalidId, displays_[3].touch_device_id());
}
diff --git a/chrome/browser/chromeos/events/event_rewriter_unittest.cc b/chrome/browser/chromeos/events/event_rewriter_unittest.cc
index bae1131..13c0843 100644
--- a/chrome/browser/chromeos/events/event_rewriter_unittest.cc
+++ b/chrome/browser/chromeos/events/event_rewriter_unittest.cc
@@ -45,7 +45,7 @@
namespace {
// The device id of the test touchpad device.
-const unsigned int kTouchPadDeviceId = 1;
+const int kTouchPadDeviceId = 1;
const int kKeyboardDeviceId = 2;
const int kMasterKeyboardDeviceId = 3;
@@ -1931,7 +1931,7 @@ TEST_F(EventRewriterAshTest, TopRowKeysAreFunctionKeys) {
}
TEST_F(EventRewriterTest, TestRewrittenModifierClick) {
- std::vector<unsigned int> device_list;
+ std::vector<int> device_list;
device_list.push_back(10);
ui::TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list);
@@ -1970,7 +1970,7 @@ TEST_F(EventRewriterTest, TestRewrittenModifierClick) {
TEST_F(EventRewriterTest, DontRewriteIfNotRewritten) {
// TODO(kpschoedel): pending changes for crbug.com/360377
// to |chromeos::EventRewriter::RewriteLocatedEvent()
- std::vector<unsigned int> device_list;
+ std::vector<int> device_list;
device_list.push_back(10);
device_list.push_back(11);
ui::TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list);
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
diff --git a/ui/events/test/events_test_utils_x11.cc b/ui/events/test/events_test_utils_x11.cc
index 3405b70..67eec36 100644
--- a/ui/events/test/events_test_utils_x11.cc
+++ b/ui/events/test/events_test_utils_x11.cc
@@ -286,19 +286,19 @@ void ScopedXI2Event::SetUpValuators(const std::vector<Valuator>& valuators) {
}
}
-void SetUpTouchPadForTest(unsigned int deviceid) {
- std::vector<unsigned int> device_list;
+void SetUpTouchPadForTest(int deviceid) {
+ std::vector<int> device_list;
device_list.push_back(deviceid);
TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list);
ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance();
- manager->SetDeviceListForTest(std::vector<unsigned int>(), device_list);
+ manager->SetDeviceListForTest(std::vector<int>(), device_list);
}
-void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices) {
+void SetUpTouchDevicesForTest(const std::vector<int>& devices) {
TouchFactory::GetInstance()->SetTouchDeviceForTest(devices);
ui::DeviceDataManagerX11* manager = ui::DeviceDataManagerX11::GetInstance();
- manager->SetDeviceListForTest(devices, std::vector<unsigned int>());
+ manager->SetDeviceListForTest(devices, std::vector<int>());
}
} // namespace ui
diff --git a/ui/events/test/events_test_utils_x11.h b/ui/events/test/events_test_utils_x11.h
index 85137cb..57c6097 100644
--- a/ui/events/test/events_test_utils_x11.h
+++ b/ui/events/test/events_test_utils_x11.h
@@ -90,10 +90,10 @@ class ScopedXI2Event {
};
// Initializes a test touchpad device for scroll events.
-void SetUpTouchPadForTest(unsigned int deviceid);
+void SetUpTouchPadForTest(int deviceid);
// Initializes a list of touchscreen devices for touch events.
-void SetUpTouchDevicesForTest(const std::vector<unsigned int>& devices);
+void SetUpTouchDevicesForTest(const std::vector<int>& devices);
} // namespace ui
diff --git a/ui/events/x/events_x_unittest.cc b/ui/events/x/events_x_unittest.cc
index 770445e..db9cb2e 100644
--- a/ui/events/x/events_x_unittest.cc
+++ b/ui/events/x/events_x_unittest.cc
@@ -230,7 +230,7 @@ TEST_F(EventsXTest, ClickCount) {
}
TEST_F(EventsXTest, TouchEventBasic) {
- std::vector<unsigned int> devices;
+ std::vector<int> devices;
devices.push_back(0);
ui::SetUpTouchDevicesForTest(devices);
std::vector<Valuator> valuators;
@@ -315,7 +315,7 @@ int GetTouchIdForTrackingId(uint32 tracking_id) {
}
TEST_F(EventsXTest, TouchEventNotRemovingFromNativeMapping) {
- std::vector<unsigned int> devices;
+ std::vector<int> devices;
devices.push_back(0);
ui::SetUpTouchDevicesForTest(devices);
std::vector<Valuator> valuators;
@@ -361,7 +361,7 @@ TEST_F(EventsXTest, TouchEventNotRemovingFromNativeMapping) {
// crash (crbug.com/467102). Copied events do not contain a proper
// base::NativeEvent and should not attempt to access it.
TEST_F(EventsXTest, CopiedTouchEventNotRemovingFromNativeMapping) {
- std::vector<unsigned int> devices;
+ std::vector<int> devices;
devices.push_back(0);
ui::SetUpTouchDevicesForTest(devices);
std::vector<Valuator> valuators;
@@ -539,9 +539,9 @@ TEST_F(EventsXTest, DisableKeyboard) {
DeviceDataManagerX11* device_data_manager =
static_cast<DeviceDataManagerX11*>(
DeviceDataManager::GetInstance());
- unsigned int blocked_device_id = 1;
- unsigned int other_device_id = 2;
- unsigned int master_device_id = 3;
+ int blocked_device_id = 1;
+ int other_device_id = 2;
+ int master_device_id = 3;
device_data_manager->DisableDevice(blocked_device_id);
scoped_ptr<std::set<KeyboardCode> > excepted_keys(new std::set<KeyboardCode>);
@@ -596,9 +596,9 @@ TEST_F(EventsXTest, DisableMouse) {
DeviceDataManagerX11* device_data_manager =
static_cast<DeviceDataManagerX11*>(
DeviceDataManager::GetInstance());
- unsigned int blocked_device_id = 1;
- unsigned int other_device_id = 2;
- std::vector<unsigned int> device_list;
+ int blocked_device_id = 1;
+ int other_device_id = 2;
+ std::vector<int> device_list;
device_list.push_back(blocked_device_id);
device_list.push_back(other_device_id);
TouchFactory::GetInstance()->SetPointerDeviceForTest(device_list);
diff --git a/ui/ozone/platform/egltest/ozone_platform_egltest.cc b/ui/ozone/platform/egltest/ozone_platform_egltest.cc
index 1e8ca15..42ce0a8 100644
--- a/ui/ozone/platform/egltest/ozone_platform_egltest.cc
+++ b/ui/ozone/platform/egltest/ozone_platform_egltest.cc
@@ -56,7 +56,7 @@ std::string GetShimLibraryName() {
void ScaleTouchEvent(TouchEvent* event, const gfx::SizeF& size) {
for (const auto& device :
DeviceDataManager::GetInstance()->touchscreen_devices()) {
- if (device.id == static_cast<unsigned int>(event->source_device_id())) {
+ if (device.id == event->source_device_id()) {
gfx::SizeF touchscreen_size = device.size;
gfx::PointF location = event->location_f();
diff --git a/ui/views/controls/menu/menu_controller_unittest.cc b/ui/views/controls/menu/menu_controller_unittest.cc
index 99e889a..73461e0 100644
--- a/ui/views/controls/menu/menu_controller_unittest.cc
+++ b/ui/views/controls/menu/menu_controller_unittest.cc
@@ -296,7 +296,7 @@ TEST_F(MenuControllerTest, TouchIdsReleasedCorrectly) {
owner->GetNativeWindow()->GetRootWindow()->AddPreTargetHandler(
&test_event_handler);
- std::vector<unsigned int> devices;
+ std::vector<int> devices;
devices.push_back(1);
ui::SetUpTouchDevicesForTest(devices);
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
index 38aa0c8..17eb63a8 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
@@ -523,7 +523,7 @@ class DesktopWindowTreeHostX11HighDPITest
void SetUp() override {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, "2");
- std::vector<unsigned int> pointer_devices;
+ std::vector<int> pointer_devices;
pointer_devices.push_back(kPointerDeviceId);
ui::TouchFactory::GetInstance()->SetPointerDeviceForTest(pointer_devices);