summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorvarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 18:05:42 +0000
committervarkha@chromium.org <varkha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 18:05:42 +0000
commit74ce7234c65015f91080d64f76a0116a8a9bb5d9 (patch)
tree64bc7b85205e886054b22fdff5cd6e797c60102a /ash
parentf20ac9d4f306df2e078fed6ad4902896044e6ea1 (diff)
downloadchromium_src-74ce7234c65015f91080d64f76a0116a8a9bb5d9.zip
chromium_src-74ce7234c65015f91080d64f76a0116a8a9bb5d9.tar.gz
chromium_src-74ce7234c65015f91080d64f76a0116a8a9bb5d9.tar.bz2
Making panels stacking order aware of launcher alignment
BUG=259522 Review URL: https://chromiumcodereview.appspot.com/19958003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213168 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/panels/panel_layout_manager.cc8
-rw-r--r--ash/wm/panels/panel_layout_manager_unittest.cc31
2 files changed, 38 insertions, 1 deletions
diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc
index 2b1e4e6..facefed 100644
--- a/ash/wm/panels/panel_layout_manager.cc
+++ b/ash/wm/panels/panel_layout_manager.cc
@@ -712,6 +712,10 @@ void PanelLayoutManager::UpdateStacking(aura::Window* active_panel) {
active_panel = last_active_panel_;
}
+ ShelfAlignment alignment = launcher_->alignment();
+ bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
+ alignment == SHELF_ALIGNMENT_BOTTOM;
+
// We want to to stack the panels like a deck of cards:
// ,--,--,--,-------.--.--.
// | | | | | | |
@@ -725,7 +729,9 @@ void PanelLayoutManager::UpdateStacking(aura::Window* active_panel) {
for (PanelList::const_iterator it = panel_windows_.begin();
it != panel_windows_.end(); ++it) {
gfx::Rect bounds = it->window->bounds();
- window_ordering.insert(std::make_pair(bounds.x() + bounds.width() / 2,
+ window_ordering.insert(std::make_pair(horizontal ?
+ bounds.x() + bounds.width() / 2 :
+ bounds.y() + bounds.height() / 2,
it->window));
}
diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc
index 26f42cc..ca231ce 100644
--- a/ash/wm/panels/panel_layout_manager_unittest.cc
+++ b/ash/wm/panels/panel_layout_manager_unittest.cc
@@ -393,6 +393,37 @@ TEST_F(PanelLayoutManagerTest, MultiplePanelStacking) {
EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get()));
}
+TEST_F(PanelLayoutManagerTest, MultiplePanelStackingVertical) {
+ // set launcher shelf to be aligned on the right
+ SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT);
+
+ // Size panels in such a way that ordering them by X coordinate would cause
+ // stacking order to be incorrect. Test that stacking order is based on Y.
+ scoped_ptr<aura::Window> w1(CreatePanelWindow(gfx::Rect(0, 0, 210, 201)));
+ scoped_ptr<aura::Window> w2(CreatePanelWindow(gfx::Rect(0, 0, 220, 201)));
+ scoped_ptr<aura::Window> w3(CreatePanelWindow(gfx::Rect(0, 0, 200, 201)));
+
+ // Default stacking order.
+ EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get()));
+ EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get()));
+
+ // Changing the active window should update the stacking order.
+ wm::ActivateWindow(w1.get());
+ launcher_view_test()->RunMessageLoopUntilAnimationsDone();
+ EXPECT_TRUE(WindowIsAbove(w1.get(), w2.get()));
+ EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get()));
+
+ wm::ActivateWindow(w2.get());
+ launcher_view_test()->RunMessageLoopUntilAnimationsDone();
+ EXPECT_TRUE(WindowIsAbove(w1.get(), w3.get()));
+ EXPECT_TRUE(WindowIsAbove(w2.get(), w3.get()));
+ EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get()));
+
+ wm::ActivateWindow(w3.get());
+ EXPECT_TRUE(WindowIsAbove(w3.get(), w2.get()));
+ EXPECT_TRUE(WindowIsAbove(w2.get(), w1.get()));
+}
+
TEST_F(PanelLayoutManagerTest, MultiplePanelCallout) {
gfx::Rect bounds(0, 0, 200, 200);
scoped_ptr<aura::Window> w1(CreatePanelWindow(bounds));