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

Side by Side Diff: ash/shell.cc

Issue 37733003: Make GetRootWindow() return a Window instead of a RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ash/shell.h ('k') | ash/shell/content_client/shell_browser_main_parts.cc » ('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 (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 9
10 #include "ash/accelerators/accelerator_controller.h" 10 #include "ash/accelerators/accelerator_controller.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return internal::GetRootWindowController(GetPrimaryRootWindow()); 195 return internal::GetRootWindowController(GetPrimaryRootWindow());
196 } 196 }
197 197
198 // static 198 // static
199 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { 199 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() {
200 return Shell::GetInstance()->display_controller()-> 200 return Shell::GetInstance()->display_controller()->
201 GetAllRootWindowControllers(); 201 GetAllRootWindowControllers();
202 } 202 }
203 203
204 // static 204 // static
205 aura::RootWindow* Shell::GetPrimaryRootWindow() { 205 aura::Window* Shell::GetPrimaryRootWindow() {
206 return GetInstance()->display_controller()->GetPrimaryRootWindow(); 206 return GetInstance()->display_controller()->GetPrimaryRootWindow();
207 } 207 }
208 208
209 // static 209 // static
210 aura::RootWindow* Shell::GetTargetRootWindow() { 210 aura::Window* Shell::GetTargetRootWindow() {
211 Shell* shell = GetInstance(); 211 Shell* shell = GetInstance();
212 if (shell->scoped_target_root_window_) 212 if (shell->scoped_target_root_window_)
213 return shell->scoped_target_root_window_; 213 return shell->scoped_target_root_window_;
214 return shell->target_root_window_; 214 return shell->target_root_window_;
215 } 215 }
216 216
217 // static 217 // static
218 gfx::Screen* Shell::GetScreen() { 218 gfx::Screen* Shell::GetScreen() {
219 return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); 219 return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
220 } 220 }
221 221
222 // static 222 // static
223 Shell::RootWindowList Shell::GetAllRootWindows() { 223 Shell::RootWindowList Shell::GetAllRootWindows() {
224 return Shell::GetInstance()->display_controller()-> 224 return Shell::GetInstance()->display_controller()->
225 GetAllRootWindows(); 225 GetAllRootWindows();
226 } 226 }
227 227
228 // static 228 // static
229 aura::Window* Shell::GetContainer(aura::RootWindow* root_window, 229 aura::Window* Shell::GetContainer(aura::Window* root_window,
230 int container_id) { 230 int container_id) {
231 return root_window->GetChildById(container_id); 231 return root_window->GetChildById(container_id);
232 } 232 }
233 233
234 // static 234 // static
235 const aura::Window* Shell::GetContainer(const aura::RootWindow* root_window, 235 const aura::Window* Shell::GetContainer(const aura::Window* root_window,
236 int container_id) { 236 int container_id) {
237 return root_window->GetChildById(container_id); 237 return root_window->GetChildById(container_id);
238 } 238 }
239 239
240 // static 240 // static
241 std::vector<aura::Window*> Shell::GetContainersFromAllRootWindows( 241 std::vector<aura::Window*> Shell::GetContainersFromAllRootWindows(
242 int container_id, 242 int container_id,
243 aura::RootWindow* priority_root) { 243 aura::Window* priority_root) {
244 std::vector<aura::Window*> containers; 244 std::vector<aura::Window*> containers;
245 RootWindowList root_windows = GetAllRootWindows(); 245 RootWindowList root_windows = GetAllRootWindows();
246 for (RootWindowList::const_iterator it = root_windows.begin(); 246 for (RootWindowList::const_iterator it = root_windows.begin();
247 it != root_windows.end(); ++it) { 247 it != root_windows.end(); ++it) {
248 aura::Window* container = (*it)->GetChildById(container_id); 248 aura::Window* container = (*it)->GetChildById(container_id);
249 if (container) { 249 if (container) {
250 if (priority_root && priority_root->Contains(container)) 250 if (priority_root && priority_root->Contains(container))
251 containers.insert(containers.begin(), container); 251 containers.insert(containers.begin(), container);
252 else 252 else
253 containers.push_back(container); 253 containers.push_back(container);
254 } 254 }
255 } 255 }
256 return containers; 256 return containers;
257 } 257 }
258 258
259 void Shell::ShowContextMenu(const gfx::Point& location_in_screen, 259 void Shell::ShowContextMenu(const gfx::Point& location_in_screen,
260 ui::MenuSourceType source_type) { 260 ui::MenuSourceType source_type) {
261 // No context menus if there is no session with an active user. 261 // No context menus if there is no session with an active user.
262 if (!session_state_delegate_->NumberOfLoggedInUsers()) 262 if (!session_state_delegate_->NumberOfLoggedInUsers())
263 return; 263 return;
264 // No context menus when screen is locked. 264 // No context menus when screen is locked.
265 if (session_state_delegate_->IsScreenLocked()) 265 if (session_state_delegate_->IsScreenLocked())
266 return; 266 return;
267 267
268 aura::RootWindow* root = 268 aura::Window* root =
269 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); 269 wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size()));
270 internal::GetRootWindowController(root)-> 270 internal::GetRootWindowController(root)->
271 ShowContextMenu(location_in_screen, source_type); 271 ShowContextMenu(location_in_screen, source_type);
272 } 272 }
273 273
274 void Shell::ToggleAppList(aura::Window* window) { 274 void Shell::ToggleAppList(aura::Window* window) {
275 // If the context window is not given, show it on the target root window. 275 // If the context window is not given, show it on the target root window.
276 if (!window) 276 if (!window)
277 window = GetTargetRootWindow(); 277 window = GetTargetRootWindow();
278 if (!app_list_controller_) 278 if (!app_list_controller_)
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 395
396 void Shell::UpdateShelfVisibility() { 396 void Shell::UpdateShelfVisibility() {
397 RootWindowControllerList controllers = GetAllRootWindowControllers(); 397 RootWindowControllerList controllers = GetAllRootWindowControllers();
398 for (RootWindowControllerList::iterator iter = controllers.begin(); 398 for (RootWindowControllerList::iterator iter = controllers.begin();
399 iter != controllers.end(); ++iter) 399 iter != controllers.end(); ++iter)
400 if ((*iter)->shelf()) 400 if ((*iter)->shelf())
401 (*iter)->UpdateShelfVisibility(); 401 (*iter)->UpdateShelfVisibility();
402 } 402 }
403 403
404 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, 404 void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior,
405 aura::RootWindow* root_window) { 405 aura::Window* root_window) {
406 ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> 406 ash::internal::ShelfLayoutManager::ForLauncher(root_window)->
407 SetAutoHideBehavior(behavior); 407 SetAutoHideBehavior(behavior);
408 } 408 }
409 409
410 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior( 410 ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior(
411 aura::RootWindow* root_window) const { 411 aura::Window* root_window) const {
412 return ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> 412 return ash::internal::ShelfLayoutManager::ForLauncher(root_window)->
413 auto_hide_behavior(); 413 auto_hide_behavior();
414 } 414 }
415 415
416 void Shell::SetShelfAlignment(ShelfAlignment alignment, 416 void Shell::SetShelfAlignment(ShelfAlignment alignment,
417 aura::RootWindow* root_window) { 417 aura::Window* root_window) {
418 if (ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> 418 if (ash::internal::ShelfLayoutManager::ForLauncher(root_window)->
419 SetAlignment(alignment)) { 419 SetAlignment(alignment)) {
420 FOR_EACH_OBSERVER( 420 FOR_EACH_OBSERVER(
421 ShellObserver, observers_, OnShelfAlignmentChanged(root_window)); 421 ShellObserver, observers_, OnShelfAlignmentChanged(root_window));
422 } 422 }
423 } 423 }
424 424
425 ShelfAlignment Shell::GetShelfAlignment(aura::RootWindow* root_window) { 425 ShelfAlignment Shell::GetShelfAlignment(aura::Window* root_window) {
426 return internal::GetRootWindowController(root_window)-> 426 return internal::GetRootWindowController(root_window)->
427 GetShelfLayoutManager()->GetAlignment(); 427 GetShelfLayoutManager()->GetAlignment();
428 } 428 }
429 429
430 void Shell::SetDimming(bool should_dim) { 430 void Shell::SetDimming(bool should_dim) {
431 RootWindowControllerList controllers = GetAllRootWindowControllers(); 431 RootWindowControllerList controllers = GetAllRootWindowControllers();
432 for (RootWindowControllerList::iterator iter = controllers.begin(); 432 for (RootWindowControllerList::iterator iter = controllers.begin();
433 iter != controllers.end(); ++iter) 433 iter != controllers.end(); ++iter)
434 (*iter)->screen_dimmer()->SetDimming(should_dim); 434 (*iter)->screen_dimmer()->SetDimming(should_dim);
435 } 435 }
436 436
437 void Shell::NotifyFullscreenStateChange(bool is_fullscreen, 437 void Shell::NotifyFullscreenStateChange(bool is_fullscreen,
438 aura::RootWindow* root_window) { 438 aura::Window* root_window) {
439 FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged( 439 FOR_EACH_OBSERVER(ShellObserver, observers_, OnFullscreenStateChanged(
440 is_fullscreen, root_window)); 440 is_fullscreen, root_window));
441 } 441 }
442 442
443 void Shell::CreateModalBackground(aura::Window* window) { 443 void Shell::CreateModalBackground(aura::Window* window) {
444 if (!modality_filter_) { 444 if (!modality_filter_) {
445 modality_filter_.reset(new internal::SystemModalContainerEventFilter(this)); 445 modality_filter_.reset(new internal::SystemModalContainerEventFilter(this));
446 AddPreTargetHandler(modality_filter_.get()); 446 AddPreTargetHandler(modality_filter_.get());
447 } 447 }
448 RootWindowControllerList controllers = GetAllRootWindowControllers(); 448 RootWindowControllerList controllers = GetAllRootWindowControllers();
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 focus_client_.reset(focus_controller); 738 focus_client_.reset(focus_controller);
739 activation_client_ = focus_controller; 739 activation_client_ = focus_controller;
740 activation_client_->AddObserver(this); 740 activation_client_->AddObserver(this);
741 focus_cycler_.reset(new internal::FocusCycler()); 741 focus_cycler_.reset(new internal::FocusCycler());
742 742
743 screen_position_controller_.reset(new internal::ScreenPositionController); 743 screen_position_controller_.reset(new internal::ScreenPositionController);
744 root_window_host_factory_.reset(delegate_->CreateRootWindowHostFactory()); 744 root_window_host_factory_.reset(delegate_->CreateRootWindowHostFactory());
745 745
746 display_controller_->Start(); 746 display_controller_->Start();
747 display_controller_->InitPrimaryDisplay(); 747 display_controller_->InitPrimaryDisplay();
748 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); 748 aura::Window* root_window = display_controller_->GetPrimaryRootWindow();
749 target_root_window_ = root_window; 749 target_root_window_ = root_window;
750 750
751 resolution_notification_controller_.reset( 751 resolution_notification_controller_.reset(
752 new internal::ResolutionNotificationController); 752 new internal::ResolutionNotificationController);
753 753
754 cursor_manager_.SetDisplay(DisplayController::GetPrimaryDisplay()); 754 cursor_manager_.SetDisplay(DisplayController::GetPrimaryDisplay());
755 755
756 nested_dispatcher_controller_.reset(new NestedDispatcherController); 756 nested_dispatcher_controller_.reset(new NestedDispatcherController);
757 accelerator_controller_.reset(new AcceleratorController); 757 accelerator_controller_.reset(new AcceleratorController);
758 758
759 // The order in which event filters are added is significant. 759 // The order in which event filters are added is significant.
760 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); 760 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter);
761 AddPreTargetHandler(event_rewriter_filter_.get()); 761 AddPreTargetHandler(event_rewriter_filter_.get());
762 762
763 // UserActivityDetector passes events to observers, so let them get 763 // UserActivityDetector passes events to observers, so let them get
764 // rewritten first. 764 // rewritten first.
765 user_activity_detector_.reset(new UserActivityDetector); 765 user_activity_detector_.reset(new UserActivityDetector);
766 AddPreTargetHandler(user_activity_detector_.get()); 766 AddPreTargetHandler(user_activity_detector_.get());
767 767
768 overlay_filter_.reset(new internal::OverlayEventFilter); 768 overlay_filter_.reset(new internal::OverlayEventFilter);
769 AddPreTargetHandler(overlay_filter_.get()); 769 AddPreTargetHandler(overlay_filter_.get());
770 AddShellObserver(overlay_filter_.get()); 770 AddShellObserver(overlay_filter_.get());
771 771
772 input_method_filter_.reset(new views::corewm::InputMethodEventFilter( 772 input_method_filter_.reset(new views::corewm::InputMethodEventFilter(
773 root_window->GetAcceleratedWidget())); 773 root_window->GetDispatcher()->GetAcceleratedWidget()));
774 AddPreTargetHandler(input_method_filter_.get()); 774 AddPreTargetHandler(input_method_filter_.get());
775 775
776 accelerator_filter_.reset(new internal::AcceleratorFilter); 776 accelerator_filter_.reset(new internal::AcceleratorFilter);
777 AddPreTargetHandler(accelerator_filter_.get()); 777 AddPreTargetHandler(accelerator_filter_.get());
778 778
779 event_transformation_handler_.reset(new internal::EventTransformationHandler); 779 event_transformation_handler_.reset(new internal::EventTransformationHandler);
780 AddPreTargetHandler(event_transformation_handler_.get()); 780 AddPreTargetHandler(event_transformation_handler_.get());
781 781
782 system_gesture_filter_.reset(new internal::SystemGestureEventFilter); 782 system_gesture_filter_.reset(new internal::SystemGestureEventFilter);
783 AddPreTargetHandler(system_gesture_filter_.get()); 783 AddPreTargetHandler(system_gesture_filter_.get());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 853
854 locale_notification_controller_.reset( 854 locale_notification_controller_.reset(
855 new internal::LocaleNotificationController); 855 new internal::LocaleNotificationController);
856 856
857 // Initialize system_tray_delegate_ after StatusAreaWidget is created. 857 // Initialize system_tray_delegate_ after StatusAreaWidget is created.
858 system_tray_delegate_->Initialize(); 858 system_tray_delegate_->Initialize();
859 859
860 // TODO(oshima): Initialize all RootWindowControllers once, and 860 // TODO(oshima): Initialize all RootWindowControllers once, and
861 // initialize controller/delegates above when initializing the 861 // initialize controller/delegates above when initializing the
862 // primary root window controller. 862 // primary root window controller.
863 internal::RootWindowController::CreateForPrimaryDisplay(root_window); 863 internal::RootWindowController::CreateForPrimaryDisplay(
864 root_window->GetDispatcher());
864 865
865 display_controller_->InitSecondaryDisplays(); 866 display_controller_->InitSecondaryDisplays();
866 867
867 // It needs to be created after RootWindowController has been created 868 // It needs to be created after RootWindowController has been created
868 // (which calls OnWindowResized has been called, otherwise the 869 // (which calls OnWindowResized has been called, otherwise the
869 // widget will not paint when restoring after a browser crash. Also it needs 870 // widget will not paint when restoring after a browser crash. Also it needs
870 // to be created after InitSecondaryDisplays() to initialize the wallpapers in 871 // to be created after InitSecondaryDisplays() to initialize the wallpapers in
871 // the correct size. 872 // the correct size.
872 user_wallpaper_delegate_->InitializeWallpaper(); 873 user_wallpaper_delegate_->InitializeWallpaper();
873 874
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 //////////////////////////////////////////////////////////////////////////////// 977 ////////////////////////////////////////////////////////////////////////////////
977 // Shell, aura::client::ActivationChangeObserver implementation: 978 // Shell, aura::client::ActivationChangeObserver implementation:
978 979
979 void Shell::OnWindowActivated(aura::Window* gained_active, 980 void Shell::OnWindowActivated(aura::Window* gained_active,
980 aura::Window* lost_active) { 981 aura::Window* lost_active) {
981 if (gained_active) 982 if (gained_active)
982 target_root_window_ = gained_active->GetRootWindow(); 983 target_root_window_ = gained_active->GetRootWindow();
983 } 984 }
984 985
985 } // namespace ash 986 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.h ('k') | ash/shell/content_client/shell_browser_main_parts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698