summaryrefslogtreecommitdiffstats
path: root/ui/events
diff options
context:
space:
mode:
authordnicoara <dnicoara@chromium.org>2014-10-28 14:19:39 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-28 21:20:03 +0000
commit60664070554a1bee80ee56189d9a6e80de430c4b (patch)
tree08f1aaf073dd9dfb5cf7e4a123ed7ae7b00d11f7 /ui/events
parenta6dcde42cfca100619ec9a981eb38ddb7b8cad97 (diff)
downloadchromium_src-60664070554a1bee80ee56189d9a6e80de430c4b.zip
chromium_src-60664070554a1bee80ee56189d9a6e80de430c4b.tar.gz
chromium_src-60664070554a1bee80ee56189d9a6e80de430c4b.tar.bz2
Use the TouchscreenDevice when looking up the size of the touch area
Removes some X11 dependencies when looking up the size of the touchscreen. BUG=425258 Review URL: https://codereview.chromium.org/683823004 Cr-Commit-Position: refs/heads/master@{#301713}
Diffstat (limited to 'ui/events')
-rw-r--r--ui/events/input_device.cc4
-rw-r--r--ui/events/input_device.h3
-rw-r--r--ui/events/touchscreen_device.cc5
-rw-r--r--ui/events/touchscreen_device.h5
-rw-r--r--ui/events/x/hotplug_event_handler_x11.cc17
5 files changed, 26 insertions, 8 deletions
diff --git a/ui/events/input_device.cc b/ui/events/input_device.cc
index 4c35624..b170b4a 100644
--- a/ui/events/input_device.cc
+++ b/ui/events/input_device.cc
@@ -11,6 +11,10 @@ namespace ui {
// static
const unsigned int InputDevice::kInvalidId = 0;
+InputDevice::InputDevice()
+ : id(kInvalidId), type(InputDeviceType::INPUT_DEVICE_UNKNOWN) {
+}
+
InputDevice::InputDevice(unsigned int id,
InputDeviceType type,
const std::string& name)
diff --git a/ui/events/input_device.h b/ui/events/input_device.h
index 526b005..83a0316 100644
--- a/ui/events/input_device.h
+++ b/ui/events/input_device.h
@@ -21,6 +21,9 @@ enum InputDeviceType {
struct EVENTS_BASE_EXPORT InputDevice {
static const unsigned int kInvalidId;
+ // Creates an invalid input device.
+ InputDevice();
+
InputDevice(unsigned int id, InputDeviceType type, const std::string& name);
virtual ~InputDevice();
diff --git a/ui/events/touchscreen_device.cc b/ui/events/touchscreen_device.cc
index 58c2370d..28ba592 100644
--- a/ui/events/touchscreen_device.cc
+++ b/ui/events/touchscreen_device.cc
@@ -10,7 +10,10 @@
namespace ui {
-TouchscreenDevice::TouchscreenDevice(int id,
+TouchscreenDevice::TouchscreenDevice() {
+}
+
+TouchscreenDevice::TouchscreenDevice(unsigned int id,
InputDeviceType type,
const std::string& name,
const gfx::Size& size)
diff --git a/ui/events/touchscreen_device.h b/ui/events/touchscreen_device.h
index d281a0b..48cad35 100644
--- a/ui/events/touchscreen_device.h
+++ b/ui/events/touchscreen_device.h
@@ -15,7 +15,10 @@ namespace ui {
// Represents a Touchscreen device state.
struct EVENTS_BASE_EXPORT TouchscreenDevice : public InputDevice {
- TouchscreenDevice(int id,
+ // Creates an invalid touchscreen device.
+ TouchscreenDevice();
+
+ TouchscreenDevice(unsigned int id,
InputDeviceType type,
const std::string& name,
const gfx::Size& size);
diff --git a/ui/events/x/hotplug_event_handler_x11.cc b/ui/events/x/hotplug_event_handler_x11.cc
index ae685f87..30dcfee 100644
--- a/ui/events/x/hotplug_event_handler_x11.cc
+++ b/ui/events/x/hotplug_event_handler_x11.cc
@@ -191,8 +191,8 @@ void HotplugEventHandlerX11::HandleTouchscreenDevices(
if (!x11_devices[i].enabled || x11_devices[i].use != XIFloatingSlave)
continue; // Assume all touchscreens are floating slaves
- double width = -1.0;
- double height = -1.0;
+ double max_x = -1.0;
+ double max_y = -1.0;
bool is_direct_touch = false;
for (int j = 0; j < x11_devices[i].num_classes; j++) {
@@ -206,13 +206,13 @@ void HotplugEventHandlerX11::HandleTouchscreenDevices(
// Ignore X axis valuator with unexpected properties
if (valuator_info->number == 0 && valuator_info->mode == Absolute &&
valuator_info->min == 0.0) {
- width = valuator_info->max;
+ max_x = valuator_info->max;
}
} else if (valuator_y == valuator_info->label) {
// Ignore Y axis valuator with unexpected properties
if (valuator_info->number == 1 && valuator_info->mode == Absolute &&
valuator_info->min == 0.0) {
- height = valuator_info->max;
+ max_y = valuator_info->max;
}
}
}
@@ -227,14 +227,19 @@ void HotplugEventHandlerX11::HandleTouchscreenDevices(
// Touchscreens should have absolute X and Y axes, and be direct touch
// devices.
- if (width > 0.0 && height > 0.0 && is_direct_touch) {
+ if (max_x > 0.0 && max_y > 0.0 && is_direct_touch) {
InputDeviceType type =
IsTouchscreenInternal(display, x11_devices[i].deviceid)
? InputDeviceType::INPUT_DEVICE_INTERNAL
: InputDeviceType::INPUT_DEVICE_EXTERNAL;
std::string name(x11_devices[i].name);
+ // |max_x| and |max_y| are inclusive values, so we need to add 1 to get
+ // the size.
devices.push_back(TouchscreenDevice(
- x11_devices[i].deviceid, type, name, gfx::Size(width, height)));
+ x11_devices[i].deviceid,
+ type,
+ name,
+ gfx::Size(max_x + 1, max_y + 1)));
}
}