diff options
author | yuzo@chromium.org <yuzo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-19 06:20:48 +0000 |
---|---|---|
committer | yuzo@chromium.org <yuzo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-19 06:20:48 +0000 |
commit | 43b5ff2e230aad8ebde1ac7c1aeccc1c7cf97d2c (patch) | |
tree | 0557863b23155ddb28b55458584e6d671ccbba57 | |
parent | ae155cb97116363c783eb4e5c6277bef8336b0cf (diff) | |
download | chromium_src-43b5ff2e230aad8ebde1ac7c1aeccc1c7cf97d2c.zip chromium_src-43b5ff2e230aad8ebde1ac7c1aeccc1c7cf97d2c.tar.gz chromium_src-43b5ff2e230aad8ebde1ac7c1aeccc1c7cf97d2c.tar.bz2 |
Fix: New window appears to the left/up if the taskbar is on left/top.
Currently, the Windows taskbar (put differently, work area) is not considered
in getting the last window bounds (while it is for the saved window bounds).
This causes new windows (CTRL-N) appear to the left/up of the existing window
instead of right/down, if the taskbar is on left or top.
TESTED=gcl try, manually
TEST=Place the taskbar on left or top of the screen and create new Chrome windows by CTRL-N and observe.
BUG=14131
Review URL: http://codereview.chromium.org/125179
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18795 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/window_sizer.cc | 5 | ||||
-rw-r--r-- | chrome/browser/window_sizer.h | 2 | ||||
-rw-r--r-- | chrome/browser/window_sizer_unittest.cc | 26 |
3 files changed, 25 insertions, 8 deletions
diff --git a/chrome/browser/window_sizer.cc b/chrome/browser/window_sizer.cc index 74956d2..59eed33 100644 --- a/chrome/browser/window_sizer.cc +++ b/chrome/browser/window_sizer.cc @@ -151,6 +151,7 @@ bool WindowSizer::GetLastWindowBounds(gfx::Rect* bounds) const { if (!state_provider_ || !state_provider_->GetLastActiveWindowState(bounds)) return false; gfx::Rect last_window_bounds = *bounds; + bounds->Offset(monitor_info_provider_->GetBoundsOffsetMatching(*bounds)); bounds->Offset(kWindowTilePixels, kWindowTilePixels); AdjustBoundsToBeVisibleOnMonitorContaining(last_window_bounds, bounds); return true; @@ -162,9 +163,7 @@ bool WindowSizer::GetSavedWindowBounds(gfx::Rect* bounds, if (!state_provider_ || !state_provider_->GetPersistentState(bounds, maximized)) return false; - const gfx::Point& taskbar_offset = - monitor_info_provider_->GetBoundsOffsetMatching(*bounds); - bounds->Offset(taskbar_offset.x(), taskbar_offset.y()); + bounds->Offset(monitor_info_provider_->GetBoundsOffsetMatching(*bounds)); AdjustBoundsToBeVisibleOnMonitorContaining(*bounds, bounds); return true; } diff --git a/chrome/browser/window_sizer.h b/chrome/browser/window_sizer.h index d1db1db..d7727f7 100644 --- a/chrome/browser/window_sizer.h +++ b/chrome/browser/window_sizer.h @@ -173,4 +173,4 @@ class WindowSizer { DISALLOW_EVIL_CONSTRUCTORS(WindowSizer); }; -#endif // #ifndef CHROME_BROWSER_WINDOW_SIZER_H_ +#endif // CHROME_BROWSER_WINDOW_SIZER_H_ diff --git a/chrome/browser/window_sizer_unittest.cc b/chrome/browser/window_sizer_unittest.cc index d443892..552a340 100644 --- a/chrome/browser/window_sizer_unittest.cc +++ b/chrome/browser/window_sizer_unittest.cc @@ -42,7 +42,7 @@ class TestMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { void AddMonitor(const gfx::Rect& bounds, const gfx::Rect& work_area) { DCHECK(bounds.Contains(work_area)); - monitor_bounds_.push_back(work_area); + monitor_bounds_.push_back(bounds); work_areas_.push_back(work_area); } @@ -166,7 +166,6 @@ static void GetWindowBounds(const gfx::Rect& monitor1_bounds, // Test that the window is sized appropriately for the first run experience // where the default window bounds calculation is invoked. TEST(WindowSizerTest, DefaultSizeCase) { - { // 4:3 monitor case, 1024x768, no taskbar gfx::Rect window_bounds; bool maximized; @@ -262,6 +261,26 @@ TEST(WindowSizerTest, LastWindowBoundsCase) { EXPECT_EQ(gfx::Rect(20, 20, 500, 400), window_bounds); } + { // taskbar on left. + gfx::Rect window_bounds; + bool maximized = false; + GetWindowBounds(tentwentyfour, taskbar_left_work_area, gfx::Rect(), + gfx::Rect(10, 10, 500, 400), false, LAST_ACTIVE, + &window_bounds, &maximized); + EXPECT_FALSE(maximized); + EXPECT_EQ(gfx::Rect(127, 20, 500, 400), window_bounds); + } + + { // taskbar on top. + gfx::Rect window_bounds; + bool maximized = false; + GetWindowBounds(tentwentyfour, taskbar_top_work_area, gfx::Rect(), + gfx::Rect(10, 10, 500, 400), false, LAST_ACTIVE, + &window_bounds, &maximized); + EXPECT_FALSE(maximized); + EXPECT_EQ(gfx::Rect(20, 54, 500, 400), window_bounds); + } + { // too small to satisify the minimum visibility condition. gfx::Rect window_bounds; bool maximized = false; @@ -343,7 +362,6 @@ TEST(WindowSizerTest, LastWindowBoundsCase) { // Test that the window opened is sized appropriately given persisted sizes. TEST(WindowSizerTest, PersistedBoundsCase) { - { // normal, in the middle of the screen somewhere. gfx::Rect initial_bounds(10, 10, 500, 400); @@ -393,7 +411,7 @@ TEST(WindowSizerTest, PersistedBoundsCase) { { // off the left but the minimum visibility condition is barely satisfied // without relocaiton. gfx::Rect initial_bounds(-470, 50, 500, 400); - + gfx::Rect window_bounds; bool maximized; GetWindowBounds(tentwentyfour, tentwentyfour, gfx::Rect(), |