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

Side by Side Diff: ash/mus/root_window_controller.cc

Issue 2259153002: mash: Port ash_sysui ShelfDelegateMus impl to mojo:ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 4 years, 3 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
« no previous file with comments | « ash/mus/root_window_controller.h ('k') | ash/mus/shelf_delegate_mus.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/mus/root_window_controller.h" 5 #include "ash/mus/root_window_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
11 #include <sstream> 11 #include <sstream>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "ash/common/root_window_controller_common.h" 16 #include "ash/common/root_window_controller_common.h"
17 #include "ash/common/shelf/shelf_layout_manager.h"
17 #include "ash/common/shell_window_ids.h" 18 #include "ash/common/shell_window_ids.h"
18 #include "ash/common/wm/always_on_top_controller.h" 19 #include "ash/common/wm/always_on_top_controller.h"
19 #include "ash/common/wm/container_finder.h" 20 #include "ash/common/wm/container_finder.h"
20 #include "ash/common/wm/dock/docked_window_layout_manager.h" 21 #include "ash/common/wm/dock/docked_window_layout_manager.h"
21 #include "ash/common/wm/panels/panel_layout_manager.h" 22 #include "ash/common/wm/panels/panel_layout_manager.h"
22 #include "ash/common/wm/root_window_layout_manager.h" 23 #include "ash/common/wm/root_window_layout_manager.h"
23 #include "ash/common/wm/workspace/workspace_layout_manager.h" 24 #include "ash/common/wm/workspace/workspace_layout_manager.h"
24 #include "ash/mus/bridge/wm_root_window_controller_mus.h" 25 #include "ash/mus/bridge/wm_root_window_controller_mus.h"
25 #include "ash/mus/bridge/wm_shelf_mus.h" 26 #include "ash/mus/bridge/wm_shelf_mus.h"
26 #include "ash/mus/bridge/wm_shell_mus.h" 27 #include "ash/mus/bridge/wm_shell_mus.h"
27 #include "ash/mus/bridge/wm_window_mus.h" 28 #include "ash/mus/bridge/wm_window_mus.h"
28 #include "ash/mus/container_ids.h" 29 #include "ash/mus/container_ids.h"
29 #include "ash/mus/non_client_frame_controller.h" 30 #include "ash/mus/non_client_frame_controller.h"
30 #include "ash/mus/property_util.h" 31 #include "ash/mus/property_util.h"
31 #include "ash/mus/screenlock_layout.h" 32 #include "ash/mus/screenlock_layout.h"
32 #include "ash/mus/shelf_layout_manager.h"
33 #include "ash/mus/window_manager.h" 33 #include "ash/mus/window_manager.h"
34 #include "base/bind.h" 34 #include "base/bind.h"
35 #include "base/command_line.h" 35 #include "base/command_line.h"
36 #include "base/memory/ptr_util.h" 36 #include "base/memory/ptr_util.h"
37 #include "mojo/public/cpp/bindings/type_converter.h" 37 #include "mojo/public/cpp/bindings/type_converter.h"
38 #include "services/shell/public/cpp/connector.h" 38 #include "services/shell/public/cpp/connector.h"
39 #include "services/ui/common/switches.h" 39 #include "services/ui/common/switches.h"
40 #include "services/ui/common/util.h" 40 #include "services/ui/common/util.h"
41 #include "services/ui/public/cpp/property_type_converters.h" 41 #include "services/ui/public/cpp/property_type_converters.h"
42 #include "services/ui/public/cpp/window.h" 42 #include "services/ui/public/cpp/window.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 } else { 156 } else {
157 // TODO(sky): likely want to constrain more than root size. 157 // TODO(sky): likely want to constrain more than root size.
158 const gfx::Size max_size = root_->bounds().size(); 158 const gfx::Size max_size = root_->bounds().size();
159 width = std::max(0, std::min(max_size.width(), pref.width())); 159 width = std::max(0, std::min(max_size.width(), pref.width()));
160 height = std::max(0, std::min(max_size.height(), pref.height())); 160 height = std::max(0, std::min(max_size.height(), pref.height()));
161 } 161 }
162 return gfx::Rect(40 + (window_count_ % 4) * 40, 40 + (window_count_ % 4) * 40, 162 return gfx::Rect(40 + (window_count_ % 4) * 40, 40 + (window_count_ % 4) * 40,
163 width, height); 163 width, height);
164 } 164 }
165 165
166 void RootWindowController::OnShelfWindowAvailable() {
167 DockedWindowLayoutManager* docked_window_layout_manager =
168 DockedWindowLayoutManager::Get(WmWindowMus::Get(root_));
169
170 DCHECK(!docked_window_layout_manager->shelf());
171 docked_window_layout_manager->SetShelf(wm_shelf_.get());
172
173 PanelLayoutManager::Get(WmWindowMus::Get(root_))->SetShelf(wm_shelf_.get());
174
175 // TODO: http://crbug.com/614182 Ash's ShelfLayoutManager implements
176 // DockedWindowLayoutManagerObserver so that it can inset by the docked
177 // windows.
178 // docked_layout_manager_->AddObserver(shelf_->shelf_layout_manager());
179 }
180
181 void RootWindowController::CreateLayoutManagers() { 166 void RootWindowController::CreateLayoutManagers() {
182 // Override the default layout managers for certain containers. 167 // Override the default layout managers for certain containers.
183 WmWindowMus* lock_screen_container = 168 WmWindowMus* lock_screen_container =
184 GetWindowByShellWindowId(kShellWindowId_LockScreenContainer); 169 GetWindowByShellWindowId(kShellWindowId_LockScreenContainer);
185 layout_managers_[lock_screen_container->mus_window()].reset( 170 layout_managers_[lock_screen_container->mus_window()].reset(
186 new ScreenlockLayout(lock_screen_container->mus_window())); 171 new ScreenlockLayout(lock_screen_container->mus_window()));
187 172
188 WmWindowMus* shelf_container = 173 // Creating the shelf also creates the status area and both layout managers.
189 GetWindowByShellWindowId(kShellWindowId_ShelfContainer);
190 ShelfLayoutManager* shelf_layout_manager =
191 new ShelfLayoutManager(shelf_container->mus_window(), this);
192 layout_managers_[shelf_container->mus_window()].reset(shelf_layout_manager);
193
194 wm_shelf_.reset(new WmShelfMus(wm_root_window_controller_.get())); 174 wm_shelf_.reset(new WmShelfMus(wm_root_window_controller_.get()));
195 175
196 WmWindowMus* default_container = 176 WmWindowMus* default_container =
197 GetWindowByShellWindowId(kShellWindowId_DefaultContainer); 177 GetWindowByShellWindowId(kShellWindowId_DefaultContainer);
198 // WorkspaceLayoutManager is not a mash::wm::LayoutManager (it's a 178 // WorkspaceLayoutManager is not a mash::wm::LayoutManager (it's a
199 // wm::LayoutManager), so it can't be in |layout_managers_|. 179 // wm::LayoutManager), so it can't be in |layout_managers_|.
200 workspace_layout_manager_ = new WorkspaceLayoutManager(default_container); 180 workspace_layout_manager_ = new WorkspaceLayoutManager(default_container);
201 default_container->SetLayoutManager( 181 default_container->SetLayoutManager(
202 base::WrapUnique(workspace_layout_manager_)); 182 base::WrapUnique(workspace_layout_manager_));
203 183
204 WmWindowMus* docked_container = 184 WmWindowMus* docked_container =
205 GetWindowByShellWindowId(kShellWindowId_DockedContainer); 185 GetWindowByShellWindowId(kShellWindowId_DockedContainer);
206 docked_container->SetLayoutManager( 186 std::unique_ptr<DockedWindowLayoutManager> docked_window_layout_manager =
207 base::MakeUnique<DockedWindowLayoutManager>(docked_container)); 187 base::MakeUnique<DockedWindowLayoutManager>(docked_container);
188 docked_window_layout_manager->SetShelf(wm_shelf_.get());
189 docked_window_layout_manager->AddObserver(wm_shelf_->shelf_layout_manager());
190 docked_container->SetLayoutManager(std::move(docked_window_layout_manager));
208 191
209 WmWindowMus* panel_container = 192 WmWindowMus* panel_container =
210 GetWindowByShellWindowId(kShellWindowId_PanelContainer); 193 GetWindowByShellWindowId(kShellWindowId_PanelContainer);
211 panel_container->SetLayoutManager( 194 std::unique_ptr<PanelLayoutManager> panel_layout_manager =
212 base::MakeUnique<PanelLayoutManager>(panel_container)); 195 base::MakeUnique<PanelLayoutManager>(panel_container);
196 panel_layout_manager->SetShelf(wm_shelf_.get());
197 panel_container->SetLayoutManager(std::move(panel_layout_manager));
213 } 198 }
214 199
215 } // namespace mus 200 } // namespace mus
216 } // namespace ash 201 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/root_window_controller.h ('k') | ash/mus/shelf_delegate_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698