| 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 "ash/common/wm_root_window_controller.h" | 5 #include "ash/common/wm_root_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/shelf/wm_shelf.h" |
| 9 #include "ash/common/shell_delegate.h" |
| 8 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| 9 #include "ash/common/wallpaper/wallpaper_delegate.h" | 11 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 10 #include "ash/common/wallpaper/wallpaper_widget_controller.h" | 12 #include "ash/common/wallpaper/wallpaper_widget_controller.h" |
| 11 #include "ash/common/wm/container_finder.h" | 13 #include "ash/common/wm/container_finder.h" |
| 12 #include "ash/common/wm/root_window_layout_manager.h" | 14 #include "ash/common/wm/root_window_layout_manager.h" |
| 13 #include "ash/common/wm/system_modal_container_layout_manager.h" | 15 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 14 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 16 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
| 15 #include "ash/common/wm/workspace_controller.h" | 17 #include "ash/common/wm/workspace_controller.h" |
| 16 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 17 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
| 18 #include "base/memory/ptr_util.h" | 20 #include "base/memory/ptr_util.h" |
| 21 #include "ui/base/models/menu_model.h" |
| 22 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 23 #include "ui/views/controls/menu/menu_runner.h" |
| 19 | 24 |
| 20 namespace ash { | 25 namespace ash { |
| 21 namespace { | 26 namespace { |
| 22 | 27 |
| 23 // Creates a new window for use as a container. | 28 // Creates a new window for use as a container. |
| 24 WmWindow* CreateContainer(int window_id, const char* name, WmWindow* parent) { | 29 WmWindow* CreateContainer(int window_id, const char* name, WmWindow* parent) { |
| 25 WmWindow* window = WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_UNKNOWN, | 30 WmWindow* window = WmShell::Get()->NewWindow(ui::wm::WINDOW_TYPE_UNKNOWN, |
| 26 ui::LAYER_NOT_DRAWN); | 31 ui::LAYER_NOT_DRAWN); |
| 27 window->SetShellWindowId(window_id); | 32 window->SetShellWindowId(window_id); |
| 28 window->SetName(name); | 33 window->SetName(name); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 89 } |
| 85 | 90 |
| 86 WmWindow* WmRootWindowController::GetContainer(int container_id) { | 91 WmWindow* WmRootWindowController::GetContainer(int container_id) { |
| 87 return root_->GetChildByShellWindowId(container_id); | 92 return root_->GetChildByShellWindowId(container_id); |
| 88 } | 93 } |
| 89 | 94 |
| 90 const WmWindow* WmRootWindowController::GetContainer(int container_id) const { | 95 const WmWindow* WmRootWindowController::GetContainer(int container_id) const { |
| 91 return root_->GetChildByShellWindowId(container_id); | 96 return root_->GetChildByShellWindowId(container_id); |
| 92 } | 97 } |
| 93 | 98 |
| 99 void WmRootWindowController::ShowContextMenu( |
| 100 const gfx::Point& location_in_screen, |
| 101 ui::MenuSourceType source_type) { |
| 102 ShellDelegate* delegate = WmShell::Get()->delegate(); |
| 103 DCHECK(delegate); |
| 104 menu_model_.reset(delegate->CreateContextMenu(GetShelf(), nullptr)); |
| 105 if (!menu_model_) |
| 106 return; |
| 107 |
| 108 menu_model_adapter_.reset(new views::MenuModelAdapter( |
| 109 menu_model_.get(), base::Bind(&WmRootWindowController::OnMenuClosed, |
| 110 base::Unretained(this)))); |
| 111 |
| 112 // The wallpaper controller may not be set yet if the user clicked on the |
| 113 // status area before the initial animation completion. See crbug.com/222218 |
| 114 if (!wallpaper_widget_controller()) |
| 115 return; |
| 116 |
| 117 menu_runner_.reset(new views::MenuRunner( |
| 118 menu_model_adapter_->CreateMenu(), |
| 119 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC)); |
| 120 ignore_result( |
| 121 menu_runner_->RunMenuAt(wallpaper_widget_controller()->widget(), nullptr, |
| 122 gfx::Rect(location_in_screen, gfx::Size()), |
| 123 views::MENU_ANCHOR_TOPLEFT, source_type)); |
| 124 } |
| 125 |
| 94 void WmRootWindowController::OnInitialWallpaperAnimationStarted() {} | 126 void WmRootWindowController::OnInitialWallpaperAnimationStarted() {} |
| 95 | 127 |
| 96 void WmRootWindowController::OnWallpaperAnimationFinished( | 128 void WmRootWindowController::OnWallpaperAnimationFinished( |
| 97 views::Widget* widget) { | 129 views::Widget* widget) { |
| 98 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished(); | 130 WmShell::Get()->wallpaper_delegate()->OnWallpaperAnimationFinished(); |
| 99 // Only removes old component when wallpaper animation finished. If we | 131 // Only removes old component when wallpaper animation finished. If we |
| 100 // remove the old one before the new wallpaper is done fading in there will | 132 // remove the old one before the new wallpaper is done fading in there will |
| 101 // be a white flash during the animation. | 133 // be a white flash during the animation. |
| 102 if (animating_wallpaper_widget_controller()) { | 134 if (animating_wallpaper_widget_controller()) { |
| 103 WallpaperWidgetController* controller = | 135 WallpaperWidgetController* controller = |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 DCHECK(lock_modal_container); | 335 DCHECK(lock_modal_container); |
| 304 lock_modal_container->SetLayoutManager( | 336 lock_modal_container->SetLayoutManager( |
| 305 base::MakeUnique<SystemModalContainerLayoutManager>( | 337 base::MakeUnique<SystemModalContainerLayoutManager>( |
| 306 lock_modal_container)); | 338 lock_modal_container)); |
| 307 } | 339 } |
| 308 | 340 |
| 309 void WmRootWindowController::DeleteWorkspaceController() { | 341 void WmRootWindowController::DeleteWorkspaceController() { |
| 310 workspace_controller_.reset(); | 342 workspace_controller_.reset(); |
| 311 } | 343 } |
| 312 | 344 |
| 345 void WmRootWindowController::OnMenuClosed() { |
| 346 menu_runner_.reset(); |
| 347 menu_model_adapter_.reset(); |
| 348 menu_model_.reset(); |
| 349 GetShelf()->UpdateVisibilityState(); |
| 350 } |
| 351 |
| 313 } // namespace ash | 352 } // namespace ash |
| OLD | NEW |