summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-28 07:08:22 +0000
committerflackr@chromium.org <flackr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-28 07:08:22 +0000
commit619005faf4abb034f00d475c6569689be5e3588b (patch)
tree51b7a2b1a8e275a8e42cbe6420e336373b50ddb2 /ash
parentacbad570a20683a99b5d1d6fbb624703bfc42371 (diff)
downloadchromium_src-619005faf4abb034f00d475c6569689be5e3588b.zip
chromium_src-619005faf4abb034f00d475c6569689be5e3588b.tar.gz
chromium_src-619005faf4abb034f00d475c6569689be5e3588b.tar.bz2
Fix panel alignment on a second display using consistent coordinate space.
BUG=224242 TEST=PanelLayoutManagerTest.PanelAlignmentSecondDisplay Review URL: https://chromiumcodereview.appspot.com/12545065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/panels/panel_layout_manager.cc6
-rw-r--r--ash/wm/panels/panel_layout_manager_unittest.cc40
2 files changed, 34 insertions, 12 deletions
diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc
index 5647c46..db65ff8 100644
--- a/ash/wm/panels/panel_layout_manager.cc
+++ b/ash/wm/panels/panel_layout_manager.cc
@@ -423,8 +423,8 @@ void PanelLayoutManager::Relayout() {
ShelfAlignment alignment = launcher_->shelf_widget()->GetAlignment();
bool horizontal = alignment == SHELF_ALIGNMENT_TOP ||
alignment == SHELF_ALIGNMENT_BOTTOM;
- gfx::Rect launcher_bounds = launcher_->shelf_widget()->
- GetWindowBoundsInScreen();
+ gfx::Rect launcher_bounds = ash::ScreenAsh::ConvertRectFromScreen(
+ panel_container_, launcher_->shelf_widget()->GetWindowBoundsInScreen());
int panel_start_bounds = kPanelIdealSpacing;
int panel_end_bounds = horizontal ?
panel_container_->bounds().width() - kPanelIdealSpacing :
@@ -579,7 +579,7 @@ void PanelLayoutManager::UpdateCallouts() {
aura::Window* panel = iter->window;
views::Widget* callout_widget = iter->callout_widget;
- gfx::Rect bounds = panel->GetBoundsInRootWindow();
+ gfx::Rect bounds = panel->GetBoundsInScreen();
gfx::Rect icon_bounds =
launcher_->GetScreenBoundsOfItemIconForWindow(panel);
if (icon_bounds.IsEmpty() || !panel->IsVisible() ||
diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc
index 2582b73..d1df50e 100644
--- a/ash/wm/panels/panel_layout_manager_unittest.cc
+++ b/ash/wm/panels/panel_layout_manager_unittest.cc
@@ -126,7 +126,7 @@ class PanelLayoutManagerTest : public test::AshTestBase {
gfx::Rect window_bounds = panel->GetBoundsInScreen();
gfx::Rect launcher_bounds = launcher->shelf_widget()->
GetWindowBoundsInScreen();
- ShelfAlignment alignment = GetAlignment();
+ ShelfAlignment alignment = GetAlignment(panel->GetRootWindow());
if (IsHorizontal(alignment)) {
// The horizontal bounds of the panel window should contain the bounds of
@@ -172,7 +172,7 @@ class PanelLayoutManagerTest : public test::AshTestBase {
EXPECT_TRUE(widget->IsVisible());
- ShelfAlignment alignment = GetAlignment();
+ ShelfAlignment alignment = GetAlignment(panel->GetRootWindow());
switch (alignment) {
case SHELF_ALIGNMENT_BOTTOM:
EXPECT_EQ(panel_bounds.bottom(), callout_bounds.y());
@@ -229,14 +229,14 @@ class PanelLayoutManagerTest : public test::AshTestBase {
test_api.RunMessageLoopUntilAnimationsDone();
}
- void SetAlignment(ShelfAlignment alignment) {
+ void SetAlignment(aura::RootWindow* root_window, ShelfAlignment alignment) {
ash::Shell* shell = ash::Shell::GetInstance();
- shell->SetShelfAlignment(alignment, shell->GetPrimaryRootWindow());
+ shell->SetShelfAlignment(alignment, root_window);
}
- ShelfAlignment GetAlignment() {
+ ShelfAlignment GetAlignment(aura::RootWindow* root_window) {
ash::Shell* shell = ash::Shell::GetInstance();
- return shell->GetShelfAlignment(shell->GetPrimaryRootWindow());
+ return shell->GetShelfAlignment(root_window);
}
private:
@@ -478,10 +478,12 @@ TEST_F(PanelLayoutManagerTest, MinimizeRestorePanel) {
DISABLED_PanelMoveBetweenMultipleDisplays
#define MAYBE_PanelAttachPositionMultipleDisplays \
DISABLED_PanelAttachPositionMultipleDisplays
+#define MAYBE_PanelAlignmentSecondDisplay DISABLED_PanelAlignmentSecondDisplay
#else
#define MAYBE_PanelMoveBetweenMultipleDisplays PanelMoveBetweenMultipleDisplays
#define MAYBE_PanelAttachPositionMultipleDisplays \
PanelAttachPositionMultipleDisplays
+#define MAYBE_PanelAlignmentSecondDisplay PanelAlignmentSecondDisplay
#endif
TEST_F(PanelLayoutManagerTest, MAYBE_PanelMoveBetweenMultipleDisplays) {
@@ -570,11 +572,31 @@ TEST_F(PanelLayoutManagerTest, MAYBE_PanelAttachPositionMultipleDisplays) {
IsCalloutAboveLauncherIcon(p1_d2.get());
}
+TEST_F(PanelLayoutManagerTest, MAYBE_PanelAlignmentSecondDisplay) {
+ UpdateDisplay("600x400,600x400");
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+
+ scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(600, 0, 50, 50)));
+ EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow());
+
+ IsPanelAboveLauncherIcon(p1_d2.get());
+ IsCalloutAboveLauncherIcon(p1_d2.get());
+
+ SetAlignment(root_windows[1], SHELF_ALIGNMENT_RIGHT);
+ IsPanelAboveLauncherIcon(p1_d2.get());
+ IsCalloutAboveLauncherIcon(p1_d2.get());
+ SetAlignment(root_windows[1], SHELF_ALIGNMENT_LEFT);
+ IsPanelAboveLauncherIcon(p1_d2.get());
+ IsCalloutAboveLauncherIcon(p1_d2.get());
+ SetAlignment(root_windows[1], SHELF_ALIGNMENT_TOP);
+ IsPanelAboveLauncherIcon(p1_d2.get());
+ IsCalloutAboveLauncherIcon(p1_d2.get());
+}
TEST_F(PanelLayoutManagerTest, AlignmentLeft) {
gfx::Rect bounds(0, 0, 201, 201);
scoped_ptr<aura::Window> w(CreatePanelWindow(bounds));
- SetAlignment(SHELF_ALIGNMENT_LEFT);
+ SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT);
IsPanelAboveLauncherIcon(w.get());
IsCalloutAboveLauncherIcon(w.get());
}
@@ -582,7 +604,7 @@ TEST_F(PanelLayoutManagerTest, AlignmentLeft) {
TEST_F(PanelLayoutManagerTest, AlignmentRight) {
gfx::Rect bounds(0, 0, 201, 201);
scoped_ptr<aura::Window> w(CreatePanelWindow(bounds));
- SetAlignment(SHELF_ALIGNMENT_RIGHT);
+ SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT);
IsPanelAboveLauncherIcon(w.get());
IsCalloutAboveLauncherIcon(w.get());
}
@@ -590,7 +612,7 @@ TEST_F(PanelLayoutManagerTest, AlignmentRight) {
TEST_F(PanelLayoutManagerTest, AlignmentTop) {
gfx::Rect bounds(0, 0, 201, 201);
scoped_ptr<aura::Window> w(CreatePanelWindow(bounds));
- SetAlignment(SHELF_ALIGNMENT_TOP);
+ SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_TOP);
IsPanelAboveLauncherIcon(w.get());
IsCalloutAboveLauncherIcon(w.get());
}