summaryrefslogtreecommitdiffstats
path: root/athena/wm
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-20 23:44:16 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-20 23:45:49 +0000
commit7b98c178f2c39411686741fc608c591fb666e1e1 (patch)
tree0e3d6bf139ae06e07b5aeede919cfa4eee17eca7 /athena/wm
parentfa256fc48d548041a5774bc4dd31a4e3b1a60135 (diff)
downloadchromium_src-7b98c178f2c39411686741fc608c591fb666e1e1.zip
chromium_src-7b98c178f2c39411686741fc608c591fb666e1e1.tar.gz
chromium_src-7b98c178f2c39411686741fc608c591fb666e1e1.tar.bz2
athena: Fix switching to a window of a different size.
When title-dragging to switch to a window that is of a different size (e.g. because it the new window was split), then make sure the window is positioned correclty during the title-drag gesture, and sized correctly at the end of the gesture. Also make sure that the window that the user switched away from is hidden after the gesture. BUG=none R=oshima@chromium.org Review URL: https://codereview.chromium.org/464163005 Cr-Commit-Position: refs/heads/master@{#290950} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290950 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'athena/wm')
-rw-r--r--athena/wm/window_manager_impl.cc52
-rw-r--r--athena/wm/window_manager_unittest.cc14
-rw-r--r--athena/wm/window_overview_mode.cc10
3 files changed, 60 insertions, 16 deletions
diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc
index d66f2ed..857256d 100644
--- a/athena/wm/window_manager_impl.cc
+++ b/athena/wm/window_manager_impl.cc
@@ -14,9 +14,12 @@
#include "athena/wm/title_drag_controller.h"
#include "athena/wm/window_list_provider_impl.h"
#include "athena/wm/window_overview_mode.h"
+#include "base/bind.h"
#include "base/logging.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/window.h"
+#include "ui/compositor/closure_animation_observer.h"
+#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#include "ui/wm/core/shadow_controller.h"
@@ -28,6 +31,14 @@
namespace athena {
namespace {
class WindowManagerImpl* instance = NULL;
+
+void SetWindowState(aura::Window* window,
+ const gfx::Rect& bounds,
+ const gfx::Transform& transform) {
+ window->SetBounds(bounds);
+ window->SetTransform(transform);
+}
+
} // namespace
class AthenaContainerLayoutManager : public aura::LayoutManager {
@@ -171,8 +182,8 @@ void WindowManagerImpl::SetInOverview(bool active) {
active ? NULL : split_view_controller_.get());
if (active) {
split_view_controller_->DeactivateSplitMode();
- FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
- OnOverviewModeEnter());
+ FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeEnter());
+
// Re-stack all windows in the order defined by window_list_provider_.
aura::Window::Windows window_list = window_list_provider_->GetWindowList();
aura::Window::Windows::iterator it;
@@ -183,8 +194,7 @@ void WindowManagerImpl::SetInOverview(bool active) {
} else {
CHECK(!split_view_controller_->IsSplitViewModeActive());
overview_.reset();
- FOR_EACH_OBSERVER(WindowManagerObserver, observers_,
- OnOverviewModeExit());
+ FOR_EACH_OBSERVER(WindowManagerObserver, observers_, OnOverviewModeExit());
}
}
@@ -286,11 +296,18 @@ 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|.
+ // Make sure |window| is active.
wm::ActivateWindow(window);
+
+ // Make sure |next_window| is visibile.
next_window->Show();
+
+ // Position |next_window| correctly (left aligned if it's larger than
+ // |window|, and center aligned otherwise).
int dx = window->bounds().x() - next_window->bounds().x();
+ if (next_window->bounds().width() < window->bounds().width())
+ dx -= (next_window->bounds().width() - window->bounds().width()) / 2;
+
if (dx) {
gfx::Transform transform;
transform.Translate(dx, 0);
@@ -302,11 +319,27 @@ void WindowManagerImpl::OnTitleDragCompleted(aura::Window* window) {
aura::Window* next_window = GetWindowBehind(window);
if (!next_window)
return;
- if (split_view_controller_->IsSplitViewModeActive())
+ if (split_view_controller_->IsSplitViewModeActive()) {
split_view_controller_->ReplaceWindow(window, next_window);
- else
+ wm::ActivateWindow(next_window);
+ } else {
+ ui::ScopedLayerAnimationSettings
+ settings(next_window->layer()->GetAnimator());
+ settings.AddObserver(new ui::ClosureAnimationObserver(
+ base::Bind(&SetWindowState,
+ base::Unretained(next_window),
+ window->bounds(),
+ gfx::Transform())));
+
+ gfx::Transform transform;
+ transform.Scale(window->bounds().width() / next_window->bounds().width(),
+ window->bounds().height() / next_window->bounds().height());
+ transform.Translate(window->bounds().x() - next_window->bounds().x(), 0);
+ next_window->SetTransform(transform);
+
OnSelectWindow(next_window);
- wm::ActivateWindow(next_window);
+ }
+ window->Hide();
}
void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) {
@@ -314,6 +347,7 @@ void WindowManagerImpl::OnTitleDragCanceled(aura::Window* window) {
if (!next_window)
return;
next_window->SetTransform(gfx::Transform());
+ next_window->Hide();
}
// static
diff --git a/athena/wm/window_manager_unittest.cc b/athena/wm/window_manager_unittest.cc
index 41d949c..b4cddf3 100644
--- a/athena/wm/window_manager_unittest.cc
+++ b/athena/wm/window_manager_unittest.cc
@@ -179,6 +179,8 @@ TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) {
EXPECT_TRUE(wm::IsActiveWindow(second.get()));
EXPECT_EQ(second.get(),
wm_api.window_list_provider()->GetWindowList().back());
+ EXPECT_TRUE(second->IsVisible());
+ EXPECT_FALSE(third->IsVisible());
// Performing the same gesture again will switch back to |third|.
generator.GestureScrollSequence(gfx::Point(20, 10),
@@ -187,6 +189,18 @@ TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindows) {
5);
EXPECT_TRUE(wm::IsActiveWindow(third.get()));
EXPECT_EQ(third.get(), wm_api.window_list_provider()->GetWindowList().back());
+ EXPECT_FALSE(second->IsVisible());
+ EXPECT_TRUE(third->IsVisible());
+
+ // Perform a swipe that doesn't go enough to perform the window switch.
+ generator.GestureScrollSequence(gfx::Point(20, 10),
+ gfx::Point(20, 90),
+ base::TimeDelta::FromMilliseconds(20),
+ 5);
+ EXPECT_TRUE(wm::IsActiveWindow(third.get()));
+ EXPECT_EQ(third.get(), wm_api.window_list_provider()->GetWindowList().back());
+ EXPECT_FALSE(second->IsVisible());
+ EXPECT_TRUE(third->IsVisible());
}
TEST_F(WindowManagerTest, TitleDragSwitchBetweenWindowsInSplitViewMode) {
diff --git a/athena/wm/window_overview_mode.cc b/athena/wm/window_overview_mode.cc
index 8677e42..b342293 100644
--- a/athena/wm/window_overview_mode.cc
+++ b/athena/wm/window_overview_mode.cc
@@ -198,13 +198,9 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
window->layer()->GetAnimator();
// Unset any in-progress animation.
- {
- ui::ScopedLayerAnimationSettings settings(animator);
- settings.SetPreemptionStrategy(
- ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET);
- window->Show();
- window->SetTransform(gfx::Transform());
- }
+ animator->AbortAllAnimations();
+ window->Show();
+ window->SetTransform(gfx::Transform());
// Setup the animation.
{
ui::ScopedLayerAnimationSettings settings(animator);