| OLD | NEW |
| 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_manager2.h" | 5 #include "ash/wm/workspace/workspace_manager2.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 DISALLOW_COPY_AND_ASSIGN(WorkspaceManagerLayoutManager2); | 88 DISALLOW_COPY_AND_ASSIGN(WorkspaceManagerLayoutManager2); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 } // namespace | 91 } // namespace |
| 92 | 92 |
| 93 // WorkspaceManager2 ----------------------------------------------------------- | 93 // WorkspaceManager2 ----------------------------------------------------------- |
| 94 | 94 |
| 95 WorkspaceManager2::WorkspaceManager2(Window* contents_view) | 95 WorkspaceManager2::WorkspaceManager2(Window* contents_view) |
| 96 : contents_view_(contents_view), | 96 : contents_view_(contents_view), |
| 97 active_workspace_(NULL), | 97 active_workspace_(NULL), |
| 98 grid_size_(0), | |
| 99 shelf_(NULL), | 98 shelf_(NULL), |
| 100 in_move_(false), | 99 in_move_(false), |
| 101 ALLOW_THIS_IN_INITIALIZER_LIST( | 100 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 102 clear_unminimizing_workspace_factory_(this)) { | 101 clear_unminimizing_workspace_factory_(this)) { |
| 103 // Clobber any existing event filter. | 102 // Clobber any existing event filter. |
| 104 contents_view->SetEventFilter(NULL); | 103 contents_view->SetEventFilter(NULL); |
| 105 // |contents_view| takes ownership of WorkspaceManagerLayoutManager2. | 104 // |contents_view| takes ownership of WorkspaceManagerLayoutManager2. |
| 106 contents_view->SetLayoutManager( | 105 contents_view->SetLayoutManager( |
| 107 new WorkspaceManagerLayoutManager2(contents_view)); | 106 new WorkspaceManagerLayoutManager2(contents_view)); |
| 108 active_workspace_ = CreateWorkspace(false); | 107 active_workspace_ = CreateWorkspace(false); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 138 // static | 137 // static |
| 139 bool WorkspaceManager2::WillRestoreMaximized(Window* window) { | 138 bool WorkspaceManager2::WillRestoreMaximized(Window* window) { |
| 140 return wm::IsWindowMinimized(window) && | 139 return wm::IsWindowMinimized(window) && |
| 141 IsMaximizedState(window->GetProperty(internal::kRestoreShowStateKey)); | 140 IsMaximizedState(window->GetProperty(internal::kRestoreShowStateKey)); |
| 142 } | 141 } |
| 143 | 142 |
| 144 bool WorkspaceManager2::IsInMaximizedMode() const { | 143 bool WorkspaceManager2::IsInMaximizedMode() const { |
| 145 return active_workspace_ && active_workspace_->is_maximized(); | 144 return active_workspace_ && active_workspace_->is_maximized(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 void WorkspaceManager2::SetGridSize(int size) { | |
| 149 grid_size_ = size; | |
| 150 std::for_each(workspaces_.begin(), workspaces_.end(), | |
| 151 std::bind2nd(std::mem_fun(&Workspace2::SetGridSize), | |
| 152 grid_size_)); | |
| 153 std::for_each(pending_workspaces_.begin(), pending_workspaces_.end(), | |
| 154 std::bind2nd(std::mem_fun(&Workspace2::SetGridSize), | |
| 155 grid_size_)); | |
| 156 } | |
| 157 | |
| 158 int WorkspaceManager2::GetGridSize() const { | |
| 159 return grid_size_; | |
| 160 } | |
| 161 | |
| 162 WorkspaceWindowState WorkspaceManager2::GetWindowState() const { | 147 WorkspaceWindowState WorkspaceManager2::GetWindowState() const { |
| 163 if (!shelf_) | 148 if (!shelf_) |
| 164 return WORKSPACE_WINDOW_STATE_DEFAULT; | 149 return WORKSPACE_WINDOW_STATE_DEFAULT; |
| 165 | 150 |
| 166 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); | 151 const gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); |
| 167 const Window::Windows& windows(active_workspace_->window()->children()); | 152 const Window::Windows& windows(active_workspace_->window()->children()); |
| 168 bool window_overlaps_launcher = false; | 153 bool window_overlaps_launcher = false; |
| 169 bool has_maximized_window = false; | 154 bool has_maximized_window = false; |
| 170 for (Window::Windows::const_iterator i = windows.begin(); | 155 for (Window::Windows::const_iterator i = windows.begin(); |
| 171 i != windows.end(); ++i) { | 156 i != windows.end(); ++i) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 308 } |
| 324 } | 309 } |
| 325 | 310 |
| 326 WorkspaceManager2::Workspaces::iterator | 311 WorkspaceManager2::Workspaces::iterator |
| 327 WorkspaceManager2::FindWorkspace(Workspace2* workspace) { | 312 WorkspaceManager2::FindWorkspace(Workspace2* workspace) { |
| 328 return std::find(workspaces_.begin(), workspaces_.end(), workspace); | 313 return std::find(workspaces_.begin(), workspaces_.end(), workspace); |
| 329 } | 314 } |
| 330 | 315 |
| 331 Workspace2* WorkspaceManager2::CreateWorkspace(bool maximized) { | 316 Workspace2* WorkspaceManager2::CreateWorkspace(bool maximized) { |
| 332 Workspace2* workspace = new Workspace2(this, contents_view_, maximized); | 317 Workspace2* workspace = new Workspace2(this, contents_view_, maximized); |
| 333 workspace->SetGridSize(grid_size_); | |
| 334 workspace->window()->SetLayoutManager(new WorkspaceLayoutManager2(workspace)); | 318 workspace->window()->SetLayoutManager(new WorkspaceLayoutManager2(workspace)); |
| 335 return workspace; | 319 return workspace; |
| 336 } | 320 } |
| 337 | 321 |
| 338 void WorkspaceManager2::MoveWorkspaceToPendingOrDelete( | 322 void WorkspaceManager2::MoveWorkspaceToPendingOrDelete( |
| 339 Workspace2* workspace, | 323 Workspace2* workspace, |
| 340 Window* stack_beneath, | 324 Window* stack_beneath, |
| 341 AnimateType animate_type) { | 325 AnimateType animate_type) { |
| 342 // We're all ready moving windows. | 326 // We're all ready moving windows. |
| 343 if (in_move_) | 327 if (in_move_) |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 if (last_show_state == ui::SHOW_STATE_MINIMIZED) | 518 if (last_show_state == ui::SHOW_STATE_MINIMIZED) |
| 535 SetUnminimizingWorkspace(new_workspace ? new_workspace : workspace); | 519 SetUnminimizingWorkspace(new_workspace ? new_workspace : workspace); |
| 536 DCHECK(!old_layer); | 520 DCHECK(!old_layer); |
| 537 } | 521 } |
| 538 } | 522 } |
| 539 UpdateShelfVisibility(); | 523 UpdateShelfVisibility(); |
| 540 } | 524 } |
| 541 | 525 |
| 542 } // namespace internal | 526 } // namespace internal |
| 543 } // namespace ash | 527 } // namespace ash |
| OLD | NEW |