OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "mash/wm/root_window_controller.h" | 5 #include "mash/wm/root_window_controller.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "components/mus/common/util.h" | 10 #include "components/mus/common/util.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 | 81 |
82 mus::Window* RootWindowController::GetWindowById(mus::Id id) { | 82 mus::Window* RootWindowController::GetWindowById(mus::Id id) { |
83 return root_->GetChildById(id); | 83 return root_->GetChildById(id); |
84 } | 84 } |
85 | 85 |
86 bool RootWindowController::WindowIsContainer(const mus::Window* window) const { | 86 bool RootWindowController::WindowIsContainer(const mus::Window* window) const { |
87 return window && window->parent() == root_; | 87 return window && window->parent() == root_; |
88 } | 88 } |
89 | 89 |
| 90 void RootWindowController::OnAccelerator(uint32_t id, |
| 91 mus::mojom::EventPtr event) { |
| 92 switch (id) { |
| 93 case kWindowSwitchAccelerator: |
| 94 window_tree_host_->ActivateNextWindow(); |
| 95 break; |
| 96 default: |
| 97 app_->OnAccelerator(id, std::move(event)); |
| 98 break; |
| 99 } |
| 100 } |
| 101 |
90 RootWindowController::RootWindowController(WindowManagerApplication* app) | 102 RootWindowController::RootWindowController(WindowManagerApplication* app) |
91 : app_(app), root_(nullptr), window_count_(0), host_client_binding_(this) { | 103 : app_(app), root_(nullptr), window_count_(0), host_client_binding_(this) { |
92 window_manager_.reset(new WindowManager); | 104 window_manager_.reset(new WindowManager); |
93 } | 105 } |
94 | 106 |
95 RootWindowController::~RootWindowController() {} | 107 RootWindowController::~RootWindowController() {} |
96 | 108 |
97 void RootWindowController::AddAccelerators() { | 109 void RootWindowController::AddAccelerators() { |
98 window_tree_host_->AddAccelerator( | 110 window_manager_->window_manager_client()->AddAccelerator( |
99 kWindowSwitchAccelerator, | 111 kWindowSwitchAccelerator, |
100 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::TAB, | 112 mus::CreateKeyMatcher(mus::mojom::KeyboardCode::TAB, |
101 mus::mojom::kEventFlagControlDown), | 113 mus::mojom::kEventFlagControlDown), |
102 base::Bind(&AssertTrue)); | 114 base::Bind(&AssertTrue)); |
103 } | 115 } |
104 | 116 |
105 void RootWindowController::OnAccelerator(uint32_t id, | |
106 mus::mojom::EventPtr event) { | |
107 switch (id) { | |
108 case kWindowSwitchAccelerator: | |
109 window_tree_host_->ActivateNextWindow(); | |
110 break; | |
111 default: | |
112 app_->OnAccelerator(id, std::move(event)); | |
113 break; | |
114 } | |
115 } | |
116 | |
117 void RootWindowController::OnEmbed(mus::Window* root) { | 117 void RootWindowController::OnEmbed(mus::Window* root) { |
118 root_ = root; | 118 root_ = root; |
119 root_->AddObserver(this); | 119 root_->AddObserver(this); |
120 | 120 |
121 app_->OnRootWindowControllerGotRoot(this); | 121 app_->OnRootWindowControllerGotRoot(this); |
122 | 122 |
123 CreateContainers(); | 123 CreateContainers(); |
124 background_layout_.reset(new BackgroundLayout( | 124 background_layout_.reset(new BackgroundLayout( |
125 GetWindowForContainer(mojom::Container::USER_BACKGROUND))); | 125 GetWindowForContainer(mojom::Container::USER_BACKGROUND))); |
126 screenlock_layout_.reset(new ScreenlockLayout( | 126 screenlock_layout_.reset(new ScreenlockLayout( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 DCHECK_EQ(mus::LoWord(window->id()), container) | 168 DCHECK_EQ(mus::LoWord(window->id()), container) |
169 << "Containers must be created before other windows!"; | 169 << "Containers must be created before other windows!"; |
170 window->SetBounds(root_->bounds()); | 170 window->SetBounds(root_->bounds()); |
171 window->SetVisible(true); | 171 window->SetVisible(true); |
172 root_->AddChild(window); | 172 root_->AddChild(window); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 } // namespace wm | 176 } // namespace wm |
177 } // namespace mash | 177 } // namespace mash |
OLD | NEW |