summaryrefslogtreecommitdiffstats
path: root/ui/aura_shell
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 16:08:32 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-27 16:08:32 +0000
commit10ee6d5ae8f1016f5e888416d330ecab569cea30 (patch)
treefb55573357650efdf2622f81d7e4e47bb2dfb984 /ui/aura_shell
parent79d6913f13490be388c9eef248d7eb5b4002350a (diff)
downloadchromium_src-10ee6d5ae8f1016f5e888416d330ecab569cea30.zip
chromium_src-10ee6d5ae8f1016f5e888416d330ecab569cea30.tar.gz
chromium_src-10ee6d5ae8f1016f5e888416d330ecab569cea30.tar.bz2
Makes overview center the active workspace. This avoids leaving extra
space though, so if you're at the first/last workspace it'll be aligned to the left/right edge. BUG=none TEST=none R=oshima@chromium.org Review URL: http://codereview.chromium.org/8399027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura_shell')
-rw-r--r--ui/aura_shell/workspace/workspace.cc5
-rw-r--r--ui/aura_shell/workspace/workspace_manager.cc17
2 files changed, 14 insertions, 8 deletions
diff --git a/ui/aura_shell/workspace/workspace.cc b/ui/aura_shell/workspace/workspace.cc
index 5623e43..8e9f2cd 100644
--- a/ui/aura_shell/workspace/workspace.cc
+++ b/ui/aura_shell/workspace/workspace.cc
@@ -60,7 +60,6 @@ void Workspace::RemoveWindow(aura::Window* window) {
Layout(NULL);
}
-
bool Workspace::Contains(aura::Window* window) const {
return std::find(windows_.begin(), windows_.end(), window) != windows_.end();
}
@@ -74,7 +73,7 @@ void Workspace::Layout(aura::Window* no_animation) {
int total_width = 0;
for (aura::Window::Windows::const_iterator i = windows_.begin();
i != windows_.end();
- i++) {
+ ++i) {
if (total_width)
total_width += kWindowHorizontalMargin;
// TODO(oshima): use restored bounds.
@@ -85,7 +84,7 @@ void Workspace::Layout(aura::Window* no_animation) {
int dx = (work_area.width() - total_width) / 2;
for (aura::Window::Windows::iterator i = windows_.begin();
i != windows_.end();
- i++) {
+ ++i) {
MoveWindowTo(*i,
gfx::Point(work_area.x() + dx, work_area.y()),
no_animation != *i);
diff --git a/ui/aura_shell/workspace/workspace_manager.cc b/ui/aura_shell/workspace/workspace_manager.cc
index 410ace1..f7a463f 100644
--- a/ui/aura_shell/workspace/workspace_manager.cc
+++ b/ui/aura_shell/workspace/workspace_manager.cc
@@ -92,7 +92,6 @@ void WorkspaceManager::SetOverview(bool overview) {
if (is_overview_ == overview)
return;
is_overview_ = overview;
- gfx::Rect bounds = viewport_->GetTargetBounds();
ui::Transform transform;
if (is_overview_) {
@@ -108,10 +107,18 @@ void WorkspaceManager::SetOverview(bool overview) {
transform.SetScale(scale, scale);
int overview_width = viewport_->bounds().width() * scale;
- int dx = overview_width < workspace_size_.width() ?
- (workspace_size_.width() - overview_width) / 2 : 0;
-
- transform.SetTranslateX(-viewport_->GetTargetBounds().x() + dx);
+ int dx = 0;
+ if (overview_width < workspace_size_.width()) {
+ dx = (workspace_size_.width() - overview_width) / 2;
+ } else if (active_workspace_) {
+ // Center the active workspace.
+ int active_workspace_mid_x = (active_workspace_->bounds().x() +
+ active_workspace_->bounds().width() / 2) * scale;
+ dx = workspace_size_.width() / 2 - active_workspace_mid_x;
+ dx = std::min(0, std::max(dx, workspace_size_.width() - overview_width));
+ }
+
+ transform.SetTranslateX(dx);
transform.SetTranslateY(workspace_size_.height() * (1.0f - scale) / 2);
} else {
transform.SetTranslateX(-active_workspace_->bounds().x());