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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 int64_t display_id) { | 262 int64_t display_id) { |
263 CHECK(HasInstance()); | 263 CHECK(HasInstance()); |
264 WmWindow* root_window = | 264 WmWindow* root_window = |
265 instance_->shell_port_->GetRootWindowForDisplayId(display_id); | 265 instance_->shell_port_->GetRootWindowForDisplayId(display_id); |
266 return root_window ? root_window->GetRootWindowController() : nullptr; | 266 return root_window ? root_window->GetRootWindowController() : nullptr; |
267 } | 267 } |
268 | 268 |
269 // static | 269 // static |
270 aura::Window* Shell::GetPrimaryRootWindow() { | 270 aura::Window* Shell::GetPrimaryRootWindow() { |
271 CHECK(HasInstance()); | 271 CHECK(HasInstance()); |
272 return instance_->shell_port_->GetPrimaryRootWindow()->aura_window(); | 272 return instance_->shell_port_->GetPrimaryRootWindow(); |
273 } | 273 } |
274 | 274 |
275 // static | 275 // static |
276 aura::Window* Shell::GetRootWindowForNewWindows() { | 276 aura::Window* Shell::GetRootWindowForNewWindows() { |
277 CHECK(Shell::HasInstance()); | 277 CHECK(Shell::HasInstance()); |
278 return WmWindow::GetAuraWindow(Shell::GetWmRootWindowForNewWindows()); | |
279 } | |
280 | |
281 // static | |
282 WmWindow* Shell::GetWmRootWindowForNewWindows() { | |
283 CHECK(Shell::HasInstance()); | |
284 Shell* shell = Shell::Get(); | 278 Shell* shell = Shell::Get(); |
285 if (shell->scoped_root_window_for_new_windows_) | 279 if (shell->scoped_root_window_for_new_windows_) |
286 return shell->scoped_root_window_for_new_windows_; | 280 return shell->scoped_root_window_for_new_windows_; |
287 return shell->root_window_for_new_windows_; | 281 return shell->root_window_for_new_windows_; |
288 } | 282 } |
289 | 283 |
290 // static | 284 // static |
291 aura::Window::Windows Shell::GetAllRootWindows() { | 285 aura::Window::Windows Shell::GetAllRootWindows() { |
292 CHECK(HasInstance()); | 286 CHECK(HasInstance()); |
293 aura::Window::Windows windows; | 287 aura::Window::Windows windows; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 void Shell::AddShellObserver(ShellObserver* observer) { | 451 void Shell::AddShellObserver(ShellObserver* observer) { |
458 shell_observers_.AddObserver(observer); | 452 shell_observers_.AddObserver(observer); |
459 } | 453 } |
460 | 454 |
461 void Shell::RemoveShellObserver(ShellObserver* observer) { | 455 void Shell::RemoveShellObserver(ShellObserver* observer) { |
462 shell_observers_.RemoveObserver(observer); | 456 shell_observers_.RemoveObserver(observer); |
463 } | 457 } |
464 | 458 |
465 void Shell::ShowAppList() { | 459 void Shell::ShowAppList() { |
466 // Show the app list on the default display for new windows. | 460 // Show the app list on the default display for new windows. |
467 app_list_->Show( | 461 app_list_->Show(display::Screen::GetScreen() |
468 GetWmRootWindowForNewWindows()->GetDisplayNearestWindow().id()); | 462 ->GetDisplayNearestWindow(GetRootWindowForNewWindows()) |
| 463 .id()); |
469 } | 464 } |
470 | 465 |
471 void Shell::DismissAppList() { | 466 void Shell::DismissAppList() { |
472 app_list_->Dismiss(); | 467 app_list_->Dismiss(); |
473 } | 468 } |
474 | 469 |
475 void Shell::ToggleAppList() { | 470 void Shell::ToggleAppList() { |
476 // Toggle the app list on the default display for new windows. | 471 // Toggle the app list on the default display for new windows. |
477 app_list_->ToggleAppList( | 472 app_list_->ToggleAppList( |
478 GetWmRootWindowForNewWindows()->GetDisplayNearestWindow().id()); | 473 display::Screen::GetScreen() |
| 474 ->GetDisplayNearestWindow(GetRootWindowForNewWindows()) |
| 475 .id()); |
479 } | 476 } |
480 | 477 |
481 bool Shell::IsAppListVisible() const { | 478 bool Shell::IsAppListVisible() const { |
482 return app_list_->IsVisible(); | 479 return app_list_->IsVisible(); |
483 } | 480 } |
484 | 481 |
485 bool Shell::GetAppListTargetVisibility() const { | 482 bool Shell::GetAppListTargetVisibility() const { |
486 return app_list_->GetTargetVisibility(); | 483 return app_list_->GetTargetVisibility(); |
487 } | 484 } |
488 | 485 |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); | 930 base::MakeUnique<::wm::FocusController>(new wm::AshFocusRules()); |
934 focus_controller_->AddObserver(this); | 931 focus_controller_->AddObserver(this); |
935 if (config != Config::CLASSIC) { | 932 if (config != Config::CLASSIC) { |
936 window_tree_client_->focus_synchronizer()->SetSingletonFocusClient( | 933 window_tree_client_->focus_synchronizer()->SetSingletonFocusClient( |
937 focus_controller_.get()); | 934 focus_controller_.get()); |
938 } | 935 } |
939 | 936 |
940 screen_position_controller_.reset(new ScreenPositionController); | 937 screen_position_controller_.reset(new ScreenPositionController); |
941 | 938 |
942 shell_port_->CreatePrimaryHost(); | 939 shell_port_->CreatePrimaryHost(); |
943 root_window_for_new_windows_ = WmWindow::Get(GetPrimaryRootWindow()); | 940 root_window_for_new_windows_ = GetPrimaryRootWindow(); |
944 | 941 |
945 if (config != Config::MASH) { | 942 if (config != Config::MASH) { |
946 resolution_notification_controller_.reset( | 943 resolution_notification_controller_.reset( |
947 new ResolutionNotificationController); | 944 new ResolutionNotificationController); |
948 } | 945 } |
949 | 946 |
950 if (cursor_manager_) { | 947 if (cursor_manager_) { |
951 cursor_manager_->SetDisplay( | 948 cursor_manager_->SetDisplay( |
952 display::Screen::GetScreen()->GetPrimaryDisplay()); | 949 display::Screen::GetScreen()->GetPrimaryDisplay()); |
953 } | 950 } |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 | 1217 |
1221 ui::EventTargeter* Shell::GetEventTargeter() { | 1218 ui::EventTargeter* Shell::GetEventTargeter() { |
1222 NOTREACHED(); | 1219 NOTREACHED(); |
1223 return nullptr; | 1220 return nullptr; |
1224 } | 1221 } |
1225 | 1222 |
1226 void Shell::OnWindowActivated( | 1223 void Shell::OnWindowActivated( |
1227 aura::client::ActivationChangeObserver::ActivationReason reason, | 1224 aura::client::ActivationChangeObserver::ActivationReason reason, |
1228 aura::Window* gained_active, | 1225 aura::Window* gained_active, |
1229 aura::Window* lost_active) { | 1226 aura::Window* lost_active) { |
1230 WmWindow* gained_active_wm = WmWindow::Get(gained_active); | 1227 if (gained_active) |
1231 if (gained_active_wm) | 1228 root_window_for_new_windows_ = gained_active->GetRootWindow(); |
1232 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); | |
1233 } | 1229 } |
1234 | 1230 |
1235 void Shell::OnSessionStateChanged(session_manager::SessionState state) { | 1231 void Shell::OnSessionStateChanged(session_manager::SessionState state) { |
1236 // Create the shelf when a session becomes active. It's safe to do this | 1232 // Create the shelf when a session becomes active. It's safe to do this |
1237 // multiple times (e.g. initial login vs. multiprofile add session). | 1233 // multiple times (e.g. initial login vs. multiprofile add session). |
1238 if (state == session_manager::SessionState::ACTIVE) { | 1234 if (state == session_manager::SessionState::ACTIVE) { |
1239 CreateShelfView(); | 1235 CreateShelfView(); |
1240 | 1236 |
1241 if (GetAshConfig() != Config::MASH) { | 1237 if (GetAshConfig() != Config::MASH) { |
1242 // Recreate the keyboard after initial login and after multiprofile login. | 1238 // Recreate the keyboard after initial login and after multiprofile login. |
(...skipping 21 matching lines...) Expand all Loading... |
1264 void Shell::OnPrefServiceInitialized( | 1260 void Shell::OnPrefServiceInitialized( |
1265 std::unique_ptr<::PrefService> pref_service) { | 1261 std::unique_ptr<::PrefService> pref_service) { |
1266 if (!instance_) | 1262 if (!instance_) |
1267 return; | 1263 return; |
1268 // |pref_service_| is null if can't connect to Chrome (as happens when | 1264 // |pref_service_| is null if can't connect to Chrome (as happens when |
1269 // running mash outside of chrome --mash and chrome isn't built). | 1265 // running mash outside of chrome --mash and chrome isn't built). |
1270 pref_service_ = std::move(pref_service); | 1266 pref_service_ = std::move(pref_service); |
1271 } | 1267 } |
1272 | 1268 |
1273 } // namespace ash | 1269 } // namespace ash |
OLD | NEW |