| Index: ui/aura_shell/workspace/workspace_manager.cc
|
| diff --git a/ui/aura_shell/workspace/workspace_manager.cc b/ui/aura_shell/workspace/workspace_manager.cc
|
| index 410ace11474528ced8138181083bd90fb09c7f42..00800991a9a26757d3cc226b1cb5fa594726ff4b 100644
|
| --- a/ui/aura_shell/workspace/workspace_manager.cc
|
| +++ b/ui/aura_shell/workspace/workspace_manager.cc
|
| @@ -60,11 +60,18 @@ Workspace* WorkspaceManager::GetActiveWorkspace() const {
|
| }
|
|
|
| Workspace* WorkspaceManager::FindBy(aura::Window* window) const {
|
| + int index = GetWorkspaceIndexContaining(window);
|
| + return index < 0 ? NULL : workspaces_[index];
|
| +}
|
| +
|
| +aura::Window* WorkspaceManager::FindRotateWindowForLocation(
|
| + const gfx::Point& point) {
|
| for (Workspaces::const_iterator i = workspaces_.begin();
|
| i != workspaces_.end();
|
| ++i) {
|
| - if ((*i)->Contains(window))
|
| - return *i;
|
| + aura::Window* window = (*i)->FindRotateWindowForLocation(point);
|
| + if (window)
|
| + return window;
|
| }
|
| return NULL;
|
| }
|
| @@ -121,6 +128,32 @@ void WorkspaceManager::SetOverview(bool overview) {
|
| viewport_->layer()->SetTransform(transform);
|
| }
|
|
|
| +void WorkspaceManager::RotateWindows(aura::Window* source,
|
| + aura::Window* target) {
|
| + DCHECK(source);
|
| + DCHECK(target);
|
| + int source_ws_index = GetWorkspaceIndexContaining(source);
|
| + int target_ws_index = GetWorkspaceIndexContaining(target);
|
| + DCHECK(source_ws_index >= 0);
|
| + DCHECK(target_ws_index >= 0);
|
| + if (source_ws_index == target_ws_index) {
|
| + workspaces_[source_ws_index]->RotateWindows(source, target);
|
| + } else {
|
| + aura::Window* insert = source;
|
| + if (source_ws_index < target_ws_index) {
|
| + for (int i = target_ws_index; i >= source_ws_index; --i) {
|
| + insert = workspaces_[i]->ShiftWindows(
|
| + insert, source, Workspace::SHIFT_TO_LEFT);
|
| + }
|
| + } else {
|
| + for (int i = target_ws_index; i <= source_ws_index; ++i) {
|
| + insert = workspaces_[i]->ShiftWindows(
|
| + insert, source, Workspace::SHIFT_TO_RIGHT);
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // WorkspaceManager, Overridden from aura::DesktopObserver:
|
|
|
| @@ -179,6 +212,17 @@ gfx::Rect WorkspaceManager::GetWorkAreaBounds(
|
| return bounds;
|
| }
|
|
|
| +// Returns the index of the workspace that contains the |window|.
|
| +int WorkspaceManager::GetWorkspaceIndexContaining(aura::Window* window) const {
|
| + for (Workspaces::const_iterator i = workspaces_.begin();
|
| + i != workspaces_.end();
|
| + ++i) {
|
| + if ((*i)->Contains(window))
|
| + return i - workspaces_.begin();
|
| + }
|
| + return -1;
|
| +}
|
| +
|
| void WorkspaceManager::UpdateViewport() {
|
| int num_workspaces = std::max(1, static_cast<int>(workspaces_.size()));
|
| int total_width = workspace_size_.width() * num_workspaces +
|
|
|