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

Side by Side Diff: athena/wm/window_manager_impl.cc

Issue 546123002: Ensure that an activity is activated when overview mode is exited (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « athena/wm/window_manager_impl.h ('k') | athena/wm/window_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/wm/window_manager_impl.h" 5 #include "athena/wm/window_manager_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "athena/screen/public/screen_manager.h" 9 #include "athena/screen/public/screen_manager.h"
10 #include "athena/util/container_priorities.h" 10 #include "athena/util/container_priorities.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } else { 94 } else {
95 window->SetBounds(gfx::Rect(work_area)); 95 window->SetBounds(gfx::Rect(work_area));
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 void AthenaContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) { 100 void AthenaContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
101 aura::Window::Windows list = instance->window_list_provider_->GetWindowList(); 101 aura::Window::Windows list = instance->window_list_provider_->GetWindowList();
102 if (std::find(list.begin(), list.end(), child) == list.end()) 102 if (std::find(list.begin(), list.end(), child) == list.end())
103 return; 103 return;
104 if (instance->split_view_controller_->IsSplitViewModeActive()) { 104
105 if (instance->split_view_controller_->IsSplitViewModeActive() &&
106 !instance->IsOverviewModeActive()) {
105 instance->split_view_controller_->ReplaceWindow( 107 instance->split_view_controller_->ReplaceWindow(
106 instance->split_view_controller_->left_window(), child); 108 instance->split_view_controller_->left_window(), child);
107 } else { 109 } else {
108 gfx::Size size = 110 gfx::Size size =
109 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); 111 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
110 child->SetBounds(gfx::Rect(size)); 112 child->SetBounds(gfx::Rect(size));
111 } 113 }
114
115 if (instance->IsOverviewModeActive()) {
116 // TODO(pkotwicz|oshima). Creating a new window should only exit overview
117 // mode if the new window is activated. crbug.com/415266
118 instance->OnSelectWindow(child);
119 }
112 } 120 }
113 121
114 void AthenaContainerLayoutManager::OnWillRemoveWindowFromLayout( 122 void AthenaContainerLayoutManager::OnWillRemoveWindowFromLayout(
115 aura::Window* child) { 123 aura::Window* child) {
116 } 124 }
117 125
118 void AthenaContainerLayoutManager::OnWindowRemovedFromLayout( 126 void AthenaContainerLayoutManager::OnWindowRemovedFromLayout(
119 aura::Window* child) { 127 aura::Window* child) {
120 } 128 }
121 129
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 container_->RemoveObserver(this); 168 container_->RemoveObserver(this);
161 container_->RemovePreTargetHandler(bezel_controller_.get()); 169 container_->RemovePreTargetHandler(bezel_controller_.get());
162 } 170 }
163 // |title_drag_controller_| needs to be reset before |container_|. 171 // |title_drag_controller_| needs to be reset before |container_|.
164 title_drag_controller_.reset(); 172 title_drag_controller_.reset();
165 container_.reset(); 173 container_.reset();
166 instance = NULL; 174 instance = NULL;
167 } 175 }
168 176
169 void WindowManagerImpl::ToggleOverview() { 177 void WindowManagerImpl::ToggleOverview() {
170 SetInOverview(overview_.get() == NULL); 178 if (IsOverviewModeActive()) {
179 SetInOverview(false);
180
181 // Activate the window which was active prior to entering overview.
182 const aura::Window::Windows windows =
183 window_list_provider_->GetWindowList();
184 if (!windows.empty()) {
185 aura::Window* window = windows.back();
186 // Show the window in case the exit overview animation has finished and
187 // |window| was hidden.
188 window->Show();
189
190 wm::ActivateWindow(window);
191 }
192 } else {
193 SetInOverview(true);
194 }
171 } 195 }
172 196
173 bool WindowManagerImpl::IsOverviewModeActive() { 197 bool WindowManagerImpl::IsOverviewModeActive() {
174 return overview_; 198 return overview_;
175 } 199 }
176 200
177 void WindowManagerImpl::SetInOverview(bool active) { 201 void WindowManagerImpl::SetInOverview(bool active) {
178 bool in_overview = !!overview_; 202 bool in_overview = !!overview_;
179 if (active == in_overview) 203 if (active == in_overview)
180 return; 204 return;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 240
217 void WindowManagerImpl::ToggleSplitViewForTest() { 241 void WindowManagerImpl::ToggleSplitViewForTest() {
218 ToggleSplitview(); 242 ToggleSplitview();
219 } 243 }
220 244
221 WindowListProvider* WindowManagerImpl::GetWindowListProvider() { 245 WindowListProvider* WindowManagerImpl::GetWindowListProvider() {
222 return window_list_provider_.get(); 246 return window_list_provider_.get();
223 } 247 }
224 248
225 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { 249 void WindowManagerImpl::OnSelectWindow(aura::Window* window) {
250 SetInOverview(false);
251
252 // Show the window in case the exit overview animation has finished and
253 // |window| was hidden.
254 window->Show();
255
256 wm::ActivateWindow(window);
257
226 if (split_view_controller_->IsSplitViewModeActive()) { 258 if (split_view_controller_->IsSplitViewModeActive()) {
227 split_view_controller_->DeactivateSplitMode(); 259 split_view_controller_->DeactivateSplitMode();
228 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); 260 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit());
229 } 261 }
230 wm::ActivateWindow(window);
231 SetInOverview(false);
232 // If |window| does not have the size of the work-area, then make sure it is 262 // If |window| does not have the size of the work-area, then make sure it is
233 // resized. 263 // resized.
234 const gfx::Size work_area = 264 const gfx::Size work_area =
235 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); 265 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
236 if (window->GetTargetBounds().size() != work_area) { 266 if (window->GetTargetBounds().size() != work_area) {
237 const gfx::Rect& window_bounds = window->bounds(); 267 const gfx::Rect& window_bounds = window->bounds();
238 const gfx::Rect desired_bounds(work_area); 268 const gfx::Rect desired_bounds(work_area);
239 gfx::Transform transform; 269 gfx::Transform transform;
240 transform.Translate(desired_bounds.x() - window_bounds.x(), 270 transform.Translate(desired_bounds.x() - window_bounds.x(),
241 desired_bounds.y() - window_bounds.y()); 271 desired_bounds.y() - window_bounds.y());
242 transform.Scale(desired_bounds.width() / window_bounds.width(), 272 transform.Scale(desired_bounds.width() / window_bounds.width(),
243 desired_bounds.height() / window_bounds.height()); 273 desired_bounds.height() / window_bounds.height());
244 window->layer()->GetAnimator()->AbortAllAnimations();
245 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 274 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
246 settings.SetPreemptionStrategy( 275 settings.SetPreemptionStrategy(
247 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 276 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
248 settings.AddObserver( 277 settings.AddObserver(
249 new ui::ClosureAnimationObserver(base::Bind(&SetWindowState, 278 new ui::ClosureAnimationObserver(base::Bind(&SetWindowState,
250 base::Unretained(window), 279 base::Unretained(window),
251 desired_bounds, 280 desired_bounds,
252 gfx::Transform()))); 281 gfx::Transform())));
253 window->SetTransform(transform); 282 window->SetTransform(transform);
254 } 283 }
255 } 284 }
256 285
257 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, 286 void WindowManagerImpl::OnSelectSplitViewWindow(aura::Window* left,
258 aura::Window* right) { 287 aura::Window* right,
288 aura::Window* to_activate) {
259 SetInOverview(false); 289 SetInOverview(false);
260 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter()); 290 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter());
261 split_view_controller_->ActivateSplitMode(left, right); 291 split_view_controller_->ActivateSplitMode(left, right);
262 } 292 wm::ActivateWindow(to_activate);
263
264 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) {
265 // TODO(oshima): Creating a new window should updates the ovewview mode
266 // instead of exitting.
267 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL)
268 SetInOverview(false);
269 } 293 }
270 294
271 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { 295 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) {
272 if (window == container_) 296 if (window == container_)
273 container_.reset(); 297 container_.reset();
274 } 298 }
275 299
276 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { 300 bool WindowManagerImpl::IsCommandEnabled(int command_id) const {
277 return true; 301 return true;
278 } 302 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 DCHECK(!instance); 426 DCHECK(!instance);
403 } 427 }
404 428
405 // static 429 // static
406 WindowManager* WindowManager::GetInstance() { 430 WindowManager* WindowManager::GetInstance() {
407 DCHECK(instance); 431 DCHECK(instance);
408 return instance; 432 return instance;
409 } 433 }
410 434
411 } // namespace athena 435 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/window_manager_impl.h ('k') | athena/wm/window_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698