diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-13 21:09:17 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-13 21:09:17 +0000 |
commit | 1a2145b860591d2e868ab98147ea4f162636d7eb (patch) | |
tree | 26a65524e4698ffc4b76eeb3409bbd0fca2ae238 | |
parent | 73238e09cc56e8b1b599ec978bec7bdd7a7730a8 (diff) | |
download | chromium_src-1a2145b860591d2e868ab98147ea4f162636d7eb.zip chromium_src-1a2145b860591d2e868ab98147ea4f162636d7eb.tar.gz chromium_src-1a2145b860591d2e868ab98147ea4f162636d7eb.tar.bz2 |
Recommit r125950, which was reverted by r125958 due to link failures on win_aura bot.
Aura/Ash split: Move ScreenAura to aura::RootWindowScreen.
What is now aura::RootWindowScreen was tightly bundled with aura::RootWindow. Instead of moving it to ash::ScreenAsh, I renamed it aurea::RootWindowScreen because there's a bunch of unit tests that use RootWindow as if it were the desktop. Screen integration stuff has been moved out of RootWindow (and related observers) and into ash::Shell.
BUG=116458
First Review URL: http://codereview.chromium.org/9616045
Review URL: http://codereview.chromium.org/9696008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126464 0039d316-1c4b-4281-b951-d872f2087c98
32 files changed, 253 insertions, 83 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index e9fdd49..cda2082 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -99,6 +99,8 @@ 'launcher/view_model.h', 'launcher/view_model_utils.cc', 'launcher/view_model_utils.h', + 'screen_ash.cc', + 'screen_ash.h', 'screenshot_delegate.h', 'shell.cc', 'shell.h', diff --git a/ui/aura/screen_aura.cc b/ash/screen_ash.cc index 27e070e..bbdf9e8 100644 --- a/ui/aura/screen_aura.cc +++ b/ash/screen_ash.cc @@ -2,65 +2,66 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ui/aura/screen_aura.h" +#include "ash/screen_ash.h" #include "base/logging.h" #include "ui/aura/root_window.h" #include "ui/aura/window.h" #include "ui/gfx/native_widget_types.h" -namespace aura { +namespace ash { -ScreenAura::ScreenAura(RootWindow* root_window) : root_window_(root_window) { +ScreenAsh::ScreenAsh(aura::RootWindow* root_window) + : root_window_(root_window) { } -ScreenAura::~ScreenAura() { +ScreenAsh::~ScreenAsh() { } -gfx::Point ScreenAura::GetCursorScreenPointImpl() { +gfx::Point ScreenAsh::GetCursorScreenPointImpl() { return root_window_->last_mouse_location(); } -gfx::Rect ScreenAura::GetMonitorWorkAreaNearestWindowImpl( +gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestWindowImpl( gfx::NativeWindow window) { return GetWorkAreaBounds(); } -gfx::Rect ScreenAura::GetMonitorAreaNearestWindowImpl( +gfx::Rect ScreenAsh::GetMonitorAreaNearestWindowImpl( gfx::NativeWindow window) { return GetBounds(); } -gfx::Rect ScreenAura::GetMonitorWorkAreaNearestPointImpl( +gfx::Rect ScreenAsh::GetMonitorWorkAreaNearestPointImpl( const gfx::Point& point) { return GetWorkAreaBounds(); } -gfx::Rect ScreenAura::GetMonitorAreaNearestPointImpl(const gfx::Point& point) { +gfx::Rect ScreenAsh::GetMonitorAreaNearestPointImpl(const gfx::Point& point) { return GetBounds(); } -gfx::NativeWindow ScreenAura::GetWindowAtCursorScreenPointImpl() { +gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPointImpl() { const gfx::Point point = GetCursorScreenPoint(); return root_window_->GetTopWindowContainingPoint(point); } -gfx::Rect ScreenAura::GetBounds() { +gfx::Rect ScreenAsh::GetBounds() { return gfx::Rect(root_window_->bounds().size()); } -gfx::Rect ScreenAura::GetWorkAreaBounds() { +gfx::Rect ScreenAsh::GetWorkAreaBounds() { gfx::Rect bounds(GetBounds()); bounds.Inset(work_area_insets_); return bounds; } -gfx::Size ScreenAura::GetPrimaryMonitorSizeImpl() { +gfx::Size ScreenAsh::GetPrimaryMonitorSizeImpl() { return GetMonitorWorkAreaNearestPoint(gfx::Point()).size(); } -int ScreenAura::GetNumMonitorsImpl() { +int ScreenAsh::GetNumMonitorsImpl() { return 1; } -} // namespace aura +} // namespace ash diff --git a/ui/aura/screen_aura.h b/ash/screen_ash.h index ee1540d..deaa76f 100644 --- a/ui/aura/screen_aura.h +++ b/ash/screen_ash.h @@ -1,26 +1,28 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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 UI_AURA_SCREEN_AURA_H_ -#define UI_AURA_SCREEN_AURA_H_ +#ifndef ASH_SCREEN_ASH_H_ +#define ASH_SCREEN_ASH_H_ #pragma once #include "base/compiler_specific.h" -#include "ui/aura/aura_export.h" +#include "ash/ash_export.h" #include "ui/gfx/insets.h" #include "ui/gfx/screen.h" namespace aura { - class RootWindow; +} + +namespace ash { // Aura implementation of gfx::Screen. Implemented here to avoid circular // dependencies. -class AURA_EXPORT ScreenAura : public gfx::Screen { +class ASH_EXPORT ScreenAsh : public gfx::Screen { public: - explicit ScreenAura(RootWindow* root_window); - virtual ~ScreenAura(); + explicit ScreenAsh(aura::RootWindow* root_window); + virtual ~ScreenAsh(); void set_work_area_insets(const gfx::Insets& insets) { work_area_insets_ = insets; @@ -50,11 +52,11 @@ class AURA_EXPORT ScreenAura : public gfx::Screen { // Insets for the work area. gfx::Insets work_area_insets_; - RootWindow* root_window_; + aura::RootWindow* root_window_; - DISALLOW_COPY_AND_ASSIGN(ScreenAura); + DISALLOW_COPY_AND_ASSIGN(ScreenAsh); }; -} // namespace aura +} // namespace ash -#endif // UI_AURA_SCREEN_AURA_H_ +#endif // ASH_SCREEN_ASH_H_ diff --git a/ash/shell.cc b/ash/shell.cc index ae5ffab6..ad8f835 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -12,6 +12,7 @@ #include "ash/focus_cycler.h" #include "ash/ime/input_method_event_filter.h" #include "ash/launcher/launcher.h" +#include "ash/screen_ash.h" #include "ash/shell_delegate.h" #include "ash/shell_factory.h" #include "ash/shell_window_ids.h" @@ -306,6 +307,7 @@ internal::WorkspaceController* Shell::TestApi::workspace_controller() { Shell::Shell(ShellDelegate* delegate) : root_window_(new aura::RootWindow), + screen_(new ScreenAsh(root_window_.get())), root_filter_(NULL), delegate_(delegate), audio_controller_(NULL), @@ -316,6 +318,7 @@ Shell::Shell(ShellDelegate* delegate) desktop_background_mode_(BACKGROUND_IMAGE), root_window_layout_(NULL), status_widget_(NULL) { + gfx::Screen::SetInstance(screen_); } Shell::~Shell() { @@ -597,6 +600,22 @@ void Shell::RotateFocus(Direction direction) { internal::FocusCycler::BACKWARD); } +void Shell::SetScreenWorkAreaInsets(const gfx::Insets& insets) { + if (screen_->work_area_insets() == insets) + return; + screen_->set_work_area_insets(insets); + FOR_EACH_OBSERVER(ShellObserver, observers_, + OnScreenWorkAreaInsetsChanged()); +} + +void Shell::AddShellObserver(ShellObserver* observer) { + observers_.AddObserver(observer); +} + +void Shell::RemoveShellObserver(ShellObserver* observer) { + observers_.RemoveObserver(observer); +} + //////////////////////////////////////////////////////////////////////////////// // Shell, private: diff --git a/ash/shell.h b/ash/shell.h index 92910ce..e6af0db 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -14,7 +14,9 @@ #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" +#include "base/observer_list.h" #include "ui/gfx/size.h" +#include "ui/gfx/insets.h" class CommandLine; @@ -45,7 +47,9 @@ class NestedDispatcherController; class NetworkController; class PowerButtonController; class PowerStatusController; +class ScreenAsh; class ShellDelegate; +class ShellObserver; class SystemTrayDelegate; class SystemTray; class VideoDetector; @@ -152,6 +156,13 @@ class ASH_EXPORT Shell { // Rotate focus through containers that can receive focus. void RotateFocus(Direction direction); + // Sets the screen's work area insets, this notifies observers too. + void SetScreenWorkAreaInsets(const gfx::Insets& insets); + + // Add/remove observer. + void AddShellObserver(ShellObserver* observer); + void RemoveShellObserver(ShellObserver* observer); + #if !defined(OS_MACOSX) AcceleratorController* accelerator_controller() { return accelerator_controller_.get(); @@ -197,6 +208,8 @@ class ASH_EXPORT Shell { Launcher* launcher() { return launcher_.get(); } + const ScreenAsh* screen() { return screen_; } + internal::ShelfLayoutManager* shelf() const { return shelf_; } SystemTray* tray() const { return tray_.get(); } @@ -234,6 +247,7 @@ class ASH_EXPORT Shell { static bool initially_hide_cursor_; scoped_ptr<aura::RootWindow> root_window_; + ScreenAsh* screen_; internal::RootWindowEventFilter* root_filter_; // not owned @@ -288,6 +302,8 @@ class ASH_EXPORT Shell { // the status area. internal::ShelfLayoutManager* shelf_; + ObserverList<ShellObserver> observers_; + // Can change at runtime. BackgroundMode desktop_background_mode_; diff --git a/ash/shell_observer.h b/ash/shell_observer.h new file mode 100644 index 0000000..0ecf927 --- /dev/null +++ b/ash/shell_observer.h @@ -0,0 +1,24 @@ +// Copyright (c) 2012 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 ASH_SHELLOBSERVER_H_ +#define ASH_SHELLOBSERVER_H_ +#pragma once + +#include "ash/ash_export.h" + +namespace ash { + +class ASH_EXPORT ShellObserver { + public: + // Invoked after the screen's work area insets changes. + virtual void OnScreenWorkAreaInsetsChanged() {} + + protected: + virtual ~ShellObserver() {} +}; + +} // namespace ash + +#endif // ASH_SHELLOBSERVER_H_ diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc index 7fc116d..6a5e5e4 100644 --- a/ash/wm/base_layout_manager.cc +++ b/ash/wm/base_layout_manager.cc @@ -20,6 +20,7 @@ namespace internal { // BaseLayoutManager, public: BaseLayoutManager::BaseLayoutManager() { + Shell::GetInstance()->AddShellObserver(this); Shell::GetRootWindow()->AddRootWindowObserver(this); } @@ -27,6 +28,7 @@ BaseLayoutManager::~BaseLayoutManager() { for (WindowSet::const_iterator i = windows_.begin(); i != windows_.end(); ++i) (*i)->RemoveObserver(this); Shell::GetRootWindow()->RemoveRootWindowObserver(this); + Shell::GetInstance()->RemoveShellObserver(this); } ///////////////////////////////////////////////////////////////////////////// @@ -70,6 +72,9 @@ void BaseLayoutManager::OnRootWindowResized(const gfx::Size& new_size) { AdjustWindowSizesForScreenChange(); } +///////////////////////////////////////////////////////////////////////////// +// BaseLayoutManager, ash::ShellObserver overrides: + void BaseLayoutManager::OnScreenWorkAreaInsetsChanged() { AdjustWindowSizesForScreenChange(); } diff --git a/ash/wm/base_layout_manager.h b/ash/wm/base_layout_manager.h index 79fd1fe..df858c8 100644 --- a/ash/wm/base_layout_manager.h +++ b/ash/wm/base_layout_manager.h @@ -9,6 +9,7 @@ #include <set> #include "ash/ash_export.h" +#include "ash/shell_observer.h" #include "base/basictypes.h" #include "base/compiler_specific.h" #include "ui/aura/layout_manager.h" @@ -29,6 +30,7 @@ namespace internal { // properly. class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, public aura::RootWindowObserver, + public ash::ShellObserver, public aura::WindowObserver { public: typedef std::set<aura::Window*> WindowSet; @@ -49,6 +51,8 @@ class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, // RootWindowObserver overrides: virtual void OnRootWindowResized(const gfx::Size& new_size) OVERRIDE; + + // ash::ShellObserver overrides: virtual void OnScreenWorkAreaInsetsChanged() OVERRIDE; // WindowObserver overrides: diff --git a/ash/wm/base_layout_manager_unittest.cc b/ash/wm/base_layout_manager_unittest.cc index b6e4901..f8045a4 100644 --- a/ash/wm/base_layout_manager_unittest.cc +++ b/ash/wm/base_layout_manager_unittest.cc @@ -4,6 +4,7 @@ #include "ash/wm/base_layout_manager.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" @@ -11,7 +12,6 @@ #include "base/compiler_specific.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/test/test_windows.h" #include "ui/base/ui_base_types.h" #include "ui/aura/window.h" @@ -27,7 +27,7 @@ class BaseLayoutManagerTest : public test::AshTestBase { virtual void SetUp() OVERRIDE { test::AshTestBase::SetUp(); - Shell::GetRootWindow()->SetScreenWorkAreaInsets( + Shell::GetInstance()->SetScreenWorkAreaInsets( gfx::Insets(1, 2, 3, 4)); Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); aura::Window* default_container = Shell::GetInstance()->GetContainer( diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index 6b37e3f..eca4c40c 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -5,10 +5,10 @@ #include "ash/wm/shelf_layout_manager.h" #include "ash/launcher/launcher.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "base/auto_reset.h" #include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" #include "ui/gfx/compositor/layer.h" #include "ui/gfx/compositor/layer_animation_observer.h" #include "ui/gfx/compositor/layer_animator.h" @@ -43,7 +43,7 @@ ShelfLayoutManager::ShelfLayoutManager(views::Widget* launcher, ShelfLayoutManager::~ShelfLayoutManager() { // Without a shelf we don't need special insets anymore. - Shell::GetRootWindow()->SetScreenWorkAreaInsets(gfx::Insets()); + Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets()); } void ShelfLayoutManager::LayoutShelf() { @@ -58,7 +58,7 @@ void ShelfLayoutManager::LayoutShelf() { status_->SetBounds(target_bounds.status_bounds); Shell::GetInstance()->launcher()->SetStatusWidth( target_bounds.status_bounds.width()); - Shell::GetRootWindow()->SetScreenWorkAreaInsets( + Shell::GetInstance()->SetScreenWorkAreaInsets( target_bounds.work_area_insets); } @@ -150,7 +150,7 @@ void ShelfLayoutManager::CalculateTargetBounds(bool visible, void ShelfLayoutManager::OnImplicitAnimationsCompleted() { TargetBounds target_bounds; CalculateTargetBounds(visible_, &target_bounds); - Shell::GetRootWindow()->SetScreenWorkAreaInsets( + Shell::GetInstance()->SetScreenWorkAreaInsets( target_bounds.work_area_insets); } diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc index 8a83cb0..fbf924d 100644 --- a/ash/wm/shelf_layout_manager_unittest.cc +++ b/ash/wm/shelf_layout_manager_unittest.cc @@ -5,11 +5,11 @@ #include "ash/wm/shelf_layout_manager.h" #include "ash/launcher/launcher.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" #include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/window.h" #include "ui/base/animation/animation_container_element.h" #include "ui/gfx/compositor/layer_animator.h" @@ -51,7 +51,7 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { shelf->LayoutShelf(); ASSERT_TRUE(shelf->visible()); - const aura::ScreenAura* screen = Shell::GetRootWindow()->screen(); + const ash::ScreenAsh* screen = Shell::GetInstance()->screen(); ASSERT_TRUE(screen); // Bottom inset should be the max of widget heights. EXPECT_EQ(shelf->max_height(), screen->work_area_insets().bottom()); @@ -96,7 +96,7 @@ TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { shelf->LayoutShelf(); ASSERT_TRUE(shelf->visible()); - const aura::ScreenAura* screen = Shell::GetRootWindow()->screen(); + const ash::ScreenAsh* screen = Shell::GetInstance()->screen(); // Hide the shelf. shelf->SetVisible(false); diff --git a/ash/wm/toplevel_layout_manager_unittest.cc b/ash/wm/toplevel_layout_manager_unittest.cc index 246c835..dff916a 100644 --- a/ash/wm/toplevel_layout_manager_unittest.cc +++ b/ash/wm/toplevel_layout_manager_unittest.cc @@ -4,6 +4,7 @@ #include "ash/wm/toplevel_layout_manager.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" @@ -12,7 +13,6 @@ #include "base/compiler_specific.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/test/test_windows.h" #include "ui/base/ui_base_types.h" #include "ui/aura/window.h" @@ -33,7 +33,7 @@ class ToplevelLayoutManagerTest : public test::AshTestBase { virtual void SetUp() OVERRIDE { test::AshTestBase::SetUp(); - Shell::GetRootWindow()->SetScreenWorkAreaInsets( + Shell::GetInstance()->SetScreenWorkAreaInsets( gfx::Insets(1, 2, 3, 4)); Shell::GetRootWindow()->SetHostSize(gfx::Size(800, 600)); aura::Window* default_container = Shell::GetInstance()->GetContainer( @@ -105,16 +105,14 @@ TEST_F(ToplevelLayoutManagerTest, ResizeMaximizedWindowOnWorkAreaInsetsChange) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); - Shell::GetRootWindow()->SetScreenWorkAreaInsets( - gfx::Insets(0, 0, 30, 0)); + Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets(0, 0, 30, 0)); window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); // Maximized window fills the work area. EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), window->bounds()); // Change work area insets. - Shell::GetRootWindow()->SetScreenWorkAreaInsets( - gfx::Insets(0, 0, 60, 0)); + Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets(0, 0, 60, 0)); // Maximized window fills the changed work area. EXPECT_EQ(gfx::Screen::GetMonitorWorkAreaNearestWindow(window.get()), window->bounds()); diff --git a/ash/wm/workspace/workspace_event_filter.cc b/ash/wm/workspace/workspace_event_filter.cc index 84046b9..786c1c5 100644 --- a/ash/wm/workspace/workspace_event_filter.cc +++ b/ash/wm/workspace/workspace_event_filter.cc @@ -4,6 +4,7 @@ #include "ash/wm/workspace/workspace_event_filter.h" +#include "ash/screen_ash.h" #include "ash/wm/property_util.h" #include "ash/wm/window_frame.h" #include "ash/wm/window_util.h" @@ -11,7 +12,6 @@ #include "ash/wm/workspace/workspace_window_resizer.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/event.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" #include "ui/base/hit_test.h" diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc index 52c50c4..b984493 100644 --- a/ash/wm/workspace/workspace_layout_manager.cc +++ b/ash/wm/workspace/workspace_layout_manager.cc @@ -4,6 +4,7 @@ #include "ash/wm/workspace/workspace_layout_manager.h" +#include "ash/screen_ash.h" #include "ash/wm/property_util.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace/workspace.h" @@ -12,7 +13,6 @@ #include "ui/aura/client/aura_constants.h" #include "ui/aura/event.h" #include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/window.h" #include "ui/aura/window_observer.h" #include "ui/base/ui_base_types.h" diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc index caf7d93..1aaa8d0 100644 --- a/ash/wm/workspace/workspace_manager.cc +++ b/ash/wm/workspace/workspace_manager.cc @@ -6,6 +6,7 @@ #include <algorithm> +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/wm/property_util.h" #include "ash/wm/shelf_layout_manager.h" @@ -19,7 +20,6 @@ #include "base/stl_util.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/window.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/compositor/layer.h" @@ -288,7 +288,7 @@ void WorkspaceManager::SetActiveWorkspace(Workspace* workspace) { gfx::Rect WorkspaceManager::GetWorkAreaBounds() { gfx::Rect bounds(workspace_size_); - bounds.Inset(Shell::GetRootWindow()->screen()->work_area_insets()); + bounds.Inset(Shell::GetInstance()->screen()->work_area_insets()); return bounds; } diff --git a/ash/wm/workspace/workspace_manager_unittest.cc b/ash/wm/workspace/workspace_manager_unittest.cc index a9312ca..20fa704 100644 --- a/ash/wm/workspace/workspace_manager_unittest.cc +++ b/ash/wm/workspace/workspace_manager_unittest.cc @@ -4,6 +4,7 @@ #include "ash/wm/workspace/workspace_manager.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" @@ -15,7 +16,6 @@ #include "ash/wm/workspace/workspace_layout_manager.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/window.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/screen.h" @@ -174,7 +174,7 @@ TEST_F(WorkspaceManagerTest, ResizeMaximizedWindowOnWorkAreaInsetsChange) { EXPECT_EQ(251, w1->bounds().height()); // Maximize the window. - Shell::GetRootWindow()->SetScreenWorkAreaInsets( + Shell::GetInstance()->SetScreenWorkAreaInsets( gfx::Insets(0, 0, 30, 0)); w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); @@ -187,7 +187,7 @@ TEST_F(WorkspaceManagerTest, ResizeMaximizedWindowOnWorkAreaInsetsChange) { EXPECT_EQ(GetWorkAreaBounds().height(), w1->bounds().height()); // Change work area insets. - Shell::GetRootWindow()->SetScreenWorkAreaInsets( + Shell::GetInstance()->SetScreenWorkAreaInsets( gfx::Insets(0, 0, 60, 0)); // Should be 1 workspace, TYPE_MAXIMIZED with w1, fills the changed work diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc index 83b5770..f26460a 100644 --- a/ash/wm/workspace/workspace_window_resizer_unittest.cc +++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc @@ -4,12 +4,12 @@ #include "ash/wm/workspace/workspace_window_resizer.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/wm/property_util.h" #include "base/string_number_conversions.h" #include "ui/aura/root_window.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/test/test_window_delegate.h" #include "ui/base/hit_test.h" @@ -52,7 +52,7 @@ class WorkspaceWindowResizerTest : public test::AshTestBase { root->SetBounds(gfx::Rect(0, 0, 800, kRootHeight)); gfx::Rect root_bounds(root->bounds()); EXPECT_EQ(kRootHeight, root_bounds.height()); - root->SetScreenWorkAreaInsets(gfx::Insets()); + Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets()); window_.reset(new aura::Window(&delegate_)); window_->Init(ui::Layer::LAYER_NOT_DRAWN); window_->SetParent(Shell::GetInstance()->GetRootWindow()); @@ -547,7 +547,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2_REMEMBER) { TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { aura::RootWindow* root = Shell::GetInstance()->GetRootWindow(); root->SetBounds(gfx::Rect(0, 0, 600, 800)); - root->SetScreenWorkAreaInsets(gfx::Insets()); + Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets()); window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); @@ -589,7 +589,7 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_RememberHeight) { aura::RootWindow* root = Shell::GetInstance()->GetRootWindow(); root->SetBounds(gfx::Rect(0, 0, 600, 800)); - root->SetScreenWorkAreaInsets(gfx::Insets()); + Shell::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets()); window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); diff --git a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc index 24acc13..a6cca5b 100644 --- a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc +++ b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc @@ -26,6 +26,7 @@ #if defined(USE_AURA) #include "ui/aura/root_window.h" +#include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" #endif @@ -125,6 +126,7 @@ class AccessibilityEventRouterViewsTest views::ViewsDelegate::views_delegate = new AccessibilityViewsDelegate(); #if defined(USE_AURA) root_window_.reset(new aura::RootWindow); + gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); test_stacking_client_.reset( new aura::test::TestStackingClient(root_window_.get())); #endif diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc index 209f884..2538644 100644 --- a/chrome/test/base/browser_with_test_window_test.cc +++ b/chrome/test/base/browser_with_test_window_test.cc @@ -22,6 +22,7 @@ #if defined(USE_AURA) #include "ui/aura/root_window.h" #include "ui/aura/test/test_activation_client.h" +#include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" #endif @@ -50,6 +51,7 @@ void BrowserWithTestWindowTest::SetUp() { browser_->SetWindowForTesting(window_.get()); #if defined(USE_AURA) root_window_.reset(new aura::RootWindow); + gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); test_activation_client_.reset( new aura::test::TestActivationClient(root_window_.get())); test_stacking_client_.reset( diff --git a/content/test/test_renderer_host.cc b/content/test/test_renderer_host.cc index b37dd1c..14293b7 100644 --- a/content/test/test_renderer_host.cc +++ b/content/test/test_renderer_host.cc @@ -14,6 +14,7 @@ #if defined(USE_AURA) #include "ui/aura/root_window.h" +#include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" #endif @@ -181,6 +182,7 @@ void RenderViewHostTestHarness::Reload() { void RenderViewHostTestHarness::SetUp() { #if defined(USE_AURA) root_window_.reset(new aura::RootWindow); + gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); test_stacking_client_.reset( new aura::test::TestStackingClient(root_window_.get())); #endif diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index bc89200..fafb0f0 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -86,8 +86,6 @@ 'root_window_view_mac.mm', 'root_window.cc', 'root_window.h', - 'screen_aura.cc', - 'screen_aura.h', 'window.cc', 'window.h', 'window_delegate.h', @@ -125,6 +123,8 @@ 'test/test_activation_client.h', 'test/test_event_filter.cc', 'test/test_event_filter.h', + 'test/test_screen.cc', + 'test/test_screen.h', 'test/test_stacking_client.cc', 'test/test_stacking_client.h', 'test/test_windows.cc', diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index 3e84db1..f4db009 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -22,7 +22,6 @@ #include "ui/aura/event_filter.h" #include "ui/aura/focus_manager.h" #include "ui/aura/gestures/gesture_recognizer.h" -#include "ui/aura/screen_aura.h" #include "ui/aura/window.h" #include "ui/aura/window_delegate.h" #include "ui/base/hit_test.h" @@ -91,7 +90,6 @@ RootWindow::RootWindow() mouse_button_flags_(0), last_cursor_(kCursorNull), cursor_shown_(true), - ALLOW_THIS_IN_INITIALIZER_LIST(screen_(new ScreenAura(this))), capture_window_(NULL), mouse_pressed_handler_(NULL), mouse_moved_handler_(NULL), @@ -108,7 +106,6 @@ RootWindow::RootWindow() should_hold_mouse_moves_(false), release_mouse_moves_after_draw_(false) { SetName("RootWindow"); - gfx::Screen::SetInstance(screen_); last_mouse_location_ = host_->QueryMouseLocation(); should_hold_mouse_moves_ = !CommandLine::ForCurrentProcess()->HasSwitch( @@ -155,14 +152,6 @@ gfx::Size RootWindow::GetHostSize() const { return rect.size(); } -void RootWindow::SetScreenWorkAreaInsets(const gfx::Insets& insets) { - if (screen_->work_area_insets() == insets) - return; - screen_->set_work_area_insets(insets); - FOR_EACH_OBSERVER(RootWindowObserver, observers_, - OnScreenWorkAreaInsetsChanged()); -} - void RootWindow::SetCursor(gfx::NativeCursor cursor) { last_cursor_ = cursor; // A lot of code seems to depend on NULL cursors actually showing an arrow, diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index f734fb4..ba83940 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -37,7 +37,6 @@ class RootWindowHost; class RootWindowObserver; class KeyEvent; class MouseEvent; -class ScreenAura; class StackingClient; class ScrollEvent; class TouchEvent; @@ -73,7 +72,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, bool cursor_shown() const { return cursor_shown_; } Window* mouse_pressed_handler() { return mouse_pressed_handler_; } Window* capture_window() { return capture_window_; } - const ScreenAura* screen() { return screen_; } // Shows the root window host. void ShowRootWindow(); @@ -82,9 +80,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, void SetHostSize(const gfx::Size& size); gfx::Size GetHostSize() const; - // Sets the screen's work area insets, this notifies observers too. - void SetScreenWorkAreaInsets(const gfx::Insets& insets); - // Sets the currently-displayed cursor. If the cursor was previously hidden // via ShowCursor(false), it will remain hidden until ShowCursor(true) is // called, at which point the cursor that was last set via SetCursor() will be @@ -313,8 +308,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, ObserverList<RootWindowObserver> observers_; - ScreenAura* screen_; - // The capture window. When not-null, this window receives all the mouse and // touch events. Window* capture_window_; diff --git a/ui/aura/root_window_observer.h b/ui/aura/root_window_observer.h index 930790d..8df353e 100644 --- a/ui/aura/root_window_observer.h +++ b/ui/aura/root_window_observer.h @@ -21,9 +21,6 @@ class AURA_EXPORT RootWindowObserver { // Invoked after the RootWindow is resized. virtual void OnRootWindowResized(const gfx::Size& new_size) {} - // Invoked after the screen's work area insets changes. - virtual void OnScreenWorkAreaInsetsChanged() {} - // Invoked when a window is focused. virtual void OnWindowFocused(Window* window) {} diff --git a/ui/aura/test/aura_test_base.cc b/ui/aura/test/aura_test_base.cc index a7399a8..203e533 100644 --- a/ui/aura/test/aura_test_base.cc +++ b/ui/aura/test/aura_test_base.cc @@ -5,6 +5,7 @@ #include "ui/aura/test/aura_test_base.h" #include "ui/aura/root_window.h" +#include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" namespace aura { @@ -19,6 +20,7 @@ AuraTestBase::~AuraTestBase() { void AuraTestBase::SetUp() { testing::Test::SetUp(); root_window_.reset(new aura::RootWindow); + gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); helper_.InitRootWindow(root_window()); helper_.SetUp(); stacking_client_.reset(new TestStackingClient(root_window())); diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc new file mode 100644 index 0000000..e61db9f --- /dev/null +++ b/ui/aura/test/test_screen.cc @@ -0,0 +1,61 @@ +// Copyright (c) 2012 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 "ui/aura/test/test_screen.h" + +#include "base/logging.h" +#include "ui/aura/root_window.h" +#include "ui/aura/window.h" +#include "ui/gfx/native_widget_types.h" + +namespace aura { + +TestScreen::TestScreen(aura::RootWindow* root_window) + : root_window_(root_window) { +} + +TestScreen::~TestScreen() { +} + +gfx::Point TestScreen::GetCursorScreenPointImpl() { + return root_window_->last_mouse_location(); +} + +gfx::Rect TestScreen::GetMonitorWorkAreaNearestWindowImpl( + gfx::NativeWindow window) { + return GetBounds(); +} + +gfx::Rect TestScreen::GetMonitorAreaNearestWindowImpl( + gfx::NativeWindow window) { + return GetBounds(); +} + +gfx::Rect TestScreen::GetMonitorWorkAreaNearestPointImpl( + const gfx::Point& point) { + return GetBounds(); +} + +gfx::Rect TestScreen::GetMonitorAreaNearestPointImpl(const gfx::Point& point) { + return GetBounds(); +} + +gfx::NativeWindow TestScreen::GetWindowAtCursorScreenPointImpl() { + const gfx::Point point = GetCursorScreenPoint(); + return root_window_->GetTopWindowContainingPoint(point); +} + +gfx::Rect TestScreen::GetBounds() { + return gfx::Rect(root_window_->bounds().size()); +} + +gfx::Size TestScreen::GetPrimaryMonitorSizeImpl() { + return GetBounds().size(); +} + +int TestScreen::GetNumMonitorsImpl() { + return 1; +} + +} // namespace aura diff --git a/ui/aura/test/test_screen.h b/ui/aura/test/test_screen.h new file mode 100644 index 0000000..59fe63d --- /dev/null +++ b/ui/aura/test/test_screen.h @@ -0,0 +1,48 @@ +// Copyright (c) 2012 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 UI_AURA_TEST_TEST_SCREEN_H_ +#define UI_AURA_TEST_TEST_SCREEN_H_ +#pragma once + +#include "base/compiler_specific.h" +#include "ui/gfx/insets.h" +#include "ui/gfx/screen.h" + +namespace aura { +class RootWindow; + +// A minimal, testing Aura implementation of gfx::Screen. +class TestScreen : public gfx::Screen { + public: + explicit TestScreen(aura::RootWindow* root_window); + virtual ~TestScreen(); + + protected: + virtual gfx::Point GetCursorScreenPointImpl() OVERRIDE; + virtual gfx::Rect GetMonitorWorkAreaNearestWindowImpl( + gfx::NativeView view) OVERRIDE; + virtual gfx::Rect GetMonitorAreaNearestWindowImpl( + gfx::NativeView view) OVERRIDE; + virtual gfx::Rect GetMonitorWorkAreaNearestPointImpl( + const gfx::Point& point) OVERRIDE; + virtual gfx::Rect GetMonitorAreaNearestPointImpl( + const gfx::Point& point) OVERRIDE; + virtual gfx::NativeWindow GetWindowAtCursorScreenPointImpl() OVERRIDE; + virtual gfx::Size GetPrimaryMonitorSizeImpl() OVERRIDE; + virtual int GetNumMonitorsImpl() OVERRIDE; + + private: + // We currently support only one monitor. These two methods return the bounds + // and work area. + gfx::Rect GetBounds(); + + aura::RootWindow* root_window_; + + DISALLOW_COPY_AND_ASSIGN(TestScreen); +}; + +} // namespace aura + +#endif // UI_AURA_TEST_TEST_SCREEN_H_ diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h index cd363b3..a451130 100644 --- a/ui/gfx/screen.h +++ b/ui/gfx/screen.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -20,7 +20,7 @@ class UI_EXPORT Screen { public: virtual ~Screen() {} -#if defined(USE_AURA) +#if defined(USE_ASH) // Sets the instance to use. This takes owernship of |screen|, deleting the // old instance. This is used on aura to avoid circular dependencies between // ui and aura. diff --git a/ui/gfx/screen_aura.cc b/ui/gfx/screen_ash.cc index ea4216f..9df6b84 100644 --- a/ui/gfx/screen_aura.cc +++ b/ui/gfx/screen_ash.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -9,9 +9,8 @@ namespace gfx { -// gfx can't depend upon aura, otherwise we have circular dependencies. So, -// gfx::Screen is pluggable for aura and Desktop plugs in the real -// implementation. +// gfx can't depend upon ash, otherwise we have circular dependencies. So, +// gfx::Screen is pluggable and Desktop plugs in the real implementation. // static Screen* Screen::instance_ = NULL; @@ -338,7 +338,7 @@ 'gfx/render_text_win.h', 'gfx/screen.h', 'gfx/screen_android.cc', - 'gfx/screen_aura.cc', + 'gfx/screen_ash.cc', 'gfx/screen_gtk.cc', 'gfx/screen_mac.mm', 'gfx/screen_wayland.cc', diff --git a/ui/views/test/views_test_base.cc b/ui/views/test/views_test_base.cc index f12c26b..7b87f2e 100644 --- a/ui/views/test/views_test_base.cc +++ b/ui/views/test/views_test_base.cc @@ -14,6 +14,7 @@ #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/aura/test/test_activation_client.h" +#include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" #include "ui/base/ime/input_method.h" @@ -88,6 +89,7 @@ void ViewsTestBase::SetUp() { views_delegate_.reset(new TestViewsDelegate()); #if defined(USE_AURA) root_window_.reset(new aura::RootWindow); + gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); root_window_->SetProperty( aura::client::kRootWindowInputMethodKey, test_input_method_.get()); diff --git a/ui/views/widget/native_widget_aura_unittest.cc b/ui/views/widget/native_widget_aura_unittest.cc index 4196cf3..3f07ef9 100644 --- a/ui/views/widget/native_widget_aura_unittest.cc +++ b/ui/views/widget/native_widget_aura_unittest.cc @@ -10,6 +10,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/aura/layout_manager.h" #include "ui/aura/root_window.h" +#include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_stacking_client.h" #include "ui/aura/window.h" #include "ui/views/widget/root_view.h" @@ -34,6 +35,7 @@ class NativeWidgetAuraTest : public testing::Test { // testing::Test overrides: virtual void SetUp() OVERRIDE { root_window_.reset(new aura::RootWindow); + gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); root_window_->SetBounds(gfx::Rect(0, 0, 640, 480)); root_window_->SetHostSize(gfx::Size(640, 480)); test_stacking_client_.reset( |