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

Unified Diff: components/mus/input_devices/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: Rebase/update. 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: components/mus/input_devices/touchscreen_device_struct_traits.h
diff --git a/components/mus/input_devices/touchscreen_device_struct_traits.h b/components/mus/input_devices/touchscreen_device_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..b8e8cc13b58236f794962c94365a3c3e8fb45478
--- /dev/null
+++ b/components/mus/input_devices/touchscreen_device_struct_traits.h
@@ -0,0 +1,49 @@
+// 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 COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_
+#define COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_
+
+#include <string>
+
+#include "base/strings/string_piece.h"
+#include "components/mus/public/interfaces/input_devices/input_devices.mojom.h"
+#include "ui/events/devices/touchscreen_device.h"
+#include "ui/gfx/geometry/size.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<input_device::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) {
+ return device.size;
+ }
+
+ static int32_t touch_points(const ui::TouchscreenDevice& device) {
+ return device.touch_points;
+ }
+
+ static bool Read(input_device::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;
+ }
+};
+
+} // namespace mojo
+
+#endif // COMPONENTS_MUS_INPUT_DEVICES_TOUCHSCREEN_DEVICE_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698