| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { | 212 void WindowManagerImpl::AddObserver(WindowManagerObserver* observer) { |
| 213 observers_.AddObserver(observer); | 213 observers_.AddObserver(observer); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { | 216 void WindowManagerImpl::RemoveObserver(WindowManagerObserver* observer) { |
| 217 observers_.RemoveObserver(observer); | 217 observers_.RemoveObserver(observer); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void WindowManagerImpl::ToggleSplitViewForTest() { |
| 221 ToggleSplitview(); |
| 222 } |
| 223 |
| 220 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { | 224 void WindowManagerImpl::OnSelectWindow(aura::Window* window) { |
| 221 if (split_view_controller_->IsSplitViewModeActive()) | 225 if (split_view_controller_->IsSplitViewModeActive()) { |
| 222 split_view_controller_->DeactivateSplitMode(); | 226 split_view_controller_->DeactivateSplitMode(); |
| 227 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
| 228 } |
| 223 wm::ActivateWindow(window); | 229 wm::ActivateWindow(window); |
| 224 SetInOverview(false); | 230 SetInOverview(false); |
| 225 // If |window| does not have the size of the work-area, then make sure it is | 231 // If |window| does not have the size of the work-area, then make sure it is |
| 226 // resized. | 232 // resized. |
| 227 const gfx::Size work_area = | 233 const gfx::Size work_area = |
| 228 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); | 234 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size(); |
| 229 if (window->GetTargetBounds().size() != work_area) { | 235 if (window->GetTargetBounds().size() != work_area) { |
| 230 const gfx::Rect& window_bounds = window->bounds(); | 236 const gfx::Rect& window_bounds = window->bounds(); |
| 231 const gfx::Rect desired_bounds(work_area); | 237 const gfx::Rect desired_bounds(work_area); |
| 232 gfx::Transform transform; | 238 gfx::Transform transform; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 243 base::Unretained(window), | 249 base::Unretained(window), |
| 244 desired_bounds, | 250 desired_bounds, |
| 245 gfx::Transform()))); | 251 gfx::Transform()))); |
| 246 window->SetTransform(transform); | 252 window->SetTransform(transform); |
| 247 } | 253 } |
| 248 } | 254 } |
| 249 | 255 |
| 250 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, | 256 void WindowManagerImpl::OnSplitViewMode(aura::Window* left, |
| 251 aura::Window* right) { | 257 aura::Window* right) { |
| 252 SetInOverview(false); | 258 SetInOverview(false); |
| 259 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeEnter()); |
| 253 split_view_controller_->ActivateSplitMode(left, right); | 260 split_view_controller_->ActivateSplitMode(left, right); |
| 254 } | 261 } |
| 255 | 262 |
| 256 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { | 263 void WindowManagerImpl::OnWindowAdded(aura::Window* new_window) { |
| 257 // TODO(oshima): Creating a new window should updates the ovewview mode | 264 // TODO(oshima): Creating a new window should updates the ovewview mode |
| 258 // instead of exitting. | 265 // instead of exitting. |
| 259 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) | 266 if (new_window->type() == ui::wm::WINDOW_TYPE_NORMAL) |
| 260 SetInOverview(false); | 267 SetInOverview(false); |
| 261 } | 268 } |
| 262 | 269 |
| 263 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { | 270 void WindowManagerImpl::OnWindowDestroying(aura::Window* window) { |
| 264 if (window == container_) | 271 if (window == container_) |
| 265 container_.reset(); | 272 container_.reset(); |
| 266 } | 273 } |
| 267 | 274 |
| 268 void WindowManagerImpl::OnWindowStackingChanged(aura::Window* window) { | |
| 269 // TODO(skuhne): Use |window_list_provider_->IsValidWindow(window)| instead. | |
| 270 if (window->type() == ui::wm::WINDOW_TYPE_NORMAL) { | |
| 271 FOR_EACH_OBSERVER(WindowManagerObserver, | |
| 272 observers_, | |
| 273 OnActivityOrderHasChanged()); | |
| 274 } | |
| 275 } | |
| 276 | |
| 277 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { | 275 bool WindowManagerImpl::IsCommandEnabled(int command_id) const { |
| 278 return true; | 276 return true; |
| 279 } | 277 } |
| 280 | 278 |
| 281 bool WindowManagerImpl::OnAcceleratorFired(int command_id, | 279 bool WindowManagerImpl::OnAcceleratorFired(int command_id, |
| 282 const ui::Accelerator& accelerator) { | 280 const ui::Accelerator& accelerator) { |
| 283 switch (command_id) { | 281 switch (command_id) { |
| 284 case CMD_TOGGLE_OVERVIEW: | 282 case CMD_TOGGLE_OVERVIEW: |
| 285 ToggleOverview(); | 283 ToggleOverview(); |
| 286 break; | 284 break; |
| 287 case CMD_TOGGLE_SPLIT_VIEW: | 285 case CMD_TOGGLE_SPLIT_VIEW: |
| 288 ToggleSplitview(); | 286 ToggleSplitview(); |
| 289 break; | 287 break; |
| 290 } | 288 } |
| 291 return true; | 289 return true; |
| 292 } | 290 } |
| 293 | 291 |
| 294 void WindowManagerImpl::ToggleSplitview() { | 292 void WindowManagerImpl::ToggleSplitview() { |
| 295 // TODO(oshima): Figure out what to do. | 293 // TODO(oshima): Figure out what to do. |
| 296 if (IsOverviewModeActive()) | 294 if (IsOverviewModeActive()) |
| 297 return; | 295 return; |
| 298 | 296 |
| 299 if (split_view_controller_->IsSplitViewModeActive()) { | 297 if (split_view_controller_->IsSplitViewModeActive()) { |
| 300 split_view_controller_->DeactivateSplitMode(); | 298 split_view_controller_->DeactivateSplitMode(); |
| 299 FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnSplitViewModeExit()); |
| 301 // Relayout so that windows are maximzied. | 300 // Relayout so that windows are maximzied. |
| 302 container_->layout_manager()->OnWindowResized(); | 301 container_->layout_manager()->OnWindowResized(); |
| 303 } else if (window_list_provider_->GetWindowList().size() > 1) { | 302 } else if (window_list_provider_->GetWindowList().size() > 1) { |
| 303 FOR_EACH_OBSERVER(WindowManagerObserver, |
| 304 observers_, |
| 305 OnSplitViewModeEnter()); |
| 304 split_view_controller_->ActivateSplitMode(NULL, NULL); | 306 split_view_controller_->ActivateSplitMode(NULL, NULL); |
| 305 } | 307 } |
| 306 } | 308 } |
| 307 | 309 |
| 308 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { | 310 aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) { |
| 309 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); | 311 const aura::Window::Windows& windows = window_list_provider_->GetWindowList(); |
| 310 aura::Window::Windows::const_reverse_iterator iter = | 312 aura::Window::Windows::const_reverse_iterator iter = |
| 311 std::find(windows.rbegin(), windows.rend(), window); | 313 std::find(windows.rbegin(), windows.rend(), window); |
| 312 CHECK(iter != windows.rend()); | 314 CHECK(iter != windows.rend()); |
| 313 ++iter; | 315 ++iter; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 DCHECK(!instance); | 401 DCHECK(!instance); |
| 400 } | 402 } |
| 401 | 403 |
| 402 // static | 404 // static |
| 403 WindowManager* WindowManager::GetInstance() { | 405 WindowManager* WindowManager::GetInstance() { |
| 404 DCHECK(instance); | 406 DCHECK(instance); |
| 405 return instance; | 407 return instance; |
| 406 } | 408 } |
| 407 | 409 |
| 408 } // namespace athena | 410 } // namespace athena |
| OLD | NEW |