blob: 50f4351c6d523dc48042117852e879cc5519af99 [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]e74aaf0a2012-10-12 18:42:2836class PanelLayoutManager;
[email protected]d90b8392012-06-13 09:34:5637class RootWindowLayoutManager;
38class ScreenDimmer;
[email protected]e74aaf0a2012-10-12 18:42:2839class ShelfLayoutManager;
40class StatusAreaWidget;
41class SystemBackgroundController;
[email protected]c0ce80e2012-10-05 23:28:2742class SystemModalContainerLayoutManager;
[email protected]d90b8392012-06-13 09:34:5643class WorkspaceController;
44
45// This class maintains the per root window state for ash. This class
46// owns the root window and other dependent objects that should be
47// deleted upon the deletion of the root window. The RootWindowController
48// for particular root window is stored as a property and can be obtained
49// using |GetRootWindowController(aura::RootWindow*)| function.
[email protected]c0ce80e2012-10-05 23:28:2750class ASH_EXPORT RootWindowController {
[email protected]d90b8392012-06-13 09:34:5651 public:
52 explicit RootWindowController(aura::RootWindow* root_window);
53 ~RootWindowController();
54
[email protected]88d71122012-10-18 07:11:0155 // Returns a RootWindowController that has a launcher for given
56 // |window|. This returns the RootWindowController for the |window|'s
57 // root window when multiple launcher mode is enabled, or the primary
58 // RootWindowController otherwise.
59 static RootWindowController* ForLauncher(aura::Window* window);
60
[email protected]e74aaf0a2012-10-12 18:42:2861 aura::RootWindow* root_window() { return root_window_.get(); }
[email protected]d90b8392012-06-13 09:34:5662
[email protected]e74aaf0a2012-10-12 18:42:2863 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:5664
[email protected]c0ce80e2012-10-05 23:28:2765 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:5666 return workspace_controller_.get();
67 }
68
[email protected]e74aaf0a2012-10-12 18:42:2869 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
70
71 Launcher* launcher() { return launcher_.get(); }
72
[email protected]88d71122012-10-18 07:11:0173 ShelfLayoutManager* shelf() const { return shelf_; }
[email protected]e74aaf0a2012-10-12 18:42:2874
[email protected]88d71122012-10-18 07:11:0175 StatusAreaWidget* status_area_widget() const {
[email protected]e74aaf0a2012-10-12 18:42:2876 return status_area_widget_;
[email protected]d90b8392012-06-13 09:34:5677 }
78
[email protected]431552c2012-10-23 00:38:3379 // Shows context menu at the |location_in_screen|. This uses
80 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
81 void ShowContextMenu(const gfx::Point& location_in_screen);
82
[email protected]8674b312012-10-12 19:02:4483 // Returns the layout-manager for the appropriate modal-container. If the
84 // window is inside the lockscreen modal container, then the layout manager
85 // for that is returned. Otherwise the layout manager for the default modal
86 // container is returned.
87 // If no window is specified (i.e. |window| is NULL), then the lockscreen
88 // modal container is used if the screen is currently locked. Otherwise, the
89 // default modal container is used.
90 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
91 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:2792
[email protected]d90b8392012-06-13 09:34:5693 aura::Window* GetContainer(int container_id);
94
[email protected]d90b8392012-06-13 09:34:5695 void InitLayoutManagers();
[email protected]697f04c2012-10-03 01:15:1096 void CreateContainers();
97
[email protected]e74aaf0a2012-10-12 18:42:2898 // Initializs the RootWindowController for primary display. This
99 // creates
100 void InitForPrimaryDisplay();
101
[email protected]e6e41d2f2012-10-29 19:22:19102 // Initializes |system_background_|. |is_first_run_after_boot| determines the
103 // background's initial content.
[email protected]697f04c2012-10-03 01:15:10104 void CreateSystemBackground(bool is_first_run_after_boot);
105
[email protected]e74aaf0a2012-10-12 18:42:28106 // Initializes |launcher_|. Does nothing if it's already initialized.
107 void CreateLauncher();
108
109 // Show launcher view if it was created hidden (before session has started).
110 void ShowLauncher();
111
[email protected]16059276d2012-10-22 18:59:50112 // Called when the user logs in.
113 void OnLoginStateChanged(user::LoginStatus status);
114
115 // Called when the login status changes after login (such as lock/unlock).
116 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
117 void UpdateAfterLoginStatusChange(user::LoginStatus status);
118
[email protected]697f04c2012-10-03 01:15:10119 // Updates |background_| to be black after the desktop background is visible.
120 void HandleDesktopBackgroundVisible();
[email protected]d90b8392012-06-13 09:34:56121
[email protected]6675e1c2012-09-11 09:15:45122 // Deletes associated objects and clears the state, but doesn't delete
123 // the root window yet. This is used to delete a secondary displays'
124 // root window safely when the display disconnect signal is received,
125 // which may come while we're in the nested message loop.
126 void Shutdown();
127
[email protected]d90b8392012-06-13 09:34:56128 // Deletes all child windows and performs necessary cleanup.
129 void CloseChildWindows();
130
[email protected]f1853122012-06-27 16:21:26131 // Moves child windows to |dest|.
132 void MoveWindowsTo(aura::RootWindow* dest);
133
[email protected]e74aaf0a2012-10-12 18:42:28134 // Force the shelf to query for it's current visibility state.
135 void UpdateShelfVisibility();
136
137 // Sets/gets the shelf auto-hide behavior.
138 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior);
139 ShelfAutoHideBehavior GetShelfAutoHideBehavior() const;
140
141 // Sets/gets the shelf alignemnt.
142 bool SetShelfAlignment(ShelfAlignment alignment);
143 ShelfAlignment GetShelfAlignment();
144
[email protected]431552c2012-10-23 00:38:33145 // Get the shelf's auto hide status.
146 bool IsShelfAutoHideMenuHideChecked();
147 ShelfAutoHideBehavior GetToggledShelfAutoHideBehavior();
148
149 private:
[email protected]a4cd6d32012-09-12 03:42:13150 // Creates each of the special window containers that holds windows of various
151 // types in the shell UI.
152 void CreateContainersInRootWindow(aura::RootWindow* root_window);
153
[email protected]d90b8392012-06-13 09:34:56154 scoped_ptr<aura::RootWindow> root_window_;
[email protected]c0ce80e2012-10-05 23:28:27155 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56156
[email protected]e74aaf0a2012-10-12 18:42:28157 // Widget containing system tray.
[email protected]88d71122012-10-18 07:11:01158 StatusAreaWidget* status_area_widget_;
[email protected]e74aaf0a2012-10-12 18:42:28159
160 // The shelf for managing the launcher and the status widget.
161 // RootWindowController does not own the shelf. Instead, it is owned
162 // by container of the status area.
[email protected]88d71122012-10-18 07:11:01163 ShelfLayoutManager* shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28164
165 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01166 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28167
168 scoped_ptr<Launcher> launcher_;
169
[email protected]e6e41d2f2012-10-29 19:22:19170 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]697f04c2012-10-03 01:15:10171
[email protected]c0ce80e2012-10-05 23:28:27172 scoped_ptr<ScreenDimmer> screen_dimmer_;
173 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]d90b8392012-06-13 09:34:56174
[email protected]a4cd6d32012-09-12 03:42:13175 // We need to own event handlers for various containers.
176 scoped_ptr<ToplevelWindowEventHandler> default_container_handler_;
177 scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_;
178 scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_;
179 scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_;
180
[email protected]d90b8392012-06-13 09:34:56181 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
182};
183
184} // namespace internal
185} // ash
186
187#endif // ASH_ROOT_WINDOW_CONTROLLER_H_