summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-21 15:09:13 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-21 15:10:36 +0000
commita105bc04f43ec8194b51796d4d59ec6dcec86acc (patch)
tree2b6e940644b005def4fc830d9b56652d918a0a02 /athena
parent935ae1dcbd5352a19ff292534adec4c792e0506f (diff)
downloadchromium_src-a105bc04f43ec8194b51796d4d59ec6dcec86acc.zip
chromium_src-a105bc04f43ec8194b51796d4d59ec6dcec86acc.tar.gz
chromium_src-a105bc04f43ec8194b51796d4d59ec6dcec86acc.tar.bz2
Make the minimized home card not overlap activities on Athena
BUG=402509 TEST=Manual, see bug NOTRY=true Review URL: https://codereview.chromium.org/465803002 Cr-Commit-Position: refs/heads/master@{#291072} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291072 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'athena')
-rw-r--r--athena/athena.gyp3
-rw-r--r--athena/home/home_card_impl.cc6
-rw-r--r--athena/main/athena_launcher.cc5
-rw-r--r--athena/main/athena_launcher.h4
-rw-r--r--athena/main/athena_main.cc33
-rw-r--r--athena/screen/public/screen_manager.h8
-rw-r--r--athena/screen/public/screen_manager_delegate.h27
-rw-r--r--athena/screen/screen_manager_impl.cc21
-rw-r--r--athena/test/athena_test_helper.cc5
-rw-r--r--athena/test/athena_test_helper.h2
-rw-r--r--athena/test/test_screen_manager_delegate.cc24
-rw-r--r--athena/test/test_screen_manager_delegate.h36
-rw-r--r--athena/wm/split_view_controller.cc6
-rw-r--r--athena/wm/window_manager_impl.cc15
14 files changed, 173 insertions, 22 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp
index 2ccd3b5..448ba4e 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -65,6 +65,7 @@
'screen/background_controller.cc',
'screen/background_controller.h',
'screen/public/screen_manager.h',
+ 'screen/public/screen_manager_delegate.h',
'screen/screen_accelerator_handler.cc',
'screen/screen_accelerator_handler.h',
'screen/screen_manager_impl.cc',
@@ -161,6 +162,8 @@
'test/sample_activity_factory.h',
'test/test_app_model_builder.cc',
'test/test_app_model_builder.h',
+ 'test/test_screen_manager_delegate.cc',
+ 'test/test_screen_manager_delegate.h',
],
},
{
diff --git a/athena/home/home_card_impl.cc b/athena/home/home_card_impl.cc
index 9a8526d..04b649a 100644
--- a/athena/home/home_card_impl.cc
+++ b/athena/home/home_card_impl.cc
@@ -519,6 +519,12 @@ void HomeCardImpl::Init() {
aura::client::GetActivationClient(container->GetRootWindow());
if (activation_client_)
activation_client_->AddObserver(this);
+
+ int work_area_bottom_inset =
+ GetBoundsForState(GetNativeWindow()->bounds(),
+ HomeCard::VISIBLE_MINIMIZED).height();
+ ScreenManager::Get()->SetWorkAreaInsets(
+ gfx::Insets(0, 0, work_area_bottom_inset, 0));
}
void HomeCardImpl::InstallAccelerators() {
diff --git a/athena/main/athena_launcher.cc b/athena/main/athena_launcher.cc
index 6932435..de4dbc7 100644
--- a/athena/main/athena_launcher.cc
+++ b/athena/main/athena_launcher.cc
@@ -91,7 +91,8 @@ class AthenaViewsDelegate : public views::ViewsDelegate {
DISALLOW_COPY_AND_ASSIGN(AthenaViewsDelegate);
};
-void StartAthenaEnv(aura::Window* root_window) {
+void StartAthenaEnv(aura::Window* root_window,
+ athena::ScreenManagerDelegate* delegate) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
// Force showing in the experimental app-list view.
@@ -116,7 +117,7 @@ void StartAthenaEnv(aura::Window* root_window) {
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE));
athena::InputManager::Create()->OnRootWindowCreated(root_window);
- athena::ScreenManager::Create(root_window);
+ athena::ScreenManager::Create(delegate, root_window);
athena::WindowManager::Create();
SetupBackgroundImage();
diff --git a/athena/main/athena_launcher.h b/athena/main/athena_launcher.h
index 8069927..66a853c 100644
--- a/athena/main/athena_launcher.h
+++ b/athena/main/athena_launcher.h
@@ -16,9 +16,11 @@ class BrowserContext;
namespace athena {
class ActivityFactory;
class AppModelBuilder;
+class ScreenManagerDelegate;
// Starts/shuts down the athena shell environment.
-void StartAthenaEnv(aura::Window* root_window);
+void StartAthenaEnv(aura::Window* root_window,
+ ScreenManagerDelegate* screen_manager_delegate);
void StartAthenaSessionWithContext(content::BrowserContext* context);
diff --git a/athena/main/athena_main.cc b/athena/main/athena_main.cc
index b4cde71..87982cc 100644
--- a/athena/main/athena_main.cc
+++ b/athena/main/athena_main.cc
@@ -6,6 +6,7 @@
#include "athena/main/athena_app_window_controller.h"
#include "athena/main/athena_launcher.h"
#include "athena/screen/public/screen_manager.h"
+#include "athena/screen/public/screen_manager_delegate.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -43,6 +44,28 @@ class AthenaDesktopController : public extensions::ShellDesktopController {
DISALLOW_COPY_AND_ASSIGN(AthenaDesktopController);
};
+class AthenaScreenManagerDelegate : public athena::ScreenManagerDelegate {
+ public:
+ explicit AthenaScreenManagerDelegate(
+ extensions::ShellDesktopController* controller)
+ : controller_(controller) {
+ }
+
+ virtual ~AthenaScreenManagerDelegate() {
+ }
+
+ private:
+ // athena::ScreenManagerDelegate:
+ virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE {
+ controller_->SetDisplayWorkAreaInsets(insets);
+ }
+
+ // Not owned.
+ extensions::ShellDesktopController* controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(AthenaScreenManagerDelegate);
+};
+
class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
public:
AthenaBrowserMainDelegate() {}
@@ -66,8 +89,12 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
extension_system->LoadApp(app_absolute_dir);
}
- athena::StartAthenaEnv(
- extensions::ShellDesktopController::instance()->host()->window());
+ extensions::ShellDesktopController* desktop_controller =
+ extensions::ShellDesktopController::instance();
+ screen_manager_delegate_.reset(
+ new AthenaScreenManagerDelegate(desktop_controller));
+ athena::StartAthenaEnv(desktop_controller->host()->window(),
+ screen_manager_delegate_.get());
athena::StartAthenaSessionWithContext(context);
}
@@ -85,6 +112,8 @@ class AthenaBrowserMainDelegate : public extensions::ShellBrowserMainDelegate {
}
private:
+ scoped_ptr<AthenaScreenManagerDelegate> screen_manager_delegate_;
+
DISALLOW_COPY_AND_ASSIGN(AthenaBrowserMainDelegate);
};
diff --git a/athena/screen/public/screen_manager.h b/athena/screen/public/screen_manager.h
index 64f9035..efaa7e8 100644
--- a/athena/screen/public/screen_manager.h
+++ b/athena/screen/public/screen_manager.h
@@ -16,6 +16,7 @@ class Window;
namespace gfx {
class ImageSkia;
+class Insets;
}
namespace ui {
@@ -27,6 +28,7 @@ class FocusRules;
}
namespace athena {
+class ScreenManagerDelegate;
// Mananges basic UI components on the screen such as background, and provide
// API for other UI components, such as window manager, home card, to
@@ -49,12 +51,16 @@ class ATHENA_EXPORT ScreenManager {
// Creates, returns and deletes the singleton object of the ScreenManager
// implementation.
- static ScreenManager* Create(aura::Window* root);
+ static ScreenManager* Create(ScreenManagerDelegate* delegate,
+ aura::Window* root);
static ScreenManager* Get();
static void Shutdown();
virtual ~ScreenManager() {}
+ // Sets the screen's work area insets.
+ virtual void SetWorkAreaInsets(const gfx::Insets& insets) = 0;
+
// Creates the container window that is used when creating a normal
// widget without specific parent.
virtual aura::Window* CreateDefaultContainer(
diff --git a/athena/screen/public/screen_manager_delegate.h b/athena/screen/public/screen_manager_delegate.h
new file mode 100644
index 0000000..dab259546
--- /dev/null
+++ b/athena/screen/public/screen_manager_delegate.h
@@ -0,0 +1,27 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATHENA_SCREEN_PUBLIC_SCREEN_MANAGER_DELEGATE_H_
+#define ATHENA_SCREEN_PUBLIC_SCREEN_MANAGER_DELEGATE_H_
+
+#include "athena/athena_export.h"
+
+namespace gfx {
+class Insets;
+}
+
+namespace athena {
+
+// Delegate of the ScreenManager.
+class ATHENA_EXPORT ScreenManagerDelegate {
+ public:
+ virtual ~ScreenManagerDelegate() {}
+
+ // Sets the screen's work area insets.
+ virtual void SetWorkAreaInsets(const gfx::Insets& insets) = 0;
+};
+
+} // namespace athena
+
+#endif // ATHENA_SCREEN_PUBLIC_SCREEN_MANAGER_DELEGATE_H_
diff --git a/athena/screen/screen_manager_impl.cc b/athena/screen/screen_manager_impl.cc
index 3877e41..166055c 100644
--- a/athena/screen/screen_manager_impl.cc
+++ b/athena/screen/screen_manager_impl.cc
@@ -8,6 +8,7 @@
#include "athena/common/fill_layout_manager.h"
#include "athena/input/public/accelerator_manager.h"
#include "athena/screen/background_controller.h"
+#include "athena/screen/public/screen_manager_delegate.h"
#include "athena/screen/screen_accelerator_handler.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -191,13 +192,14 @@ class AthenaEventTargeter : public aura::WindowTargeter,
class ScreenManagerImpl : public ScreenManager {
public:
- explicit ScreenManagerImpl(aura::Window* root_window);
+ ScreenManagerImpl(ScreenManagerDelegate* delegate, aura::Window* root_window);
virtual ~ScreenManagerImpl();
void Init();
private:
// ScreenManager:
+ virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE;
virtual aura::Window* CreateDefaultContainer(
const ContainerParams& params) OVERRIDE;
virtual aura::Window* CreateContainer(const ContainerParams& params) OVERRIDE;
@@ -206,6 +208,8 @@ class ScreenManagerImpl : public ScreenManager {
virtual void SetRotation(gfx::Display::Rotation rotation) OVERRIDE;
virtual ui::LayerAnimator* GetScreenAnimator() OVERRIDE;
+ // Not owned.
+ ScreenManagerDelegate* delegate_;
aura::Window* root_window_;
aura::Window* background_window_;
@@ -218,8 +222,10 @@ class ScreenManagerImpl : public ScreenManager {
DISALLOW_COPY_AND_ASSIGN(ScreenManagerImpl);
};
-ScreenManagerImpl::ScreenManagerImpl(aura::Window* root_window)
- : root_window_(root_window) {
+ScreenManagerImpl::ScreenManagerImpl(ScreenManagerDelegate* delegate,
+ aura::Window* root_window)
+ : delegate_(delegate),
+ root_window_(root_window) {
DCHECK(root_window_);
DCHECK(!instance);
instance = this;
@@ -245,6 +251,10 @@ void ScreenManagerImpl::Init() {
accelerator_handler_.reset(new ScreenAcceleratorHandler(root_window_));
}
+void ScreenManagerImpl::SetWorkAreaInsets(const gfx::Insets& insets) {
+ delegate_->SetWorkAreaInsets(insets);
+}
+
aura::Window* ScreenManagerImpl::CreateDefaultContainer(
const ContainerParams& params) {
aura::Window* container = CreateContainer(params);
@@ -355,8 +365,9 @@ ScreenManager::ContainerParams::ContainerParams(const std::string& n,
}
// static
-ScreenManager* ScreenManager::Create(aura::Window* root_window) {
- (new ScreenManagerImpl(root_window))->Init();
+ScreenManager* ScreenManager::Create(ScreenManagerDelegate* delegate,
+ aura::Window* root_window) {
+ (new ScreenManagerImpl(delegate, root_window))->Init();
DCHECK(instance);
return instance;
}
diff --git a/athena/test/athena_test_helper.cc b/athena/test/athena_test_helper.cc
index f8916a1..6a9121a 100644
--- a/athena/test/athena_test_helper.cc
+++ b/athena/test/athena_test_helper.cc
@@ -8,6 +8,7 @@
#include "athena/screen/public/screen_manager.h"
#include "athena/test/sample_activity_factory.h"
#include "athena/test/test_app_model_builder.h"
+#include "athena/test/test_screen_manager_delegate.h"
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
@@ -70,6 +71,8 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
test_screen_.reset(aura::TestScreen::Create(host_size));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
host_.reset(test_screen_->CreateHostForPrimaryDisplay());
+ screen_manager_delegate_.reset(
+ new TestScreenManagerDelegate(test_screen_.get()));
input_method_filter_.reset(new ::wm::InputMethodEventFilter(
root_window()->GetHost()->GetAcceleratedWidget()));
@@ -87,7 +90,7 @@ void AthenaTestHelper::SetUp(ui::ContextFactory* context_factory) {
// Ensure width != height so tests won't confuse them.
host()->SetBounds(gfx::Rect(host_size));
- athena::StartAthenaEnv(root_window());
+ athena::StartAthenaEnv(root_window(), screen_manager_delegate_.get());
athena::StartAthenaSession(new SampleActivityFactory(),
new TestAppModelBuilder());
}
diff --git a/athena/test/athena_test_helper.h b/athena/test/athena_test_helper.h
index 7b7a2a0..a2bff53 100644
--- a/athena/test/athena_test_helper.h
+++ b/athena/test/athena_test_helper.h
@@ -33,6 +33,7 @@ class InputMethodEventFilter;
namespace athena {
namespace test {
+class TestScreenManagerDelegate;
// A helper class owned by tests that does common initialization required for
// Athena use. This class creates a root window with clients and other objects
@@ -63,6 +64,7 @@ class AthenaTestHelper {
scoped_ptr<aura::WindowTreeHost> host_;
scoped_ptr<aura::TestScreen> test_screen_;
+ scoped_ptr<TestScreenManagerDelegate> screen_manager_delegate_;
scoped_ptr<aura::client::FocusClient> focus_client_;
scoped_ptr< ::wm::InputMethodEventFilter> input_method_filter_;
scoped_ptr<ui::ScopedAnimationDurationScaleMode> zero_duration_mode_;
diff --git a/athena/test/test_screen_manager_delegate.cc b/athena/test/test_screen_manager_delegate.cc
new file mode 100644
index 0000000..b3d9916
--- /dev/null
+++ b/athena/test/test_screen_manager_delegate.cc
@@ -0,0 +1,24 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/test/test_screen_manager_delegate.h"
+
+#include "ui/aura/test/test_screen.h"
+
+namespace athena {
+namespace test {
+
+TestScreenManagerDelegate::TestScreenManagerDelegate(aura::TestScreen* screen)
+ : screen_(screen) {
+}
+
+TestScreenManagerDelegate::~TestScreenManagerDelegate() {
+}
+
+void TestScreenManagerDelegate::SetWorkAreaInsets(const gfx::Insets& insets) {
+ screen_->SetWorkAreaInsets(insets);
+}
+
+} // namespace test
+} // namespace athena
diff --git a/athena/test/test_screen_manager_delegate.h b/athena/test/test_screen_manager_delegate.h
new file mode 100644
index 0000000..9b7a146
--- /dev/null
+++ b/athena/test/test_screen_manager_delegate.h
@@ -0,0 +1,36 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ATHENA_TEST_TEST_SCREEN_MANAGER_DELEGATE_H_
+#define ATHENA_TEST_TEST_SCREEN_MANAGER_DELEGATE_H_
+
+#include "athena/screen/public/screen_manager_delegate.h"
+#include "base/macros.h"
+
+namespace aura {
+class TestScreen;
+}
+
+namespace athena {
+namespace test {
+
+class TestScreenManagerDelegate : public ScreenManagerDelegate {
+ public:
+ explicit TestScreenManagerDelegate(aura::TestScreen* screen);
+ virtual ~TestScreenManagerDelegate();
+
+ private:
+ // ScreenManagerDelegate:
+ virtual void SetWorkAreaInsets(const gfx::Insets& insets) OVERRIDE;
+
+ // Not owned.
+ aura::TestScreen* screen_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestScreenManagerDelegate);
+};
+
+} // namespace test
+} // namespace athena
+
+#endif // ATHENA_TEST_TEST_SCREEN_MANAGER_DELEGATE_H_
diff --git a/athena/wm/split_view_controller.cc b/athena/wm/split_view_controller.cc
index cf39f2e..6e4a1c3 100644
--- a/athena/wm/split_view_controller.cc
+++ b/athena/wm/split_view_controller.cc
@@ -168,9 +168,9 @@ void SplitViewController::OnAnimationCompleted(aura::Window* window) {
return;
DCHECK(window == left_window_ || window == right_window_);
if (state_ == ACTIVE) {
- gfx::Rect window_bounds = gfx::Rect(container_->bounds().size());
- int container_width = window_bounds.width();
- window_bounds.set_width(container_width / 2);
+ int container_width = container_->bounds().width();
+ gfx::Display display = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
+ gfx::Rect window_bounds(container_width / 2, display.work_area().height());
window->SetTransform(gfx::Transform());
if (window == left_window_) {
left_window_->SetBounds(window_bounds);
diff --git a/athena/wm/window_manager_impl.cc b/athena/wm/window_manager_impl.cc
index 857256d..638ea88 100644
--- a/athena/wm/window_manager_impl.cc
+++ b/athena/wm/window_manager_impl.cc
@@ -101,13 +101,14 @@ void AthenaContainerLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
aura::Window::Windows list = instance->window_list_provider_->GetWindowList();
if (std::find(list.begin(), list.end(), child) == list.end())
return;
- aura::Window* window = NULL;
- if (instance->split_view_controller_->IsSplitViewModeActive())
- window = instance->split_view_controller_->left_window();
- else
- window = instance->container_.get();
- CHECK(window);
- child->SetBounds(gfx::Rect(window->bounds().size()));
+ gfx::Size size;
+ if (instance->split_view_controller_->IsSplitViewModeActive()) {
+ size = instance->split_view_controller_->left_window()->bounds().size();
+ } else {
+ size =
+ gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area().size();
+ }
+ child->SetBounds(gfx::Rect(size));
}
void AthenaContainerLayoutManager::OnWillRemoveWindowFromLayout(