Chromium Code Reviews| Index: ui/events/devices/mojo/touchscreen_device_struct_traits.h |
| diff --git a/ui/events/devices/mojo/touchscreen_device_struct_traits.h b/ui/events/devices/mojo/touchscreen_device_struct_traits.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fc362166b5deb8d4bd1255dca72e2fe45cbfffb7 |
| --- /dev/null |
| +++ b/ui/events/devices/mojo/touchscreen_device_struct_traits.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_EVENTS_DEVICES_MOJO_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |
| +#define UI_EVENTS_DEVICES_MOJO_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/strings/string_piece.h" |
| +#include "ui/events/devices/mojo/input_devices.mojom.h" |
| +#include "ui/events/devices/touchscreen_device.h" |
| +#include "ui/gfx/geometry/size.h" |
| + |
| +namespace mojo { |
| + |
| +template <> |
| +struct StructTraits<ui::mojom::TouchscreenDevice, ui::TouchscreenDevice> { |
| + static const ui::InputDevice& input_device( |
| + const ui::TouchscreenDevice& device) { |
| + return static_cast<const ui::InputDevice&>(device); |
| + } |
| + |
| + static gfx::Size size(const ui::TouchscreenDevice& device) { |
|
sadrul
2016/06/08 16:31:09
const &
kylechar
2016/06/08 18:13:16
Done.
|
| + return device.size; |
| + } |
| + |
| + static int32_t touch_points(const ui::TouchscreenDevice& device) { |
| + return device.touch_points; |
| + } |
| + |
| + static bool Read(ui::mojom::TouchscreenDeviceDataView data, |
| + ui::TouchscreenDevice* out) { |
| + if (!data.ReadInputDevice(static_cast<ui::InputDevice*>(out))) |
| + return false; |
| + |
| + if (!data.ReadSize(&out->size)) |
| + return false; |
| + |
| + out->touch_points = data.touch_points(); |
| + |
| + return true; |
| + } |
| +}; |
| + |
|
sadrul
2016/06/08 16:31:09
This could maybe go in the input_device_struct_tra
kylechar
2016/06/08 18:13:16
Sure, done.
|
| +} // namespace mojo |
| + |
| +#endif // UI_EVENTS_DEVICES_MOJO_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |