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 "components/native_viewport/public/interfaces/native_viewport.mojom.h"
12 #include "components/window_manager/public/interfaces/window_manager_internal.mojom.h"
14 namespace view_manager
{
16 class ConnectionManager
;
18 // Handles dispatching events to the right location as well as updating focus.
19 class EventDispatcher
: public mojo::NativeViewportEventDispatcher
{
21 explicit EventDispatcher(ConnectionManager
* connection_manager
);
22 ~EventDispatcher() override
;
24 void AddAccelerator(mojo::KeyboardCode keyboard_code
, mojo::EventFlags flags
);
25 void RemoveAccelerator(mojo::KeyboardCode keyboard_code
,
26 mojo::EventFlags flags
);
28 // NativeViewportEventDispatcher:
29 void OnEvent(mojo::EventPtr event
, const OnEventCallback
& callback
) override
;
33 Accelerator(mojo::KeyboardCode keyboard_code
, mojo::EventFlags flags
)
34 : keyboard_code(keyboard_code
), flags(flags
) {}
36 // So we can use this in a set.
37 bool operator<(const Accelerator
& other
) const {
38 if (keyboard_code
== other
.keyboard_code
)
39 return flags
< other
.flags
;
40 return keyboard_code
< other
.keyboard_code
;
43 mojo::KeyboardCode keyboard_code
;
44 mojo::EventFlags flags
;
47 ConnectionManager
* connection_manager_
;
49 std::set
<Accelerator
> accelerators_
;
51 DISALLOW_COPY_AND_ASSIGN(EventDispatcher
);
54 } // namespace view_manager
56 #endif // COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_