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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_
6 #define COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_
10 #include "base/basictypes.h"
11 #include "ui/mojo/events/input_event_constants.mojom.h"
12 #include "ui/mojo/events/input_events.mojom.h"
13 #include "ui/mojo/events/input_key_codes.mojom.h"
15 namespace view_manager
{
17 class ConnectionManager
;
20 // Handles dispatching events to the right location as well as updating focus.
21 class EventDispatcher
{
23 explicit EventDispatcher(ConnectionManager
* connection_manager
);
26 void AddAccelerator(mojo::KeyboardCode keyboard_code
, mojo::EventFlags flags
);
27 void RemoveAccelerator(mojo::KeyboardCode keyboard_code
,
28 mojo::EventFlags flags
);
30 void OnEvent(ServerView
* root
, mojo::EventPtr event
);
34 Accelerator(mojo::KeyboardCode keyboard_code
, mojo::EventFlags flags
)
35 : keyboard_code(keyboard_code
), flags(flags
) {}
37 // So we can use this in a set.
38 bool operator<(const Accelerator
& other
) const {
39 if (keyboard_code
== other
.keyboard_code
)
40 return flags
< other
.flags
;
41 return keyboard_code
< other
.keyboard_code
;
44 mojo::KeyboardCode keyboard_code
;
45 mojo::EventFlags flags
;
48 ConnectionManager
* connection_manager_
;
50 std::set
<Accelerator
> accelerators_
;
52 DISALLOW_COPY_AND_ASSIGN(EventDispatcher
);
55 } // namespace view_manager
57 #endif // COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_