OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ | 5 #ifndef UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ |
6 #define UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ | 6 #define UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "ui/events/devices/input_device.h" | 10 #include "ui/events/devices/input_device.h" |
11 #include "ui/events/devices/mojo/input_devices.mojom.h" | 11 #include "ui/events/devices/mojo/input_devices.mojom.h" |
12 #include "ui/events/devices/stylus_state.h" | 12 #include "ui/events/devices/stylus_state.h" |
13 #include "ui/events/devices/touchscreen_device.h" | 13 #include "ui/events/devices/touchscreen_device.h" |
14 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
15 | 15 |
16 namespace mojo { | 16 namespace mojo { |
17 | 17 |
18 template <> | 18 template <> |
19 struct EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType> { | 19 struct EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType> { |
20 static ui::mojom::InputDeviceType ToMojom(ui::InputDeviceType type); | 20 static ui::mojom::InputDeviceType ToMojom(ui::InputDeviceType type); |
21 static bool FromMojom(ui::mojom::InputDeviceType type, | 21 static bool FromMojom(ui::mojom::InputDeviceType type, |
22 ui::InputDeviceType* output); | 22 ui::InputDeviceType* output); |
23 }; | 23 }; |
24 | 24 |
25 template <> | 25 template <> |
26 struct StructTraits<ui::mojom::InputDevice, ui::InputDevice> { | 26 struct StructTraits<ui::mojom::InputDeviceDataView, ui::InputDevice> { |
27 static int32_t id(const ui::InputDevice& device) { return device.id; } | 27 static int32_t id(const ui::InputDevice& device) { return device.id; } |
28 | 28 |
29 static ui::InputDeviceType type(const ui::InputDevice& device) { | 29 static ui::InputDeviceType type(const ui::InputDevice& device) { |
30 return device.type; | 30 return device.type; |
31 } | 31 } |
32 | 32 |
33 static const std::string& name(const ui::InputDevice& device) { | 33 static const std::string& name(const ui::InputDevice& device) { |
34 return device.name; | 34 return device.name; |
35 } | 35 } |
36 | 36 |
(...skipping 12 matching lines...) Expand all Loading... |
49 static bool Read(ui::mojom::InputDeviceDataView data, ui::InputDevice* out); | 49 static bool Read(ui::mojom::InputDeviceDataView data, ui::InputDevice* out); |
50 }; | 50 }; |
51 | 51 |
52 template <> | 52 template <> |
53 struct EnumTraits<ui::mojom::StylusState, ui::StylusState> { | 53 struct EnumTraits<ui::mojom::StylusState, ui::StylusState> { |
54 static ui::mojom::StylusState ToMojom(ui::StylusState type); | 54 static ui::mojom::StylusState ToMojom(ui::StylusState type); |
55 static bool FromMojom(ui::mojom::StylusState type, ui::StylusState* output); | 55 static bool FromMojom(ui::mojom::StylusState type, ui::StylusState* output); |
56 }; | 56 }; |
57 | 57 |
58 template <> | 58 template <> |
59 struct StructTraits<ui::mojom::TouchscreenDevice, ui::TouchscreenDevice> { | 59 struct StructTraits<ui::mojom::TouchscreenDeviceDataView, |
| 60 ui::TouchscreenDevice> { |
60 static const ui::InputDevice& input_device( | 61 static const ui::InputDevice& input_device( |
61 const ui::TouchscreenDevice& device) { | 62 const ui::TouchscreenDevice& device) { |
62 return static_cast<const ui::InputDevice&>(device); | 63 return static_cast<const ui::InputDevice&>(device); |
63 } | 64 } |
64 | 65 |
65 static const gfx::Size& size(const ui::TouchscreenDevice& device) { | 66 static const gfx::Size& size(const ui::TouchscreenDevice& device) { |
66 return device.size; | 67 return device.size; |
67 } | 68 } |
68 | 69 |
69 static int32_t touch_points(const ui::TouchscreenDevice& device) { | 70 static int32_t touch_points(const ui::TouchscreenDevice& device) { |
70 return device.touch_points; | 71 return device.touch_points; |
71 } | 72 } |
72 | 73 |
73 static bool Read(ui::mojom::TouchscreenDeviceDataView data, | 74 static bool Read(ui::mojom::TouchscreenDeviceDataView data, |
74 ui::TouchscreenDevice* out); | 75 ui::TouchscreenDevice* out); |
75 }; | 76 }; |
76 | 77 |
77 } // namespace mojo | 78 } // namespace mojo |
78 | 79 |
79 #endif // UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ | 80 #endif // UI_EVENTS_DEVICES_MOJO_INPUT_DEVICE_STRUCT_TRAITS_H_ |
OLD | NEW |