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

Unified Diff: ash/mus/bridge/wm_shell_mus.cc

Issue 2187703003: Wires up registering accelerators from mash with the wm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 4 years, 5 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 | « ash/mus/bridge/wm_shell_mus.h ('k') | ash/mus/window_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/bridge/wm_shell_mus.cc
diff --git a/ash/mus/bridge/wm_shell_mus.cc b/ash/mus/bridge/wm_shell_mus.cc
index f6aacd9ae83e576c9c766b88bf8ca50358ea7b2f..4e64d2d37fca75096c94ca25c3036911a75896ac 100644
--- a/ash/mus/bridge/wm_shell_mus.cc
+++ b/ash/mus/bridge/wm_shell_mus.cc
@@ -21,11 +21,13 @@
#include "ash/common/wm/window_resizer.h"
#include "ash/common/wm_activation_observer.h"
#include "ash/mus/accelerators/accelerator_controller_delegate_mus.h"
+#include "ash/mus/accelerators/accelerator_controller_registrar.h"
#include "ash/mus/bridge/wm_root_window_controller_mus.h"
#include "ash/mus/bridge/wm_window_mus.h"
#include "ash/mus/container_ids.h"
#include "ash/mus/drag_window_resizer.h"
#include "ash/mus/root_window_controller.h"
+#include "ash/mus/window_manager.h"
#include "base/memory/ptr_util.h"
#include "components/user_manager/user_info_impl.h"
#include "services/ui/common/util.h"
@@ -99,16 +101,24 @@ class SessionStateDelegateStub : public SessionStateDelegate {
} // namespace
WmShellMus::WmShellMus(std::unique_ptr<ShellDelegate> shell_delegate,
- ::ui::WindowTreeClient* client)
+ WindowManager* window_manager)
: WmShell(std::move(shell_delegate)),
- client_(client),
+ window_manager_(window_manager),
session_state_delegate_(new SessionStateDelegateStub) {
- client_->AddObserver(this);
+ window_tree_client()->AddObserver(this);
WmShell::Set(this);
+ uint16_t accelerator_namespace_id = 0u;
+ const bool add_result =
+ window_manager->GetNextAcceleratorNamespaceId(&accelerator_namespace_id);
+ // WmShellMus is created early on, so that this should always succeed.
+ DCHECK(add_result);
accelerator_controller_delegate_.reset(new AcceleratorControllerDelegateMus);
+ accelerator_controller_registrar_.reset(new AcceleratorControllerRegistrar(
+ window_manager_, accelerator_namespace_id));
SetAcceleratorController(base::MakeUnique<AcceleratorController>(
- accelerator_controller_delegate_.get()));
+ accelerator_controller_delegate_.get(),
+ accelerator_controller_registrar_.get()));
CreateMaximizeModeController();
@@ -132,7 +142,8 @@ WmShellMus::~WmShellMus() {
DeleteWindowCycleController();
DeleteWindowSelectorController();
DeleteMruWindowTracker();
- RemoveClientObserver();
+ if (window_tree_client())
+ window_tree_client()->RemoveObserver(this);
WmShell::Set(nullptr);
}
@@ -176,15 +187,15 @@ WmRootWindowControllerMus* WmShellMus::GetRootWindowControllerWithDisplayId(
}
WmWindow* WmShellMus::NewContainerWindow() {
- return WmWindowMus::Get(client_->NewWindow());
+ return WmWindowMus::Get(window_tree_client()->NewWindow());
}
WmWindow* WmShellMus::GetFocusedWindow() {
- return WmWindowMus::Get(client_->GetFocusedWindow());
+ return WmWindowMus::Get(window_tree_client()->GetFocusedWindow());
}
WmWindow* WmShellMus::GetActiveWindow() {
- return GetToplevelAncestor(client_->GetFocusedWindow());
+ return GetToplevelAncestor(window_tree_client()->GetFocusedWindow());
}
WmWindow* WmShellMus::GetPrimaryRootWindow() {
@@ -328,20 +339,16 @@ void WmShellMus::ToggleIgnoreExternalKeyboard() {
}
#endif // defined(OS_CHROMEOS)
+::ui::WindowTreeClient* WmShellMus::window_tree_client() {
+ return window_manager_->window_tree_client();
+}
+
// static
bool WmShellMus::IsActivationParent(::ui::Window* window) {
return window && IsActivatableShellWindowId(
WmWindowMus::Get(window)->GetShellWindowId());
}
-void WmShellMus::RemoveClientObserver() {
- if (!client_)
- return;
-
- client_->RemoveObserver(this);
- client_ = nullptr;
-}
-
// TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114.
void WmShellMus::OnWindowTreeFocusChanged(::ui::Window* gained_focus,
::ui::Window* lost_focus) {
@@ -355,8 +362,8 @@ void WmShellMus::OnWindowTreeFocusChanged(::ui::Window* gained_focus,
}
void WmShellMus::OnDidDestroyClient(::ui::WindowTreeClient* client) {
- DCHECK_EQ(client, client_);
- RemoveClientObserver();
+ DCHECK_EQ(window_tree_client(), client);
+ client->RemoveObserver(this);
}
} // namespace mus
« no previous file with comments | « ash/mus/bridge/wm_shell_mus.h ('k') | ash/mus/window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698