Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/common/container_priorities.h" | 9 #include "athena/common/container_priorities.h" |
| 10 #include "athena/screen/public/screen_manager.h" | 10 #include "athena/screen/public/screen_manager.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 | 186 |
| 187 // Re-stack all windows in the order defined by window_list_provider_. | 187 // Re-stack all windows in the order defined by window_list_provider_. |
| 188 aura::Window::Windows window_list = window_list_provider_->GetWindowList(); | 188 aura::Window::Windows window_list = window_list_provider_->GetWindowList(); |
| 189 aura::Window::Windows::iterator it; | 189 aura::Window::Windows::iterator it; |
| 190 for (it = window_list.begin(); it != window_list.end(); ++it) | 190 for (it = window_list.begin(); it != window_list.end(); ++it) |
| 191 container_->StackChildAtTop(*it); | 191 container_->StackChildAtTop(*it); |
| 192 overview_ = WindowOverviewMode::Create( | 192 overview_ = WindowOverviewMode::Create( |
| 193 container_.get(), window_list_provider_.get(), | 193 container_.get(), window_list_provider_.get(), |
| 194 split_view_controller_.get(), this); | 194 split_view_controller_.get(), this); |
| 195 } else { | 195 } else { |
| 196 overview_.reset(); | 196 // Deleting the WindowOverviewMode object may call back to SetInOverview(). |
| 197 // Clear |overview_| first, then delete the object. | |
| 198 WindowOverviewMode* to_delete = overview_.release(); | |
| 199 delete to_delete; | |
| 200 | |
| 197 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); | 201 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit()); |
| 198 } | 202 } |
| 199 } | 203 } |
| 200 | 204 |
| 201 void WindowManagerImpl::InstallAccelerators() { | 205 void WindowManagerImpl::InstallAccelerators() { |
| 202 const AcceleratorData accelerator_data[] = { | 206 const AcceleratorData accelerator_data[] = { |
| 203 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, | 207 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_NONE, CMD_TOGGLE_OVERVIEW, |
| 204 AF_NONE}, | 208 AF_NONE}, |
| 205 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, | 209 {TRIGGER_ON_PRESS, ui::VKEY_F6, ui::EF_CONTROL_DOWN, |
| 206 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, | 210 CMD_TOGGLE_SPLIT_VIEW, AF_NONE}, |
| 207 }; | 211 }; |
| 208 AcceleratorManager::Get()->RegisterAccelerators( | 212 AcceleratorManager::Get()->RegisterAccelerators( |
| 209 accelerator_data, arraysize(accelerator_data), this); | 213 accelerator_data, arraysize(accelerator_data), this); |
| 210 } | 214 } |
| 211 | 215 |
| 212 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { | 216 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { |
| 213 observers_.AddObserver(observer); | 217 observers_.AddObserver(observer); |
| 214 } | 218 } |
| 215 | 219 |
| 216 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { | 220 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { |
| 217 observers_.RemoveObserver(observer); | 221 observers_.RemoveObserver(observer); |
| 218 } | 222 } |
| 219 | 223 |
| 220 void WindowManagerImpl::ToggleSplitViewForTest() { | 224 void WindowManagerImpl::ToggleSplitViewForTest() { |
| 221 ToggleSplitview(); | 225 ToggleSplitview(); |
| 222 } | 226 } |
| 223 | 227 |
| 224 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 228 void WindowManagerImpl::OnSelectWindow(aura::Window* window, |
| 229 SplitType split_type) { | |
| 230 SetInOverview(false); | |
| 231 window->layer()->SetOpacity(1.0f); | |
| 232 window->Show(); | |
| 233 wm::ActivateWindow(window); | |
| 234 | |
| 235 if (split_type != SPLIT_NONE) { | |
| 236 FOR_EACH_OBSERVER(WindowManagerObserver, | |
| 237 observers_, | |
| 238 OnSplitViewModeEnter()); | |
| 239 if (split_type == SPLIT_LEFT) | |
| 240 split_view_controller_->ActivateSplitMode(window, NULL); | |
| 241 else | |
| 242 split_view_controller_->ActivateSplitMode(NULL, window); | |
| 243 return; | |
| 244 } | |
| 245 | |
| 225 if (split_view_controller_->IsSplitViewModeActive()) { | 246 if (split_view_controller_->IsSplitViewModeActive()) { |
| 226 split_view_controller_->DeactivateSplitMode(); | 247 split_view_controller_->DeactivateSplitMode(); |
|
pkotwicz
2014/09/05 22:02:07
This ends up hiding the windows in split view imme
| |
| 227 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); | 248 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
| 228 } | 249 } |
| 229 wm::ActivateWindow(window); | 250 |
| 230 SetInOverview(false); | |
| 231 // If |window| does not have the size of the work-area, then make sure it is | 251 // If |window| does not have the size of the work-area, then make sure it is |
| 232 // resized. | 252 // resized. |
| 233 const gfx::Size work_area = | 253 const gfx::Size work_area = |
| 234 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 254 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
| 235 if (window->GetTargetBounds().size() != work_area) { | 255 if (window->GetTargetBounds().size() != work_area) { |
| 236 const gfx::Rect& window_bounds = window->bounds(); | 256 const gfx::Rect& window_bounds = window->bounds(); |
| 237 const gfx::Rect desired_bounds(work_area); | 257 const gfx::Rect desired_bounds(work_area); |
| 238 gfx::Transform transform; | 258 gfx::Transform transform; |
| 239 transform.Translate(desired_bounds.x() - window_bounds.x(), | 259 transform.Translate(desired_bounds.x() - window_bounds.x(), |
| 240 desired_bounds.y() - window_bounds.y()); | 260 desired_bounds.y() - window_bounds.y()); |
| 241 transform.Scale(desired_bounds.width() / window_bounds.width(), | 261 transform.Scale(desired_bounds.width() / window_bounds.width(), |
| 242 desired_bounds.height() / window_bounds.height()); | 262 desired_bounds.height() / window_bounds.height()); |
| 243 window->layer()->GetAnimator()->AbortAllAnimations(); | |
| 244 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 263 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 245 settings.SetPreemptionStrategy( | 264 settings.SetPreemptionStrategy( |
| 246 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 265 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 247 settings.AddObserver( | 266 settings.AddObserver( |
| 248 new ui::ClosureAnimationObserver(base::Bind(&SetWindowState, | 267 new ui::ClosureAnimationObserver(base::Bind(&SetWindowState, |
| 249 base::Unretained(window), | 268 base::Unretained(window), |
| 250 desired_bounds, | 269 desired_bounds, |
| 251 gfx::Transform()))); | 270 gfx::Transform()))); |
| 252 window->SetTransform(transform); | 271 window->SetTransform(transform); |
| 253 } | 272 } |
| 254 } | 273 } |
| 255 | 274 |
| 256 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, | |
| 257 aura::Window* right) { | |
| 258 SetInOverview(false); | |
| 259 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter()); | |
| 260 split_view_controller_->ActivateSplitMode(left, right); | |
| 261 } | |
| 262 | |
| 263 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { | 275 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { |
| 264 // TODO(oshima): Creating a new window should updates the ovewview mode | 276 // TODO(oshima): Creating a new window should updates the ovewview mode |
| 265 // instead of exitting. | 277 // instead of exitting. |
| 266 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) | 278 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) |
| 267 SetInOverview(false); | 279 SetInOverview(false); |
| 268 } | 280 } |
| 269 | 281 |
| 270 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { | 282 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { |
| 271 if (window == container_) | 283 if (window == container_) |
| 272 container_.reset(); | 284 container_.reset(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 DCHECK(!instance); | 413 DCHECK(!instance); |
| 402 } | 414 } |
| 403 | 415 |
| 404 // static | 416 // static |
| 405 WindowManager* WindowManager::GetInstance() { | 417 WindowManager* WindowManager::GetInstance() { |
| 406 DCHECK(instance); | 418 DCHECK(instance); |
| 407 return instance; | 419 return instance; |
| 408 } | 420 } |
| 409 | 421 |
| 410 } // namespace athena | 422 } // namespace athena |
| OLD | NEW |