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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mash/wm/BUILD.gn ('k') | mash/wm/accelerator_registrar_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mash/wm/accelerator_registrar_impl.h
diff --git a/mash/wm/accelerator_registrar_impl.h b/mash/wm/accelerator_registrar_impl.h
index cbff525c042987a1c1c62c29396a111fb300589d..94a16c21857f04045c2d59038294972f63d0f23a 100644
--- a/mash/wm/accelerator_registrar_impl.h
+++ b/mash/wm/accelerator_registrar_impl.h
@@ -7,20 +7,15 @@
#include <stdint.h>
-#include <set>
+#include <map>
#include "base/callback.h"
#include "base/macros.h"
#include "components/mus/public/interfaces/accelerator_registrar.mojom.h"
+#include "mash/wm/root_windows_observer.h"
#include "mojo/common/weak_binding_set.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
-namespace mus {
-namespace mojom {
-class WindowTreeHost;
-}
-}
-
namespace mash {
namespace wm {
@@ -30,24 +25,37 @@ class WindowManagerApplication;
// connection. This manages its own lifetime, and destroys itself when the
// AcceleratorRegistrar and all its AcceleratorHandlers are disconnected. Upon
// destruction, it calls the DestroyCallback.
-class AcceleratorRegistrarImpl : public mus::mojom::AcceleratorRegistrar {
+class AcceleratorRegistrarImpl : public mus::mojom::AcceleratorRegistrar,
+ public RootWindowsObserver {
public:
using DestroyCallback = base::Callback<void(AcceleratorRegistrarImpl*)>;
- AcceleratorRegistrarImpl(mus::mojom::WindowTreeHost* host,
+ AcceleratorRegistrarImpl(WindowManagerApplication* wm_app,
uint32_t accelerator_namespace,
mojo::InterfaceRequest<AcceleratorRegistrar> request,
const DestroyCallback& destroy_callback);
+ void Destroy();
+
+ // Returns true if this AcceleratorRegistrar has an accelerator with the
+ // specified id.
bool OwnsAccelerator(uint32_t accelerator_id) const;
+
void ProcessAccelerator(uint32_t accelerator_id, mus::mojom::EventPtr event);
private:
+ struct Accelerator;
+
~AcceleratorRegistrarImpl() override;
uint32_t ComputeAcceleratorId(uint32_t accelerator_id) const;
void OnBindingGone();
void OnHandlerGone();
+ void AddAcceleratorToRoot(RootWindowController* root,
+ uint32_t namespaced_accelerator_id);
+
+ void RemoveAllAccelerators();
+
// mus::mojom::AcceleratorRegistrar:
void SetHandler(mus::mojom::AcceleratorHandlerPtr handler) override;
void AddAccelerator(uint32_t accelerator_id,
@@ -55,11 +63,14 @@ class AcceleratorRegistrarImpl : public mus::mojom::AcceleratorRegistrar {
const AddAcceleratorCallback& callback) override;
void RemoveAccelerator(uint32_t accelerator_id) override;
- mus::mojom::WindowTreeHost* host_;
+ // RootWindowsObserver:
+ void OnRootWindowControllerAdded(RootWindowController* controller) override;
+
+ WindowManagerApplication* wm_app_;
mus::mojom::AcceleratorHandlerPtr accelerator_handler_;
mojo::Binding<AcceleratorRegistrar> binding_;
uint32_t accelerator_namespace_;
- std::set<uint32_t> accelerator_ids_;
+ std::map<uint32_t, Accelerator> accelerators_;
DestroyCallback destroy_callback_;
DISALLOW_COPY_AND_ASSIGN(AcceleratorRegistrarImpl);
« 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