| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell.h" | 5 #include "ash/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 RootWindowControllerList root_window_controllers; | 260 RootWindowControllerList root_window_controllers; |
| 261 for (WmWindow* root_window : instance_->shell_port_->GetAllRootWindows()) | 261 for (WmWindow* root_window : instance_->shell_port_->GetAllRootWindows()) |
| 262 root_window_controllers.push_back(root_window->GetRootWindowController()); | 262 root_window_controllers.push_back(root_window->GetRootWindowController()); |
| 263 return root_window_controllers; | 263 return root_window_controllers; |
| 264 } | 264 } |
| 265 | 265 |
| 266 // static | 266 // static |
| 267 RootWindowController* Shell::GetRootWindowControllerWithDisplayId( | 267 RootWindowController* Shell::GetRootWindowControllerWithDisplayId( |
| 268 int64_t display_id) { | 268 int64_t display_id) { |
| 269 CHECK(HasInstance()); | 269 CHECK(HasInstance()); |
| 270 WmWindow* root_window = | 270 aura::Window* root_window = |
| 271 instance_->shell_port_->GetRootWindowForDisplayId(display_id); | 271 instance_->shell_port_->GetRootWindowForDisplayId(display_id); |
| 272 return root_window ? root_window->GetRootWindowController() : nullptr; | 272 return GetRootWindowController(root_window); |
| 273 } | 273 } |
| 274 | 274 |
| 275 // static | 275 // static |
| 276 aura::Window* Shell::GetPrimaryRootWindow() { | 276 aura::Window* Shell::GetPrimaryRootWindow() { |
| 277 CHECK(HasInstance()); | 277 CHECK(HasInstance()); |
| 278 return instance_->shell_port_->GetPrimaryRootWindow()->aura_window(); | 278 return instance_->shell_port_->GetPrimaryRootWindow(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 // static | 281 // static |
| 282 aura::Window* Shell::GetRootWindowForNewWindows() { | 282 aura::Window* Shell::GetRootWindowForNewWindows() { |
| 283 CHECK(Shell::HasInstance()); | 283 CHECK(Shell::HasInstance()); |
| 284 return WmWindow::GetAuraWindow(Shell::GetWmRootWindowForNewWindows()); | |
| 285 } | |
| 286 | |
| 287 // static | |
| 288 WmWindow* Shell::GetWmRootWindowForNewWindows() { | |
| 289 CHECK(Shell::HasInstance()); | |
| 290 Shell* shell = Shell::Get(); | 284 Shell* shell = Shell::Get(); |
| 291 if (shell->scoped_root_window_for_new_windows_) | 285 if (shell->scoped_root_window_for_new_windows_) |
| 292 return shell->scoped_root_window_for_new_windows_; | 286 return shell->scoped_root_window_for_new_windows_; |
| 293 return shell->root_window_for_new_windows_; | 287 return shell->root_window_for_new_windows_; |
| 294 } | 288 } |
| 295 | 289 |
| 296 // static | 290 // static |
| 297 aura::Window::Windows Shell::GetAllRootWindows() { | 291 aura::Window::Windows Shell::GetAllRootWindows() { |
| 298 CHECK(HasInstance()); | 292 CHECK(HasInstance()); |
| 299 aura::Window::Windows windows; | 293 aura::Window::Windows windows; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 void Shell::AddShellObserver(ShellObserver* observer) { | 442 void Shell::AddShellObserver(ShellObserver* observer) { |
| 449 shell_observers_.AddObserver(observer); | 443 shell_observers_.AddObserver(observer); |
| 450 } | 444 } |
| 451 | 445 |
| 452 void Shell::RemoveShellObserver(ShellObserver* observer) { | 446 void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 453 shell_observers_.RemoveObserver(observer); | 447 shell_observers_.RemoveObserver(observer); |
| 454 } | 448 } |
| 455 | 449 |
| 456 void Shell::ShowAppList() { | 450 void Shell::ShowAppList() { |
| 457 // Show the app list on the default display for new windows. | 451 // Show the app list on the default display for new windows. |
| 458 app_list_->Show( | 452 app_list_->Show(display::Screen::GetScreen() |
| 459 GetWmRootWindowForNewWindows()->GetDisplayNearestWindow().id()); | 453 ->GetDisplayNearestWindow(GetRootWindowForNewWindows()) |
| 454 .id()); |
| 460 } | 455 } |
| 461 | 456 |
| 462 void Shell::DismissAppList() { | 457 void Shell::DismissAppList() { |
| 463 app_list_->Dismiss(); | 458 app_list_->Dismiss(); |
| 464 } | 459 } |
| 465 | 460 |
| 466 void Shell::ToggleAppList() { | 461 void Shell::ToggleAppList() { |
| 467 // Toggle the app list on the default display for new windows. | 462 // Toggle the app list on the default display for new windows. |
| 468 app_list_->ToggleAppList( | 463 app_list_->ToggleAppList( |
| 469 GetWmRootWindowForNewWindows()->GetDisplayNearestWindow().id()); | 464 display::Screen::GetScreen() |
| 465 ->GetDisplayNearestWindow(GetRootWindowForNewWindows()) |
| 466 .id()); |
| 470 } | 467 } |
| 471 | 468 |
| 472 bool Shell::IsAppListVisible() const { | 469 bool Shell::IsAppListVisible() const { |
| 473 return app_list_->IsVisible(); | 470 return app_list_->IsVisible(); |
| 474 } | 471 } |
| 475 | 472 |
| 476 bool Shell::GetAppListTargetVisibility() const { | 473 bool Shell::GetAppListTargetVisibility() const { |
| 477 return app_list_->GetTargetVisibility(); | 474 return app_list_->GetTargetVisibility(); |
| 478 } | 475 } |
| 479 | 476 |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); | 926 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); |
| 930 focus_controller_->AddObserver(this); | 927 focus_controller_->AddObserver(this); |
| 931 if (config != Config::CLASSIC) { | 928 if (config != Config::CLASSIC) { |
| 932 window_tree_client_->focus_synchronizer()->SetSingletonFocusClient( | 929 window_tree_client_->focus_synchronizer()->SetSingletonFocusClient( |
| 933 focus_controller_.get()); | 930 focus_controller_.get()); |
| 934 } | 931 } |
| 935 | 932 |
| 936 screen_position_controller_.reset(new ScreenPositionController); | 933 screen_position_controller_.reset(new ScreenPositionController); |
| 937 | 934 |
| 938 shell_port_->CreatePrimaryHost(); | 935 shell_port_->CreatePrimaryHost(); |
| 939 root_window_for_new_windows_ = WmWindow::Get(GetPrimaryRootWindow()); | 936 root_window_for_new_windows_ = GetPrimaryRootWindow(); |
| 940 | 937 |
| 941 if (config != Config::MASH) { | 938 if (config != Config::MASH) { |
| 942 resolution_notification_controller_.reset( | 939 resolution_notification_controller_.reset( |
| 943 new ResolutionNotificationController); | 940 new ResolutionNotificationController); |
| 944 } | 941 } |
| 945 | 942 |
| 946 if (cursor_manager_) { | 943 if (cursor_manager_) { |
| 947 cursor_manager_->SetDisplay( | 944 cursor_manager_->SetDisplay( |
| 948 display::Screen::GetScreen()->GetPrimaryDisplay()); | 945 display::Screen::GetScreen()->GetPrimaryDisplay()); |
| 949 } | 946 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 | 1213 |
| 1217 ui::EventTargeter* Shell::GetEventTargeter() { | 1214 ui::EventTargeter* Shell::GetEventTargeter() { |
| 1218 NOTREACHED(); | 1215 NOTREACHED(); |
| 1219 return nullptr; | 1216 return nullptr; |
| 1220 } | 1217 } |
| 1221 | 1218 |
| 1222 void Shell::OnWindowActivated( | 1219 void Shell::OnWindowActivated( |
| 1223 aura::client::ActivationChangeObserver::ActivationReason reason, | 1220 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 1224 aura::Window* gained_active, | 1221 aura::Window* gained_active, |
| 1225 aura::Window* lost_active) { | 1222 aura::Window* lost_active) { |
| 1226 WmWindow* gained_active_wm = WmWindow::Get(gained_active); | 1223 if (gained_active) |
| 1227 if (gained_active_wm) | 1224 root_window_for_new_windows_ = gained_active->GetRootWindow(); |
| 1228 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); | |
| 1229 } | 1225 } |
| 1230 | 1226 |
| 1231 void Shell::OnSessionStateChanged(session_manager::SessionState state) { | 1227 void Shell::OnSessionStateChanged(session_manager::SessionState state) { |
| 1232 // Initialize the shelf when a session becomes active. It's safe to do this | 1228 // Initialize the shelf when a session becomes active. It's safe to do this |
| 1233 // multiple times (e.g. initial login vs. multiprofile add session). | 1229 // multiple times (e.g. initial login vs. multiprofile add session). |
| 1234 if (state == session_manager::SessionState::ACTIVE) { | 1230 if (state == session_manager::SessionState::ACTIVE) { |
| 1235 InitializeShelf(); | 1231 InitializeShelf(); |
| 1236 if (GetAshConfig() != Config::MASH) { | 1232 if (GetAshConfig() != Config::MASH) { |
| 1237 // Recreate the keyboard after initial login and after multiprofile login. | 1233 // Recreate the keyboard after initial login and after multiprofile login. |
| 1238 CreateKeyboard(); | 1234 CreateKeyboard(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 void Shell::OnPrefServiceInitialized( | 1271 void Shell::OnPrefServiceInitialized( |
| 1276 std::unique_ptr<::PrefService> pref_service) { | 1272 std::unique_ptr<::PrefService> pref_service) { |
| 1277 if (!instance_) | 1273 if (!instance_) |
| 1278 return; | 1274 return; |
| 1279 // |pref_service_| is null if can't connect to Chrome (as happens when | 1275 // |pref_service_| is null if can't connect to Chrome (as happens when |
| 1280 // running mash outside of chrome --mash and chrome isn't built). | 1276 // running mash outside of chrome --mash and chrome isn't built). |
| 1281 pref_service_ = std::move(pref_service); | 1277 pref_service_ = std::move(pref_service); |
| 1282 } | 1278 } |
| 1283 | 1279 |
| 1284 } // namespace ash | 1280 } // namespace ash |
| OLD | NEW |