| OLD | NEW |
| (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_ | |
| OLD | NEW |