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

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

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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 | « components/mus/ws/BUILD.gn ('k') | components/mus/ws/accelerator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_MUS_WS_ACCELERATOR_H_
6 #define COMPONENTS_MUS_WS_ACCELERATOR_H_
7
8 #include <stdint.h>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/mus/public/interfaces/event_matcher.mojom.h"
13 #include "components/mus/ws/event_matcher.h"
14
15 namespace ui {
16 class Event;
17 }
18
19 namespace mus {
20 namespace ws {
21
22 // An Accelerator encompasses an id defined by the client, along with a unique
23 // mojom::EventMatcher. See WindowManagerClient.
24 //
25 // This provides a WeakPtr, as the client might delete the accelerator between
26 // an event having been matched and the dispatch of the accelerator to the
27 // client.
28 class Accelerator {
29 public:
30 Accelerator(uint32_t id, const mojom::EventMatcher& matcher);
31 ~Accelerator();
32
33 // Returns true if |event| and |phase | matches the definition in the
34 // mojom::EventMatcher used for initialization.
35 bool MatchesEvent(const ui::Event& event,
36 const ui::mojom::AcceleratorPhase phase) const;
37
38 // Returns true if |other| was created with an identical mojom::EventMatcher.
39 bool EqualEventMatcher(const Accelerator* other) const;
40
41 base::WeakPtr<Accelerator> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
42
43 uint32_t id() const { return id_; }
44
45 private:
46 uint32_t id_;
47 ui::mojom::AcceleratorPhase accelerator_phase_;
48 EventMatcher event_matcher_;
49 base::WeakPtrFactory<Accelerator> weak_factory_;
50
51 DISALLOW_COPY_AND_ASSIGN(Accelerator);
52 };
53
54 } // namespace ws
55 } // namespace mus
56
57 #endif // COMPONENTS_MUS_WS_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « components/mus/ws/BUILD.gn ('k') | components/mus/ws/accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698