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

Side by Side Diff: mash/wm/accelerator_registrar_impl.h

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

Powered by Google App Engine
This is Rietveld 408576698