summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai <mukai@chromium.org>2014-11-10 17:28:49 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-11 01:29:05 +0000
commit6a4118079e42983d26074f4b76839da34ae6d6c9 (patch)
treee964e3e8990525b491ab7e708adab5c20c3582a0
parent03ef2046664b096b28ccc753d081050a3cd117d5 (diff)
downloadchromium_src-6a4118079e42983d26074f4b76839da34ae6d6c9.zip
chromium_src-6a4118079e42983d26074f4b76839da34ae6d6c9.tar.gz
chromium_src-6a4118079e42983d26074f4b76839da34ae6d6c9.tar.bz2
Fills athena background always.
BUG=431861 R=oshima@chromium.org, mohsen@chromium.org TEST=manually Review URL: https://codereview.chromium.org/697143005 Cr-Commit-Position: refs/heads/master@{#303563}
-rw-r--r--athena/screen/screen_manager_impl.cc2
-rw-r--r--athena/system/background_controller.cc2
-rw-r--r--athena/util/fill_layout_manager.cc25
-rw-r--r--athena/util/fill_layout_manager.h2
-rw-r--r--athena/util/fill_layout_manager_unittest.cc51
-rw-r--r--athena/virtual_keyboard/virtual_keyboard_manager_impl.cc1
6 files changed, 62 insertions, 21 deletions
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index 20a4bd5..8f960eb 100644
--- a/athena/screen/screen_manager_impl.cc
+++ b/athena/screen/screen_manager_impl.cc
@@ -8,7 +8,6 @@
#include "athena/screen/modal_window_controller.h"
#include "athena/screen/screen_accelerator_handler.h"
#include "athena/util/container_priorities.h"
-#include "athena/util/fill_layout_manager.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/client/aura_constants.h"
@@ -260,7 +259,6 @@ void ScreenManagerImpl::Init() {
aura::client::SetActivationClient(root_window_, focus_controller);
focus_client_.reset(focus_controller);
- root_window_->SetLayoutManager(new FillLayoutManager(root_window_));
capture_client_.reset(new ::wm::ScopedCaptureClient(root_window_));
accelerator_handler_.reset(new ScreenAcceleratorHandler());
diff --git a/athena/system/background_controller.cc b/athena/system/background_controller.cc
index acfb280..67b0b7f 100644
--- a/athena/system/background_controller.cc
+++ b/athena/system/background_controller.cc
@@ -5,6 +5,7 @@
#include "athena/system/background_controller.h"
#include "athena/system/public/system_ui.h"
+#include "athena/util/fill_layout_manager.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
@@ -60,6 +61,7 @@ BackgroundController::BackgroundController(aura::Window* background_container) {
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.parent = background_container;
background_widget->Init(params);
+ FillLayoutManager::SetAlwaysFill(background_widget->GetNativeWindow());
background_widget->GetNativeWindow()->layer()->SetMasksToBounds(true);
background_view_ = new BackgroundView;
background_widget->SetContentsView(background_view_);
diff --git a/athena/util/fill_layout_manager.cc b/athena/util/fill_layout_manager.cc
index 8e239a2..2a3eb22 100644
--- a/athena/util/fill_layout_manager.cc
+++ b/athena/util/fill_layout_manager.cc
@@ -6,19 +6,31 @@
#include "base/logging.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_property.h"
+
+// This is to avoid creating type definitoin for kAlwaysFillWindowKey.
+DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ATHENA_EXPORT, bool);
namespace athena {
namespace {
+DEFINE_LOCAL_WINDOW_PROPERTY_KEY(bool, kAlwaysFillWindowKey, false);
+
// TODO(oshima): Implement real window/layout manager. crbug.com/388362.
bool ShouldFill(aura::Window* window) {
- return window->type() != ui::wm::WINDOW_TYPE_MENU &&
- window->type() != ui::wm::WINDOW_TYPE_TOOLTIP &&
- window->type() != ui::wm::WINDOW_TYPE_POPUP;
+ return window->GetProperty(kAlwaysFillWindowKey) ||
+ (window->type() != ui::wm::WINDOW_TYPE_MENU &&
+ window->type() != ui::wm::WINDOW_TYPE_TOOLTIP &&
+ window->type() != ui::wm::WINDOW_TYPE_POPUP);
}
} // namespace
+// static
+void FillLayoutManager::SetAlwaysFill(aura::Window* window) {
+ window->SetProperty(kAlwaysFillWindowKey, true);
+}
+
FillLayoutManager::FillLayoutManager(aura::Window* container)
: container_(container) {
DCHECK(container_);
@@ -40,16 +52,21 @@ void FillLayoutManager::OnWindowResized() {
void FillLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
if (ShouldFill(child))
- SetChildBoundsDirect(child, (gfx::Rect(container_->bounds().size())));
+ SetChildBoundsDirect(child, gfx::Rect(container_->bounds().size()));
}
void FillLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) {
}
+
void FillLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) {
}
+
void FillLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
bool visible) {
+ if (visible && ShouldFill(child))
+ SetChildBoundsDirect(child, gfx::Rect(container_->bounds().size()));
}
+
void FillLayoutManager::SetChildBounds(aura::Window* child,
const gfx::Rect& requested_bounds) {
if (!ShouldFill(child))
diff --git a/athena/util/fill_layout_manager.h b/athena/util/fill_layout_manager.h
index 50e7df8..38748f9 100644
--- a/athena/util/fill_layout_manager.h
+++ b/athena/util/fill_layout_manager.h
@@ -12,6 +12,8 @@ namespace athena {
class ATHENA_EXPORT FillLayoutManager : public aura::LayoutManager {
public:
+ static void SetAlwaysFill(aura::Window* window);
+
explicit FillLayoutManager(aura::Window* container);
~FillLayoutManager() override;
diff --git a/athena/util/fill_layout_manager_unittest.cc b/athena/util/fill_layout_manager_unittest.cc
index d478e3d..9f31220 100644
--- a/athena/util/fill_layout_manager_unittest.cc
+++ b/athena/util/fill_layout_manager_unittest.cc
@@ -18,47 +18,68 @@ TEST(FillLayoutManagerTest, ChildWindowSizedCorrectly) {
scoped_ptr<aura::Window> child(new aura::Window(nullptr));
child->SetBounds(gfx::Rect(0, 0, 5, 10));
- EXPECT_NE(child->bounds().size().ToString(),
- parent->bounds().size().ToString());
+ EXPECT_NE(parent->bounds().size().ToString(),
+ child->bounds().size().ToString());
parent->AddChild(child.get());
- EXPECT_EQ(child->bounds().size().ToString(),
- parent->bounds().size().ToString());
+ EXPECT_EQ(parent->bounds().size().ToString(),
+ child->bounds().size().ToString());
parent->SetBounds(gfx::Rect(0, 0, 100, 200));
- EXPECT_EQ(child->bounds().size().ToString(),
- parent->bounds().size().ToString());
+ EXPECT_EQ(parent->bounds().size().ToString(),
+ child->bounds().size().ToString());
// Menu, tooltip, and popup should not be filled.
scoped_ptr<aura::Window> menu(new aura::Window(nullptr));
menu->SetType(ui::wm::WINDOW_TYPE_MENU);
menu->SetBounds(gfx::Rect(0, 0, 5, 10));
- EXPECT_EQ(menu->bounds().ToString(), "0,0 5x10");
+ EXPECT_EQ("0,0 5x10", menu->bounds().ToString());
parent->AddChild(menu.get());
- EXPECT_EQ(menu->bounds().ToString(), "0,0 5x10");
+ EXPECT_EQ("0,0 5x10", menu->bounds().ToString());
menu->SetBounds(gfx::Rect(0, 0, 100, 200));
- EXPECT_EQ(menu->bounds().ToString(), "0,0 100x200");
+ EXPECT_EQ("0,0 100x200", menu->bounds().ToString());
scoped_ptr<aura::Window> tooltip(new aura::Window(nullptr));
tooltip->SetType(ui::wm::WINDOW_TYPE_TOOLTIP);
tooltip->SetBounds(gfx::Rect(0, 0, 5, 10));
- EXPECT_EQ(tooltip->bounds().ToString(), "0,0 5x10");
+ EXPECT_EQ("0,0 5x10", tooltip->bounds().ToString());
parent->AddChild(tooltip.get());
- EXPECT_EQ(tooltip->bounds().ToString(), "0,0 5x10");
+ EXPECT_EQ("0,0 5x10", tooltip->bounds().ToString());
tooltip->SetBounds(gfx::Rect(0, 0, 100, 200));
- EXPECT_EQ(tooltip->bounds().ToString(), "0,0 100x200");
+ EXPECT_EQ("0,0 100x200", tooltip->bounds().ToString());
scoped_ptr<aura::Window> popup(new aura::Window(nullptr));
popup->SetType(ui::wm::WINDOW_TYPE_POPUP);
popup->SetBounds(gfx::Rect(0, 0, 5, 10));
- EXPECT_EQ(popup->bounds().ToString(), "0,0 5x10");
+ EXPECT_EQ("0,0 5x10", popup->bounds().ToString());
parent->AddChild(popup.get());
- EXPECT_EQ(popup->bounds().ToString(), "0,0 5x10");
+ EXPECT_EQ("0,0 5x10", popup->bounds().ToString());
popup->SetBounds(gfx::Rect(0, 0, 100, 200));
- EXPECT_EQ(popup->bounds().ToString(), "0,0 100x200");
+ EXPECT_EQ("0,0 100x200", popup->bounds().ToString());
+
+ // Frameless window is TYPE_POPUP, but some frameless window may want to be
+ // filled with the specific key.
+ scoped_ptr<aura::Window> frameless(new aura::Window(nullptr));
+ frameless->SetType(ui::wm::WINDOW_TYPE_POPUP);
+ frameless->SetBounds(gfx::Rect(0, 0, 5, 10));
+
+ EXPECT_EQ("0,0 5x10", frameless->bounds().ToString());
+
+ // Adding frameless to |parent|, then set the flag. This order respects
+ // the actual order of creating a views::Widget.
+ parent->AddChild(frameless.get());
+ FillLayoutManager::SetAlwaysFill(frameless.get());
+ frameless->Show();
+
+ EXPECT_EQ(parent->bounds().size().ToString(),
+ frameless->bounds().size().ToString());
+
+ frameless->SetBounds(gfx::Rect(0, 0, 10, 20));
+ EXPECT_EQ(parent->bounds().size().ToString(),
+ frameless->bounds().size().ToString());
}
} // namespace athena
diff --git a/athena/virtual_keyboard/virtual_keyboard_manager_impl.cc b/athena/virtual_keyboard/virtual_keyboard_manager_impl.cc
index 7acca11..abb0b3f 100644
--- a/athena/virtual_keyboard/virtual_keyboard_manager_impl.cc
+++ b/athena/virtual_keyboard/virtual_keyboard_manager_impl.cc
@@ -88,6 +88,7 @@ class VirtualKeyboardManagerImpl : public VirtualKeyboardManager {
// ResetInstance takes ownership.
keyboard::KeyboardController::ResetInstance(controller);
aura::Window* kb_container = controller->GetContainerWindow();
+ FillLayoutManager::SetAlwaysFill(kb_container);
container_->AddChild(kb_container);
kb_container->Show();
}