Chromium Code Reviews| Index: athena/wm/split_view_controller.cc |
| diff --git a/athena/wm/split_view_controller.cc b/athena/wm/split_view_controller.cc |
| index cde465798a80420057ab96ae344b69ef951a8cad..cc2c54a3310230667e76e7d221498696060549b7 100644 |
| --- a/athena/wm/split_view_controller.cc |
| +++ b/athena/wm/split_view_controller.cc |
| @@ -15,6 +15,7 @@ |
| #include "ui/events/event_handler.h" |
| #include "ui/gfx/display.h" |
| #include "ui/gfx/screen.h" |
| +#include "ui/wm/core/window_util.h" |
| namespace athena { |
| namespace { |
| @@ -45,22 +46,17 @@ class CallbackAnimationObserver : public ui::ImplicitAnimationObserver { |
| SplitViewController::SplitViewController( |
| aura::Window* container, |
| - WindowListProvider* window_list_provider, |
| - WindowManager* window_manager) |
| + WindowListProvider* window_list_provider) |
| : state_(INACTIVE), |
| container_(container), |
| - window_manager_(window_manager), |
| window_list_provider_(window_list_provider), |
| - current_activity_window_(NULL), |
| left_window_(NULL), |
| right_window_(NULL), |
| separator_position_(0), |
| weak_factory_(this) { |
| - window_manager->AddObserver(this); |
| } |
| SplitViewController::~SplitViewController() { |
| - window_manager_->RemoveObserver(this); |
| } |
| bool SplitViewController::IsSplitViewModeActive() const { |
| @@ -193,67 +189,43 @@ void SplitViewController::UpdateSeparatorPositionFromScrollDelta(float delta) { |
| : display_bounds.right() - container_bounds.x() + delta; |
| } |
| -aura::Window* SplitViewController::GetCurrentActivityWindow() { |
| - if (!current_activity_window_) { |
| - aura::Window::Windows windows = window_list_provider_->GetWindowList(); |
| - if (windows.empty()) |
| - return NULL; |
| - current_activity_window_ = windows.back(); |
| - } |
| - return current_activity_window_; |
| -} |
| - |
| /////////////////////////////////////////////////////////////////////////////// |
| -// Begin BezelController::ScrollDelegate overrides. |
| +// BezelController::ScrollDelegate: |
| + |
| void SplitViewController::ScrollBegin(BezelController::Bezel bezel, |
| float delta) { |
| if (!CanScroll()) |
| return; |
| state_ = SCROLLING; |
| - aura::Window* current_window = GetCurrentActivityWindow(); |
| - CHECK(current_window); |
| aura::Window::Windows windows = window_list_provider_->GetWindowList(); |
| CHECK(windows.size() >= 2); |
| - aura::Window::Windows::const_iterator it = |
| - std::find(windows.begin(), windows.end(), current_window); |
| - CHECK(it != windows.end()); |
| + aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); |
| + aura::Window* current_window = *(iter); |
| + CHECK(wm::IsActiveWindow(current_window)); |
| if (delta > 0) { |
| right_window_ = current_window; |
| - // reverse iterator points to the position before normal iterator |it| |
| - aura::Window::Windows::const_reverse_iterator rev_it(it); |
| - // circle to end if needed. |
| - left_window_ = rev_it == windows.rend() ? windows.back() : *(rev_it); |
| + left_window_ = *(iter + 1); |
| } else { |
| left_window_ = current_window; |
| - ++it; |
| - // circle to front if needed. |
| - right_window_ = it == windows.end() ? windows.front() : *it; |
| + right_window_ = *(iter + 1); |
| } |
| CHECK(left_window_); |
| CHECK(right_window_); |
| - // TODO(oshima|mfomitchev): crbug.com/388362 |
| - // Until we are properly hiding off-screen windows in window manager: |
| - // Loop through all windows and hide them |
| - for (it = windows.begin(); it != windows.end(); ++it) { |
| - if (*it != left_window_ && *it != right_window_) |
| - (*it)->Hide(); |
| - } |
| - |
| UpdateSeparatorPositionFromScrollDelta(delta); |
| UpdateLayout(false); |
| } |
| -// Max distance from the scroll end position to the middle of the screen where |
| -// we would go into the split view mode. |
| -const int kMaxDistanceFromMiddle = 120; |
| void SplitViewController::ScrollEnd() { |
| if (state_ != SCROLLING) |
| return; |
| + // Max distance from the scroll end position to the middle of the screen where |
| + // we would go into the split view mode. |
| + const int kMaxDistanceFromMiddle = 120; |
| int container_width = container_->GetBoundsInScreen().width(); |
| if (std::abs(container_width / 2 - separator_position_) <= |
| kMaxDistanceFromMiddle) { |
| @@ -261,11 +233,9 @@ void SplitViewController::ScrollEnd() { |
| separator_position_ = container_width / 2; |
| } else if (separator_position_ < container_width / 2) { |
| separator_position_ = 0; |
|
mfomitchev
2014/08/15 14:42:28
I think we need to call wm::ActiveWindow(right_win
sadrul
2014/08/15 16:07:12
Done.
|
| - current_activity_window_ = right_window_; |
| state_ = INACTIVE; |
| } else { |
| separator_position_ = container_width; |
|
mfomitchev
2014/08/15 14:42:28
Ditto for wm::ActiveWindow(left_window_)
sadrul
2014/08/15 16:07:12
Done.
|
| - current_activity_window_ = left_window_; |
| state_ = INACTIVE; |
| } |
| UpdateLayout(true); |
| @@ -280,34 +250,9 @@ void SplitViewController::ScrollUpdate(float delta) { |
| bool SplitViewController::CanScroll() { |
| // TODO(mfomitchev): return false in vertical orientation, in full screen. |
| - bool result = (!window_manager_->IsOverviewModeActive() && |
| - !IsSplitViewModeActive() && |
| + bool result = (!IsSplitViewModeActive() && |
| window_list_provider_->GetWindowList().size() >= 2); |
| return result; |
| } |
| -/////////////////////////////////////////////////////////////////////////////// |
| -// WindowManagerObserver overrides |
| -void SplitViewController::OnOverviewModeEnter() { |
| - if (state_ == ACTIVE) { |
| - CHECK(left_window_); |
| - CHECK(right_window_); |
| - window_list_provider_->MoveToFront(right_window_); |
| - window_list_provider_->MoveToFront(left_window_); |
| - // TODO(mfomitchev): This shouldn't be done here, but the overview mode's |
| - // transition animation currently looks bad if the starting transform of |
| - // any window is not gfx::Transform(). |
| - right_window_->SetTransform(gfx::Transform()); |
| - } else if (current_activity_window_) { |
| - window_list_provider_->MoveToFront(current_activity_window_); |
| - } |
| - state_ = INACTIVE; |
|
mfomitchev
2014/08/15 14:42:28
Until split-overview is implemented, going to over
sadrul
2014/08/15 16:07:12
A good fix for this for now would be to explicitly
mfomitchev
2014/08/15 16:43:26
Sure. So what are you going to do now? Wait for os
|
| - left_window_ = NULL; |
| - right_window_ = NULL; |
| - current_activity_window_ = NULL; |
| -} |
| - |
| -void SplitViewController::OnOverviewModeExit() { |
| -} |
| - |
| } // namespace athena |