blob: 4d9cc8dd69903a030a099f6e2cea153532a7f250 [file] [log] [blame]
[email protected]d90b8392012-06-13 09:34:561// 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
3// found in the LICENSE file.
4
5#ifndef ASH_ROOT_WINDOW_CONTROLLER_H_
6#define ASH_ROOT_WINDOW_CONTROLLER_H_
[email protected]d90b8392012-06-13 09:34:567
[email protected]c0ce80e2012-10-05 23:28:278#include "ash/ash_export.h"
[email protected]16059276d2012-10-22 18:59:509#include "ash/system/user/login_status.h"
[email protected]e74aaf0a2012-10-12 18:42:2810#include "ash/wm/shelf_types.h"
[email protected]d90b8392012-06-13 09:34:5611#include "base/basictypes.h"
12#include "base/memory/scoped_ptr.h"
13
14class SkBitmap;
15
[email protected]431552c2012-10-23 00:38:3316namespace gfx {
17class Point;
18}
19
[email protected]d90b8392012-06-13 09:34:5620namespace aura {
21class EventFilter;
22class RootWindow;
23class Window;
24namespace shared {
25class InputMethodEventFilter;
26class RootWindowEventFilter;
27} // namespace shared
28} // namespace aura
29
30namespace ash {
[email protected]e74aaf0a2012-10-12 18:42:2831class Launcher;
[email protected]a4cd6d32012-09-12 03:42:1332class ToplevelWindowEventHandler;
[email protected]e74aaf0a2012-10-12 18:42:2833
[email protected]d90b8392012-06-13 09:34:5634namespace internal {
35
[email protected]bca9a7e2012-11-10 06:25:4936class BootSplashScreen;
[email protected]e74aaf0a2012-10-12 18:42:2837class PanelLayoutManager;
[email protected]d90b8392012-06-13 09:34:5638class RootWindowLayoutManager;
39class ScreenDimmer;
[email protected]e74aaf0a2012-10-12 18:42:2840class ShelfLayoutManager;
41class StatusAreaWidget;
42class SystemBackgroundController;
[email protected]c0ce80e2012-10-05 23:28:2743class SystemModalContainerLayoutManager;
[email protected]d90b8392012-06-13 09:34:5644class WorkspaceController;
45
46// This class maintains the per root window state for ash. This class
47// owns the root window and other dependent objects that should be
48// deleted upon the deletion of the root window. The RootWindowController
49// for particular root window is stored as a property and can be obtained
50// using |GetRootWindowController(aura::RootWindow*)| function.
[email protected]c0ce80e2012-10-05 23:28:2751class ASH_EXPORT RootWindowController {
[email protected]d90b8392012-06-13 09:34:5652 public:
53 explicit RootWindowController(aura::RootWindow* root_window);
54 ~RootWindowController();
55
[email protected]88d71122012-10-18 07:11:0156 // Returns a RootWindowController that has a launcher for given
57 // |window|. This returns the RootWindowController for the |window|'s
58 // root window when multiple launcher mode is enabled, or the primary
59 // RootWindowController otherwise.
60 static RootWindowController* ForLauncher(aura::Window* window);
61
[email protected]e74aaf0a2012-10-12 18:42:2862 aura::RootWindow* root_window() { return root_window_.get(); }
[email protected]d90b8392012-06-13 09:34:5663
[email protected]e74aaf0a2012-10-12 18:42:2864 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:5665
[email protected]c0ce80e2012-10-05 23:28:2766 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:5667 return workspace_controller_.get();
68 }
69
[email protected]e74aaf0a2012-10-12 18:42:2870 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
71
72 Launcher* launcher() { return launcher_.get(); }
73
[email protected]88d71122012-10-18 07:11:0174 ShelfLayoutManager* shelf() const { return shelf_; }
[email protected]e74aaf0a2012-10-12 18:42:2875
[email protected]88d71122012-10-18 07:11:0176 StatusAreaWidget* status_area_widget() const {
[email protected]e74aaf0a2012-10-12 18:42:2877 return status_area_widget_;
[email protected]d90b8392012-06-13 09:34:5678 }
79
[email protected]431552c2012-10-23 00:38:3380 // Shows context menu at the |location_in_screen|. This uses
81 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
82 void ShowContextMenu(const gfx::Point& location_in_screen);
83
[email protected]8674b312012-10-12 19:02:4484 // Returns the layout-manager for the appropriate modal-container. If the
85 // window is inside the lockscreen modal container, then the layout manager
86 // for that is returned. Otherwise the layout manager for the default modal
87 // container is returned.
88 // If no window is specified (i.e. |window| is NULL), then the lockscreen
89 // modal container is used if the screen is currently locked. Otherwise, the
90 // default modal container is used.
91 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
92 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:2793
[email protected]d90b8392012-06-13 09:34:5694 aura::Window* GetContainer(int container_id);
95
[email protected]d90b8392012-06-13 09:34:5696 void InitLayoutManagers();
[email protected]697f04c2012-10-03 01:15:1097 void CreateContainers();
98
[email protected]e74aaf0a2012-10-12 18:42:2899 // Initializs the RootWindowController for primary display. This
100 // creates
101 void InitForPrimaryDisplay();
102
[email protected]bca9a7e2012-11-10 06:25:49103 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
104 // |is_first_run_after_boot| determines the background's initial color.
[email protected]697f04c2012-10-03 01:15:10105 void CreateSystemBackground(bool is_first_run_after_boot);
106
[email protected]e74aaf0a2012-10-12 18:42:28107 // Initializes |launcher_|. Does nothing if it's already initialized.
108 void CreateLauncher();
109
110 // Show launcher view if it was created hidden (before session has started).
111 void ShowLauncher();
112
[email protected]16059276d2012-10-22 18:59:50113 // Called when the user logs in.
114 void OnLoginStateChanged(user::LoginStatus status);
115
116 // Called when the login status changes after login (such as lock/unlock).
117 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
118 void UpdateAfterLoginStatusChange(user::LoginStatus status);
119
[email protected]bca9a7e2012-11-10 06:25:49120 // Called when the brightness/grayscale animation from white to the login
121 // desktop background image has started. Starts |boot_splash_screen_|'s
122 // hiding animation (if the screen is non-NULL).
123 void HandleInitialDesktopBackgroundAnimationStarted();
124
125 // Called when the login background is fully visible. Updates |background_|
126 // to be black and drops |boot_splash_screen_|.
[email protected]697f04c2012-10-03 01:15:10127 void HandleDesktopBackgroundVisible();
[email protected]d90b8392012-06-13 09:34:56128
[email protected]6675e1c2012-09-11 09:15:45129 // Deletes associated objects and clears the state, but doesn't delete
130 // the root window yet. This is used to delete a secondary displays'
131 // root window safely when the display disconnect signal is received,
132 // which may come while we're in the nested message loop.
133 void Shutdown();
134
[email protected]d90b8392012-06-13 09:34:56135 // Deletes all child windows and performs necessary cleanup.
136 void CloseChildWindows();
137
[email protected]f1853122012-06-27 16:21:26138 // Moves child windows to |dest|.
139 void MoveWindowsTo(aura::RootWindow* dest);
140
[email protected]e74aaf0a2012-10-12 18:42:28141 // Force the shelf to query for it's current visibility state.
142 void UpdateShelfVisibility();
143
144 // Sets/gets the shelf auto-hide behavior.
145 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior);
146 ShelfAutoHideBehavior GetShelfAutoHideBehavior() const;
147
148 // Sets/gets the shelf alignemnt.
149 bool SetShelfAlignment(ShelfAlignment alignment);
150 ShelfAlignment GetShelfAlignment();
151
[email protected]431552c2012-10-23 00:38:33152 // Get the shelf's auto hide status.
153 bool IsShelfAutoHideMenuHideChecked();
154 ShelfAutoHideBehavior GetToggledShelfAutoHideBehavior();
155
156 private:
[email protected]a4cd6d32012-09-12 03:42:13157 // Creates each of the special window containers that holds windows of various
158 // types in the shell UI.
159 void CreateContainersInRootWindow(aura::RootWindow* root_window);
160
[email protected]d90b8392012-06-13 09:34:56161 scoped_ptr<aura::RootWindow> root_window_;
[email protected]c0ce80e2012-10-05 23:28:27162 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56163
[email protected]e74aaf0a2012-10-12 18:42:28164 // Widget containing system tray.
[email protected]88d71122012-10-18 07:11:01165 StatusAreaWidget* status_area_widget_;
[email protected]e74aaf0a2012-10-12 18:42:28166
167 // The shelf for managing the launcher and the status widget.
168 // RootWindowController does not own the shelf. Instead, it is owned
169 // by container of the status area.
[email protected]88d71122012-10-18 07:11:01170 ShelfLayoutManager* shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28171
172 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01173 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28174
175 scoped_ptr<Launcher> launcher_;
176
[email protected]e6e41d2f2012-10-29 19:22:19177 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]bca9a7e2012-11-10 06:25:49178 scoped_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]697f04c2012-10-03 01:15:10179
[email protected]c0ce80e2012-10-05 23:28:27180 scoped_ptr<ScreenDimmer> screen_dimmer_;
181 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]d90b8392012-06-13 09:34:56182
[email protected]a4cd6d32012-09-12 03:42:13183 // We need to own event handlers for various containers.
184 scoped_ptr<ToplevelWindowEventHandler> default_container_handler_;
185 scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_;
186 scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_;
187 scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_;
188
[email protected]d90b8392012-06-13 09:34:56189 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
190};
191
192} // namespace internal
193} // ash
194
195#endif // ASH_ROOT_WINDOW_CONTROLLER_H_