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

Unified Diff: mash/wm/window_manager_application.cc

Issue 1488713002: mus: Introduce AcceleratorRegistrar and AcceleratorHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot.merge Created 5 years 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/window_manager_application.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mash/wm/window_manager_application.cc
diff --git a/mash/wm/window_manager_application.cc b/mash/wm/window_manager_application.cc
index 0f7bdf8ca6671e581b08910dfdaf00fdc3a18083..3a211d5d37292335fbb914b61c031d18ab22b838 100644
--- a/mash/wm/window_manager_application.cc
+++ b/mash/wm/window_manager_application.cc
@@ -10,6 +10,7 @@
#include "components/mus/public/cpp/window.h"
#include "components/mus/public/cpp/window_tree_connection.h"
#include "components/mus/public/cpp/window_tree_host_factory.h"
+#include "mash/wm/accelerator_registrar_impl.h"
#include "mash/wm/background_layout.h"
#include "mash/wm/shelf_layout.h"
#include "mash/wm/window_layout.h"
@@ -63,6 +64,11 @@ void WindowManagerApplication::AddAccelerators() {
base::Bind(&AssertTrue));
}
+void WindowManagerApplication::OnAcceleratorRegistrarDestroyed(
+ AcceleratorRegistrarImpl* registrar) {
+ accelerator_registrars_.erase(registrar);
+}
+
void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) {
app_ = app;
tracing_.Initialize(app);
@@ -80,7 +86,8 @@ void WindowManagerApplication::Initialize(mojo::ApplicationImpl* app) {
bool WindowManagerApplication::ConfigureIncomingConnection(
mojo::ApplicationConnection* connection) {
- connection->AddService(this);
+ connection->AddService<mus::mojom::AcceleratorRegistrar>(this);
+ connection->AddService<mus::mojom::WindowManager>(this);
return true;
}
@@ -91,7 +98,12 @@ void WindowManagerApplication::OnAccelerator(uint32_t id,
window_tree_host_->ActivateNextWindow();
break;
default:
- NOTREACHED() << "Unknown accelerator command: " << id;
+ for (auto* registrar : accelerator_registrars_) {
+ if (registrar->OwnsAccelerator(id)) {
+ registrar->ProcessAccelerator(id, event.Pass());
+ break;
+ }
+ }
}
}
@@ -128,6 +140,24 @@ void WindowManagerApplication::OnConnectionLost(
void WindowManagerApplication::Create(
mojo::ApplicationConnection* connection,
+ mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) {
+ static int accelerator_registrar_count = 0;
+ if (accelerator_registrar_count == std::numeric_limits<int>::max()) {
+ // Restart from zero if we have reached the limit. It is technically
+ // possible to end up with multiple active registrars with the same
+ // namespace, but it is highly unlikely. In the event that multiple
+ // registrars have the same namespace, this new registrar will be unable to
+ // install accelerators.
+ accelerator_registrar_count = 0;
+ }
+ accelerator_registrars_.insert(new AcceleratorRegistrarImpl(
+ window_tree_host_.get(), ++accelerator_registrar_count, request.Pass(),
+ base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed,
+ base::Unretained(this))));
+}
+
+void WindowManagerApplication::Create(
+ mojo::ApplicationConnection* connection,
mojo::InterfaceRequest<mus::mojom::WindowManager> request) {
if (root_) {
window_manager_binding_.AddBinding(window_manager_.get(), request.Pass());
« no previous file with comments | « mash/wm/window_manager_application.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698