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

Side by Side Diff: ash/mus/accelerator_registrar_impl.h

Issue 2072343002: Changes how window manager obtains WindowTree from mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include Created 4 years, 6 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 | « no previous file | ash/mus/accelerator_registrar_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ 5 #ifndef ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_
6 #define ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ 6 #define ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 11
12 #include "ash/mus/root_windows_observer.h"
13 #include "base/callback.h" 12 #include "base/callback.h"
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" 14 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h"
16 #include "mojo/public/cpp/bindings/binding_set.h" 15 #include "mojo/public/cpp/bindings/binding_set.h"
17 #include "mojo/public/cpp/bindings/strong_binding.h" 16 #include "mojo/public/cpp/bindings/strong_binding.h"
18 17
19 namespace ash { 18 namespace ash {
20 namespace mus { 19 namespace mus {
21 20
22 class WindowManagerApplication; 21 class WindowManager;
23 22
24 // Manages AcceleratorHandlers from a particular AcceleratorRegistrar 23 // Manages AcceleratorHandlers from a particular AcceleratorRegistrar
25 // connection. This manages its own lifetime, and destroys itself when the 24 // connection. This manages its own lifetime, and destroys itself when the
26 // AcceleratorRegistrar and all its AcceleratorHandlers are disconnected. Upon 25 // AcceleratorRegistrar and all its AcceleratorHandlers are disconnected. Upon
27 // destruction, it calls the DestroyCallback. 26 // destruction, it calls the DestroyCallback.
28 class AcceleratorRegistrarImpl : public ::mus::mojom::AcceleratorRegistrar, 27 class AcceleratorRegistrarImpl : public ::mus::mojom::AcceleratorRegistrar {
29 public RootWindowsObserver {
30 public: 28 public:
31 using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>; 29 using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>;
32 AcceleratorRegistrarImpl(WindowManagerApplication* wm_app, 30 AcceleratorRegistrarImpl(WindowManager* window_manager,
33 uint32_t accelerator_namespace, 31 uint32_t accelerator_namespace,
34 mojo::InterfaceRequest<AcceleratorRegistrar> request, 32 mojo::InterfaceRequest<AcceleratorRegistrar> request,
35 const DestroyCallback& destroy_callback); 33 const DestroyCallback& destroy_callback);
36 34
37 void Destroy(); 35 void Destroy();
38 36
39 // Returns true if this AcceleratorRegistrar has an accelerator with the 37 // Returns true if this AcceleratorRegistrar has an accelerator with the
40 // specified id. 38 // specified id.
41 bool OwnsAccelerator(uint32_t accelerator_id) const; 39 bool OwnsAccelerator(uint32_t accelerator_id) const;
42 40
43 void ProcessAccelerator(uint32_t accelerator_id, const ui::Event& event); 41 void ProcessAccelerator(uint32_t accelerator_id, const ui::Event& event);
44 42
45 private: 43 private:
46 struct Accelerator;
47
48 ~AcceleratorRegistrarImpl() override; 44 ~AcceleratorRegistrarImpl() override;
49 45
50 uint32_t ComputeAcceleratorId(uint32_t accelerator_id) const; 46 uint32_t ComputeAcceleratorId(uint32_t accelerator_id) const;
51 void OnBindingGone(); 47 void OnBindingGone();
52 void OnHandlerGone(); 48 void OnHandlerGone();
53 49
54 void AddAcceleratorToRoot(RootWindowController* root,
55 uint32_t namespaced_accelerator_id);
56
57 void RemoveAllAccelerators(); 50 void RemoveAllAccelerators();
58 51
59 // ::mus::mojom::AcceleratorRegistrar: 52 // ::mus::mojom::AcceleratorRegistrar:
60 void SetHandler(::mus::mojom::AcceleratorHandlerPtr handler) override; 53 void SetHandler(::mus::mojom::AcceleratorHandlerPtr handler) override;
61 void AddAccelerator(uint32_t accelerator_id, 54 void AddAccelerator(uint32_t accelerator_id,
62 ::mus::mojom::EventMatcherPtr matcher, 55 ::mus::mojom::EventMatcherPtr matcher,
63 const AddAcceleratorCallback& callback) override; 56 const AddAcceleratorCallback& callback) override;
64 void RemoveAccelerator(uint32_t accelerator_id) override; 57 void RemoveAccelerator(uint32_t accelerator_id) override;
65 58
66 // RootWindowsObserver: 59 WindowManager* window_manager_;
67 void OnRootWindowControllerAdded(RootWindowController* controller) override;
68
69 WindowManagerApplication* wm_app_;
70 ::mus::mojom::AcceleratorHandlerPtr accelerator_handler_; 60 ::mus::mojom::AcceleratorHandlerPtr accelerator_handler_;
71 mojo::Binding<AcceleratorRegistrar> binding_; 61 mojo::Binding<AcceleratorRegistrar> binding_;
72 uint32_t accelerator_namespace_; 62 uint32_t accelerator_namespace_;
73 std::map<uint32_t, Accelerator> accelerators_; 63 std::set<uint32_t> accelerators_;
74 DestroyCallback destroy_callback_; 64 DestroyCallback destroy_callback_;
75 65
76 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl); 66 DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl);
77 }; 67 };
78 68
79 } // namespace mus 69 } // namespace mus
80 } // namespace ash 70 } // namespace ash
81 71
82 #endif // ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_ 72 #endif // ASH_MUS_ACCELERATOR_REGISTRAR_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | ash/mus/accelerator_registrar_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698