summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/accelerators/accelerator_controller.cc11
-rw-r--r--ash/accelerators/accelerator_controller_unittest.cc6
-rw-r--r--ash/ash.gyp14
-rw-r--r--ash/display/display_change_observer_x11.cc (renamed from ui/aura/display_change_observer_x11.cc)17
-rw-r--r--ash/display/display_change_observer_x11.h (renamed from ui/aura/display_change_observer_x11.h)10
-rw-r--r--ash/display/display_controller.cc27
-rw-r--r--ash/display/display_controller.h10
-rw-r--r--ash/display/display_controller_unittest.cc14
-rw-r--r--ash/display/display_manager.cc (renamed from ash/display/multi_display_manager.cc)106
-rw-r--r--ash/display/display_manager.h (renamed from ash/display/multi_display_manager.h)74
-rw-r--r--ash/display/display_manager_unittest.cc (renamed from ash/display/multi_display_manager_unittest.cc)55
-rw-r--r--ash/extended_desktop_unittest.cc8
-rw-r--r--ash/root_window_controller.cc2
-rw-r--r--ash/root_window_controller_unittest.cc1
-rw-r--r--ash/screen_ash.cc30
-rw-r--r--ash/screen_ash.h11
-rw-r--r--ash/shell.cc20
-rw-r--r--ash/shell.h12
-rw-r--r--ash/system/chromeos/tray_display.cc14
-rw-r--r--ash/system/chromeos/tray_display.h4
-rw-r--r--ash/test/ash_test_base.cc17
-rw-r--r--ash/test/ash_test_base.h4
-rw-r--r--ash/test/display_manager_test_api.cc (renamed from ash/test/multi_display_manager_test_api.cc)16
-rw-r--r--ash/test/display_manager_test_api.h (renamed from ash/test/multi_display_manager_test_api.h)19
-rw-r--r--ash/wm/shelf_layout_manager_unittest.cc19
-rw-r--r--ash/wm/system_gesture_event_filter_unittest.cc6
-rw-r--r--ash/wm/window_cycle_controller_unittest.cc2
-rw-r--r--chrome/browser/chromeos/display/display_preferences.cc17
-rw-r--r--chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc16
-rw-r--r--chrome/browser/ui/ash/ash_init.cc6
-rw-r--r--chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc2
-rw-r--r--chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc1
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc4
-rw-r--r--chrome/browser/ui/webui/options/chromeos/display_options_handler.cc11
-rw-r--r--chrome/browser/ui/webui/options/chromeos/display_options_handler.h6
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/chrome_tests_unit.gypi10
-rw-r--r--content/browser/renderer_host/render_widget_host_unittest.cc8
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc15
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.h6
-rw-r--r--content/shell/DEPS2
-rw-r--r--content/shell/shell_aura.cc7
-rw-r--r--ui/aura/aura.gyp12
-rw-r--r--ui/aura/bench/bench_main.cc12
-rw-r--r--ui/aura/demo/demo_main.cc8
-rw-r--r--ui/aura/display_manager.cc86
-rw-r--r--ui/aura/display_manager.h110
-rw-r--r--ui/aura/display_observer.h34
-rw-r--r--ui/aura/display_util.cc52
-rw-r--r--ui/aura/display_util.h35
-rw-r--r--ui/aura/env.cc12
-rw-r--r--ui/aura/env.h12
-rw-r--r--ui/aura/root_window.cc7
-rw-r--r--ui/aura/single_display_manager.cc108
-rw-r--r--ui/aura/single_display_manager.h62
-rw-r--r--ui/aura/test/aura_test_helper.cc8
-rw-r--r--ui/aura/test/test_screen.cc47
-rw-r--r--ui/aura/test/test_screen.h26
-rw-r--r--ui/gfx/display_observer.cc (renamed from ui/aura/display_observer.cc)6
-rw-r--r--ui/gfx/display_observer.h33
-rw-r--r--ui/gfx/screen.h5
-rw-r--r--ui/gfx/screen_android.cc8
-rw-r--r--ui/gfx/screen_gtk.cc8
-rw-r--r--ui/gfx/screen_ios.mm8
-rw-r--r--ui/gfx/screen_mac.mm8
-rw-r--r--ui/gfx/screen_win.cc8
-rw-r--r--ui/gfx/screen_win.h2
-rw-r--r--ui/ui.gyp2
-rw-r--r--ui/views/widget/desktop_aura/desktop_screen_x11.cc11
69 files changed, 586 insertions, 786 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc
index 00951a3..31e09af 100644
--- a/ash/accelerators/accelerator_controller.cc
+++ b/ash/accelerators/accelerator_controller.cc
@@ -14,7 +14,7 @@
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/desktop_background/user_wallpaper_delegate.h"
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/focus_cycler.h"
#include "ash/ime_control_delegate.h"
#include "ash/launcher/launcher.h"
@@ -117,7 +117,7 @@ bool HandleToggleSpokenFeedback() {
void HandleCycleDisplayMode() {
Shell* shell = Shell::GetInstance();
if (!base::chromeos::IsRunningOnChromeOS()) {
- internal::MultiDisplayManager::CycleDisplay();
+ internal::DisplayManager::CycleDisplay();
} else if (shell->output_configurator()->connected_output_count() > 1) {
internal::OutputConfiguratorAnimation* animation =
shell->output_configurator_animation();
@@ -739,7 +739,7 @@ bool AcceleratorController::PerformAction(int action,
case TOGGLE_ROOT_WINDOW_FULL_SCREEN:
return HandleToggleRootWindowFullScreen();
case DISPLAY_TOGGLE_SCALE:
- internal::MultiDisplayManager::ToggleDisplayScale();
+ internal::DisplayManager::ToggleDisplayScale();
return true;
case MAGNIFY_SCREEN_ZOOM_IN:
return HandleMagnifyScreen(1);
@@ -798,12 +798,9 @@ bool AcceleratorController::PerformAction(int action,
void AcceleratorController::SetBrightnessControlDelegate(
scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) {
- internal::MultiDisplayManager* display_manager =
- static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
// Install brightness control delegate only when internal
// display exists.
- if (display_manager->HasInternalDisplay())
+ if (Shell::GetInstance()->display_manager()->HasInternalDisplay())
brightness_control_delegate_.swap(brightness_control_delegate);
}
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc
index 070dd02..7012f4f 100644
--- a/ash/accelerators/accelerator_controller_unittest.cc
+++ b/ash/accelerators/accelerator_controller_unittest.cc
@@ -5,7 +5,7 @@
#include "ash/accelerators/accelerator_controller.h"
#include "ash/accelerators/accelerator_table.h"
#include "ash/caps_lock_delegate.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/ime_control_delegate.h"
#include "ash/screenshot_delegate.h"
#include "ash/shell.h"
@@ -17,7 +17,6 @@
#include "ash/test/test_shell_delegate.h"
#include "ash/volume_control_delegate.h"
#include "ash/wm/window_util.h"
-#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h"
@@ -314,8 +313,7 @@ class AcceleratorControllerTest : public test::AshTestBase {
protected:
void EnableInternalDisplay() {
- static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager())->
+ Shell::GetInstance()->display_manager()->
SetFirstDisplayAsInternalDisplayForTest();
}
diff --git a/ash/ash.gyp b/ash/ash.gyp
index ac60ac8..ce847a8 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -75,14 +75,16 @@
'desktop_background/desktop_background_widget_controller.cc',
'desktop_background/desktop_background_widget_controller.h',
'desktop_background/user_wallpaper_delegate.h',
+ 'display/display_change_observer_x11.cc',
+ 'display/display_change_observer_x11.h',
'display/display_controller.cc',
'display/display_controller.h',
'display/display_error_dialog.cc',
'display/display_error_dialog.h',
+ 'display/display_manager.cc',
+ 'display/display_manager.h',
'display/mouse_cursor_event_filter.cc',
'display/mouse_cursor_event_filter.h',
- 'display/multi_display_manager.cc',
- 'display/multi_display_manager.h',
'display/output_configurator_animation.cc',
'display/output_configurator_animation.h',
'display/screen_position_controller.cc',
@@ -460,15 +462,14 @@
'sources': [
'test/ash_test_base.cc',
'test/ash_test_base.h',
- 'test/ash_unittests.cc',
'test/capture_tracking_view.cc',
'test/capture_tracking_view.h',
'test/cursor_manager_test_api.cc',
'test/cursor_manager_test_api.h',
'test/launcher_view_test_api.cc',
'test/launcher_view_test_api.h',
- 'test/multi_display_manager_test_api.cc',
- 'test/multi_display_manager_test_api.h',
+ 'test/display_manager_test_api.cc',
+ 'test/display_manager_test_api.h',
'test/test_activation_delegate.cc',
'test/test_activation_delegate.h',
'test/test_launcher_delegate.cc',
@@ -523,7 +524,7 @@
'dip_unittest.cc',
'display/display_controller_unittest.cc',
'display/mouse_cursor_event_filter_unittest.cc',
- 'display/multi_display_manager_unittest.cc',
+ 'display/display_manager_unittest.cc',
'display/screen_position_controller_unittest.cc',
'drag_drop/drag_drop_controller_unittest.cc',
'drag_drop/drag_drop_tracker_unittest.cc',
@@ -554,6 +555,7 @@
'shell/window_watcher_unittest.cc',
'system/tray/system_tray_unittest.cc',
'system/web_notification/web_notification_tray_unittest.cc',
+ 'test/ash_unittests.cc',
'tooltips/tooltip_controller_unittest.cc',
'wm/activation_controller_unittest.cc',
'wm/base_layout_manager_unittest.cc',
diff --git a/ui/aura/display_change_observer_x11.cc b/ash/display/display_change_observer_x11.cc
index 21dab9c..ed96094 100644
--- a/ui/aura/display_change_observer_x11.cc
+++ b/ash/display/display_change_observer_x11.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/aura/display_change_observer_x11.h"
+#include "ash/display/display_change_observer_x11.h"
#include <algorithm>
#include <map>
@@ -11,14 +11,14 @@
#include <X11/extensions/Xrandr.h>
+#include "ash/display/display_manager.h"
+#include "ash/shell.h"
#include "base/message_pump_aurax11.h"
-#include "ui/aura/env.h"
-#include "ui/aura/display_manager.h"
#include "ui/base/x/x11_util.h"
#include "ui/compositor/dip_util.h"
#include "ui/gfx/display.h"
-namespace aura {
+namespace ash {
namespace internal {
namespace {
@@ -99,9 +99,6 @@ bool DisplayChangeObserverX11::Dispatch(const base::NativeEvent& event) {
}
void DisplayChangeObserverX11::NotifyDisplayChange() {
- if (!DisplayManager::use_fullscreen_host_window())
- return; // Use the default display that display manager determined.
-
XRRScreenResources* screen_resources =
XRRGetScreenResources(xdisplay_, x_root_window_);
std::map<XID, XRRCrtcInfo*> crtc_info_map;
@@ -185,9 +182,9 @@ void DisplayChangeObserverX11::NotifyDisplayChange() {
++id;
}
}
-
- Env::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
+ // DisplayManager can be null during the boot.
+ Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
}
} // namespace internal
-} // namespace aura
+} // namespace ash
diff --git a/ui/aura/display_change_observer_x11.h b/ash/display/display_change_observer_x11.h
index 6d7fe60..d9740ea 100644
--- a/ui/aura/display_change_observer_x11.h
+++ b/ash/display/display_change_observer_x11.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_AURA_DISPLAY_CHANGE_OBSERVER_X11_H
-#define UI_AURA_DISPLAY_CHANGE_OBSERVER_X11_H
+#ifndef ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_X11_H
+#define ASH_DISPLAY_DISPLAY_CHANGE_OBSERVER_X11_H
#include <X11/Xlib.h>
@@ -13,7 +13,7 @@
#include "base/basictypes.h"
#include "base/message_loop.h"
-namespace aura {
+namespace ash {
namespace internal {
// An object that observes changes in display configuration and
@@ -41,6 +41,6 @@ class DisplayChangeObserverX11 : public MessageLoop::Dispatcher {
};
} // namespace internal
-} // namespace aura
+} // namespace ash
-#endif // UI_AURA_DISPLAY_CHANGE_OBSERVER_X11_H
+#endif // ASH_DISPLAY_AURA_DISPLAY_CHANGE_OBSERVER_X11_H
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index b15df8e..36bc0db 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include "ash/ash_switches.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
@@ -78,9 +78,8 @@ std::string GetStringFromPosition(DisplayLayout::Position position) {
return std::string("unknown");
}
-internal::MultiDisplayManager* GetDisplayManager() {
- return static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
+internal::DisplayManager* GetDisplayManager() {
+ return Shell::GetInstance()->display_manager();
}
} // namespace
@@ -161,11 +160,11 @@ DisplayController::DisplayController()
// stale display info from previous tests.
primary_display_id = gfx::Display::kInvalidDisplayID;
- GetDisplayManager()->AddObserver(this);
+ Shell::GetScreen()->AddObserver(this);
}
DisplayController::~DisplayController() {
- GetDisplayManager()->RemoveObserver(this);
+ Shell::GetScreen()->RemoveObserver(this);
// Delete all root window controllers, which deletes root window
// from the last so that the primary root window gets deleted last.
for (std::map<int64, aura::RootWindow*>::const_reverse_iterator it =
@@ -182,11 +181,16 @@ const gfx::Display& DisplayController::GetPrimaryDisplay() {
return GetDisplayManager()->GetDisplayForId(primary_display_id);
}
+// static
+bool DisplayController::HasPrimaryDisplay() {
+ return primary_display_id != gfx::Display::kInvalidDisplayID;
+}
+
void DisplayController::InitPrimaryDisplay() {
const gfx::Display* primary_candidate = GetDisplayManager()->GetDisplayAt(0);
#if defined(OS_CHROMEOS)
if (base::chromeos::IsRunningOnChromeOS()) {
- internal::MultiDisplayManager* display_manager = GetDisplayManager();
+ internal::DisplayManager* display_manager = GetDisplayManager();
// On ChromeOS device, root windows are stacked vertically, and
// default primary is the one on top.
int count = display_manager->GetNumDisplays();
@@ -210,7 +214,7 @@ void DisplayController::InitPrimaryDisplay() {
}
void DisplayController::InitSecondaryDisplays() {
- internal::MultiDisplayManager* display_manager = GetDisplayManager();
+ internal::DisplayManager* display_manager = GetDisplayManager();
for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
const gfx::Display* display = display_manager->GetDisplayAt(i);
if (primary_display_id != display->id()) {
@@ -350,8 +354,7 @@ void DisplayController::SetPrimaryDisplayId(int64 id) {
if (desired_primary_display_id_ == primary_display_id)
return;
- aura::DisplayManager* display_manager =
- aura::Env::GetInstance()->display_manager();
+ internal::DisplayManager* display_manager = GetDisplayManager();
for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) {
gfx::Display* display = display_manager->GetDisplayAt(i);
if (display->id() == id) {
@@ -363,7 +366,7 @@ void DisplayController::SetPrimaryDisplayId(int64 id) {
void DisplayController::SetPrimaryDisplay(
const gfx::Display& new_primary_display) {
- internal::MultiDisplayManager* display_manager = GetDisplayManager();
+ internal::DisplayManager* display_manager = GetDisplayManager();
DCHECK(new_primary_display.is_valid());
DCHECK(display_manager->IsActiveDisplay(new_primary_display));
@@ -423,7 +426,7 @@ void DisplayController::SetPrimaryDisplay(
}
gfx::Display* DisplayController::GetSecondaryDisplay() {
- internal::MultiDisplayManager* display_manager = GetDisplayManager();
+ internal::DisplayManager* display_manager = GetDisplayManager();
CHECK_EQ(2U, display_manager->GetNumDisplays());
return display_manager->GetDisplayAt(0)->id() == primary_display_id ?
display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0);
diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h
index 0c9de47..a1dbedf 100644
--- a/ash/display/display_controller.h
+++ b/ash/display/display_controller.h
@@ -13,8 +13,7 @@
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/observer_list.h"
-#include "ui/aura/display_observer.h"
-#include "ui/aura/display_manager.h"
+#include "ui/gfx/display_observer.h"
#include "ui/gfx/display.h"
namespace aura {
@@ -68,7 +67,7 @@ struct ASH_EXPORT DisplayLayout {
// DisplayController owns and maintains RootWindows for each attached
// display, keeping them in sync with display configuration changes.
-class ASH_EXPORT DisplayController : public aura::DisplayObserver {
+class ASH_EXPORT DisplayController : public gfx::DisplayObserver {
public:
class ASH_EXPORT Observer {
public:
@@ -87,6 +86,9 @@ class ASH_EXPORT DisplayController : public aura::DisplayObserver {
// object as this can be accessed after Shell is closed.
static const gfx::Display& GetPrimaryDisplay();
+ // True if the primary display has been initialized.
+ static bool HasPrimaryDisplay();
+
// Initializes primary display.
void InitPrimaryDisplay();
@@ -126,7 +128,7 @@ class ASH_EXPORT DisplayController : public aura::DisplayObserver {
std::vector<internal::RootWindowController*> GetAllRootWindowControllers();
// Returns the current overscan insets for the specified |display_id|. See
- // multi_display_manager.h for the details.
+ // display_manager.h for the details.
gfx::Insets GetOverscanInsets(int64 display_id) const;
const DisplayLayout& default_display_layout() const {
diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc
index 9082bef..4b06fc1 100644
--- a/ash/display/display_controller_unittest.cc
+++ b/ash/display/display_controller_unittest.cc
@@ -4,12 +4,12 @@
#include "ash/display/display_controller.h"
+#include "ash/display/display_manager.h"
#include "ash/launcher/launcher.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/cursor_manager_test_api.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window_tracker.h"
@@ -92,7 +92,7 @@ TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) {
UpdateDisplay("500x500,400x400");
EXPECT_EQ(2, observer.CountAndReset()); // resize and add
gfx::Display* secondary_display =
- aura::Env::GetInstance()->display_manager()->GetDisplayAt(1);
+ Shell::GetInstance()->display_manager()->GetDisplayAt(1);
gfx::Insets insets(5, 5, 5, 5);
secondary_display->UpdateWorkAreaFromInsets(insets);
@@ -165,7 +165,7 @@ TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) {
EXPECT_EQ(3, observer.CountAndReset());
gfx::Display* secondary_display =
- aura::Env::GetInstance()->display_manager()->GetDisplayAt(1);
+ Shell::GetInstance()->display_manager()->GetDisplayAt(1);
gfx::Insets insets(5, 5, 5, 5);
secondary_display->UpdateWorkAreaFromInsets(insets);
@@ -235,7 +235,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) {
gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay();
- std::string secondary_name = aura::Env::GetInstance()->
+ std::string secondary_name = Shell::GetInstance()->
display_manager()->GetDisplayNameFor(secondary_display);
DisplayLayout secondary_layout(DisplayLayout::RIGHT, 50);
display_controller->SetLayoutForDisplayName(secondary_name, secondary_layout);
@@ -325,7 +325,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) {
gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay();
- std::string secondary_name = aura::Env::GetInstance()->
+ std::string secondary_name = Shell::GetInstance()->
display_manager()->GetDisplayNameFor(secondary_display);
DisplayLayout secondary_layout(DisplayLayout::RIGHT, 50);
display_controller->SetLayoutForDisplayName(secondary_name, secondary_layout);
@@ -395,8 +395,8 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) {
std::vector<gfx::Display> displays;
displays.push_back(primary_display);
displays.push_back(secondary_display);
- aura::DisplayManager* display_manager =
- aura::Env::GetInstance()->display_manager();
+ internal::DisplayManager* display_manager =
+ Shell::GetInstance()->display_manager();
display_manager->OnNativeDisplaysChanged(displays);
EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays());
diff --git a/ash/display/multi_display_manager.cc b/ash/display/display_manager.cc
index 46f1abc..7016732 100644
--- a/ash/display/multi_display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include <string>
#include <vector>
#include "ash/display/display_controller.h"
+#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "base/command_line.h"
#include "base/stl_util.h"
@@ -17,6 +18,7 @@
#include "grit/ash_strings.h"
#include "ui/aura/aura_switches.h"
#include "ui/aura/client/screen_position_client.h"
+#include "ui/aura/display_util.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/root_window_host.h"
@@ -79,30 +81,26 @@ using std::vector;
DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey,
gfx::Display::kInvalidDisplayID);
-MultiDisplayManager::MultiDisplayManager() :
+DisplayManager::DisplayManager() :
internal_display_id_(gfx::Display::kInvalidDisplayID),
force_bounds_changed_(false) {
Init();
}
-MultiDisplayManager::~MultiDisplayManager() {
+DisplayManager::~DisplayManager() {
}
// static
-void MultiDisplayManager::CycleDisplay() {
- MultiDisplayManager* manager = static_cast<MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
- manager->CycleDisplayImpl();
+void DisplayManager::CycleDisplay() {
+ Shell::GetInstance()->display_manager()->CycleDisplayImpl();
}
// static
-void MultiDisplayManager::ToggleDisplayScale() {
- MultiDisplayManager* manager = static_cast<MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
- manager->ScaleDisplayImpl();
+void DisplayManager::ToggleDisplayScale() {
+ Shell::GetInstance()->display_manager()->ScaleDisplayImpl();
}
-bool MultiDisplayManager::IsActiveDisplay(const gfx::Display& display) const {
+bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const {
for (DisplayList::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
if ((*iter).id() == display.id())
@@ -111,15 +109,15 @@ bool MultiDisplayManager::IsActiveDisplay(const gfx::Display& display) const {
return false;
}
-bool MultiDisplayManager::HasInternalDisplay() const {
+bool DisplayManager::HasInternalDisplay() const {
return internal_display_id_ != gfx::Display::kInvalidDisplayID;
}
-bool MultiDisplayManager::IsInternalDisplayId(int64 id) const {
+bool DisplayManager::IsInternalDisplayId(int64 id) const {
return internal_display_id_ == id;
}
-bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow(
+bool DisplayManager::UpdateWorkAreaOfDisplayNearestWindow(
const aura::Window* window,
const gfx::Insets& insets) {
const RootWindow* root = window->GetRootWindow();
@@ -129,11 +127,11 @@ bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow(
return old_work_area != display.work_area();
}
-const gfx::Display& MultiDisplayManager::GetDisplayForId(int64 id) const {
- return const_cast<MultiDisplayManager*>(this)->FindDisplayForId(id);
+const gfx::Display& DisplayManager::GetDisplayForId(int64 id) const {
+ return const_cast<DisplayManager*>(this)->FindDisplayForId(id);
}
-const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint(
+const gfx::Display& DisplayManager::FindDisplayContainingPoint(
const gfx::Point& point_in_screen) const {
for (DisplayList::const_iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
@@ -144,8 +142,8 @@ const gfx::Display& MultiDisplayManager::FindDisplayContainingPoint(
return GetInvalidDisplay();
}
-void MultiDisplayManager::SetOverscanInsets(int64 display_id,
- const gfx::Insets& insets_in_dip) {
+void DisplayManager::SetOverscanInsets(int64 display_id,
+ const gfx::Insets& insets_in_dip) {
DisplayList displays = displays_;
std::map<int64, gfx::Insets>::const_iterator old_overscan =
overscan_mapping_.find(display_id);
@@ -166,13 +164,13 @@ void MultiDisplayManager::SetOverscanInsets(int64 display_id,
OnNativeDisplaysChanged(displays);
}
-gfx::Insets MultiDisplayManager::GetOverscanInsets(int64 display_id) const {
+gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const {
std::map<int64, gfx::Insets>::const_iterator it =
overscan_mapping_.find(display_id);
return (it != overscan_mapping_.end()) ? it->second : gfx::Insets();
}
-void MultiDisplayManager::OnNativeDisplaysChanged(
+void DisplayManager::OnNativeDisplaysChanged(
const std::vector<gfx::Display>& updated_displays) {
if (updated_displays.empty()) {
// Don't update the displays when all displays are disconnected.
@@ -230,8 +228,8 @@ void MultiDisplayManager::OnNativeDisplaysChanged(
std::vector<size_t> changed_display_indices;
std::vector<size_t> added_display_indices;
gfx::Display current_primary;
- if (Shell::HasInstance())
- current_primary = Shell::GetScreen()->GetPrimaryDisplay();
+ if (DisplayController::HasPrimaryDisplay())
+ current_primary = DisplayController::GetPrimaryDisplay();
for (DisplayList::iterator curr_iter = displays_.begin(),
new_iter = new_displays.begin();
@@ -291,24 +289,22 @@ void MultiDisplayManager::OnNativeDisplaysChanged(
removed_displays.end());
for (std::vector<size_t>::iterator iter = changed_display_indices.begin();
iter != changed_display_indices.end(); ++iter) {
- NotifyBoundsChanged(displays_[*iter]);
+ Shell::GetInstance()->screen()->NotifyBoundsChanged(displays_[*iter]);
}
for (std::vector<size_t>::iterator iter = added_display_indices.begin();
iter != added_display_indices.end(); ++iter) {
- NotifyDisplayAdded(displays_[*iter]);
+ Shell::GetInstance()->screen()->NotifyDisplayAdded(displays_[*iter]);
}
-
for (DisplayList::const_reverse_iterator iter = removed_displays.rbegin();
iter != removed_displays.rend(); ++iter) {
- NotifyDisplayRemoved(displays_.back());
+ Shell::GetInstance()->screen()->NotifyDisplayRemoved(displays_.back());
displays_.pop_back();
}
EnsurePointerInDisplays();
}
-RootWindow* MultiDisplayManager::CreateRootWindowForDisplay(
+RootWindow* DisplayManager::CreateRootWindowForDisplay(
const gfx::Display& display) {
-
RootWindow::CreateParams params(display.bounds_in_pixel());
#if defined(OS_WIN)
if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
@@ -325,26 +321,26 @@ RootWindow* MultiDisplayManager::CreateRootWindowForDisplay(
return root_window;
}
-gfx::Display* MultiDisplayManager::GetDisplayAt(size_t index) {
+gfx::Display* DisplayManager::GetDisplayAt(size_t index) {
return index < displays_.size() ? &displays_[index] : NULL;
}
-size_t MultiDisplayManager::GetNumDisplays() const {
+size_t DisplayManager::GetNumDisplays() const {
return displays_.size();
}
-const gfx::Display& MultiDisplayManager::GetDisplayNearestWindow(
+const gfx::Display& DisplayManager::GetDisplayNearestWindow(
const Window* window) const {
if (!window)
return DisplayController::GetPrimaryDisplay();
const RootWindow* root = window->GetRootWindow();
- MultiDisplayManager* manager = const_cast<MultiDisplayManager*>(this);
+ DisplayManager* manager = const_cast<DisplayManager*>(this);
return root ?
manager->FindDisplayForRootWindow(root) :
DisplayController::GetPrimaryDisplay();
}
-const gfx::Display& MultiDisplayManager::GetDisplayNearestPoint(
+const gfx::Display& DisplayManager::GetDisplayNearestPoint(
const gfx::Point& point) const {
// Fallback to the primary display if there is no root display containing
// the |point|.
@@ -352,7 +348,7 @@ const gfx::Display& MultiDisplayManager::GetDisplayNearestPoint(
return display.is_valid() ? display : DisplayController::GetPrimaryDisplay();
}
-const gfx::Display& MultiDisplayManager::GetDisplayMatching(
+const gfx::Display& DisplayManager::GetDisplayMatching(
const gfx::Rect& rect) const {
if (rect.IsEmpty())
return GetDisplayNearestPoint(rect.origin());
@@ -373,7 +369,7 @@ const gfx::Display& MultiDisplayManager::GetDisplayMatching(
return matching ? *matching : DisplayController::GetPrimaryDisplay();
}
-std::string MultiDisplayManager::GetDisplayNameFor(
+std::string DisplayManager::GetDisplayNameFor(
const gfx::Display& display) {
if (!display.is_valid())
return l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
@@ -386,18 +382,18 @@ std::string MultiDisplayManager::GetDisplayNameFor(
return base::StringPrintf("Display %d", static_cast<int>(display.id()));
}
-void MultiDisplayManager::OnRootWindowResized(const aura::RootWindow* root,
- const gfx::Size& old_size) {
- if (!use_fullscreen_host_window()) {
+void DisplayManager::OnRootWindowResized(const aura::RootWindow* root,
+ const gfx::Size& old_size) {
+ if (!aura::UseFullscreenHostWindow()) {
gfx::Display& display = FindDisplayForRootWindow(root);
if (display.size() != root->GetHostSize()) {
display.SetSize(root->GetHostSize());
- NotifyBoundsChanged(display);
+ Shell::GetInstance()->screen()->NotifyBoundsChanged(display);
}
}
}
-void MultiDisplayManager::Init() {
+void DisplayManager::Init() {
#if defined(OS_CHROMEOS)
if (base::chromeos::IsRunningOnChromeOS()) {
std::vector<XID> outputs;
@@ -417,7 +413,7 @@ void MultiDisplayManager::Init() {
#if defined(OS_WIN)
if (base::win::GetVersion() >= base::win::VERSION_WIN8)
- set_use_fullscreen_host_window(true);
+ aura::SetUseFullscreenHostWindow(true);
#endif
// TODO(oshima): Move this logic to DisplayChangeObserver.
const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
@@ -432,17 +428,17 @@ void MultiDisplayManager::Init() {
AddDisplayFromSpec(std::string() /* default */);
}
-void MultiDisplayManager::CycleDisplayImpl() {
+void DisplayManager::CycleDisplayImpl() {
DCHECK(!displays_.empty());
std::vector<gfx::Display> new_displays;
new_displays.push_back(DisplayController::GetPrimaryDisplay());
// Add if there is only one display.
if (displays_.size() == 1)
- new_displays.push_back(CreateDisplayFromSpec("100+200-500x400"));
+ new_displays.push_back(aura::CreateDisplayFromSpec("100+200-500x400"));
OnNativeDisplaysChanged(new_displays);
}
-void MultiDisplayManager::ScaleDisplayImpl() {
+void DisplayManager::ScaleDisplayImpl() {
DCHECK(!displays_.empty());
std::vector<gfx::Display> new_displays;
for (DisplayList::const_iterator iter = displays_.begin();
@@ -458,7 +454,7 @@ void MultiDisplayManager::ScaleDisplayImpl() {
OnNativeDisplaysChanged(new_displays);
}
-gfx::Display& MultiDisplayManager::FindDisplayForRootWindow(
+gfx::Display& DisplayManager::FindDisplayForRootWindow(
const aura::RootWindow* root_window) {
int64 id = root_window->GetProperty(kDisplayIdKey);
// if id is |kInvaildDisplayID|, it's being deleted.
@@ -468,7 +464,7 @@ gfx::Display& MultiDisplayManager::FindDisplayForRootWindow(
return display;
}
-gfx::Display& MultiDisplayManager::FindDisplayForId(int64 id) {
+gfx::Display& DisplayManager::FindDisplayForId(int64 id) {
for (DisplayList::iterator iter = displays_.begin();
iter != displays_.end(); ++iter) {
if ((*iter).id() == id)
@@ -478,8 +474,8 @@ gfx::Display& MultiDisplayManager::FindDisplayForId(int64 id) {
return GetInvalidDisplay();
}
-void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) {
- gfx::Display display = CreateDisplayFromSpec(spec);
+void DisplayManager::AddDisplayFromSpec(const std::string& spec) {
+ gfx::Display display = aura::CreateDisplayFromSpec(spec);
const gfx::Insets insets = display.GetWorkAreaInsets();
const gfx::Rect& native_bounds = display.bounds_in_pixel();
@@ -488,16 +484,16 @@ void MultiDisplayManager::AddDisplayFromSpec(const std::string& spec) {
displays_.push_back(display);
}
-int64 MultiDisplayManager::SetFirstDisplayAsInternalDisplayForTest() {
+int64 DisplayManager::SetFirstDisplayAsInternalDisplayForTest() {
internal_display_id_ = displays_[0].id();
internal_display_.reset(new gfx::Display);
*internal_display_ = displays_[0];
return internal_display_id_;
}
-void MultiDisplayManager::EnsurePointerInDisplays() {
+void DisplayManager::EnsurePointerInDisplays() {
// Don't try to move the pointer during the boot/startup.
- if (!Shell::HasInstance())
+ if (!DisplayController::HasPrimaryDisplay())
return;
gfx::Point location_in_screen = Shell::GetScreen()->GetCursorScreenPoint();
gfx::Point target_location;
@@ -533,7 +529,7 @@ void MultiDisplayManager::EnsurePointerInDisplays() {
root_window->MoveCursorTo(target_location);
}
-void MultiDisplayManager::RefreshDisplayNames() {
+void DisplayManager::RefreshDisplayNames() {
display_names_.clear();
#if defined(OS_CHROMEOS)
@@ -564,7 +560,7 @@ void MultiDisplayManager::RefreshDisplayNames() {
#endif
}
-void MultiDisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const {
+void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const {
DisplayList::iterator iter_to_update = to_update->begin();
DisplayList::const_iterator iter = displays_.begin();
for (; iter != displays_.end() && iter_to_update != to_update->end();
diff --git a/ash/display/multi_display_manager.h b/ash/display/display_manager.h
index 40b9f30..a3c8b12 100644
--- a/ash/display/multi_display_manager.h
+++ b/ash/display/display_manager.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_
-#define ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_
+#ifndef ASH_DISPLAY_DISPLAY_MANAGER_H_
+#define ASH_DISPLAY_DISPLAY_MANAGER_H_
#include <string>
#include <vector>
@@ -11,7 +11,6 @@
#include "ash/ash_export.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/root_window_observer.h"
#include "ui/aura/window.h"
@@ -24,29 +23,28 @@ class Rect;
namespace ash {
class AcceleratorControllerTest;
namespace test {
-class MultiDisplayManagerTestApi;
+class DisplayManagerTestApi;
class SystemGestureEventFilterTest;
}
namespace internal {
-// MultiDisplayManager maintains the current display configurations,
+// DisplayManager maintains the current display configurations,
// and notifies observers when configuration changes.
// This is exported for unittest.
//
// TODO(oshima): gfx::Screen needs to return translated coordinates
// if the root window is translated. crbug.com/119268.
-class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager,
- public aura::RootWindowObserver {
+class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
public:
- MultiDisplayManager();
- virtual ~MultiDisplayManager();
+ DisplayManager();
+ virtual ~DisplayManager();
// Used to emulate display change when run in a desktop environment instead
// of on a device.
static void CycleDisplay();
static void ToggleDisplayScale();
- // When set to true, the MultiMonitorManager calls OnDisplayBoundsChanged
+ // When set to true, the MonitorManager calls OnDisplayBoundsChanged
// even if the display's bounds didn't change. Used to swap primary
// display.
void set_force_bounds_changed(bool force_bounds_changed) {
@@ -83,21 +81,35 @@ class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager,
// the display.
gfx::Insets GetOverscanInsets(int64 display_id) const;
- // DisplayManager overrides:
- virtual void OnNativeDisplaysChanged(
- const std::vector<gfx::Display>& displays) OVERRIDE;
- virtual aura::RootWindow* CreateRootWindowForDisplay(
- const gfx::Display& display) OVERRIDE;
- virtual gfx::Display* GetDisplayAt(size_t index) OVERRIDE;
-
- virtual size_t GetNumDisplays() const OVERRIDE;
- virtual const gfx::Display& GetDisplayNearestPoint(
- const gfx::Point& point) const OVERRIDE;
- virtual const gfx::Display& GetDisplayNearestWindow(
- const aura::Window* window) const OVERRIDE;
- virtual const gfx::Display& GetDisplayMatching(
- const gfx::Rect& match_rect)const OVERRIDE;
- virtual std::string GetDisplayNameFor(const gfx::Display& display) OVERRIDE;
+ // Called when display configuration has changed. The new display
+ // configurations is passed as a vector of Display object, which
+ // contains each display's new infomration.
+ void OnNativeDisplaysChanged(const std::vector<gfx::Display>& displays);
+
+ // Create a root window for given |display|.
+ aura::RootWindow* CreateRootWindowForDisplay(const gfx::Display& display);
+
+ // Obsoleted: Do not use in new code.
+ // Returns the display at |index|. The display at 0 is
+ // no longer considered "primary".
+ gfx::Display* GetDisplayAt(size_t index);
+
+ size_t GetNumDisplays() const;
+
+ // Returns the display object nearest given |window|.
+ const gfx::Display& GetDisplayNearestPoint(
+ const gfx::Point& point) const;
+
+ // Returns the display object nearest given |point|.
+ const gfx::Display& GetDisplayNearestWindow(
+ const aura::Window* window) const;
+
+ // Returns the display that most closely intersects |match_rect|.
+ const gfx::Display& GetDisplayMatching(
+ const gfx::Rect& match_rect)const;
+
+ // Returns the human-readable name for the display specified by |display|.
+ std::string GetDisplayNameFor(const gfx::Display& display);
// RootWindowObserver overrides:
virtual void OnRootWindowResized(const aura::RootWindow* root,
@@ -105,12 +117,12 @@ class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager,
private:
FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint);
- FRIEND_TEST_ALL_PREFIXES(MultiDisplayManagerTest, TestNativeDisplaysChanged);
- FRIEND_TEST_ALL_PREFIXES(MultiDisplayManagerTest,
+ FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged);
+ FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest,
NativeDisplaysChangedAfterPrimaryChange);
friend class ash::AcceleratorControllerTest;
- friend class test::MultiDisplayManagerTestApi;
- friend class MultiDisplayManagerTest;
+ friend class test::DisplayManagerTestApi;
+ friend class DisplayManagerTest;
friend class test::SystemGestureEventFilterTest;
typedef std::vector<gfx::Display> DisplayList;
@@ -158,7 +170,7 @@ class ASH_EXPORT MultiDisplayManager : public aura::DisplayManager,
// The cached display's name for the display ID.
std::map<int64, std::string> display_names_;
- DISALLOW_COPY_AND_ASSIGN(MultiDisplayManager);
+ DISALLOW_COPY_AND_ASSIGN(DisplayManager);
};
extern const aura::WindowProperty<int64>* const kDisplayIdKey;
@@ -166,4 +178,4 @@ extern const aura::WindowProperty<int64>* const kDisplayIdKey;
} // namespace internal
} // namespace ash
-#endif // ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_
+#endif // ASH_DISPLAY_DISPLAY_MANAGER_H_
diff --git a/ash/display/multi_display_manager_unittest.cc b/ash/display/display_manager_unittest.cc
index 1bf60a7..12ed8d20 100644
--- a/ash/display/multi_display_manager_unittest.cc
+++ b/ash/display/display_manager_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/display/display_controller.h"
#include "ash/screen_ash.h"
@@ -10,10 +10,10 @@
#include "ash/test/ash_test_base.h"
#include "base/format_macros.h"
#include "base/stringprintf.h"
-#include "ui/aura/display_observer.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window_observer.h"
+#include "ui/gfx/display_observer.h"
#include "ui/gfx/display.h"
namespace ash {
@@ -22,30 +22,29 @@ namespace internal {
using std::vector;
using std::string;
-class MultiDisplayManagerTest : public test::AshTestBase,
- public aura::DisplayObserver,
- public aura::WindowObserver {
+class DisplayManagerTest : public test::AshTestBase,
+ public gfx::DisplayObserver,
+ public aura::WindowObserver {
public:
- MultiDisplayManagerTest()
+ DisplayManagerTest()
: removed_count_(0U),
root_window_destroyed_(false) {
}
- virtual ~MultiDisplayManagerTest() {}
+ virtual ~DisplayManagerTest() {}
virtual void SetUp() OVERRIDE {
AshTestBase::SetUp();
- display_manager()->AddObserver(this);
+ Shell::GetScreen()->AddObserver(this);
Shell::GetPrimaryRootWindow()->AddObserver(this);
}
virtual void TearDown() OVERRIDE {
Shell::GetPrimaryRootWindow()->RemoveObserver(this);
- display_manager()->RemoveObserver(this);
+ Shell::GetScreen()->RemoveObserver(this);
AshTestBase::TearDown();
}
- MultiDisplayManager* display_manager() {
- return static_cast<MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
+ DisplayManager* display_manager() {
+ return Shell::GetInstance()->display_manager();
}
const vector<gfx::Display>& changed() const { return changed_; }
const vector<gfx::Display>& added() const { return added_; }
@@ -93,7 +92,7 @@ class MultiDisplayManagerTest : public test::AshTestBase,
size_t removed_count_;
bool root_window_destroyed_;
- DISALLOW_COPY_AND_ASSIGN(MultiDisplayManagerTest);
+ DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest);
};
#if defined(OS_CHROMEOS)
@@ -110,9 +109,7 @@ class MultiDisplayManagerTest : public test::AshTestBase,
#define MAYBE_ZeroOverscanInsets DISABLED_ZeroOverscanInsets
#endif
-TEST_F(MultiDisplayManagerTest, MAYBE_NativeDisplayTest) {
- aura::DisplayManager::set_use_fullscreen_host_window(true);
-
+TEST_F(DisplayManagerTest, MAYBE_NativeDisplayTest) {
EXPECT_EQ(1U, display_manager()->GetNumDisplays());
// Update primary and add seconary.
@@ -197,32 +194,30 @@ TEST_F(MultiDisplayManagerTest, MAYBE_NativeDisplayTest) {
EXPECT_EQ("1000,1000 600x400",
display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString());
reset();
-
- aura::DisplayManager::set_use_fullscreen_host_window(false);
}
// Test in emulation mode (use_fullscreen_host_window=false)
-TEST_F(MultiDisplayManagerTest, MAYBE_EmulatorTest) {
+TEST_F(DisplayManagerTest, MAYBE_EmulatorTest) {
EXPECT_EQ(1U, display_manager()->GetNumDisplays());
- MultiDisplayManager::CycleDisplay();
+ DisplayManager::CycleDisplay();
// Update primary and add seconary.
EXPECT_EQ(2U, display_manager()->GetNumDisplays());
EXPECT_EQ("0 1 0", GetCountSummary());
reset();
- MultiDisplayManager::CycleDisplay();
+ DisplayManager::CycleDisplay();
EXPECT_EQ(1U, display_manager()->GetNumDisplays());
EXPECT_EQ("0 0 1", GetCountSummary());
reset();
- MultiDisplayManager::CycleDisplay();
+ DisplayManager::CycleDisplay();
EXPECT_EQ(2U, display_manager()->GetNumDisplays());
EXPECT_EQ("0 1 0", GetCountSummary());
reset();
}
-TEST_F(MultiDisplayManagerTest, MAYBE_OverscanInsetsTest) {
+TEST_F(DisplayManagerTest, MAYBE_OverscanInsetsTest) {
UpdateDisplay("0+0-500x500,0+501-400x400");
reset();
ASSERT_EQ(2u, display_manager()->GetNumDisplays());
@@ -279,7 +274,7 @@ TEST_F(MultiDisplayManagerTest, MAYBE_OverscanInsetsTest) {
EXPECT_EQ("188x190", display_manager()->GetDisplayAt(1)->size().ToString());
}
-TEST_F(MultiDisplayManagerTest, MAYBE_ZeroOverscanInsets) {
+TEST_F(DisplayManagerTest, MAYBE_ZeroOverscanInsets) {
// Make sure the display change events is emitted for overscan inset changes.
UpdateDisplay("0+0-500x500,0+501-400x400");
ASSERT_EQ(2u, display_manager()->GetNumDisplays());
@@ -313,8 +308,7 @@ TEST_F(MultiDisplayManagerTest, MAYBE_ZeroOverscanInsets) {
DISABLED_NativeDisplaysChangedAfterPrimaryChange
#endif
-TEST_F(MultiDisplayManagerTest, MAYBE_TestDeviceScaleOnlyChange) {
- aura::DisplayManager::set_use_fullscreen_host_window(true);
+TEST_F(DisplayManagerTest, MAYBE_TestDeviceScaleOnlyChange) {
UpdateDisplay("1000x600");
EXPECT_EQ(1,
Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor());
@@ -325,10 +319,9 @@ TEST_F(MultiDisplayManagerTest, MAYBE_TestDeviceScaleOnlyChange) {
Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor());
EXPECT_EQ("500x300",
Shell::GetPrimaryRootWindow()->bounds().size().ToString());
- aura::DisplayManager::set_use_fullscreen_host_window(false);
}
-TEST_F(MultiDisplayManagerTest, MAYBE_TestNativeDisplaysChanged) {
+TEST_F(DisplayManagerTest, MAYBE_TestNativeDisplaysChanged) {
const int64 internal_display_id =
display_manager()->SetFirstDisplayAsInternalDisplayForTest();
const gfx::Display native_display(internal_display_id,
@@ -403,7 +396,7 @@ TEST_F(MultiDisplayManagerTest, MAYBE_TestNativeDisplaysChanged) {
DISABLED_EnsurePointerInDisplays_2ndOnLeft
#endif
-TEST_F(MultiDisplayManagerTest, MAYBE_EnsurePointerInDisplays) {
+TEST_F(DisplayManagerTest, MAYBE_EnsurePointerInDisplays) {
UpdateDisplay("200x200,300x300");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
@@ -441,7 +434,7 @@ TEST_F(MultiDisplayManagerTest, MAYBE_EnsurePointerInDisplays) {
EXPECT_EQ("150,140", env->last_mouse_location().ToString());
}
-TEST_F(MultiDisplayManagerTest, MAYBE_EnsurePointerInDisplays_2ndOnLeft) {
+TEST_F(DisplayManagerTest, MAYBE_EnsurePointerInDisplays_2ndOnLeft) {
UpdateDisplay("200x200,300x300");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
@@ -476,7 +469,7 @@ TEST_F(MultiDisplayManagerTest, MAYBE_EnsurePointerInDisplays_2ndOnLeft) {
EXPECT_EQ("150,150", env->last_mouse_location().ToString());
}
-TEST_F(MultiDisplayManagerTest, MAYBE_NativeDisplaysChangedAfterPrimaryChange) {
+TEST_F(DisplayManagerTest, MAYBE_NativeDisplaysChangedAfterPrimaryChange) {
const int64 internal_display_id =
display_manager()->SetFirstDisplayAsInternalDisplayForTest();
const gfx::Display native_display(internal_display_id,
diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc
index b6cde73..741287b 100644
--- a/ash/extended_desktop_unittest.cc
+++ b/ash/extended_desktop_unittest.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
@@ -17,7 +17,6 @@
#include "base/string_util.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/client/capture_client.h"
-#include "ui/aura/env.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
@@ -76,9 +75,8 @@ class ModalWidgetDelegate : public views::WidgetDelegateView {
DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate);
};
-internal::MultiDisplayManager* GetDisplayManager() {
- return static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
+internal::DisplayManager* GetDisplayManager() {
+ return Shell::GetInstance()->display_manager();
}
// An event filter which moves the target window to the secondary root window
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 82c4b21..5a1b36e 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -9,7 +9,7 @@
#include "ash/ash_switches.h"
#include "ash/desktop_background/desktop_background_widget_controller.h"
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/focus_cycler.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc
index 7b1605b..c58638a 100644
--- a/ash/root_window_controller_unittest.cc
+++ b/ash/root_window_controller_unittest.cc
@@ -5,7 +5,6 @@
#include "ash/root_window_controller.h"
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
diff --git a/ash/screen_ash.cc b/ash/screen_ash.cc
index e5417a2..fa9a986 100644
--- a/ash/screen_ash.cc
+++ b/ash/screen_ash.cc
@@ -5,7 +5,7 @@
#include "ash/screen_ash.h"
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/wm/property_util.h"
@@ -14,7 +14,6 @@
#include "base/logging.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
@@ -22,9 +21,8 @@
namespace ash {
namespace {
-internal::MultiDisplayManager* GetDisplayManager() {
- return static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
+internal::DisplayManager* GetDisplayManager() {
+ return Shell::GetInstance()->display_manager();
}
} // namespace
@@ -89,6 +87,20 @@ const gfx::Display& ScreenAsh::GetDisplayForId(int64 display_id) {
return GetDisplayManager()->GetDisplayForId(display_id);
}
+void ScreenAsh::NotifyBoundsChanged(const gfx::Display& display) {
+ FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_,
+ OnDisplayBoundsChanged(display));
+}
+
+void ScreenAsh::NotifyDisplayAdded(const gfx::Display& display) {
+ FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_, OnDisplayAdded(display));
+}
+
+void ScreenAsh::NotifyDisplayRemoved(const gfx::Display& display) {
+ FOR_EACH_OBSERVER(
+ gfx::DisplayObserver, observers_, OnDisplayRemoved(display));
+}
+
bool ScreenAsh::IsDIPEnabled() {
return true;
}
@@ -122,4 +134,12 @@ gfx::Display ScreenAsh::GetPrimaryDisplay() const {
return DisplayController::GetPrimaryDisplay();
}
+void ScreenAsh::AddObserver(gfx::DisplayObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void ScreenAsh::RemoveObserver(gfx::DisplayObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
} // namespace ash
diff --git a/ash/screen_ash.h b/ash/screen_ash.h
index b737bfc..7e1d108 100644
--- a/ash/screen_ash.h
+++ b/ash/screen_ash.h
@@ -7,6 +7,7 @@
#include "ash/ash_export.h"
#include "base/compiler_specific.h"
+#include "base/observer_list.h"
#include "ui/gfx/screen.h"
namespace gfx {
@@ -55,12 +56,16 @@ class ASH_EXPORT ScreenAsh : public gfx::Screen {
// invalid display if no such display is connected.
static const gfx::Display& GetDisplayForId(int64 display_id);
+ // Notifies observers of display configuration changes.
+ void NotifyBoundsChanged(const gfx::Display& display);
+ void NotifyDisplayAdded(const gfx::Display& display);
+ void NotifyDisplayRemoved(const gfx::Display& display);
+
protected:
// Implementation of gfx::Screen:
virtual bool IsDIPEnabled() OVERRIDE;
virtual gfx::Point GetCursorScreenPoint() OVERRIDE;
virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE;
-
virtual int GetNumDisplays() OVERRIDE;
virtual gfx::Display GetDisplayNearestWindow(
gfx::NativeView view) const OVERRIDE;
@@ -69,8 +74,12 @@ class ASH_EXPORT ScreenAsh : public gfx::Screen {
virtual gfx::Display GetDisplayMatching(
const gfx::Rect& match_rect) const OVERRIDE;
virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
+ virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE;
+ virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE;
private:
+ ObserverList<gfx::DisplayObserver> observers_;
+
DISALLOW_COPY_AND_ASSIGN(ScreenAsh);
};
diff --git a/ash/shell.cc b/ash/shell.cc
index 45dc886..623df98 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -16,7 +16,7 @@
#include "ash/desktop_background/user_wallpaper_delegate.h"
#include "ash/display/display_controller.h"
#include "ash/display/mouse_cursor_event_filter.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/display/screen_position_controller.h"
#include "ash/drag_drop/drag_drop_controller.h"
#include "ash/focus_cycler.h"
@@ -70,7 +70,6 @@
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/stacking_client.h"
#include "ui/aura/client/user_action_client.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/layout_manager.h"
@@ -97,7 +96,9 @@
#endif
#if defined(OS_CHROMEOS)
+#include "ash/display/display_change_observer_x11.h"
#include "ash/display/output_configurator_animation.h"
+#include "base/chromeos/chromeos_version.h"
#include "base/message_pump_aurax11.h"
#include "chromeos/display/output_configurator.h"
#include "content/public/browser/gpu_data_manager.h"
@@ -202,6 +203,7 @@ Shell::Shell(ShellDelegate* delegate)
browser_context_(NULL),
simulate_modal_window_open_for_testing_(false) {
DCHECK(delegate_.get());
+ display_manager_.reset(new internal::DisplayManager);
ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_);
if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE))
@@ -304,8 +306,6 @@ Shell::~Shell() {
// static
Shell* Shell::CreateInstance(ShellDelegate* delegate) {
CHECK(!instance_);
- aura::Env::GetInstance()->SetDisplayManager(
- new internal::MultiDisplayManager());
instance_ = new Shell(delegate);
instance_->Init();
return instance_;
@@ -392,6 +392,13 @@ bool Shell::IsLauncherPerDisplayEnabled() {
}
void Shell::Init() {
+#if defined(OS_CHROMEOS)
+ if (base::chromeos::IsRunningOnChromeOS()) {
+ display_change_observer_.reset(new internal::DisplayChangeObserverX11);
+ display_change_observer_->NotifyDisplayChange();
+ }
+#endif
+
// Install the custom factory first so that views::FocusManagers for Tray,
// Launcher, and WallPaper could be created by the factory.
views::FocusManagerFactory::Install(new AshFocusManagerFactory);
@@ -612,10 +619,7 @@ void Shell::RotateFocus(Direction direction) {
void Shell::SetDisplayWorkAreaInsets(Window* contains,
const gfx::Insets& insets) {
- internal::MultiDisplayManager* display_manager =
- static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
- if (!display_manager->UpdateWorkAreaOfDisplayNearestWindow(contains, insets))
+ if (!display_manager_->UpdateWorkAreaOfDisplayNearestWindow(contains, insets))
return;
FOR_EACH_OBSERVER(ShellObserver, observers_,
OnDisplayWorkAreaInsetsChanged());
diff --git a/ash/shell.h b/ash/shell.h
index 72073dc..38fd7e7 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -87,6 +87,8 @@ class AcceleratorFilter;
class ActivationController;
class AppListController;
class CaptureController;
+class DisplayChangeObserverX11;
+class DisplayManager;
class DragDropController;
class EventClientImpl;
class EventRewriterEventFilter;
@@ -263,6 +265,9 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate,
}
#endif // !defined(OS_MACOSX)
+ internal::DisplayManager* display_manager() {
+ return display_manager_.get();
+ }
views::corewm::CompoundEventFilter* env_filter() {
return env_filter_.get();
}
@@ -322,7 +327,7 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate,
return magnification_controller_.get();
}
- const ScreenAsh* screen() { return screen_; }
+ ScreenAsh* screen() { return screen_; }
// Force the shelf to query for it's current visibility state.
void UpdateShelfVisibility();
@@ -519,11 +524,16 @@ class ASH_EXPORT Shell : internal::SystemModalContainerEventFilterDelegate,
// a heads-up display. This is enabled only if --ash-touch-hud flag is used.
scoped_ptr<internal::TouchObserverHUD> touch_observer_hud_;
+ scoped_ptr<internal::DisplayManager> display_manager_;
+
#if defined(OS_CHROMEOS)
// Controls video output device state.
scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
scoped_ptr<internal::OutputConfiguratorAnimation>
output_configurator_animation_;
+
+ // Receives output change events and udpates the display manager.
+ scoped_ptr<internal::DisplayChangeObserverX11> display_change_observer_;
#endif // defined(OS_CHROMEOS)
CursorManager cursor_manager_;
diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc
index 1a09c2e..bf958d6 100644
--- a/ash/system/chromeos/tray_display.cc
+++ b/ash/system/chromeos/tray_display.cc
@@ -5,7 +5,7 @@
#include "ash/system/chromeos/tray_display.h"
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray.h"
@@ -15,7 +15,6 @@
#include "base/utf_string_conversions.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/env.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -78,8 +77,7 @@ class DisplayView : public ash::internal::ActionableView {
private:
// Returns the name of the currently connected external display.
string16 GetExternalDisplayName() {
- MultiDisplayManager* display_manager = static_cast<MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager();
gfx::Display external_display(gfx::Display::kInvalidDisplayID);
if (display_manager->HasInternalDisplay()) {
@@ -118,13 +116,13 @@ class DisplayView : public ash::internal::ActionableView {
TrayDisplay::TrayDisplay()
: default_(NULL) {
- aura::Env::GetInstance()->display_manager()->AddObserver(this);
- ash::Shell::GetInstance()->output_configurator()->AddObserver(this);
+ Shell::GetScreen()->AddObserver(this);
+ Shell::GetInstance()->output_configurator()->AddObserver(this);
}
TrayDisplay::~TrayDisplay() {
- aura::Env::GetInstance()->display_manager()->RemoveObserver(this);
- ash::Shell::GetInstance()->output_configurator()->RemoveObserver(this);
+ Shell::GetScreen()->RemoveObserver(this);
+ Shell::GetInstance()->output_configurator()->RemoveObserver(this);
}
views::View* TrayDisplay::CreateDefaultView(user::LoginStatus status) {
diff --git a/ash/system/chromeos/tray_display.h b/ash/system/chromeos/tray_display.h
index 77994b6..0685a9d 100644
--- a/ash/system/chromeos/tray_display.h
+++ b/ash/system/chromeos/tray_display.h
@@ -7,7 +7,7 @@
#include "ash/system/tray/system_tray_item.h"
#include "base/memory/scoped_ptr.h"
-#include "ui/aura/display_observer.h"
+#include "ui/gfx/display_observer.h"
#include "chromeos/display/output_configurator.h"
@@ -22,7 +22,7 @@ class DisplayView;
class TrayDisplay : public SystemTrayItem,
public chromeos::OutputConfigurator::Observer,
- public aura::DisplayObserver {
+ public gfx::DisplayObserver {
public:
TrayDisplay();
virtual ~TrayDisplay();
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc
index 870c259..eaa2288 100644
--- a/ash/test/ash_test_base.cc
+++ b/ash/test/ash_test_base.cc
@@ -8,14 +8,13 @@
#include <vector>
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/shell.h"
-#include "ash/test/multi_display_manager_test_api.h"
+#include "ash/test/display_manager_test_api.h"
#include "ash/test/test_shell_delegate.h"
#include "base/run_loop.h"
#include "content/public/test/web_contents_tester.h"
#include "ui/aura/env.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/root_window.h"
#include "ui/base/ime/text_input_test_support.h"
#include "ui/compositor/layer_animator.h"
@@ -70,17 +69,13 @@ void AshTestBase::ChangeDisplayConfig(float scale,
display.SetScaleAndBounds(scale, bounds_in_pixel);
std::vector<gfx::Display> displays;
displays.push_back(display);
- aura::Env::GetInstance()->display_manager()->OnNativeDisplaysChanged(
- displays);
+ Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
}
void AshTestBase::UpdateDisplay(const std::string& display_specs) {
- internal::MultiDisplayManager* multi_display_manager =
- static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
- MultiDisplayManagerTestApi multi_display_manager_test_api(
- multi_display_manager);
- multi_display_manager_test_api.UpdateDisplay(display_specs);
+ DisplayManagerTestApi display_manager_test_api(
+ Shell::GetInstance()->display_manager());
+ display_manager_test_api.UpdateDisplay(display_specs);
}
void AshTestBase::RunAllPendingInMessageLoop() {
diff --git a/ash/test/ash_test_base.h b/ash/test/ash_test_base.h
index b5007e5..e21225a 100644
--- a/ash/test/ash_test_base.h
+++ b/ash/test/ash_test_base.h
@@ -15,7 +15,7 @@
namespace ash {
namespace internal {
-class MultiDisplayManager;
+class DisplayManager;
} // internal
namespace test {
@@ -46,7 +46,7 @@ class AshTestBase : public testing::Test {
void ChangeDisplayConfig(float scale, const gfx::Rect& bounds);
// Update the display configuration as given in |display_specs|.
- // See ash::test::MultiDisplayManagerTestApi::UpdateDisplay for more details.
+ // See ash::test::DisplayManagerTestApi::UpdateDisplay for more details.
void UpdateDisplay(const std::string& display_specs);
protected:
diff --git a/ash/test/multi_display_manager_test_api.cc b/ash/test/display_manager_test_api.cc
index 9d35016..f068b64 100644
--- a/ash/test/multi_display_manager_test_api.cc
+++ b/ash/test/display_manager_test_api.cc
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/test/multi_display_manager_test_api.h"
+#include "ash/test/display_manager_test_api.h"
#include <vector>
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/shell.h"
#include "base/string_split.h"
+#include "ui/aura/display_util.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/display.h"
@@ -23,21 +24,21 @@ std::vector<gfx::Display> CreateDisplaysFromString(
base::SplitString(specs, ',', &parts);
for (std::vector<std::string>::const_iterator iter = parts.begin();
iter != parts.end(); ++iter) {
- displays.push_back(aura::DisplayManager::CreateDisplayFromSpec(*iter));
+ displays.push_back(aura::CreateDisplayFromSpec(*iter));
}
return displays;
}
} // namespace
-MultiDisplayManagerTestApi::MultiDisplayManagerTestApi(
- internal::MultiDisplayManager* display_manager)
+DisplayManagerTestApi::DisplayManagerTestApi(
+ internal::DisplayManager* display_manager)
: display_manager_(display_manager) {
}
-MultiDisplayManagerTestApi::~MultiDisplayManagerTestApi() {}
+DisplayManagerTestApi::~DisplayManagerTestApi() {}
-void MultiDisplayManagerTestApi::UpdateDisplay(
+void DisplayManagerTestApi::UpdateDisplay(
const std::string& display_specs) {
std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs);
display_manager_->SetDisplayIdsForTest(&displays);
@@ -66,6 +67,5 @@ void MultiDisplayManagerTestApi::UpdateDisplay(
}
}
-
} // namespace test
} // namespace ash
diff --git a/ash/test/multi_display_manager_test_api.h b/ash/test/display_manager_test_api.h
index 9b23267..57e961d 100644
--- a/ash/test/multi_display_manager_test_api.h
+++ b/ash/test/display_manager_test_api.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_TEST_MULTI_DISPLAY_MANAGER_TEST_API_H_
-#define ASH_TEST_MULTI_DISPLAY_MANAGER_TEST_API_H_
+#ifndef ASH_TEST_DISPLAY_MANAGER_TEST_API_H_
+#define ASH_TEST_DISPLAY_MANAGER_TEST_API_H_
#include <string>
@@ -11,16 +11,15 @@
namespace ash {
namespace internal {
-class MultiDisplayManager;
+class DisplayManager;
} // internal
namespace test {
-class MultiDisplayManagerTestApi {
+class DisplayManagerTestApi {
public:
- explicit MultiDisplayManagerTestApi(
- internal::MultiDisplayManager* display_manager);
- virtual ~MultiDisplayManagerTestApi();
+ explicit DisplayManagerTestApi(internal::DisplayManager* display_manager);
+ virtual ~DisplayManagerTestApi();
// Update the display configuration as given in |display_specs|. The format of
// |display_spec| is a list of comma separated spec for each displays. Please
@@ -29,12 +28,12 @@ class MultiDisplayManagerTestApi {
void UpdateDisplay(const std::string& display_specs);
private:
- internal::MultiDisplayManager* display_manager_; // not owned
+ internal::DisplayManager* display_manager_; // not owned
- DISALLOW_COPY_AND_ASSIGN(MultiDisplayManagerTestApi);
+ DISALLOW_COPY_AND_ASSIGN(DisplayManagerTestApi);
};
} // namespace test
} // namespace ash
-#endif // ASH_TEST_MULTI_DISPLAY_MANAGER_TEST_API_H_
+#endif // ASH_TEST_DISPLAY_MANAGER_TEST_API_H_
diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc
index 4a4637a..984ef6c 100644
--- a/ash/wm/shelf_layout_manager_unittest.cc
+++ b/ash/wm/shelf_layout_manager_unittest.cc
@@ -7,6 +7,7 @@
#include "ash/accelerators/accelerator_controller.h"
#include "ash/accelerators/accelerator_table.h"
#include "ash/ash_switches.h"
+#include "ash/display/display_manager.h"
#include "ash/focus_cycler.h"
#include "ash/launcher/launcher.h"
#include "ash/root_window_controller.h"
@@ -22,8 +23,6 @@
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/env.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/window.h"
@@ -204,10 +203,8 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) {
shelf->launcher_widget()->GetWindowBoundsInScreen());
int shelf_height = shelf->GetIdealBounds().height();
- const aura::DisplayManager* manager =
- aura::Env::GetInstance()->display_manager();
- const gfx::Display& display =
- manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
+ const gfx::Display& display = Shell::GetInstance()->display_manager()->
+ GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
ASSERT_NE(-1, display.id());
// Bottom inset should be the max of widget heights.
EXPECT_EQ(shelf_height,
@@ -256,10 +253,8 @@ TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
shelf->LayoutShelf();
EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state());
- const aura::DisplayManager* manager =
- aura::Env::GetInstance()->display_manager();
- const gfx::Display& display =
- manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
+ const gfx::Display& display = Shell::GetInstance()->display_manager()->
+ GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
// Hide the shelf.
SetState(shelf, ShelfLayoutManager::HIDDEN);
@@ -613,8 +608,8 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) {
shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
gfx::Rect launcher_bounds(
shelf->launcher_widget()->GetWindowBoundsInScreen());
- const aura::DisplayManager* manager =
- aura::Env::GetInstance()->display_manager();
+ const internal::DisplayManager* manager =
+ Shell::GetInstance()->display_manager();
gfx::Display display =
manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow());
ASSERT_NE(-1, display.id());
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc
index 14bba69..765083c 100644
--- a/ash/wm/system_gesture_event_filter_unittest.cc
+++ b/ash/wm/system_gesture_event_filter_unittest.cc
@@ -6,7 +6,7 @@
#include "ash/accelerators/accelerator_controller.h"
#include "ash/ash_switches.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/launcher/launcher.h"
#include "ash/launcher/launcher_model.h"
#include "ash/shell.h"
@@ -20,7 +20,6 @@
#include "base/command_line.h"
#include "base/time.h"
#include "base/timer.h"
-#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_windows.h"
@@ -162,8 +161,7 @@ class SystemGestureEventFilterTest : public AshTestBase {
::switches::kEnableBezelTouch);
test::AshTestBase::SetUp();
// Enable brightness key.
- static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager())->
+ Shell::GetInstance()->display_manager()->
SetFirstDisplayAsInternalDisplayForTest();
}
diff --git a/ash/wm/window_cycle_controller_unittest.cc b/ash/wm/window_cycle_controller_unittest.cc
index 9629ddf..fefb0de 100644
--- a/ash/wm/window_cycle_controller_unittest.cc
+++ b/ash/wm/window_cycle_controller_unittest.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
diff --git a/chrome/browser/chromeos/display/display_preferences.cc b/chrome/browser/chromeos/display/display_preferences.cc
index 127d23a..ebbfb76 100644
--- a/chrome/browser/chromeos/display/display_preferences.cc
+++ b/chrome/browser/chromeos/display/display_preferences.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/chromeos/display/display_preferences.h"
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/shell.h"
#include "base/string16.h"
#include "base/string_number_conversions.h"
@@ -18,8 +18,6 @@
#include "chrome/common/pref_names.h"
#include "googleurl/src/url_canon.h"
#include "googleurl/src/url_util.h"
-#include "ui/aura/display_manager.h"
-#include "ui/aura/env.h"
#include "ui/gfx/display.h"
#include "ui/gfx/insets.h"
@@ -70,9 +68,8 @@ void InsetsToValue(const gfx::Insets& insets, base::DictionaryValue* value) {
value->SetInteger("right", insets.right());
}
-ash::internal::MultiDisplayManager* GetDisplayManager() {
- return static_cast<ash::internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
+ash::internal::DisplayManager* GetDisplayManager() {
+ return ash::Shell::GetInstance()->display_manager();
}
// Returns true id the current user can write display preferences to
@@ -118,7 +115,7 @@ void NotifyDisplayLayoutChanged(PrefService* pref_service) {
void NotifyDisplayOverscans() {
PrefService* local_state = g_browser_process->local_state();
- ash::internal::MultiDisplayManager* display_manager = GetDisplayManager();
+ ash::internal::DisplayManager* display_manager = GetDisplayManager();
const base::DictionaryValue* overscans = local_state->GetDictionary(
prefs::kDisplayOverscans);
@@ -142,6 +139,8 @@ void NotifyDisplayOverscans() {
continue;
}
+ // TODO(oshima|mukai): DisplayManager is internal class.
+ // Move |SetOverscanInsets| to display controller.
display_manager->SetOverscanInsets(display_id, insets);
}
}
@@ -183,10 +182,8 @@ void SetDisplayLayoutPref(PrefService* pref_service,
ash::DisplayLayout display_layout(
static_cast<ash::DisplayLayout::Position>(layout), offset);
- aura::DisplayManager* display_manager =
- aura::Env::GetInstance()->display_manager();
std::string name;
- EscapeDisplayName(display_manager->GetDisplayNameFor(display),
+ EscapeDisplayName(GetDisplayManager()->GetDisplayNameFor(display),
&name);
DCHECK(!name.empty());
diff --git a/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc b/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc
index 9711729..a5ed8af 100644
--- a/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc
+++ b/chrome/browser/chromeos/login/wallpaper_manager_browsertest.cc
@@ -7,9 +7,9 @@
#include "ash/desktop_background/desktop_background_resources.h"
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/desktop_background/desktop_background_controller_observer.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/shell.h"
-#include "ash/test/multi_display_manager_test_api.h"
+#include "ash/test/display_manager_test_api.h"
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/string_number_conversions.h"
@@ -20,7 +20,6 @@
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/test/base/testing_browser_process.h"
#include "ui/aura/env.h"
-#include "ui/aura/display_manager.h"
#include "ui/base/resource/resource_bundle.h"
using namespace ash;
@@ -70,15 +69,12 @@ class WallpaperManagerBrowserTest : public CrosInProcessBrowserTest,
}
// Update the display configuration as given in |display_specs|.
- // See ash::test::MultiDisplayManagerTestApi::UpdateDisplay for more
+ // See ash::test::DisplayManagerTestApi::UpdateDisplay for more
// details.
void UpdateDisplay(const std::string& display_specs) {
- internal::MultiDisplayManager* multi_display_manager =
- static_cast<internal::MultiDisplayManager*>(
- aura::Env::GetInstance()->display_manager());
- ash::test::MultiDisplayManagerTestApi multi_display_manager_test_api(
- multi_display_manager);
- multi_display_manager_test_api.UpdateDisplay(display_specs);
+ ash::test::DisplayManagerTestApi display_manager_test_api(
+ ash::Shell::GetInstance()->display_manager());
+ display_manager_test_api.UpdateDisplay(display_specs);
}
void WaitAsyncWallpaperLoad() {
diff --git a/chrome/browser/ui/ash/ash_init.cc b/chrome/browser/ui/ash/ash_init.cc
index d45a93c..5705e79 100644
--- a/chrome/browser/ui/ash/ash_init.cc
+++ b/chrome/browser/ui/ash/ash_init.cc
@@ -19,7 +19,7 @@
#include "chrome/browser/ui/ash/screenshot_taker.h"
#include "chrome/common/chrome_switches.h"
#include "ui/aura/aura_switches.h"
-#include "ui/aura/display_manager.h"
+#include "ui/aura/display_util.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/compositor/compositor_setup.h"
@@ -56,16 +56,14 @@ void OpenAsh() {
ui::HideHostCursor();
}
#endif
-
if (use_fullscreen) {
- aura::DisplayManager::set_use_fullscreen_host_window(true);
+ aura::SetUseFullscreenHostWindow(true);
#if defined(OS_CHROMEOS)
// Hide the mouse cursor completely at boot.
if (!chromeos::UserManager::Get()->IsUserLoggedIn())
ash::Shell::set_initially_hide_cursor(true);
#endif
}
-
// Its easier to mark all windows as persisting and exclude the ones we care
// about (browser windows), rather than explicitly excluding certain windows.
ash::SetDefaultPersistsAcrossAllWorkspaces(true);
diff --git a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc
index c5cf354..4c5dff5 100644
--- a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc
+++ b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/toolkit_extra_parts.h"
#include "chrome/browser/ui/aura/stacking_client_aura.h"
#include "ui/aura/env.h"
-#include "ui/aura/single_display_manager.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
@@ -38,7 +37,6 @@ void ChromeBrowserMainExtraPartsAura::PreProfileInit() {
{
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
views::CreateDesktopScreen());
- aura::Env::GetInstance()->SetDisplayManager(new aura::SingleDisplayManager);
stacking_client_.reset(new views::DesktopStackingClient);
aura::client::SetStackingClient(stacking_client_.get());
}
diff --git a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
index 1585439..44b9f3e3 100644
--- a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
+++ b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc
@@ -12,7 +12,6 @@
#include "chrome/browser/ui/views/ash/tab_scrubber.h"
#include "chrome/common/chrome_switches.h"
#include "ui/aura/env.h"
-#include "ui/aura/single_display_manager.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/screen_type_delegate.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
index 8ee2ea3..7bca443 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
@@ -34,7 +34,7 @@
#if defined(USE_ASH)
#include "ash/display/display_controller.h"
-#include "ash/display/multi_display_manager.h"
+#include "ash/display/display_manager.h"
#include "ash/shell.h"
#include "ash/test/cursor_manager_test_api.h"
#include "ash/wm/cursor_manager.h"
@@ -1286,7 +1286,7 @@ void CancelDragTabToWindowInSeparateDisplayStep3(
ASSERT_EQ(2u, BrowserList::size());
// Switching display mode should cancel the drag operation.
- ash::internal::MultiDisplayManager::CycleDisplay();
+ ash::internal::DisplayManager::CycleDisplay();
}
// Invoked from the nested message loop.
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
index b016273..6266096 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc
@@ -7,6 +7,7 @@
#include <string>
#include "ash/display/display_controller.h"
+#include "ash/display/display_manager.h"
#include "ash/display/output_configurator_animation.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
@@ -22,8 +23,6 @@
#include "chromeos/display/output_configurator.h"
#include "content/public/browser/web_ui.h"
#include "grit/generated_resources.h"
-#include "ui/aura/env.h"
-#include "ui/aura/display_manager.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/display.h"
#include "ui/gfx/rect.h"
@@ -33,11 +32,11 @@ namespace chromeos {
namespace options {
DisplayOptionsHandler::DisplayOptionsHandler() {
- aura::Env::GetInstance()->display_manager()->AddObserver(this);
+ ash::Shell::GetScreen()->AddObserver(this);
}
DisplayOptionsHandler::~DisplayOptionsHandler() {
- aura::Env::GetInstance()->display_manager()->RemoveObserver(this);
+ ash::Shell::GetScreen()->RemoveObserver(this);
}
void DisplayOptionsHandler::GetLocalizedValues(
@@ -133,8 +132,8 @@ void DisplayOptionsHandler::UpdateDisplaySectionVisibility() {
}
void DisplayOptionsHandler::SendDisplayInfo() {
- aura::DisplayManager* display_manager =
- aura::Env::GetInstance()->display_manager();
+ ash::internal::DisplayManager* display_manager =
+ ash::Shell::GetInstance()->display_manager();
ash::DisplayController* display_controller =
ash::Shell::GetInstance()->display_controller();
chromeos::OutputConfigurator* output_configurator =
diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.h b/chrome/browser/ui/webui/options/chromeos/display_options_handler.h
index d53660d..b41a304 100644
--- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.h
+++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.h
@@ -8,7 +8,7 @@
#include <vector>
#include "chrome/browser/ui/webui/options/options_ui.h"
-#include "ui/aura/display_observer.h"
+#include "ui/gfx/display_observer.h"
namespace base {
class DictionaryValue;
@@ -22,7 +22,7 @@ namespace options {
// Display options overlay page UI handler.
class DisplayOptionsHandler : public ::options::OptionsPageUIHandler,
- public aura::DisplayObserver {
+ public gfx::DisplayObserver {
public:
DisplayOptionsHandler();
virtual ~DisplayOptionsHandler();
@@ -35,7 +35,7 @@ class DisplayOptionsHandler : public ::options::OptionsPageUIHandler,
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
- // aura::DisplayObserver implementation.
+ // gfx::DisplayObserver implementation.
virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 31e0dae..b03b2dd 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -659,7 +659,7 @@
'../testing/gtest.gyp:gtest',
],
'include_dirs': [
- '..',
+ '..,'
],
'sources': [
'test/chromedriver/chrome_finder_unittest.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 4a7f675..6c5b2b1 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1560,9 +1560,6 @@
'test/data/unit/framework_unittest.gtestjs',
'test/logging/win/mof_data_parser_unittest.cc',
'tools/convert_dict/convert_dict_unittest.cc',
- '../ash/test/test_launcher_delegate.cc',
- '../ash/test/test_launcher_delegate.h',
- '../ash/test/test_shell_delegate.cc',
# TODO(joi): Move to 'base_prefs' target in base/base.gyp once
# Prefs move is complete and dependencies have been broken.
@@ -1700,6 +1697,7 @@
],
'dependencies': [
'../ash/ash.gyp:ash_resources',
+ '../ash/ash.gyp:test_support_ash',
],
# We eventually want to compile both in Win Aura builds, see
# http://crbug.com/155545.
@@ -1726,12 +1724,6 @@
['exclude', '^browser/ui/panels/display_settings_provider_win_unittest.cc'],
['exclude', '^browser/bookmarks/bookmark_node_data_unittest.cc'],
],
- 'sources': [
- '../ash/test/multi_display_manager_test_api.cc',
- '../ash/test/multi_display_manager_test_api.h',
- '../ash/test/ash_test_base.cc',
- '../ash/test/ash_test_base.h',
- ],
}],
['enable_task_manager==0', {
'sources/': [
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc
index 8f96246..ce518c5 100644
--- a/content/browser/renderer_host/render_widget_host_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -24,10 +24,12 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/screen.h"
#if defined(USE_AURA)
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
#include "ui/aura/env.h"
+#include "ui/aura/test/test_screen.h"
#endif
#if defined(OS_WIN) || defined(USE_AURA)
@@ -389,6 +391,10 @@ class RenderWidgetHostTest : public testing::Test {
browser_context_.reset(new TestBrowserContext());
delegate_.reset(new MockRenderWidgetHostDelegate());
process_ = new RenderWidgetHostProcess(browser_context_.get());
+#if defined(USE_AURA)
+ screen_.reset(new aura::TestScreen);
+ gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
+#endif
host_.reset(
new MockRenderWidgetHost(delegate_.get(), process_, MSG_ROUTING_NONE));
view_.reset(new TestView(host_.get()));
@@ -404,6 +410,7 @@ class RenderWidgetHostTest : public testing::Test {
#if defined(USE_AURA)
aura::Env::DeleteInstance();
+ screen_.reset();
#endif
// Process all pending tasks to avoid leaks.
@@ -520,6 +527,7 @@ class RenderWidgetHostTest : public testing::Test {
scoped_ptr<MockRenderWidgetHostDelegate> delegate_;
scoped_ptr<MockRenderWidgetHost> host_;
scoped_ptr<TestView> view_;
+ scoped_ptr<gfx::Screen> screen_;
private:
WebTouchEvent touch_event_;
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 3147897..013632f 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -34,7 +34,6 @@
#include "ui/aura/client/stacking_client.h"
#include "ui/aura/client/tooltip_client.h"
#include "ui/aura/client/window_types.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -292,11 +291,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host)
window_->AddObserver(window_observer_.get());
aura::client::SetTooltipText(window_, &tooltip_);
aura::client::SetActivationDelegate(window_, this);
- aura::DisplayManager* display_manager =
- aura::Env::GetInstance()->display_manager();
- // display_manager can be NULL in tests.
- if (display_manager)
- display_manager->AddObserver(this);
+ gfx::Screen::GetScreenFor(window_)->AddObserver(this);
}
////////////////////////////////////////////////////////////////////////////////
@@ -1316,7 +1311,7 @@ void RenderWidgetHostViewAura::ExtendSelectionAndDelete(
}
////////////////////////////////////////////////////////////////////////////////
-// RenderWidgetHostViewAura, aura::DisplayObserver implementation:
+// RenderWidgetHostViewAura, gfx::DisplayObserver implementation:
void RenderWidgetHostViewAura::OnDisplayBoundsChanged(
const gfx::Display& display) {
@@ -1802,11 +1797,7 @@ RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
popup_child_host_view_->popup_parent_host_view_ = NULL;
}
aura::client::SetTooltipText(window_, NULL);
- aura::DisplayManager* display_manager =
- aura::Env::GetInstance()->display_manager();
- // display_manager can be NULL in tests.
- if (display_manager)
- display_manager->RemoveObserver(this);
+ gfx::Screen::GetScreenFor(window_)->RemoveObserver(this);
// This call is usually no-op since |this| object is already removed from the
// Aura root window and we don't have a way to get an input method object
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
index ac35d7c..6146668 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -17,10 +17,10 @@
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/common/content_export.h"
#include "ui/aura/client/activation_delegate.h"
-#include "ui/aura/display_observer.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/compositor/compositor_observer.h"
+#include "ui/gfx/display_observer.h"
#include "ui/gfx/rect.h"
#include "webkit/glue/webcursor.h"
@@ -48,7 +48,7 @@ class RenderWidgetHostViewAura
: public RenderWidgetHostViewBase,
public ui::CompositorObserver,
public ui::TextInputClient,
- public aura::DisplayObserver,
+ public gfx::DisplayObserver,
public aura::WindowDelegate,
public aura::client::ActivationDelegate,
public ImageTransportFactoryObserver,
@@ -163,7 +163,7 @@ class RenderWidgetHostViewAura
base::i18n::TextDirection direction) OVERRIDE;
virtual void ExtendSelectionAndDelete(size_t before, size_t after) OVERRIDE;
- // Overridden from aura::DisplayObserver:
+ // Overridden from gfx::DisplayObserver:
virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE;
virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE;
virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE;
diff --git a/content/shell/DEPS b/content/shell/DEPS
index b7fd438..64bcfea 100644
--- a/content/shell/DEPS
+++ b/content/shell/DEPS
@@ -19,8 +19,6 @@ include_rules = [
# The content_shell for aura must work with the views and aura
"+ui/aura",
"+ui/views",
- # Ash is needed for ScreenAsh on ChromeOS.
- "+ash",
# For WebTestRunner library
"+third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public",
diff --git a/content/shell/shell_aura.cc b/content/shell/shell_aura.cc
index 235cdd9..22feb77 100644
--- a/content/shell/shell_aura.cc
+++ b/content/shell/shell_aura.cc
@@ -6,10 +6,8 @@
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/single_display_manager.h"
#include "ui/aura/window.h"
#include "ui/base/accessibility/accessibility_types.h"
#include "ui/base/clipboard/clipboard.h"
@@ -29,9 +27,9 @@
#include "ui/views/widget/widget_delegate.h"
#if defined(OS_CHROMEOS)
-#include "ash/screen_ash.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "content/shell/shell_stacking_client_ash.h"
+#include "ui/aura/test/test_screen.h"
#else
#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
#endif
@@ -283,11 +281,10 @@ void Shell::PlatformInitialize() {
#if defined(OS_CHROMEOS)
chromeos::DBusThreadManager::Initialize();
#endif
- aura::Env::GetInstance()->SetDisplayManager(new aura::SingleDisplayManager);
#if defined(OS_CHROMEOS)
stacking_client_ = new content::ShellStackingClientAsh();
gfx::Screen::SetScreenInstance(
- gfx::SCREEN_TYPE_NATIVE, new ash::ScreenAsh);
+ gfx::SCREEN_TYPE_NATIVE, new aura::TestScreen);
#else
stacking_client_ = new views::DesktopStackingClient();
gfx::Screen::SetScreenInstance(
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 68d7c36..6fe1f70 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -64,8 +64,8 @@
'device_list_updater_aurax11.cc',
'device_list_updater_aurax11.h',
'dispatcher_win.cc',
- 'display_observer.cc',
- 'display_observer.h',
+ 'display_util.cc',
+ 'display_util.h',
'env.cc',
'env.h',
'env_observer.h',
@@ -76,10 +76,6 @@
'focus_manager.h',
'layout_manager.cc',
'layout_manager.h',
- 'display_change_observer_x11.cc',
- 'display_change_observer_x11.h',
- 'display_manager.cc',
- 'display_manager.h',
'remote_root_window_host_win.cc',
'remote_root_window_host_win.h',
'root_window_host.h',
@@ -96,8 +92,6 @@
'root_window_view_mac.mm',
'root_window.cc',
'root_window.h',
- 'single_display_manager.cc',
- 'single_display_manager.h',
'ui_controls_win.cc',
'ui_controls_x11.cc',
'window.cc',
@@ -209,6 +203,7 @@
'../ui.gyp:ui_resources',
'../../ipc/ipc.gyp:ipc',
'aura',
+ 'test_support_aura',
],
'include_dirs': [
'..',
@@ -231,6 +226,7 @@
'../ui.gyp:ui',
'../ui.gyp:ui_resources',
'aura',
+ 'test_support_aura',
],
'include_dirs': [
'..',
diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc
index c15ece4..6d255ec 100644
--- a/ui/aura/bench/bench_main.cc
+++ b/ui/aura/bench/bench_main.cc
@@ -13,10 +13,11 @@
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/skia/include/core/SkXfermode.h"
#include "ui/aura/client/default_capture_client.h"
+#include "ui/aura/display_util.h"
#include "ui/aura/env.h"
#include "ui/aura/focus_manager.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/single_display_manager.h"
+#include "ui/aura/test/test_screen.h"
#include "ui/aura/window.h"
#include "ui/base/hit_test.h"
#include "ui/base/resource/resource_bundle.h"
@@ -297,11 +298,12 @@ int main(int argc, char** argv) {
MessageLoop message_loop(MessageLoop::TYPE_UI);
ui::CompositorTestSupport::Initialize();
- aura::SingleDisplayManager* manager = new aura::SingleDisplayManager;
- manager->set_use_fullscreen_host_window(true);
- aura::Env::GetInstance()->SetDisplayManager(manager);
+ aura::Env::GetInstance();
+ aura::SetUseFullscreenHostWindow(true);
+ aura::TestScreen test_screen;
+ gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, &test_screen);
scoped_ptr<aura::RootWindow> root_window(
- aura::DisplayManager::CreateRootWindowForPrimaryDisplay());
+ test_screen.CreateRootWindowForPrimaryDisplay());
aura::client::SetCaptureClient(
root_window.get(),
new aura::client::DefaultCaptureClient(root_window.get()));
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 46dbe72..91c95d3 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -12,7 +12,7 @@
#include "ui/aura/client/stacking_client.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/single_display_manager.h"
+#include "ui/aura/test/test_screen.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/events/event.h"
@@ -122,9 +122,11 @@ int DemoMain() {
// Create the message-loop here before creating the root window.
MessageLoop message_loop(MessageLoop::TYPE_UI);
ui::CompositorTestSupport::Initialize();
- aura::Env::GetInstance()->SetDisplayManager(new aura::SingleDisplayManager);
+ aura::Env::GetInstance();
+ aura::TestScreen test_screen;
+ gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, &test_screen);
scoped_ptr<aura::RootWindow> root_window(
- aura::DisplayManager::CreateRootWindowForPrimaryDisplay());
+ test_screen.CreateRootWindowForPrimaryDisplay());
scoped_ptr<DemoStackingClient> stacking_client(new DemoStackingClient(
root_window.get()));
diff --git a/ui/aura/display_manager.cc b/ui/aura/display_manager.cc
deleted file mode 100644
index ca5157b..0000000
--- a/ui/aura/display_manager.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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/display_manager.h"
-
-#include <stdio.h>
-
-#include "base/logging.h"
-#include "ui/aura/display_observer.h"
-#include "ui/aura/env.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/root_window_host.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/rect.h"
-
-namespace aura {
-namespace {
-// Default bounds for a display.
-const int kDefaultHostWindowX = 200;
-const int kDefaultHostWindowY = 200;
-const int kDefaultHostWindowWidth = 1280;
-const int kDefaultHostWindowHeight = 1024;
-} // namespace
-
-// static
-bool DisplayManager::use_fullscreen_host_window_ = false;
-
-// static
-gfx::Display DisplayManager::CreateDisplayFromSpec(const std::string& spec) {
- static int64 synthesized_display_id = 1000;
- gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY,
- kDefaultHostWindowWidth, kDefaultHostWindowHeight);
- int x = 0, y = 0, width, height;
- float scale = 1.0f;
- if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2 ||
- sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height,
- &scale) >= 4) {
- bounds.SetRect(x, y, width, height);
- } else if (use_fullscreen_host_window_) {
- bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize());
- }
- gfx::Display display(synthesized_display_id++);
- display.SetScaleAndBounds(scale, bounds);
- DVLOG(1) << "Display bounds=" << bounds.ToString() << ", scale=" << scale;
- return display;
-}
-
-// static
-RootWindow* DisplayManager::CreateRootWindowForPrimaryDisplay() {
- DisplayManager* manager = aura::Env::GetInstance()->display_manager();
- RootWindow* root =
- manager->CreateRootWindowForDisplay(*manager->GetDisplayAt(0));
- if (use_fullscreen_host_window_)
- root->ConfineCursorToWindow();
- return root;
-}
-
-DisplayManager::DisplayManager() {
-}
-
-DisplayManager::~DisplayManager() {
-}
-
-void DisplayManager::AddObserver(DisplayObserver* observer) {
- observers_.AddObserver(observer);
-}
-
-void DisplayManager::RemoveObserver(DisplayObserver* observer) {
- observers_.RemoveObserver(observer);
-}
-
-void DisplayManager::NotifyBoundsChanged(const gfx::Display& display) {
- FOR_EACH_OBSERVER(DisplayObserver, observers_,
- OnDisplayBoundsChanged(display));
-}
-
-void DisplayManager::NotifyDisplayAdded(const gfx::Display& display) {
- FOR_EACH_OBSERVER(DisplayObserver, observers_, OnDisplayAdded(display));
-}
-
-void DisplayManager::NotifyDisplayRemoved(const gfx::Display& display) {
- FOR_EACH_OBSERVER(DisplayObserver, observers_, OnDisplayRemoved(display));
-}
-
-} // namespace aura
diff --git a/ui/aura/display_manager.h b/ui/aura/display_manager.h
deleted file mode 100644
index 796c6cf..0000000
--- a/ui/aura/display_manager.h
+++ /dev/null
@@ -1,110 +0,0 @@
-// 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_DISPLAY_MANAGER_H_
-#define UI_AURA_DISPLAY_MANAGER_H_
-
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/observer_list.h"
-#include "ui/aura/aura_export.h"
-
-namespace gfx {
-class Display;
-class Point;
-class Rect;
-class Size;
-}
-
-namespace aura {
-class DisplayObserver;
-class RootWindow;
-class Window;
-
-// DisplayManager creates, deletes and updates Display objects when
-// display configuration changes, and notifies DisplayObservers about
-// the change. This is owned by Env and its lifetime is longer than
-// any windows.
-class AURA_EXPORT DisplayManager {
- public:
- static void set_use_fullscreen_host_window(bool use_fullscreen) {
- use_fullscreen_host_window_ = use_fullscreen;
- }
- static bool use_fullscreen_host_window() {
- return use_fullscreen_host_window_;
- }
-
- // Creates a display from string spec. 100+200-1440x800 creates display
- // whose size is 1440x800 at the location (100, 200) in screen's coordinates.
- // The location can be omitted and be just "1440x800", which creates
- // display at the origin of the screen. An empty string creates
- // the display with default size.
- // The device scale factor can be specified by "*", like "1280x780*2",
- // or will use the value of |gfx::Display::GetForcedDeviceScaleFactor()| if
- // --force-device-scale-factor is specified.
- static gfx::Display CreateDisplayFromSpec(const std::string& spec);
-
- // A utility function to create a root window for primary display.
- static RootWindow* CreateRootWindowForPrimaryDisplay();
-
- DisplayManager();
- virtual ~DisplayManager();
-
- // Adds/removes DisplayObservers.
- void AddObserver(DisplayObserver* observer);
- void RemoveObserver(DisplayObserver* observer);
-
- // Called when display configuration has changed. The new display
- // configurations is passed as a vector of Display object, which
- // contains each display's new infomration.
- virtual void OnNativeDisplaysChanged(
- const std::vector<gfx::Display>& display) = 0;
-
- // Create a root window for given |display|.
- virtual RootWindow* CreateRootWindowForDisplay(
- const gfx::Display& display) = 0;
-
- // Obsoleted: Do not use in new code.
- // Returns the display at |index|. The display at 0 is
- // no longer considered "primary".
- virtual gfx::Display* GetDisplayAt(size_t index) = 0;
-
- virtual size_t GetNumDisplays() const = 0;
-
- // Returns the display object nearest given |window|.
- virtual const gfx::Display& GetDisplayNearestWindow(
- const Window* window) const = 0;
-
- // Returns the display object nearest given |point|.
- virtual const gfx::Display& GetDisplayNearestPoint(
- const gfx::Point& point) const = 0;
-
- // Returns the display that most closely intersects |match_rect|.
- virtual const gfx::Display& GetDisplayMatching(
- const gfx::Rect& match_rect) const = 0;
-
- // Returns the human-readable name for the display specified by |display|.
- virtual std::string GetDisplayNameFor(const gfx::Display& display) = 0;
-
- protected:
- // Calls observers' OnDisplayBoundsChanged methods.
- void NotifyBoundsChanged(const gfx::Display& display);
- void NotifyDisplayAdded(const gfx::Display& display);
- void NotifyDisplayRemoved(const gfx::Display& display);
-
- private:
- // If set before the RootWindow is created, the host window will cover the
- // entire display. Note that this can still be overridden via the
- // switches::kAuraHostWindowSize flag.
- static bool use_fullscreen_host_window_;
-
- ObserverList<DisplayObserver> observers_;
- DISALLOW_COPY_AND_ASSIGN(DisplayManager);
-};
-
-} // namespace aura
-
-#endif // UI_AURA_DISPLAY_MANAGER_H_
diff --git a/ui/aura/display_observer.h b/ui/aura/display_observer.h
deleted file mode 100644
index cdaa08d..0000000
--- a/ui/aura/display_observer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// 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_DISPLAY_OBSERVER_H_
-#define UI_AURA_DISPLAY_OBSERVER_H_
-
-#include "ui/aura/aura_export.h"
-
-namespace gfx {
-class Display;
-}
-
-namespace aura {
-
-// Observers for display configuration changes.
-class AURA_EXPORT DisplayObserver {
- public:
- // Called when the |display|'s bound has changed.
- virtual void OnDisplayBoundsChanged(const gfx::Display& display) = 0;
-
- // Called when |new_display| has been added.
- virtual void OnDisplayAdded(const gfx::Display& new_display) = 0;
-
- // Called when |old_display| has been removed.
- virtual void OnDisplayRemoved(const gfx::Display& old_display) = 0;
-
- protected:
- virtual ~DisplayObserver();
-};
-
-} // namespace aura
-
-#endif // UI_AURA_DISPLAY_OBSERVER_H_
diff --git a/ui/aura/display_util.cc b/ui/aura/display_util.cc
new file mode 100644
index 0000000..07f6965
--- /dev/null
+++ b/ui/aura/display_util.cc
@@ -0,0 +1,52 @@
+// 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/display_util.h"
+
+#include "ui/aura/root_window_host.h"
+#include "ui/gfx/display.h"
+#include "base/logging.h"
+#include "base/string_number_conversions.h"
+
+namespace aura {
+namespace {
+
+bool use_fullscreen_host_window = false;
+
+// Default bounds for a display.
+const int kDefaultHostWindowX = 200;
+const int kDefaultHostWindowY = 200;
+const int kDefaultHostWindowWidth = 1280;
+const int kDefaultHostWindowHeight = 1024;
+
+} // namespace
+
+void SetUseFullscreenHostWindow(bool value) {
+ use_fullscreen_host_window = value;
+}
+
+bool UseFullscreenHostWindow() {
+ return use_fullscreen_host_window;
+}
+
+gfx::Display CreateDisplayFromSpec(const std::string& spec) {
+ static int64 synthesized_display_id = 1000;
+ gfx::Rect bounds(kDefaultHostWindowX, kDefaultHostWindowY,
+ kDefaultHostWindowWidth, kDefaultHostWindowHeight);
+ int x = 0, y = 0, width, height;
+ float scale = 1.0f;
+ if (sscanf(spec.c_str(), "%dx%d*%f", &width, &height, &scale) >= 2 ||
+ sscanf(spec.c_str(), "%d+%d-%dx%d*%f", &x, &y, &width, &height,
+ &scale) >= 4) {
+ bounds.SetRect(x, y, width, height);
+ } else if (use_fullscreen_host_window) {
+ bounds = gfx::Rect(aura::RootWindowHost::GetNativeScreenSize());
+ }
+ gfx::Display display(synthesized_display_id++);
+ display.SetScaleAndBounds(scale, bounds);
+ DVLOG(1) << "Display bounds=" << bounds.ToString() << ", scale=" << scale;
+ return display;
+}
+
+} // namespace aura
diff --git a/ui/aura/display_util.h b/ui/aura/display_util.h
new file mode 100644
index 0000000..4505e98
--- /dev/null
+++ b/ui/aura/display_util.h
@@ -0,0 +1,35 @@
+// 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_DISPLAY_UTIL_H_
+#define UI_AURA_DISPLAY_UTIL_H_
+
+#include <string>
+
+#include "ui/aura/aura_export.h"
+
+namespace gfx {
+class Display;
+}
+
+namespace aura {
+
+// TODO(oshima): OBSOLETE. Eliminate this flag.
+AURA_EXPORT void SetUseFullscreenHostWindow(bool use_fullscreen_window);
+AURA_EXPORT bool UseFullscreenHostWindow();
+
+// Creates a display from string spec. 100+200-1440x800 creates display
+// whose size is 1440x800 at the location (100, 200) in screen's coordinates.
+// The location can be omitted and be just "1440x800", which creates
+// display at the origin of the screen. An empty string creates
+// the display with default size.
+// The device scale factor can be specified by "*", like "1280x780*2",
+// or will use the value of |gfx::Display::GetForcedDeviceScaleFactor()| if
+// --force-device-scale-factor is specified.
+// static gfx::Display CreateDisplayFromSpec(const std::string& spec);
+AURA_EXPORT gfx::Display CreateDisplayFromSpec(const std::string& str);
+
+} // namespace aura
+
+#endif // UI_AURA_DISPLAY_UTIL_H_
diff --git a/ui/aura/env.cc b/ui/aura/env.cc
index f562ef1..06734c8 100644
--- a/ui/aura/env.cc
+++ b/ui/aura/env.cc
@@ -8,7 +8,6 @@
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/event_filter.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/root_window_host.h"
#include "ui/aura/window.h"
#include "ui/compositor/compositor.h"
@@ -16,7 +15,6 @@
#if defined(USE_X11)
#include "base/message_pump_aurax11.h"
-#include "ui/aura/display_change_observer_x11.h"
#endif
namespace aura {
@@ -89,14 +87,6 @@ void Env::SetCursorShown(bool cursor_shown) {
}
}
-void Env::SetDisplayManager(DisplayManager* display_manager) {
- display_manager_.reset(display_manager);
-#if defined(USE_X11)
- // Update the display manager with latest info.
- display_change_observer_->NotifyDisplayChange();
-#endif
-}
-
#if !defined(OS_MACOSX)
MessageLoop::Dispatcher* Env::GetDispatcher() {
#if defined(USE_X11)
@@ -115,8 +105,6 @@ void Env::Init() {
dispatcher_.reset(CreateDispatcher());
#endif
#if defined(USE_X11)
- display_change_observer_.reset(new internal::DisplayChangeObserverX11);
-
// We can't do this with a root window listener because XI_HierarchyChanged
// messages don't have a target window.
base::MessagePumpAuraX11::Current()->AddObserver(
diff --git a/ui/aura/env.h b/ui/aura/env.h
index 50d373a..48ff533 100644
--- a/ui/aura/env.h
+++ b/ui/aura/env.h
@@ -21,13 +21,8 @@
namespace aura {
class EnvObserver;
class EventFilter;
-class DisplayManager;
class Window;
-namespace internal {
-class DisplayChangeObserverX11;
-}
-
#if !defined(USE_X11)
// Creates a platform-specific native event dispatcher.
MessageLoop::Dispatcher* CreateDispatcher();
@@ -77,11 +72,6 @@ class AURA_EXPORT Env : public ui::EventTarget {
stacking_client_ = stacking_client;
}
- // Gets/sets DisplayManager. The DisplayManager's ownership is
- // transfered.
- DisplayManager* display_manager() { return display_manager_.get(); }
- void SetDisplayManager(DisplayManager* display_manager);
-
// Returns the native event dispatcher. The result should only be passed to
// base::RunLoop(dispatcher), or used to dispatch an event by
// |Dispatch(const NativeEvent&)| on it. It must never be stored.
@@ -116,10 +106,8 @@ class AURA_EXPORT Env : public ui::EventTarget {
bool is_touch_down_;
bool render_white_bg_;
client::StackingClient* stacking_client_;
- scoped_ptr<DisplayManager> display_manager_;
#if defined(USE_X11)
- scoped_ptr<internal::DisplayChangeObserverX11> display_change_observer_;
DeviceListUpdaterAuraX11 device_list_updater_aurax11_;
#endif
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index a98aac4..bd8d969 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -18,7 +18,6 @@
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/event_client.h"
#include "ui/aura/client/screen_position_client.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/env.h"
#include "ui/aura/event_filter.h"
#include "ui/aura/focus_manager.h"
@@ -70,9 +69,9 @@ void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
}
}
-float GetDeviceScaleFactorFromDisplay(const Window* window) {
- DisplayManager* display_manager = Env::GetInstance()->display_manager();
- return display_manager->GetDisplayNearestWindow(window).device_scale_factor();
+float GetDeviceScaleFactorFromDisplay(Window* window) {
+ return gfx::Screen::GetScreenFor(window)->
+ GetDisplayNearestWindow(window).device_scale_factor();
}
Window* ConsumerToWindow(ui::GestureConsumer* consumer) {
diff --git a/ui/aura/single_display_manager.cc b/ui/aura/single_display_manager.cc
deleted file mode 100644
index c9a5bbe..0000000
--- a/ui/aura/single_display_manager.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// 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/single_display_manager.h"
-
-#include <string>
-
-#include "base/command_line.h"
-#include "ui/aura/aura_switches.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/root_window_host.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/rect.h"
-
-namespace aura {
-
-using std::string;
-
-namespace {
-// Default bounds for the primary display.
-const int kDefaultHostWindowX = 200;
-const int kDefaultHostWindowY = 200;
-const int kDefaultHostWindowWidth = 1280;
-const int kDefaultHostWindowHeight = 1024;
-} // namespace
-
-SingleDisplayManager::SingleDisplayManager()
- : root_window_(NULL) {
- Init();
-}
-
-SingleDisplayManager::~SingleDisplayManager() {
- // All displays must have been deleted when display manager is deleted.
- CHECK(!root_window_);
-}
-
-void SingleDisplayManager::OnNativeDisplaysChanged(
- const std::vector<gfx::Display>& displays) {
- DCHECK(displays.size() > 0);
- if (use_fullscreen_host_window()) {
- display_.SetSize(displays[0].bounds().size());
- NotifyBoundsChanged(display_);
- }
-}
-
-RootWindow* SingleDisplayManager::CreateRootWindowForDisplay(
- const gfx::Display& display) {
- DCHECK(!root_window_);
- DCHECK_EQ(display_.id(), display.id());
- root_window_ = new RootWindow(RootWindow::CreateParams(display.bounds()));
- root_window_->AddObserver(this);
- root_window_->Init();
- return root_window_;
-}
-
-gfx::Display* SingleDisplayManager::GetDisplayAt(size_t index) {
- return &display_;
-}
-
-size_t SingleDisplayManager::GetNumDisplays() const {
- return 1;
-}
-
-const gfx::Display& SingleDisplayManager::GetDisplayNearestWindow(
- const Window* window) const {
- return display_;
-}
-
-const gfx::Display& SingleDisplayManager::GetDisplayNearestPoint(
- const gfx::Point& point) const {
- return display_;
-}
-
-const gfx::Display& SingleDisplayManager::GetDisplayMatching(
- const gfx::Rect& match_rect) const {
- return display_;
-}
-
-std::string SingleDisplayManager::GetDisplayNameFor(
- const gfx::Display& display) {
- return "Display";
-}
-
-void SingleDisplayManager::OnWindowBoundsChanged(
- Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) {
- if (!use_fullscreen_host_window()) {
- Update(new_bounds.size());
- NotifyBoundsChanged(display_);
- }
-}
-
-void SingleDisplayManager::OnWindowDestroying(Window* window) {
- if (root_window_ == window)
- root_window_ = NULL;
-}
-
-void SingleDisplayManager::Init() {
- const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kAuraHostWindowSize);
- display_ = CreateDisplayFromSpec(size_str);
-}
-
-void SingleDisplayManager::Update(const gfx::Size size) {
- display_.SetSize(size);
-}
-
-} // namespace aura
diff --git a/ui/aura/single_display_manager.h b/ui/aura/single_display_manager.h
deleted file mode 100644
index de31ab6..0000000
--- a/ui/aura/single_display_manager.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// 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_SINGLE_DISPLAY_MANAGER_H_
-#define UI_AURA_SINGLE_DISPLAY_MANAGER_H_
-
-#include "base/compiler_specific.h"
-#include "ui/aura/aura_export.h"
-#include "ui/aura/display_manager.h"
-#include "ui/aura/window_observer.h"
-#include "ui/gfx/display.h"
-
-namespace gfx {
-class Rect;
-}
-
-namespace aura {
-
-// A display manager assuming there is one display.
-class AURA_EXPORT SingleDisplayManager : public DisplayManager,
- public WindowObserver {
- public:
- SingleDisplayManager();
- virtual ~SingleDisplayManager();
-
- // DisplayManager overrides:
- virtual void OnNativeDisplaysChanged(
- const std::vector<gfx::Display>& display) OVERRIDE;
- virtual RootWindow* CreateRootWindowForDisplay(
- const gfx::Display& display) OVERRIDE;
- virtual gfx::Display* GetDisplayAt(size_t index) OVERRIDE;
-
- virtual size_t GetNumDisplays() const OVERRIDE;
-
- virtual const gfx::Display& GetDisplayNearestWindow(
- const Window* window) const OVERRIDE;
- virtual const gfx::Display& GetDisplayNearestPoint(
- const gfx::Point& point) const OVERRIDE;
- virtual const gfx::Display& GetDisplayMatching(
- const gfx::Rect& match_rect) const OVERRIDE;
- virtual std::string GetDisplayNameFor(const gfx::Display& display) OVERRIDE;
-
- // WindowObserver overrides:
- virtual void OnWindowBoundsChanged(Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) OVERRIDE;
- virtual void OnWindowDestroying(Window* window) OVERRIDE;
-
- private:
- void Init();
- void Update(const gfx::Size size);
-
- RootWindow* root_window_;
- gfx::Display display_;
-
- DISALLOW_COPY_AND_ASSIGN(SingleDisplayManager);
-};
-
-} // namespace aura
-
-#endif // UI_AURA_SINGLE_DISPLAY_MANAGER_H_
diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc
index 73ab56a..d6db502 100644
--- a/ui/aura/test/aura_test_helper.cc
+++ b/ui/aura/test/aura_test_helper.cc
@@ -10,9 +10,7 @@
#include "ui/aura/client/default_capture_client.h"
#include "ui/aura/env.h"
#include "ui/aura/focus_manager.h"
-#include "ui/aura/display_manager.h"
#include "ui/aura/root_window.h"
-#include "ui/aura/single_display_manager.h"
#include "ui/aura/test/test_activation_client.h"
#include "ui/aura/test/test_screen.h"
#include "ui/aura/test/test_stacking_client.h"
@@ -44,10 +42,10 @@ AuraTestHelper::~AuraTestHelper() {
void AuraTestHelper::SetUp() {
setup_called_ = true;
- Env::GetInstance()->SetDisplayManager(new SingleDisplayManager);
- root_window_.reset(aura::DisplayManager::CreateRootWindowForPrimaryDisplay());
- test_screen_.reset(new aura::TestScreen(root_window_.get()));
+ aura::Env::GetInstance();
+ test_screen_.reset(new TestScreen());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
+ root_window_.reset(test_screen_->CreateRootWindowForPrimaryDisplay());
ui_controls::InstallUIControlsAura(CreateUIControlsAura(root_window_.get()));
focus_manager_.reset(new FocusManager);
diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc
index 8aa4166..b80b73f 100644
--- a/ui/aura/test/test_screen.cc
+++ b/ui/aura/test/test_screen.cc
@@ -4,7 +4,10 @@
#include "ui/aura/test/test_screen.h"
+#include "base/command_line.h"
#include "base/logging.h"
+#include "ui/aura/aura_switches.h"
+#include "ui/aura/display_util.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
@@ -13,17 +16,43 @@
namespace aura {
-TestScreen::TestScreen(aura::RootWindow* root_window)
- : root_window_(root_window) {
+TestScreen::TestScreen() : root_window_(NULL) {
+ const std::string size_str =
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kAuraHostWindowSize);
+ display_ = aura::CreateDisplayFromSpec(size_str);
}
TestScreen::~TestScreen() {
}
+RootWindow* TestScreen::CreateRootWindowForPrimaryDisplay() {
+ DCHECK(!root_window_);
+ root_window_ = new RootWindow(RootWindow::CreateParams(display_.bounds()));
+ root_window_->AddObserver(this);
+ root_window_->Init();
+ if (UseFullscreenHostWindow())
+ root_window_->ConfineCursorToWindow();
+ return root_window_;
+}
+
bool TestScreen::IsDIPEnabled() {
return true;
}
+void TestScreen::OnWindowBoundsChanged(
+ Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) {
+ if (!UseFullscreenHostWindow()) {
+ DCHECK_EQ(root_window_, window);
+ display_.SetSize(new_bounds.size());
+ }
+}
+
+void TestScreen::OnWindowDestroying(Window* window) {
+ if (root_window_ == window)
+ root_window_ = NULL;
+}
+
gfx::Point TestScreen::GetCursorScreenPoint() {
return Env::GetInstance()->last_mouse_location();
}
@@ -39,23 +68,25 @@ int TestScreen::GetNumDisplays() {
gfx::Display TestScreen::GetDisplayNearestWindow(
gfx::NativeWindow window) const {
- return GetMonitor();
+ return display_;
}
gfx::Display TestScreen::GetDisplayNearestPoint(const gfx::Point& point) const {
- return GetMonitor();
+ return display_;
}
gfx::Display TestScreen::GetDisplayMatching(const gfx::Rect& match_rect) const {
- return GetMonitor();
+ return display_;
}
gfx::Display TestScreen::GetPrimaryDisplay() const {
- return GetMonitor();
+ return display_;
+}
+
+void TestScreen::AddObserver(gfx::DisplayObserver* observer) {
}
-gfx::Display TestScreen::GetMonitor() const {
- return gfx::Display(0, root_window_->bounds());
+void TestScreen::RemoveObserver(gfx::DisplayObserver* observer) {
}
} // namespace aura
diff --git a/ui/aura/test/test_screen.h b/ui/aura/test/test_screen.h
index ca5524c..8b9d74b 100644
--- a/ui/aura/test/test_screen.h
+++ b/ui/aura/test/test_screen.h
@@ -6,18 +6,34 @@
#define UI_AURA_TEST_TEST_SCREEN_H_
#include "base/compiler_specific.h"
+#include "ui/aura/window_observer.h"
+#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
+namespace gfx {
+class Rect;
+}
+
namespace aura {
class RootWindow;
+class Window;
// A minimal, testing Aura implementation of gfx::Screen.
-class TestScreen : public gfx::Screen {
+class TestScreen : public gfx::Screen,
+ public WindowObserver {
public:
- explicit TestScreen(aura::RootWindow* root_window);
+ TestScreen();
virtual ~TestScreen();
+ RootWindow* CreateRootWindowForPrimaryDisplay();
+
protected:
+ // WindowObserver overrides:
+ virtual void OnWindowBoundsChanged(Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) OVERRIDE;
+ virtual void OnWindowDestroying(Window* window) OVERRIDE;
+
// gfx::Screen overrides:
virtual bool IsDIPEnabled() OVERRIDE;
virtual gfx::Point GetCursorScreenPoint() OVERRIDE;
@@ -30,12 +46,14 @@ class TestScreen : public gfx::Screen {
virtual gfx::Display GetDisplayMatching(
const gfx::Rect& match_rect) const OVERRIDE;
virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
+ virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE;
+ virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE;
private:
- gfx::Display GetMonitor() const;
-
aura::RootWindow* root_window_;
+ gfx::Display display_;
+
DISALLOW_COPY_AND_ASSIGN(TestScreen);
};
diff --git a/ui/aura/display_observer.cc b/ui/gfx/display_observer.cc
index d9120fd..f8e3c07 100644
--- a/ui/aura/display_observer.cc
+++ b/ui/gfx/display_observer.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/aura/display_observer.h"
+#include "ui/gfx/display_observer.h"
-namespace aura {
+namespace gfx {
DisplayObserver::~DisplayObserver() {
}
-} // namespace aura
+} // namespace gfx
diff --git a/ui/gfx/display_observer.h b/ui/gfx/display_observer.h
new file mode 100644
index 0000000..85a4086
--- /dev/null
+++ b/ui/gfx/display_observer.h
@@ -0,0 +1,33 @@
+// 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_GFX_DISPLAY_OBSERVER_H_
+#define UI_GFX_DISPLAY_OBSERVER_H_
+
+#include "ui/base/ui_export.h"
+
+namespace gfx {
+class Display;
+
+// Observers for display configuration changes.
+// TODO(oshima): consolidate |WorkAreaWatcherObserver| and
+// |DisplaySettingsProvier|. crbug.com/122863.
+class UI_EXPORT DisplayObserver {
+ public:
+ // Called when the |display|'s bound has changed.
+ virtual void OnDisplayBoundsChanged(const Display& display) = 0;
+
+ // Called when |new_display| has been added.
+ virtual void OnDisplayAdded(const Display& new_display) = 0;
+
+ // Called when |old_display| has been removed.
+ virtual void OnDisplayRemoved(const Display& old_display) = 0;
+
+ protected:
+ virtual ~DisplayObserver();
+};
+
+} // namespace gfx
+
+#endif // UI_GFX_DISPLAY_OBSERVER_H_
diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h
index 1a04214..9410d02 100644
--- a/ui/gfx/screen.h
+++ b/ui/gfx/screen.h
@@ -13,6 +13,7 @@
#include "ui/gfx/screen_type_delegate.h"
namespace gfx {
+class DisplayObserver;
class Rect;
// A utility class for getting various info about screen size, displays,
@@ -70,6 +71,10 @@ class UI_EXPORT Screen {
// Returns the primary display.
virtual gfx::Display GetPrimaryDisplay() const = 0;
+ // Adds/Removes display observers.
+ virtual void AddObserver(DisplayObserver* observer) = 0;
+ virtual void RemoveObserver(DisplayObserver* observer) = 0;
+
private:
DISALLOW_COPY_AND_ASSIGN(Screen);
};
diff --git a/ui/gfx/screen_android.cc b/ui/gfx/screen_android.cc
index 2111661..a80582e 100644
--- a/ui/gfx/screen_android.cc
+++ b/ui/gfx/screen_android.cc
@@ -48,6 +48,14 @@ class ScreenAndroid : public Screen {
return GetPrimaryDisplay();
}
+ virtual void AddObserver(DisplayObserver* observer) OVERRIDE {
+ // no display change on Android.
+ }
+
+ virtual void RemoveObserver(DisplayObserver* observer) OVERRIDE {
+ // no display change on Android.
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(ScreenAndroid);
};
diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc
index 5aefb15..8ef803d 100644
--- a/ui/gfx/screen_gtk.cc
+++ b/ui/gfx/screen_gtk.cc
@@ -165,6 +165,14 @@ class ScreenGtk : public gfx::Screen {
return display;
}
+ virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE {
+ // TODO(oshima): crbug.com/122863.
+ }
+
+ virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {
+ // TODO(oshima): crbug.com/122863.
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(ScreenGtk);
};
diff --git a/ui/gfx/screen_ios.mm b/ui/gfx/screen_ios.mm
index d1572af..dfb0d1b 100644
--- a/ui/gfx/screen_ios.mm
+++ b/ui/gfx/screen_ios.mm
@@ -63,6 +63,14 @@ class ScreenIos : public gfx::Screen {
display.set_device_scale_factor([mainScreen scale]);
return display;
}
+
+ virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE {
+ // no display change on iOS.
+ }
+
+ virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {
+ // no display change on iOS.
+ }
};
} // namespace
diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm
index 595ca3e..15bbf37 100644
--- a/ui/gfx/screen_mac.mm
+++ b/ui/gfx/screen_mac.mm
@@ -168,6 +168,14 @@ class ScreenMac : public gfx::Screen {
return display;
}
+ virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE {
+ // TODO(oshima): crbug.com/122863.
+ }
+
+ virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE {
+ // TODO(oshima): crbug.com/122863.
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(ScreenMac);
};
diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc
index 072f47a..9b33c6b 100644
--- a/ui/gfx/screen_win.cc
+++ b/ui/gfx/screen_win.cc
@@ -90,6 +90,14 @@ gfx::Display ScreenWin::GetPrimaryDisplay() const {
return display;
}
+void ScreenWin::AddObserver(DisplayObserver* observer) {
+ // TODO(oshima): crbug.com/122863.
+}
+
+void ScreenWin::RemoveObserver(DisplayObserver* observer) {
+ // TODO(oshima): crbug.com/122863.
+}
+
HWND ScreenWin::GetHWNDFromNativeView(NativeView window) const {
#if defined(USE_AURA)
NOTREACHED();
diff --git a/ui/gfx/screen_win.h b/ui/gfx/screen_win.h
index 7cfc265..f6b7d40a 100644
--- a/ui/gfx/screen_win.h
+++ b/ui/gfx/screen_win.h
@@ -29,6 +29,8 @@ class UI_EXPORT ScreenWin : public gfx::Screen {
virtual gfx::Display GetDisplayMatching(
const gfx::Rect& match_rect) const OVERRIDE;
virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
+ virtual void AddObserver(DisplayObserver* observer) OVERRIDE;
+ virtual void RemoveObserver(DisplayObserver* observer) OVERRIDE;
// Returns the HWND associated with the NativeView.
virtual HWND GetHWNDFromNativeView(NativeView window) const;
diff --git a/ui/ui.gyp b/ui/ui.gyp
index bd359fd..2942fd2 100644
--- a/ui/ui.gyp
+++ b/ui/ui.gyp
@@ -383,6 +383,8 @@
'gfx/color_utils.h',
'gfx/display.cc',
'gfx/display.h',
+ 'gfx/display_observer.cc',
+ 'gfx/display_observer.h',
'gfx/favicon_size.cc',
'gfx/favicon_size.h',
'gfx/font.cc',
diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index 9ce56a8..77dbaa4 100644
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -47,6 +47,8 @@ class DesktopScreenX11 : public gfx::Screen {
virtual gfx::Display GetDisplayMatching(
const gfx::Rect& match_rect) const OVERRIDE;
virtual gfx::Display GetPrimaryDisplay() const OVERRIDE;
+ virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE;
+ virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DesktopScreenX11);
@@ -122,6 +124,15 @@ gfx::Display DesktopScreenX11::GetPrimaryDisplay() const {
return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize()));
}
+void DesktopScreenX11::AddObserver(gfx::DisplayObserver* observer) {
+ // TODO(erg|oshima): Do the right thing once we know what that is.
+ // crbug.com/122863
+}
+void DesktopScreenX11::RemoveObserver(gfx::DisplayObserver* observer) {
+ // TODO(erg|oshima): Do the right thing once we know what that is.
+ // crbug.com/122863
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////