Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: ui/events/devices/mojo/touchscreen_device_struct_traits.h

Issue 1992443002: Add Mojo IPC based input-device service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_ddm
Patch Set: Fixes for comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698