| Index: ui/aura_shell/shell.cc
|
| diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc
|
| index aa2798dfdb732ad61c5f502417c5cb9810e0aaf0..e45f85eca29227c2897df632187b26fd95bf7c71 100644
|
| --- a/ui/aura_shell/shell.cc
|
| +++ b/ui/aura_shell/shell.cc
|
| @@ -10,12 +10,14 @@
|
| #include "ui/aura/toplevel_window_container.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/aura/window_types.h"
|
| +#include "ui/aura_shell/default_container_event_filter.h"
|
| #include "ui/aura_shell/default_container_layout_manager.h"
|
| #include "ui/aura_shell/desktop_layout_manager.h"
|
| #include "ui/aura_shell/launcher/launcher.h"
|
| #include "ui/aura_shell/shell_delegate.h"
|
| #include "ui/aura_shell/shell_factory.h"
|
| #include "ui/aura_shell/shell_window_ids.h"
|
| +#include "ui/aura_shell/workspace/workspace_manager.h"
|
| #include "ui/base/view_prop.h"
|
| #include "ui/gfx/compositor/layer.h"
|
| #include "views/widget/native_widget_aura.h"
|
| @@ -25,6 +27,9 @@ namespace aura_shell {
|
|
|
| namespace {
|
|
|
| +// The right/left margin of work area in the screen.
|
| +const int kWorkAreaHorizontalMargin = 15;
|
| +
|
| using views::Widget;
|
|
|
| // Creates each of the special window containers that holds windows of various
|
| @@ -38,8 +43,8 @@ void CreateSpecialContainers(aura::Window::Windows* containers) {
|
|
|
| aura::Window* default_container = new aura::ToplevelWindowContainer;
|
| default_container->set_id(internal::kShellWindowId_DefaultContainer);
|
| - default_container->SetLayoutManager(
|
| - new internal::DefaultContainerLayoutManager(default_container));
|
| + default_container->SetEventFilter(
|
| + new internal::DefaultContainerEventFilter(default_container));
|
| containers->push_back(default_container);
|
|
|
| aura::Window* always_on_top_container = new aura::ToplevelWindowContainer;
|
| @@ -65,60 +70,6 @@ void CreateSpecialContainers(aura::Window::Windows* containers) {
|
| containers->push_back(menu_container);
|
| }
|
|
|
| -typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair;
|
| -
|
| -void CalculateWindowBoundsAndScaleForTiling(
|
| - const gfx::Size& containing_size,
|
| - const aura::Window::Windows& windows,
|
| - float* x_scale,
|
| - float* y_scale,
|
| - std::vector<WindowAndBoundsPair>* bounds) {
|
| - *x_scale = 1.0f;
|
| - *y_scale = 1.0f;
|
| - int total_width = 0;
|
| - int max_height = 0;
|
| - int shown_window_count = 0;
|
| - for (aura::Window::Windows::const_iterator i = windows.begin();
|
| - i != windows.end(); ++i) {
|
| - if ((*i)->IsVisible()) {
|
| - total_width += (*i)->bounds().width();
|
| - max_height = std::max((*i)->bounds().height(), max_height);
|
| - shown_window_count++;
|
| - }
|
| - }
|
| -
|
| - if (shown_window_count == 0)
|
| - return;
|
| -
|
| - const int kPadding = 10;
|
| - total_width += (shown_window_count - 1) * kPadding;
|
| - if (total_width > containing_size.width()) {
|
| - *x_scale = static_cast<float>(containing_size.width()) /
|
| - static_cast<float>(total_width);
|
| - }
|
| - if (max_height > containing_size.height()) {
|
| - *y_scale = static_cast<float>(containing_size.height()) /
|
| - static_cast<float>(max_height);
|
| - }
|
| - *x_scale = *y_scale = std::min(*x_scale, *y_scale);
|
| -
|
| - int x = std::max(0, static_cast<int>(
|
| - (containing_size.width() * - total_width * *x_scale) / 2));
|
| - for (aura::Window::Windows::const_iterator i = windows.begin();
|
| - i != windows.end();
|
| - ++i) {
|
| - if ((*i)->IsVisible()) {
|
| - const gfx::Rect& current_bounds((*i)->bounds());
|
| - int y = (containing_size.height() -
|
| - current_bounds.height() * *y_scale) / 2;
|
| - bounds->push_back(std::make_pair(*i,
|
| - gfx::Rect(x, y, current_bounds.width(), current_bounds.height())));
|
| - x += static_cast<int>(
|
| - static_cast<float>(current_bounds.width() + kPadding) * *x_scale);
|
| - }
|
| - }
|
| -}
|
| -
|
| } // namespace
|
|
|
| // static
|
| @@ -168,9 +119,18 @@ void Shell::Init() {
|
| launcher_.reset(new Launcher(toplevel_container));
|
| desktop_layout->set_launcher_widget(launcher_->widget());
|
| desktop_layout->set_status_area_widget(internal::CreateStatusArea());
|
| +
|
| desktop_window->screen()->set_work_area_insets(
|
| - gfx::Insets(0, 0, launcher_->widget()->GetWindowScreenBounds().height(),
|
| - 0));
|
| + gfx::Insets(
|
| + 0, kWorkAreaHorizontalMargin,
|
| + launcher_->widget()->GetWindowScreenBounds().height(),
|
| + kWorkAreaHorizontalMargin));
|
| +
|
| + // Workspace Manager
|
| + workspace_manager_.reset(new WorkspaceManager(toplevel_container));
|
| + toplevel_container->SetLayoutManager(
|
| + new internal::DefaultContainerLayoutManager(
|
| + toplevel_container, workspace_manager_.get()));
|
|
|
| // Force a layout.
|
| desktop_layout->OnWindowResized();
|
| @@ -189,49 +149,8 @@ const aura::Window* Shell::GetContainer(int container_id) const {
|
| return aura::Desktop::GetInstance()->GetChildById(container_id);
|
| }
|
|
|
| -void Shell::TileWindows() {
|
| - to_restore_.clear();
|
| - aura::Window* window_container =
|
| - aura::Desktop::GetInstance()->GetChildById(
|
| - internal::kShellWindowId_DefaultContainer);
|
| - const aura::Window::Windows& windows = window_container->children();
|
| - if (windows.empty())
|
| - return;
|
| - float x_scale = 1.0f;
|
| - float y_scale = 1.0f;
|
| - std::vector<WindowAndBoundsPair> bounds;
|
| - CalculateWindowBoundsAndScaleForTiling(window_container->bounds().size(),
|
| - windows, &x_scale, &y_scale, &bounds);
|
| - if (bounds.empty())
|
| - return;
|
| - ui::Transform transform;
|
| - transform.SetScale(x_scale, y_scale);
|
| - for (size_t i = 0; i < bounds.size(); ++i) {
|
| - to_restore_.push_back(
|
| - std::make_pair(bounds[i].first, bounds[i].first->bounds()));
|
| - bounds[i].first->layer()->SetAnimation(
|
| - aura::Window::CreateDefaultAnimation());
|
| - bounds[i].first->SetBounds(bounds[i].second);
|
| - bounds[i].first->layer()->SetTransform(transform);
|
| - bounds[i].first->layer()->SetOpacity(0.5f);
|
| - }
|
| -
|
| - MessageLoop::current()->PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&Shell::RestoreTiledWindows, method_factory_.GetWeakPtr()),
|
| - 2000);
|
| -}
|
| -
|
| -void Shell::RestoreTiledWindows() {
|
| - ui::Transform identity_transform;
|
| - for (size_t i = 0; i < to_restore_.size(); ++i) {
|
| - to_restore_[i].first->layer()->SetAnimation(
|
| - aura::Window::CreateDefaultAnimation());
|
| - to_restore_[i].first->SetBounds(to_restore_[i].second);
|
| - to_restore_[i].first->layer()->SetTransform(identity_transform);
|
| - to_restore_[i].first->layer()->SetOpacity(1.0f);
|
| - }
|
| - to_restore_.clear();
|
| +void Shell::ToggleOverview() {
|
| + workspace_manager_->SetOverview(!workspace_manager_->is_overview());
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|