summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-15 21:10:44 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-15 21:12:43 +0000
commita0917d8b69db8ad2ae62bcf1fcc3c26b502e258b (patch)
tree2f28b15b60a282f043ba6d7c43860782d6679d00
parent7b2c06ddde1145adc5928e2d775de7dd28a9479d (diff)
downloadchromium_src-a0917d8b69db8ad2ae62bcf1fcc3c26b502e258b.zip
chromium_src-a0917d8b69db8ad2ae62bcf1fcc3c26b502e258b.tar.gz
chromium_src-a0917d8b69db8ad2ae62bcf1fcc3c26b502e258b.tar.bz2
athena: Fix switching windows with title-drag in split-view.
When split-view mode, make sure dragging the tiel to switch between windows works as expected. BUG=397272 R=mfomitchev@chromium.org, mukai@chromium.org Review URL: https://codereview.chromium.org/468763002 Cr-Commit-Position: refs/heads/master@{#290008} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290008 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--athena/wm/split_view_controller.cc22
-rw-r--r--athena/wm/split_view_controller.h3
-rw-r--r--athena/wm/split_view_controller_unittest.cc1
-rw-r--r--athena/wm/title_drag_controller.cc8
-rw-r--r--athena/wm/window_manager_impl.cc47
5 files changed, 70 insertions, 11 deletions
diff --git a/athena/wm/split_view_controller.cc b/athena/wm/split_view_controller.cc
index 088de30..2329089 100644
--- a/athena/wm/split_view_controller.cc
+++ b/athena/wm/split_view_controller.cc
@@ -85,6 +85,28 @@ void SplitViewController::ActivateSplitMode(aura::Window* left,
UpdateLayout(true);
}
+void SplitViewController::ReplaceWindow(aura::Window* window,
+ aura::Window* replace_with) {
+ CHECK(IsSplitViewModeActive());
+ CHECK(replace_with);
+ CHECK(window == left_window_ || window == right_window_);
+ CHECK(replace_with != left_window_ && replace_with != right_window_);
+#if !defined(NDEBUG)
+ aura::Window::Windows windows = window_list_provider_->GetWindowList();
+ DCHECK(std::find(windows.begin(), windows.end(), replace_with) !=
+ windows.end());
+#endif
+
+ replace_with->SetBounds(window->bounds());
+ replace_with->SetTransform(gfx::Transform());
+ if (window == left_window_)
+ left_window_ = replace_with;
+ else
+ right_window_ = replace_with;
+ wm::ActivateWindow(replace_with);
+ window->SetTransform(gfx::Transform());
+}
+
void SplitViewController::DeactivateSplitMode() {
CHECK_NE(SCROLLING, state_);
state_ = INACTIVE;
diff --git a/athena/wm/split_view_controller.h b/athena/wm/split_view_controller.h
index 4e0d3cc..8d8db77 100644
--- a/athena/wm/split_view_controller.h
+++ b/athena/wm/split_view_controller.h
@@ -39,6 +39,9 @@ class ATHENA_EXPORT SplitViewController
// making any necessary changes.
void DeactivateSplitMode();
+ void ReplaceWindow(aura::Window* window,
+ aura::Window* replace_with);
+
aura::Window* left_window() { return left_window_; }
aura::Window* right_window() { return right_window_; }
diff --git a/athena/wm/split_view_controller_unittest.cc b/athena/wm/split_view_controller_unittest.cc
index 78e44db..268a3ac 100644
--- a/athena/wm/split_view_controller_unittest.cc
+++ b/athena/wm/split_view_controller_unittest.cc
@@ -6,7 +6,6 @@
#include "athena/common/fill_layout_manager.h"
#include "athena/test/athena_test_base.h"
-#include "athena/wm/public/window_list_provider.h"
#include "athena/wm/window_list_provider_impl.h"
#include "base/memory/scoped_vector.h"
#include "ui/aura/test/test_window_delegate.h"
diff --git a/athena/wm/title_drag_controller.cc b/athena/wm/title_drag_controller.cc
index 36bf8238..b41b7fd 100644
--- a/athena/wm/title_drag_controller.cc
+++ b/athena/wm/title_drag_controller.cc
@@ -60,15 +60,15 @@ void TitleDragController::OnTransitionEnd(aura::Window* window, bool complete) {
weak_ptr_.InvalidateWeakPtrs();
if (!tracker_.Contains(window))
window = NULL;
- if (complete && window && wm::IsActiveWindow(window))
- delegate_->OnTitleDragCompleted(window);
- else
- delegate_->OnTitleDragCanceled(window);
shadow_.reset();
if (window) {
window->SetTransform(gfx::Transform());
tracker_.Remove(window);
}
+ if (complete && window && wm::IsActiveWindow(window))
+ delegate_->OnTitleDragCompleted(window);
+ else
+ delegate_->OnTitleDragCanceled(window);
}
void TitleDragController::OnGestureEvent(ui::GestureEvent* gesture) {
diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc
index eaaa0cd..e3bb2b2 100644
--- a/athena/wm/window_manager_impl.cc
+++ b/athena/wm/window_manager_impl.cc
@@ -247,23 +247,58 @@ bool WindowManagerImpl::OnAcceleratorFired(int command_id,
}
aura::Window* WindowManagerImpl::GetWindowBehind(aura::Window* window) {
- const aura::Window::Windows& windows = container_->children();
- aura::Window::Windows::const_iterator iter =
- std::find(windows.begin(), windows.end(), window);
- CHECK(iter != windows.end());
- return (iter == windows.begin()) ? NULL : *(iter - 1);
+ const aura::Window::Windows& windows = window_list_provider_->GetWindowList();
+ aura::Window::Windows::const_reverse_iterator iter =
+ std::find(windows.rbegin(), windows.rend(), window);
+ CHECK(iter != windows.rend());
+ ++iter;
+ aura::Window* behind = NULL;
+ if (iter != windows.rend())
+ behind = *iter++;
+
+ if (split_view_controller_->IsSplitViewModeActive()) {
+ aura::Window* left = split_view_controller_->left_window();
+ aura::Window* right = split_view_controller_->right_window();
+ CHECK(window == left || window == right);
+ if (behind == left || behind == right)
+ behind = (iter == windows.rend()) ? NULL : *iter;
+ }
+
+ return behind;
}
void WindowManagerImpl::OnTitleDragStarted(aura::Window* window) {
+ aura::Window* next_window = GetWindowBehind(window);
+ if (!next_window)
+ return;
+ // Make sure |window| is active. Also make sure that |next_window| is visible,
+ // and positioned to match the top-left edge of |window|.
+ wm::ActivateWindow(window);
+ next_window->Show();
+ int dx = window->bounds().x() - next_window->bounds().x();
+ if (dx) {
+ gfx::Transform transform;
+ transform.Translate(dx, 0);
+ next_window->SetTransform(transform);
+ }
}
void WindowManagerImpl::OnTitleDragCompleted(aura::Window* window) {
aura::Window* next_window = GetWindowBehind(window);
- if (next_window)
+ if (!next_window)
+ return;
+ if (split_view_controller_->IsSplitViewModeActive())
+ split_view_controller_->ReplaceWindow(window, next_window);
+ else
OnSelectWindow(next_window);
+ wm::ActivateWindow(next_window);
}
void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) {
+ aura::Window* next_window = GetWindowBehind(window);
+ if (!next_window)
+ return;
+ next_window->SetTransform(gfx::Transform());
}
AthenaContainerLayoutManager::AthenaContainerLayoutManager() {