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

Side by Side Diff: components/view_manager/event_dispatcher.h

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 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
OLDNEW
(Empty)
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.
4
5 #ifndef COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_
6 #define COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_
7
8 #include <map>
9
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"
14
15 namespace view_manager {
16
17 class ServerView;
18 class ViewTreeHostImpl;
19
20 // Handles dispatching events to the right location as well as updating focus.
21 class EventDispatcher {
22 public:
23 explicit EventDispatcher(ViewTreeHostImpl* view_tree_host);
24 ~EventDispatcher();
25
26 void AddAccelerator(uint32_t id,
27 mojo::KeyboardCode keyboard_code,
28 mojo::EventFlags flags);
29 void RemoveAccelerator(uint32_t id);
30
31 void OnEvent(mojo::EventPtr event);
32
33 private:
34 struct Accelerator {
35 Accelerator(mojo::KeyboardCode keyboard_code, mojo::EventFlags flags)
36 : keyboard_code(keyboard_code), flags(flags) {}
37
38 // So we can use this in a set.
39 bool operator<(const Accelerator& other) const {
40 if (keyboard_code == other.keyboard_code)
41 return flags < other.flags;
42 return keyboard_code < other.keyboard_code;
43 }
44
45 mojo::KeyboardCode keyboard_code;
46 mojo::EventFlags flags;
47 };
48
49 // Looks to see if there is an accelerator bound to the specified code/flags.
50 // If there is one, sets |accelerator_id| to the id of the accelerator invoked
51 // and returns true. If there is none, returns false so normal key event
52 // processing can continue.
53 bool FindAccelerator(const mojo::Event& event, uint32_t* accelerator_id);
54
55 // Returns the ServerView that should receive |event|. If |event| is a
56 // pointer-type event, then this function also updates the event location to
57 // make sure it is in the returned target's coordinate space.
58 ServerView* FindEventTarget(mojo::Event* event);
59
60 ViewTreeHostImpl* view_tree_host_;
61
62 using Entry = std::pair<uint32_t, Accelerator>;
63 std::map<uint32_t, Accelerator> accelerators_;
64
65 DISALLOW_COPY_AND_ASSIGN(EventDispatcher);
66 };
67
68 } // namespace view_manager
69
70 #endif // COMPONENTS_VIEW_MANAGER_EVENT_DISPATCHER_H_
OLDNEW
« no previous file with comments | « components/view_manager/display_manager_factory.h ('k') | components/view_manager/event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698