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

Side by Side Diff: services/ui/input_manager/input_associate.h

Issue 1776473005: Mozart: Implement basic input event dispatch with hit testing. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-7
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « services/ui/input_manager/BUILD.gn ('k') | services/ui/input_manager/input_associate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ 5 #ifndef SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_
6 #define SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ 6 #define SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_
7 7
8 #include <memory>
9 #include <unordered_map>
10
8 #include "base/macros.h" 11 #include "base/macros.h"
9 #include "mojo/common/strong_binding_set.h"
10 #include "mojo/services/ui/input/interfaces/input_connection.mojom.h"
11 #include "mojo/services/ui/input/interfaces/input_dispatcher.mojom.h"
12 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h" 12 #include "mojo/services/ui/views/interfaces/view_associates.mojom.h"
13 #include "mojo/ui/associates/view_inspector_client.h"
14 #include "services/ui/input_manager/input_connection_impl.h"
15 #include "services/ui/input_manager/input_dispatcher_impl.h"
13 16
14 namespace input_manager { 17 namespace input_manager {
15 18
19 class ViewTreeHitTester;
20
16 // InputManager's ViewAssociate interface implementation. 21 // InputManager's ViewAssociate interface implementation.
17 class InputAssociate : public mojo::ui::ViewAssociate { 22 class InputAssociate : public mojo::ui::ViewAssociate {
18 public: 23 public:
19 InputAssociate(); 24 InputAssociate();
20 ~InputAssociate() override; 25 ~InputAssociate() override;
21 26
22 private: 27 const scoped_refptr<mojo::ui::ViewInspectorClient>& inspector() {
23 // InputConnection implementation. 28 return inspector_;
24 // Binds incoming requests to the relevant view token. 29 }
25 class InputConnectionImpl : public mojo::ui::InputConnection {
26 public:
27 InputConnectionImpl(InputAssociate* associate,
28 mojo::ui::ViewTokenPtr view_token);
29 ~InputConnectionImpl() override;
30
31 private:
32 void SetListener(
33 mojo::InterfaceHandle<mojo::ui::InputListener> listener) override;
34
35 InputAssociate* const associate_;
36 mojo::ui::ViewTokenPtr view_token_;
37
38 DISALLOW_COPY_AND_ASSIGN(InputConnectionImpl);
39 };
40
41 // InputDispatcher implementation.
42 // Binds incoming requests to the relevant view token.
43 class InputDispatcherImpl : public mojo::ui::InputDispatcher {
44 public:
45 InputDispatcherImpl(InputAssociate* associate,
46 mojo::ui::ViewTreeTokenPtr view_tree_token);
47 ~InputDispatcherImpl() override;
48
49 private:
50 void DispatchEvent(mojo::EventPtr event) override;
51
52 InputAssociate* const associate_;
53 mojo::ui::ViewTreeTokenPtr view_tree_token_;
54
55 DISALLOW_COPY_AND_ASSIGN(InputDispatcherImpl);
56 };
57 30
58 // |ViewAssociate|: 31 // |ViewAssociate|:
59 void Connect(mojo::InterfaceHandle<mojo::ui::ViewInspector> inspector, 32 void Connect(mojo::InterfaceHandle<mojo::ui::ViewInspector> inspector,
60 const ConnectCallback& callback) override; 33 const ConnectCallback& callback) override;
61 void ConnectToViewService( 34 void ConnectToViewService(
62 mojo::ui::ViewTokenPtr view_token, 35 mojo::ui::ViewTokenPtr view_token,
63 const mojo::String& service_name, 36 const mojo::String& service_name,
64 mojo::ScopedMessagePipeHandle client_handle) override; 37 mojo::ScopedMessagePipeHandle client_handle) override;
65 void ConnectToViewTreeService( 38 void ConnectToViewTreeService(
66 mojo::ui::ViewTreeTokenPtr view_tree_token, 39 mojo::ui::ViewTreeTokenPtr view_tree_token,
67 const mojo::String& service_name, 40 const mojo::String& service_name,
68 mojo::ScopedMessagePipeHandle client_handle) override; 41 mojo::ScopedMessagePipeHandle client_handle) override;
69 42
70 // Incoming service calls. 43 // Delivers an event to a view.
71 void SetListener(mojo::ui::ViewToken* view_token, 44 void DeliverEvent(const mojo::ui::ViewToken* view_token,
72 mojo::InterfaceHandle<mojo::ui::InputListener> listener); 45 mojo::EventPtr event);
73 void DispatchEvent(mojo::ui::ViewTreeToken* view_tree_token,
74 mojo::EventPtr event);
75 46
76 // Callbacks. 47 // Callbacks.
77 void OnEventFinished(bool handled); 48 void OnInputConnectionDied(InputConnectionImpl* connection);
49 void OnInputDispatcherDied(InputDispatcherImpl* dispatcher);
78 50
79 mojo::StrongBindingSet<mojo::ui::InputConnection> input_connections_; 51 private:
80 mojo::StrongBindingSet<mojo::ui::InputDispatcher> input_dispatchers_; 52 void CreateInputConnection(
53 mojo::ui::ViewTokenPtr view_token,
54 mojo::InterfaceRequest<mojo::ui::InputConnection> request);
55 void CreateInputDispatcher(
56 mojo::ui::ViewTreeTokenPtr view_tree_token,
57 mojo::InterfaceRequest<mojo::ui::InputDispatcher> request);
81 58
82 mojo::ui::InputListenerPtr listener_; 59 scoped_refptr<mojo::ui::ViewInspectorClient> inspector_;
60 std::unordered_map<uint32_t, std::unique_ptr<InputConnectionImpl>>
61 input_connections_by_view_token_;
62 std::unordered_map<uint32_t, std::unique_ptr<InputDispatcherImpl>>
63 input_dispatchers_by_view_tree_token_;
83 64
84 DISALLOW_COPY_AND_ASSIGN(InputAssociate); 65 DISALLOW_COPY_AND_ASSIGN(InputAssociate);
85 }; 66 };
86 67
87 } // namespace input_manager 68 } // namespace input_manager
88 69
89 #endif // SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_ 70 #endif // SERVICES_UI_INPUT_MANAGER_INPUT_ASSOCIATE_IMPL_H_
OLDNEW
« no previous file with comments | « services/ui/input_manager/BUILD.gn ('k') | services/ui/input_manager/input_associate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698