summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-22 01:39:10 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-22 01:39:10 +0000
commit07bb4fa652d9a1445008b292a862b9146aa68108 (patch)
tree668debfcb5669fe7158aa06b3ee44060163beb1d /ui
parent128efa85a82224cc3c605fbf3ce86da154582252 (diff)
downloadchromium_src-07bb4fa652d9a1445008b292a862b9146aa68108.zip
chromium_src-07bb4fa652d9a1445008b292a862b9146aa68108.tar.gz
chromium_src-07bb4fa652d9a1445008b292a862b9146aa68108.tar.bz2
aura: Resize toplevel windows correctly when the desktop is resized.
BUG=none TEST=ToplevelWindowTest: MaximizeAfterDesktopResize and FullscreenAfterDesktopResize Review URL: http://codereview.chromium.org/8369004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/window.cc16
-rw-r--r--ui/aura/window_unittest.cc48
-rw-r--r--ui/aura_shell/default_container_layout_manager.cc11
-rw-r--r--ui/aura_shell/default_container_layout_manager.h4
4 files changed, 72 insertions, 7 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index f41edf5..8b1a396 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -93,13 +93,21 @@ bool Window::IsVisible() const {
}
void Window::Maximize() {
- if (UpdateShowStateAndRestoreBounds(ui::SHOW_STATE_MAXIMIZED))
- SetBoundsInternal(gfx::Screen::GetMonitorWorkAreaNearestWindow(this));
+ // The desktop size may have changed, so make sure the window is maximized to
+ // the correct size even if it's already maximized.
+ gfx::Rect rect = gfx::Screen::GetMonitorWorkAreaNearestWindow(this);
+ if (UpdateShowStateAndRestoreBounds(ui::SHOW_STATE_MAXIMIZED) ||
+ rect != bounds())
+ SetBoundsInternal(rect);
}
void Window::Fullscreen() {
- if (UpdateShowStateAndRestoreBounds(ui::SHOW_STATE_FULLSCREEN))
- SetBoundsInternal(gfx::Screen::GetMonitorAreaNearestWindow(this));
+ // The desktop size may have changed, so make sure the window is fullscreen to
+ // the correct size even if it's already fullscreen.
+ gfx::Rect rect = gfx::Screen::GetMonitorAreaNearestWindow(this);
+ if (UpdateShowStateAndRestoreBounds(ui::SHOW_STATE_FULLSCREEN) ||
+ rect != bounds())
+ SetBoundsInternal(rect);
}
void Window::Restore() {
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index ceacf65..ea5f686 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -1052,6 +1052,54 @@ TEST_F(ToplevelWindowTest, TopMostActivate) {
EXPECT_EQ(w2.get(), toplevel_container_.GetTopmostWindowToActivate(NULL));
}
+// Tests that maximized windows get resized after desktop is resized.
+TEST_F(ToplevelWindowTest, MaximizeAfterDesktopResize) {
+ gfx::Rect window_bounds(10, 10, 300, 400);
+ scoped_ptr<Window> w1(CreateTestToplevelWindow(NULL, window_bounds));
+
+ w1->Show();
+ EXPECT_EQ(window_bounds, w1->bounds());
+
+ w1->Maximize();
+ EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(w1.get()),
+ w1->bounds());
+
+ // Resize the desktop.
+ Desktop* desktop = Desktop::GetInstance();
+ gfx::Size desktop_size = desktop->GetHostSize();
+ desktop->SetBounds(gfx::Rect(0, 0, desktop_size.width() + 100,
+ desktop_size.height() + 200));
+
+ EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(w1.get()),
+ w1->bounds());
+
+ w1->Restore();
+ EXPECT_EQ(window_bounds, w1->bounds());
+}
+
+// Tests that fullscreen windows get resized after desktop is resized.
+TEST_F(ToplevelWindowTest, FullscreenAfterDesktopResize) {
+ gfx::Rect window_bounds(10, 10, 300, 400);
+ scoped_ptr<Window> w1(CreateTestToplevelWindow(NULL, window_bounds));
+
+ w1->Show();
+ EXPECT_EQ(window_bounds, w1->bounds());
+
+ w1->Fullscreen();
+ EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(w1.get()), w1->bounds());
+
+ // Resize the desktop.
+ Desktop* desktop = Desktop::GetInstance();
+ gfx::Size desktop_size = desktop->GetHostSize();
+ desktop->SetBounds(gfx::Rect(0, 0, desktop_size.width() + 100,
+ desktop_size.height() + 200));
+
+ EXPECT_EQ(gfx::Screen::GetMonitorAreaNearestWindow(w1.get()), w1->bounds());
+
+ w1->Restore();
+ EXPECT_EQ(window_bounds, w1->bounds());
+}
+
class WindowObserverTest : public WindowTest,
public WindowObserver {
public:
diff --git a/ui/aura_shell/default_container_layout_manager.cc b/ui/aura_shell/default_container_layout_manager.cc
index 0d312f1..264c532 100644
--- a/ui/aura_shell/default_container_layout_manager.cc
+++ b/ui/aura_shell/default_container_layout_manager.cc
@@ -31,8 +31,15 @@ DefaultContainerLayoutManager::~DefaultContainerLayoutManager() {}
void DefaultContainerLayoutManager::OnWindowResized() {
aura::Window::Windows::const_iterator i = owner_->children().begin();
// Use SetBounds because window may be maximized or fullscreen.
- for (; i != owner_->children().end(); ++i)
- (*i)->SetBounds((*i)->bounds());
+ for (; i != owner_->children().end(); ++i) {
+ aura::Window* w = *i;
+ if (w->show_state() == ui::SHOW_STATE_MAXIMIZED)
+ w->Maximize();
+ else if (w->show_state() == ui::SHOW_STATE_FULLSCREEN)
+ w->Fullscreen();
+ else
+ w->SetBounds(w->bounds());
+ }
NOTIMPLEMENTED();
}
diff --git a/ui/aura_shell/default_container_layout_manager.h b/ui/aura_shell/default_container_layout_manager.h
index 3ea8946..a693024 100644
--- a/ui/aura_shell/default_container_layout_manager.h
+++ b/ui/aura_shell/default_container_layout_manager.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/aura/layout_manager.h"
+#include "ui/aura_shell/aura_shell_export.h"
namespace aura {
class Window;
@@ -22,7 +23,8 @@ namespace aura_shell {
namespace internal {
// LayoutManager for the default window container.
-class DefaultContainerLayoutManager : public aura::LayoutManager {
+class AURA_SHELL_EXPORT DefaultContainerLayoutManager
+ : public aura::LayoutManager {
public:
explicit DefaultContainerLayoutManager(aura::Window* owner);
virtual ~DefaultContainerLayoutManager();