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

Side by Side Diff: mash/wm/window_manager_application.cc

Issue 1576683002: Add rudimentary mash shelf functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. 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 unified diff | Download patch
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 #include "mash/wm/window_manager_application.h" 5 #include "mash/wm/window_manager_application.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 host_client_binding_.Bind(GetProxy(&host_client)); 85 host_client_binding_.Bind(GetProxy(&host_client));
86 mus::CreateSingleWindowTreeHost(app, std::move(host_client), this, 86 mus::CreateSingleWindowTreeHost(app, std::move(host_client), this,
87 &window_tree_host_, std::move(window_manager), 87 &window_tree_host_, std::move(window_manager),
88 window_manager_.get()); 88 window_manager_.get());
89 } 89 }
90 90
91 bool WindowManagerApplication::ConfigureIncomingConnection( 91 bool WindowManagerApplication::ConfigureIncomingConnection(
92 mojo::ApplicationConnection* connection) { 92 mojo::ApplicationConnection* connection) {
93 connection->AddService<mus::mojom::AcceleratorRegistrar>(this); 93 connection->AddService<mus::mojom::AcceleratorRegistrar>(this);
94 connection->AddService<mus::mojom::WindowManager>(this); 94 connection->AddService<mus::mojom::WindowManager>(this);
95 connection->AddService<mus::mojom::UserWindowController>(this);
95 return true; 96 return true;
96 } 97 }
97 98
98 void WindowManagerApplication::OnAccelerator(uint32_t id, 99 void WindowManagerApplication::OnAccelerator(uint32_t id,
99 mus::mojom::EventPtr event) { 100 mus::mojom::EventPtr event) {
100 switch (id) { 101 switch (id) {
101 case kWindowSwitchCmd: 102 case kWindowSwitchCmd:
102 window_tree_host_->ActivateNextWindow(); 103 window_tree_host_->ActivateNextWindow();
103 break; 104 break;
104 default: 105 default:
(...skipping 25 matching lines...) Expand all
130 131
131 ui_init_.reset(new ui::mojo::UIInit(views::GetDisplaysFromWindow(root))); 132 ui_init_.reset(new ui::mojo::UIInit(views::GetDisplaysFromWindow(root)));
132 aura_init_.reset(new views::AuraInit(app_, "mash_wm_resources.pak")); 133 aura_init_.reset(new views::AuraInit(app_, "mash_wm_resources.pak"));
133 window_manager_->Initialize(this); 134 window_manager_->Initialize(this);
134 135
135 for (auto request : requests_) 136 for (auto request : requests_)
136 window_manager_binding_.AddBinding(window_manager_.get(), 137 window_manager_binding_.AddBinding(window_manager_.get(),
137 std::move(*request)); 138 std::move(*request));
138 requests_.clear(); 139 requests_.clear();
139 140
141 for (auto request : user_window_controller_requests_)
142 user_window_controller_binding_.AddBinding(window_manager_.get(),
143 std::move(*request));
144 user_window_controller_requests_.clear();
145
140 shadow_controller_.reset(new ShadowController(root->connection())); 146 shadow_controller_.reset(new ShadowController(root->connection()));
141 } 147 }
142 148
143 void WindowManagerApplication::OnConnectionLost( 149 void WindowManagerApplication::OnConnectionLost(
144 mus::WindowTreeConnection* connection) { 150 mus::WindowTreeConnection* connection) {
145 // TODO(sky): shutdown. 151 // TODO(sky): shutdown.
146 NOTIMPLEMENTED(); 152 NOTIMPLEMENTED();
147 shadow_controller_.reset(); 153 shadow_controller_.reset();
148 } 154 }
149 155
(...skipping 21 matching lines...) Expand all
171 mojo::InterfaceRequest<mus::mojom::WindowManager> request) { 177 mojo::InterfaceRequest<mus::mojom::WindowManager> request) {
172 if (root_) { 178 if (root_) {
173 window_manager_binding_.AddBinding(window_manager_.get(), 179 window_manager_binding_.AddBinding(window_manager_.get(),
174 std::move(request)); 180 std::move(request));
175 } else { 181 } else {
176 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>( 182 requests_.push_back(new mojo::InterfaceRequest<mus::mojom::WindowManager>(
177 std::move(request))); 183 std::move(request)));
178 } 184 }
179 } 185 }
180 186
187 void WindowManagerApplication::Create(
188 mojo::ApplicationConnection* connection,
189 mojo::InterfaceRequest<mus::mojom::UserWindowController> request) {
190 if (root_) {
191 user_window_controller_binding_.AddBinding(window_manager_.get(),
192 std::move(request));
193 } else {
194 user_window_controller_requests_.push_back(
195 new mojo::InterfaceRequest<mus::mojom::UserWindowController>(
196 std::move(request)));
197 }
198 }
199
181 void WindowManagerApplication::OnWindowDestroyed(mus::Window* window) { 200 void WindowManagerApplication::OnWindowDestroyed(mus::Window* window) {
182 DCHECK_EQ(window, root_); 201 DCHECK_EQ(window, root_);
183 root_->RemoveObserver(this); 202 root_->RemoveObserver(this);
184 // Delete the |window_manager_| here so that WindowManager doesn't have to 203 // Delete the |window_manager_| here so that WindowManager doesn't have to
185 // worry about the possibility of |root_| being null. 204 // worry about the possibility of |root_| being null.
186 window_manager_.reset(); 205 window_manager_.reset();
187 root_ = nullptr; 206 root_ = nullptr;
188 } 207 }
189 208
190 void WindowManagerApplication::CreateContainers() { 209 void WindowManagerApplication::CreateContainers() {
191 for (uint16_t container = 210 for (uint16_t container =
192 static_cast<uint16_t>(mojom::CONTAINER_ALL_USER_BACKGROUND); 211 static_cast<uint16_t>(mojom::CONTAINER_ALL_USER_BACKGROUND);
193 container < static_cast<uint16_t>(mojom::CONTAINER_COUNT); ++container) { 212 container < static_cast<uint16_t>(mojom::CONTAINER_COUNT); ++container) {
194 mus::Window* window = root_->connection()->NewWindow(); 213 mus::Window* window = root_->connection()->NewWindow();
195 DCHECK_EQ(mus::LoWord(window->id()), container) 214 DCHECK_EQ(mus::LoWord(window->id()), container)
196 << "Containers must be created before other windows!"; 215 << "Containers must be created before other windows!";
197 window->SetBounds(root_->bounds()); 216 window->SetBounds(root_->bounds());
198 window->SetVisible(true); 217 window->SetVisible(true);
199 root_->AddChild(window); 218 root_->AddChild(window);
200 } 219 }
201 } 220 }
202 221
203 } // namespace wm 222 } // namespace wm
204 } // namespace mash 223 } // namespace mash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698