| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "ui/aura_shell/workspace/workspace_manager.h" | 4 #include "ui/aura_shell/workspace/workspace_manager.h" |
| 5 | 5 |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 | 7 |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "ui/aura/desktop.h" | 9 #include "ui/aura/desktop.h" |
| 10 #include "ui/aura/screen_aura.h" | 10 #include "ui/aura/screen_aura.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 Workspace* WorkspaceManager::FindBy(aura::Window* window) const { | 62 Workspace* WorkspaceManager::FindBy(aura::Window* window) const { |
| 63 for (Workspaces::const_iterator i = workspaces_.begin(); | 63 for (Workspaces::const_iterator i = workspaces_.begin(); |
| 64 i != workspaces_.end(); | 64 i != workspaces_.end(); |
| 65 ++i) { | 65 ++i) { |
| 66 if ((*i)->Contains(window)) | 66 if ((*i)->Contains(window)) |
| 67 return *i; | 67 return *i; |
| 68 } | 68 } |
| 69 return NULL; | 69 return NULL; |
| 70 } | 70 } |
| 71 | 71 |
| 72 aura::Window* WorkspaceManager::FindSwapWindowForLocation( |
| 73 const gfx::Point& point) { |
| 74 for (Workspaces::const_iterator i = workspaces_.begin(); |
| 75 i != workspaces_.end(); |
| 76 ++i) { |
| 77 aura::Window* window = (*i)->FindSwapWindowForLocation(point); |
| 78 if (window) |
| 79 return window; |
| 80 } |
| 81 return NULL; |
| 82 } |
| 83 |
| 72 void WorkspaceManager::LayoutWorkspaces() { | 84 void WorkspaceManager::LayoutWorkspaces() { |
| 73 UpdateViewport(); | 85 UpdateViewport(); |
| 74 | 86 |
| 75 gfx::Rect bounds(workspace_size_); | 87 gfx::Rect bounds(workspace_size_); |
| 76 int x = 0; | 88 int x = 0; |
| 77 for (Workspaces::const_iterator i = workspaces_.begin(); | 89 for (Workspaces::const_iterator i = workspaces_.begin(); |
| 78 i != workspaces_.end(); | 90 i != workspaces_.end(); |
| 79 ++i) { | 91 ++i) { |
| 80 Workspace* workspace = *i; | 92 Workspace* workspace = *i; |
| 81 bounds.set_x(x); | 93 bounds.set_x(x); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 transform.SetTranslateX(-viewport_->GetTargetBounds().x() + dx); | 126 transform.SetTranslateX(-viewport_->GetTargetBounds().x() + dx); |
| 115 transform.SetTranslateY(workspace_size_.height() * (1.0f - scale) / 2); | 127 transform.SetTranslateY(workspace_size_.height() * (1.0f - scale) / 2); |
| 116 } else { | 128 } else { |
| 117 transform.SetTranslateX(-active_workspace_->bounds().x()); | 129 transform.SetTranslateX(-active_workspace_->bounds().x()); |
| 118 } | 130 } |
| 119 | 131 |
| 120 viewport_->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); | 132 viewport_->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); |
| 121 viewport_->layer()->SetTransform(transform); | 133 viewport_->layer()->SetTransform(transform); |
| 122 } | 134 } |
| 123 | 135 |
| 136 void WorkspaceManager::SwapWindow(aura::Window* drag, aura::Window* target) { |
| 137 Workspace* source_ws = FindBy(drag); |
| 138 Workspace* target_ws = FindBy(target); |
| 139 DCHECK(source_ws); |
| 140 DCHECK(target_ws); |
| 141 if (source_ws == target_ws) { |
| 142 source_ws->SwapWindow(drag, target); |
| 143 } else { |
| 144 source_ws->ReplaceWindow(drag, target, true); |
| 145 target_ws->ReplaceWindow(target, drag, false); |
| 146 } |
| 147 } |
| 148 |
| 124 //////////////////////////////////////////////////////////////////////////////// | 149 //////////////////////////////////////////////////////////////////////////////// |
| 125 // WorkspaceManager, Overridden from aura::DesktopObserver: | 150 // WorkspaceManager, Overridden from aura::DesktopObserver: |
| 126 | 151 |
| 127 void WorkspaceManager::OnDesktopResized(const gfx::Size& new_size) { | 152 void WorkspaceManager::OnDesktopResized(const gfx::Size& new_size) { |
| 128 workspace_size_ = | 153 workspace_size_ = |
| 129 gfx::Screen::GetMonitorAreaNearestWindow(viewport_).size(); | 154 gfx::Screen::GetMonitorAreaNearestWindow(viewport_).size(); |
| 130 LayoutWorkspaces(); | 155 LayoutWorkspaces(); |
| 131 } | 156 } |
| 132 | 157 |
| 133 void WorkspaceManager::OnActiveWindowChanged(aura::Window* active) { | 158 void WorkspaceManager::OnActiveWindowChanged(aura::Window* active) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // Move to active workspace. | 216 // Move to active workspace. |
| 192 if (active_workspace_) { | 217 if (active_workspace_) { |
| 193 ui::Transform transform; | 218 ui::Transform transform; |
| 194 transform.SetTranslateX(-active_workspace_->bounds().x()); | 219 transform.SetTranslateX(-active_workspace_->bounds().x()); |
| 195 viewport_->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); | 220 viewport_->layer()->SetAnimation(aura::Window::CreateDefaultAnimation()); |
| 196 viewport_->SetTransform(transform); | 221 viewport_->SetTransform(transform); |
| 197 } | 222 } |
| 198 } | 223 } |
| 199 | 224 |
| 200 } // namespace aura_shell | 225 } // namespace aura_shell |
| OLD | NEW |