| // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef ASH_ROOT_WINDOW_CONTROLLER_H_ |
| #define ASH_ROOT_WINDOW_CONTROLLER_H_ |
| |
| #include "ash/ash_export.h" |
| #include "ash/shelf/shelf_types.h" |
| #include "ash/system/user/login_status.h" |
| #include "base/basictypes.h" |
| #include "base/memory/scoped_ptr.h" |
| |
| class SkBitmap; |
| |
| namespace aura { |
| class EventFilter; |
| class RootWindow; |
| class Window; |
| } |
| |
| namespace gfx { |
| class Point; |
| } |
| |
| namespace views { |
| namespace corewm { |
| class InputMethodEventFilter; |
| class RootWindowEventFilter; |
| } |
| } |
| |
| namespace keyboard { |
| class KeyboardController; |
| } |
| |
| namespace ash { |
| class StackingController; |
| class ShelfWidget; |
| class SystemTray; |
| class ToplevelWindowEventHandler; |
| |
| namespace internal { |
| |
| class BootSplashScreen; |
| class PanelLayoutManager; |
| class RootWindowLayoutManager; |
| class ScreenDimmer; |
| class ShelfLayoutManager; |
| class StatusAreaWidget; |
| class SystemBackgroundController; |
| class SystemModalContainerLayoutManager; |
| class TouchObserverHUD; |
| class WorkspaceController; |
| |
| // This class maintains the per root window state for ash. This class |
| // owns the root window and other dependent objects that should be |
| // deleted upon the deletion of the root window. The RootWindowController |
| // for particular root window is stored as a property and can be obtained |
| // using |GetRootWindowController(aura::RootWindow*)| function. |
| class ASH_EXPORT RootWindowController { |
| public: |
| explicit RootWindowController(aura::RootWindow* root_window); |
| ~RootWindowController(); |
| |
| // Returns a RootWindowController that has a launcher for given |
| // |window|. This returns the RootWindowController for the |window|'s |
| // root window when multiple launcher mode is enabled, or the primary |
| // RootWindowController otherwise. |
| static RootWindowController* ForLauncher(aura::Window* window); |
| |
| // Returns a RootWindowController of the window's root window. |
| static RootWindowController* ForWindow(const aura::Window* window); |
| |
| // Returns the RootWindowController of the active root window. |
| static internal::RootWindowController* ForActiveRootWindow(); |
| |
| aura::RootWindow* root_window() { return root_window_.get(); } |
| |
| RootWindowLayoutManager* root_window_layout() { return root_window_layout_; } |
| |
| WorkspaceController* workspace_controller() { |
| return workspace_controller_.get(); |
| } |
| |
| ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); } |
| |
| // Access the shelf associated with this root window controller, |
| // NULL if no such shelf exists. |
| ShelfWidget* shelf() { return shelf_.get(); } |
| |
| TouchObserverHUD* touch_observer_hud() { return touch_observer_hud_; } |
| |
| // Sets the touch HUD. The RootWindowController will not own this HUD; its |
| // lifetime is managed by itself. |
| void set_touch_observer_hud(TouchObserverHUD* hud) { |
| touch_observer_hud_ = hud; |
| } |
| // Access the shelf layout manager associated with this root |
| // window controller, NULL if no such shelf exists. |
| ShelfLayoutManager* GetShelfLayoutManager(); |
| |
| // Returns the system tray on this root window. Note that |
| // calling this on the root window that doesn't have a launcher will |
| // lead to a crash. |
| SystemTray* GetSystemTray(); |
| |
| // Shows context menu at the |location_in_screen|. This uses |
| // |ShellDelegate::CreateContextMenu| to define the content of the menu. |
| void ShowContextMenu(const gfx::Point& location_in_screen); |
| |
| // Returns the layout-manager for the appropriate modal-container. If the |
| // window is inside the lockscreen modal container, then the layout manager |
| // for that is returned. Otherwise the layout manager for the default modal |
| // container is returned. |
| // If no window is specified (i.e. |window| is NULL), then the lockscreen |
| // modal container is used if the screen is currently locked. Otherwise, the |
| // default modal container is used. |
| SystemModalContainerLayoutManager* GetSystemModalLayoutManager( |
| aura::Window* window); |
| |
| aura::Window* GetContainer(int container_id); |
| |
| void InitLayoutManagers(); |
| void CreateContainers(); |
| |
| // Initializs the RootWindowController for primary display. This |
| // creates |
| void InitForPrimaryDisplay(); |
| |
| // Initializes |system_background_| and possibly also |boot_splash_screen_|. |
| // |is_first_run_after_boot| determines the background's initial color. |
| void CreateSystemBackground(bool is_first_run_after_boot); |
| |
| // Show launcher view if it was created hidden (before session has started). |
| void ShowLauncher(); |
| |
| // Called when the launcher associated with this root window is created. |
| void OnLauncherCreated(); |
| |
| // Called when the user logs in. |
| void OnLoginStateChanged(user::LoginStatus status); |
| |
| // Called when the login status changes after login (such as lock/unlock). |
| // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. |
| void UpdateAfterLoginStatusChange(user::LoginStatus status); |
| |
| // Called when the brightness/grayscale animation from white to the login |
| // desktop background image has started. Starts |boot_splash_screen_|'s |
| // hiding animation (if the screen is non-NULL). |
| void HandleInitialDesktopBackgroundAnimationStarted(); |
| |
| // Called when the login background is fully visible. Updates |background_| |
| // to be black and drops |boot_splash_screen_|. |
| void HandleDesktopBackgroundVisible(); |
| |
| // Deletes associated objects and clears the state, but doesn't delete |
| // the root window yet. This is used to delete a secondary displays' |
| // root window safely when the display disconnect signal is received, |
| // which may come while we're in the nested message loop. |
| void Shutdown(); |
| |
| // Deletes all child windows and performs necessary cleanup. |
| void CloseChildWindows(); |
| |
| // Moves child windows to |dest|. |
| void MoveWindowsTo(aura::RootWindow* dest); |
| |
| // Force the shelf to query for it's current visibility state. |
| void UpdateShelfVisibility(); |
| |
| // Returns the window, if any, which is in fullscreen mode in the active |
| // workspace. Exposed here so clients of Ash don't need to know the details |
| // of workspace management. |
| aura::Window* GetFullscreenWindow() const; |
| |
| private: |
| // Creates each of the special window containers that holds windows of various |
| // types in the shell UI. |
| void CreateContainersInRootWindow(aura::RootWindow* root_window); |
| |
| // Initializes the virtual keyboard. |
| void InitKeyboard(); |
| |
| scoped_ptr<aura::RootWindow> root_window_; |
| RootWindowLayoutManager* root_window_layout_; |
| |
| scoped_ptr<StackingController> stacking_controller_; |
| |
| scoped_ptr<keyboard::KeyboardController> keyboard_controller_; |
| |
| // The shelf for managing the launcher and the status widget. |
| scoped_ptr<ShelfWidget> shelf_; |
| |
| // Manages layout of panels. Owned by PanelContainer. |
| PanelLayoutManager* panel_layout_manager_; |
| |
| scoped_ptr<SystemBackgroundController> system_background_; |
| scoped_ptr<BootSplashScreen> boot_splash_screen_; |
| |
| scoped_ptr<ScreenDimmer> screen_dimmer_; |
| scoped_ptr<WorkspaceController> workspace_controller_; |
| |
| // Heads-up display for touch events. The RootWindowController does not own |
| // this HUD; its lifetime is managed by itself. |
| TouchObserverHUD* touch_observer_hud_; |
| |
| // We need to own event handlers for various containers. |
| scoped_ptr<ToplevelWindowEventHandler> default_container_handler_; |
| scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_; |
| scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_; |
| scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_; |
| scoped_ptr<ToplevelWindowEventHandler> panel_container_handler_; |
| |
| DISALLOW_COPY_AND_ASSIGN(RootWindowController); |
| }; |
| |
| } // namespace internal |
| } // ash |
| |
| #endif // ASH_ROOT_WINDOW_CONTROLLER_H_ |