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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager.cc

Issue 169643005: Adding a gray semi transparent backdrop behind the topmost window within the default container (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests Created 6 years, 10 months 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
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/wm/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_util.h" 9 #include "ash/screen_util.h"
10 #include "ash/session_state_delegate.h" 10 #include "ash/session_state_delegate.h"
11 #include "ash/shelf/shelf_layout_manager.h" 11 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/wm/always_on_top_controller.h" 13 #include "ash/wm/always_on_top_controller.h"
14 #include "ash/wm/window_animations.h" 14 #include "ash/wm/window_animations.h"
15 #include "ash/wm/window_positioner.h" 15 #include "ash/wm/window_positioner.h"
16 #include "ash/wm/window_properties.h" 16 #include "ash/wm/window_properties.h"
17 #include "ash/wm/window_state.h" 17 #include "ash/wm/window_state.h"
18 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
19 #include "ash/wm/workspace/workspace_layout_manager_backdrop.h"
19 #include "ui/aura/client/activation_client.h" 20 #include "ui/aura/client/activation_client.h"
20 #include "ui/aura/client/aura_constants.h" 21 #include "ui/aura/client/aura_constants.h"
21 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
22 #include "ui/aura/window_observer.h" 23 #include "ui/aura/window_observer.h"
23 #include "ui/base/ui_base_types.h" 24 #include "ui/base/ui_base_types.h"
24 #include "ui/compositor/layer.h" 25 #include "ui/compositor/layer.h"
25 #include "ui/events/event.h" 26 #include "ui/events/event.h"
26 #include "ui/gfx/screen.h" 27 #include "ui/gfx/screen.h"
27 #include "ui/views/corewm/window_util.h" 28 #include "ui/views/corewm/window_util.h"
28 29
(...skipping 23 matching lines...) Expand all
52 for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i) 53 for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i)
53 (*i)->RemoveObserver(this); 54 (*i)->RemoveObserver(this);
54 Shell::GetInstance()->RemoveShellObserver(this); 55 Shell::GetInstance()->RemoveShellObserver(this);
55 Shell::GetInstance()->activation_client()->RemoveObserver(this); 56 Shell::GetInstance()->activation_client()->RemoveObserver(this);
56 } 57 }
57 58
58 void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) { 59 void WorkspaceLayoutManager::SetShelf(internal::ShelfLayoutManager* shelf) {
59 shelf_ = shelf; 60 shelf_ = shelf;
60 } 61 }
61 62
63 void WorkspaceLayoutManager::AddBackdropBehindTopWindow(bool enable) {
64 if ((NULL != backdrop_.get()) == enable)
sky 2014/03/06 01:03:18 nit: creating a local variable for NULL != backdro
Mr4D (OOO till 08-26) 2014/03/06 17:17:16 Done.
65 return;
66 if (enable)
67 backdrop_.reset(new WorkspaceLayoutManagerBackdrop(window_));
68 else
69 backdrop_.reset();
70 }
71
62 ////////////////////////////////////////////////////////////////////////////// 72 //////////////////////////////////////////////////////////////////////////////
63 // WorkspaceLayoutManager, aura::LayoutManager implementation: 73 // WorkspaceLayoutManager, aura::LayoutManager implementation:
64 74
65 void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) { 75 void WorkspaceLayoutManager::OnWindowAddedToLayout(Window* child) {
66 wm::WindowState* window_state = wm::GetWindowState(child); 76 wm::WindowState* window_state = wm::GetWindowState(child);
67 window_state->OnWMEvent(wm::ADDED_TO_WORKSPACE); 77 window_state->OnWMEvent(wm::ADDED_TO_WORKSPACE);
68 windows_.insert(child); 78 windows_.insert(child);
69 child->AddObserver(this); 79 child->AddObserver(this);
70 window_state->AddObserver(this); 80 window_state->AddObserver(this);
71 UpdateShelfVisibility(); 81 UpdateShelfVisibility();
72 UpdateFullscreenState(); 82 UpdateFullscreenState();
83 UpdateStackingAndVisibilityOfBackdrop();
sky 2014/03/06 01:03:18 How about a delegate method that is called at all
Mr4D (OOO till 08-26) 2014/03/06 17:17:16 Done.
73 WindowPositioner::RearrangeVisibleWindowOnShow(child); 84 WindowPositioner::RearrangeVisibleWindowOnShow(child);
74 } 85 }
75 86
76 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) { 87 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(Window* child) {
77 windows_.erase(child); 88 windows_.erase(child);
78 child->RemoveObserver(this); 89 child->RemoveObserver(this);
79 wm::GetWindowState(child)->RemoveObserver(this); 90 wm::GetWindowState(child)->RemoveObserver(this);
80 91
81 if (child->TargetVisibility()) 92 if (child->TargetVisibility())
82 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); 93 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child);
83 } 94 }
84 95
85 void WorkspaceLayoutManager::OnWindowRemovedFromLayout(Window* child) { 96 void WorkspaceLayoutManager::OnWindowRemovedFromLayout(Window* child) {
86 UpdateShelfVisibility(); 97 UpdateShelfVisibility();
87 UpdateFullscreenState(); 98 UpdateFullscreenState();
99 UpdateStackingAndVisibilityOfBackdrop();
88 } 100 }
89 101
90 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child, 102 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(Window* child,
91 bool visible) { 103 bool visible) {
92 wm::WindowState* window_state = wm::GetWindowState(child); 104 wm::WindowState* window_state = wm::GetWindowState(child);
93 // Attempting to show a minimized window. Unminimize it. 105 // Attempting to show a minimized window. Unminimize it.
94 if (visible && window_state->IsMinimized()) 106 if (visible && window_state->IsMinimized())
95 window_state->Unminimize(); 107 window_state->Unminimize();
96 108
97 if (child->TargetVisibility()) { 109 if (child->TargetVisibility()) {
98 WindowPositioner::RearrangeVisibleWindowOnShow(child); 110 WindowPositioner::RearrangeVisibleWindowOnShow(child);
99 } else { 111 } else {
100 if (wm::GetWindowState(child)->IsFullscreen()) 112 if (wm::GetWindowState(child)->IsFullscreen())
101 UpdateFullscreenState(); 113 UpdateFullscreenState();
102 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child); 114 WindowPositioner::RearrangeVisibleWindowOnHideOrRemove(child);
103 } 115 }
104 UpdateShelfVisibility(); 116 UpdateShelfVisibility();
117 UpdateStackingAndVisibilityOfBackdrop();
105 } 118 }
106 119
107 void WorkspaceLayoutManager::SetChildBounds( 120 void WorkspaceLayoutManager::SetChildBounds(
108 Window* child, 121 Window* child,
109 const gfx::Rect& requested_bounds) { 122 const gfx::Rect& requested_bounds) {
110 wm::WindowState* window_state = wm::GetWindowState(child); 123 wm::WindowState* window_state = wm::GetWindowState(child);
111 window_state->RequestBounds(requested_bounds); 124 window_state->RequestBounds(requested_bounds);
112 UpdateShelfVisibility(); 125 UpdateShelfVisibility();
113 } 126 }
114 127
(...skipping 17 matching lines...) Expand all
132 if (key == aura::client::kAlwaysOnTopKey && 145 if (key == aura::client::kAlwaysOnTopKey &&
133 window->GetProperty(aura::client::kAlwaysOnTopKey)) { 146 window->GetProperty(aura::client::kAlwaysOnTopKey)) {
134 GetRootWindowController(window->GetRootWindow())-> 147 GetRootWindowController(window->GetRootWindow())->
135 always_on_top_controller()->GetContainer(window)->AddChild(window); 148 always_on_top_controller()->GetContainer(window)->AddChild(window);
136 } 149 }
137 } 150 }
138 151
139 void WorkspaceLayoutManager::OnWindowStackingChanged(aura::Window* window) { 152 void WorkspaceLayoutManager::OnWindowStackingChanged(aura::Window* window) {
140 UpdateShelfVisibility(); 153 UpdateShelfVisibility();
141 UpdateFullscreenState(); 154 UpdateFullscreenState();
155 UpdateStackingAndVisibilityOfBackdrop();
142 } 156 }
143 157
144 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) { 158 void WorkspaceLayoutManager::OnWindowDestroying(aura::Window* window) {
145 if (root_window_ == window) { 159 if (root_window_ == window) {
146 root_window_->RemoveObserver(this); 160 root_window_->RemoveObserver(this);
147 root_window_ = NULL; 161 root_window_ = NULL;
148 } 162 }
149 } 163 }
150 164
151 void WorkspaceLayoutManager::OnWindowBoundsChanged(aura::Window* window, 165 void WorkspaceLayoutManager::OnWindowBoundsChanged(aura::Window* window,
(...skipping 22 matching lines...) Expand all
174 188
175 void WorkspaceLayoutManager::OnPostWindowShowTypeChange( 189 void WorkspaceLayoutManager::OnPostWindowShowTypeChange(
176 wm::WindowState* window_state, 190 wm::WindowState* window_state,
177 wm::WindowShowType old_type) { 191 wm::WindowShowType old_type) {
178 192
179 // Notify observers that fullscreen state may be changing. 193 // Notify observers that fullscreen state may be changing.
180 if (window_state->IsFullscreen() || old_type == wm::SHOW_TYPE_FULLSCREEN) 194 if (window_state->IsFullscreen() || old_type == wm::SHOW_TYPE_FULLSCREEN)
181 UpdateFullscreenState(); 195 UpdateFullscreenState();
182 196
183 UpdateShelfVisibility(); 197 UpdateShelfVisibility();
198 UpdateStackingAndVisibilityOfBackdrop();
184 } 199 }
185 200
186 ////////////////////////////////////////////////////////////////////////////// 201 //////////////////////////////////////////////////////////////////////////////
187 // WorkspaceLayoutManager, private: 202 // WorkspaceLayoutManager, private:
188 203
189 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( 204 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange(
190 wm::WMEvent event) { 205 wm::WMEvent event) {
191 DCHECK(event == wm::DISPLAY_BOUNDS_CHANGED || 206 DCHECK(event == wm::DISPLAY_BOUNDS_CHANGED ||
192 event == wm::WORKAREA_BOUNDS_CHANGED); 207 event == wm::WORKAREA_BOUNDS_CHANGED);
193 208
(...skipping 18 matching lines...) Expand all
212 ++it) { 227 ++it) {
213 wm::GetWindowState(*it)->OnWMEvent(event); 228 wm::GetWindowState(*it)->OnWMEvent(event);
214 } 229 }
215 } 230 }
216 231
217 void WorkspaceLayoutManager::UpdateShelfVisibility() { 232 void WorkspaceLayoutManager::UpdateShelfVisibility() {
218 if (shelf_) 233 if (shelf_)
219 shelf_->UpdateVisibilityState(); 234 shelf_->UpdateVisibilityState();
220 } 235 }
221 236
237 void WorkspaceLayoutManager::UpdateStackingAndVisibilityOfBackdrop() {
238 if (backdrop_)
239 backdrop_->RestackOrHideWindow();
240 }
241
222 void WorkspaceLayoutManager::UpdateFullscreenState() { 242 void WorkspaceLayoutManager::UpdateFullscreenState() {
223 bool is_fullscreen = GetRootWindowController( 243 bool is_fullscreen = GetRootWindowController(
224 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; 244 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL;
225 if (is_fullscreen != is_fullscreen_) { 245 if (is_fullscreen != is_fullscreen_) {
226 ash::Shell::GetInstance()->NotifyFullscreenStateChange( 246 ash::Shell::GetInstance()->NotifyFullscreenStateChange(
227 is_fullscreen, window_->GetRootWindow()); 247 is_fullscreen, window_->GetRootWindow());
228 is_fullscreen_ = is_fullscreen; 248 is_fullscreen_ = is_fullscreen;
229 } 249 }
230 } 250 }
231 251
232 } // namespace internal 252 } // namespace internal
233 } // namespace ash 253 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698