OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |
| 6 #define COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/strings/string_piece.h" |
| 11 #include "components/mus/public/interfaces/input_devices/input_devices.mojom.h" |
| 12 #include "ui/events/devices/touchscreen_device.h" |
| 13 #include "ui/gfx/geometry/size.h" |
| 14 |
| 15 namespace mojo { |
| 16 |
| 17 template <> |
| 18 struct StructTraits<input_device::mojom::TouchscreenDevice, |
| 19 ui::TouchscreenDevice> { |
| 20 static const ui::InputDevice& input_device( |
| 21 const ui::TouchscreenDevice& device) { |
| 22 return static_cast<const ui::InputDevice&>(device); |
| 23 } |
| 24 |
| 25 static gfx::Size size(const ui::TouchscreenDevice& device) { |
| 26 return device.size; |
| 27 } |
| 28 |
| 29 static int32_t touch_points(const ui::TouchscreenDevice& device) { |
| 30 return device.touch_points; |
| 31 } |
| 32 |
| 33 static bool Read(input_device::mojom::TouchscreenDeviceDataView data, |
| 34 ui::TouchscreenDevice* out) { |
| 35 if (!data.ReadInputDevice(static_cast<ui::InputDevice*>(out))) |
| 36 return false; |
| 37 |
| 38 if (!data.ReadSize(&out->size)) |
| 39 return false; |
| 40 |
| 41 out->touch_points = data.touch_points(); |
| 42 |
| 43 return true; |
| 44 } |
| 45 }; |
| 46 |
| 47 } // namespace mojo |
| 48 |
| 49 #endif // COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_ |
OLD | NEW |