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

Side by Side Diff: components/mus/ws/accelerator.h

Issue 1909733002: mus: Add EventObserver to allow passively listening to UI events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_MUS_WS_ACCELERATOR_H_ 5 #ifndef COMPONENTS_MUS_WS_ACCELERATOR_H_
6 #define COMPONENTS_MUS_WS_ACCELERATOR_H_ 6 #define COMPONENTS_MUS_WS_ACCELERATOR_H_
7 7
8 #include <stdint.h>
9
8 #include "base/macros.h" 10 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
11 #include "components/mus/public/interfaces/input_event_matcher.mojom.h" 12 #include "components/mus/public/interfaces/input_event_matcher.mojom.h"
12 #include "ui/events/event.h" 13 #include "components/mus/ws/event_tester.h"
13 #include "ui/gfx/geometry/rect_f.h" 14
15 namespace ui {
16 class Event;
17 }
14 18
15 namespace mus { 19 namespace mus {
16 namespace ws { 20 namespace ws {
17 21
18 // An Accelerator encompasses an id defined by the client, along with a unique 22 // An Accelerator encompasses an id defined by the client, along with a unique
19 // mojom::EventMatcher. See WindowManagerClient. 23 // mojom::EventMatcher. See WindowManagerClient.
20 // 24 //
21 // This provides a WeakPtr, as the client might delete the accelerator between 25 // This provides a WeakPtr, as the client might delete the accelerator between
22 // an event having been matched and the dispatch of the accelerator to the 26 // an event having been matched and the dispatch of the accelerator to the
23 // client. 27 // client.
24 class Accelerator { 28 class Accelerator {
25 public: 29 public:
26 Accelerator(uint32_t id, const mojom::EventMatcher& matcher); 30 Accelerator(uint32_t id, const mojom::EventMatcher& matcher);
27 ~Accelerator(); 31 ~Accelerator();
28 32
29 // Returns true if |event| and |phase | matches the definition in the 33 // Returns true if |event| and |phase | matches the definition in the
30 // mojom::EventMatcher used for initialization. 34 // mojom::EventMatcher used for initialization.
31 bool MatchesEvent(const ui::Event& event, 35 bool MatchesEvent(const ui::Event& event,
32 const mojom::AcceleratorPhase phase) const; 36 const mojom::AcceleratorPhase phase) const;
33 37
34 // Returns true if |other| was created with an identical mojom::EventMatcher. 38 // Returns true if |other| was created with an identical mojom::EventMatcher.
35 bool EqualEventMatcher(const Accelerator* other) const; 39 bool EqualEventMatcher(const Accelerator* other) const;
36 40
37 base::WeakPtr<Accelerator> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } 41 base::WeakPtr<Accelerator> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
38 42
39 uint32_t id() const { return id_; } 43 uint32_t id() const { return id_; }
40 44
41 private: 45 private:
42 enum MatchFields {
43 NONE = 0,
44 TYPE = 1 << 0,
45 FLAGS = 1 << 1,
46 KEYBOARD_CODE = 1 << 2,
47 POINTER_KIND = 1 << 3,
48 POINTER_LOCATION = 1 << 4,
49 };
50
51 uint32_t id_; 46 uint32_t id_;
52 uint32_t fields_to_match_;
53 mojom::AcceleratorPhase accelerator_phase_; 47 mojom::AcceleratorPhase accelerator_phase_;
54 ui::EventType event_type_; 48 EventTester event_tester_;
55 // Bitfields of kEventFlag* and kMouseEventFlag* values in
56 // input_event_constants.mojom.
57 int event_flags_;
58 int ignore_event_flags_;
59 uint16_t keyboard_code_;
60 ui::EventPointerType pointer_type_;
61 gfx::RectF pointer_region_;
62
63 base::WeakPtrFactory<Accelerator> weak_factory_; 49 base::WeakPtrFactory<Accelerator> weak_factory_;
64 50
65 DISALLOW_COPY_AND_ASSIGN(Accelerator); 51 DISALLOW_COPY_AND_ASSIGN(Accelerator);
66 }; 52 };
67 53
68 } // namespace ws 54 } // namespace ws
69 } // namespace mus 55 } // namespace mus
70 56
71 #endif // COMPONENTS_MUS_WS_ACCELERATOR_H_ 57 #endif // COMPONENTS_MUS_WS_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698