blob: e264b3cef21920dff96237fab87dcf5a689e1e54 [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]c601e732012-10-11 15:39:3736class ColoredWindowController;
[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]697f04c2012-10-03 01:15:10103 // Initializes |background_|. |is_first_run_after_boot| determines the
104 // background's initial color.
105 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]697f04c2012-10-03 01:15:10120 // Updates |background_| to be black after the desktop background is visible.
121 void HandleDesktopBackgroundVisible();
[email protected]d90b8392012-06-13 09:34:56122
[email protected]6675e1c2012-09-11 09:15:45123 // Deletes associated objects and clears the state, but doesn't delete
124 // the root window yet. This is used to delete a secondary displays'
125 // root window safely when the display disconnect signal is received,
126 // which may come while we're in the nested message loop.
127 void Shutdown();
128
[email protected]d90b8392012-06-13 09:34:56129 // Deletes all child windows and performs necessary cleanup.
130 void CloseChildWindows();
131
[email protected]f1853122012-06-27 16:21:26132 // Moves child windows to |dest|.
133 void MoveWindowsTo(aura::RootWindow* dest);
134
[email protected]e74aaf0a2012-10-12 18:42:28135 // Force the shelf to query for it's current visibility state.
136 void UpdateShelfVisibility();
137
138 // Sets/gets the shelf auto-hide behavior.
139 void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior);
140 ShelfAutoHideBehavior GetShelfAutoHideBehavior() const;
141
142 // Sets/gets the shelf alignemnt.
143 bool SetShelfAlignment(ShelfAlignment alignment);
144 ShelfAlignment GetShelfAlignment();
145
[email protected]431552c2012-10-23 00:38:33146 // Get the shelf's auto hide status.
147 bool IsShelfAutoHideMenuHideChecked();
148 ShelfAutoHideBehavior GetToggledShelfAutoHideBehavior();
149
150 private:
[email protected]a4cd6d32012-09-12 03:42:13151 // Creates each of the special window containers that holds windows of various
152 // types in the shell UI.
153 void CreateContainersInRootWindow(aura::RootWindow* root_window);
154
[email protected]d90b8392012-06-13 09:34:56155 scoped_ptr<aura::RootWindow> root_window_;
[email protected]c0ce80e2012-10-05 23:28:27156 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56157
[email protected]e74aaf0a2012-10-12 18:42:28158 // Widget containing system tray.
[email protected]88d71122012-10-18 07:11:01159 StatusAreaWidget* status_area_widget_;
[email protected]e74aaf0a2012-10-12 18:42:28160
161 // The shelf for managing the launcher and the status widget.
162 // RootWindowController does not own the shelf. Instead, it is owned
163 // by container of the status area.
[email protected]88d71122012-10-18 07:11:01164 ShelfLayoutManager* shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28165
166 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01167 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28168
169 scoped_ptr<Launcher> launcher_;
170
[email protected]697f04c2012-10-03 01:15:10171 // A background layer that's displayed beneath all other layers. Without
172 // this, portions of the root window that aren't covered by layers will be
173 // painted white; this can show up if e.g. it takes a long time to decode the
174 // desktop background image when displaying the login screen.
[email protected]c601e732012-10-11 15:39:37175 scoped_ptr<ColoredWindowController> background_;
[email protected]697f04c2012-10-03 01:15:10176
[email protected]c0ce80e2012-10-05 23:28:27177 scoped_ptr<ScreenDimmer> screen_dimmer_;
178 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]d90b8392012-06-13 09:34:56179
[email protected]a4cd6d32012-09-12 03:42:13180 // We need to own event handlers for various containers.
181 scoped_ptr<ToplevelWindowEventHandler> default_container_handler_;
182 scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_;
183 scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_;
184 scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_;
185
[email protected]d90b8392012-06-13 09:34:56186 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
187};
188
189} // namespace internal
190} // ash
191
192#endif // ASH_ROOT_WINDOW_CONTROLLER_H_