From e72fa4d643005f438978d8a9c21272f3acd64061 Mon Sep 17 00:00:00 2001 From: "oshima@chromium.org" Date: Wed, 27 Jun 2012 21:51:44 +0000 Subject: Revert r 144499 "Rename the remaining usage of Monitor to Display" Temporarily reverting rename change to investigate 133784 TBR=oshima@chromium.org BUG=123160 TEST=none Review URL: https://chromiumcodereview.appspot.com/10689014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144573 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/accelerators/accelerator_controller.cc | 18 +- ash/accelerators/accelerator_table.cc | 6 +- ash/accelerators/accelerator_table.h | 6 +- ash/ash.gyp | 18 +- ash/dip_unittest.cc | 6 +- ash/display/display_controller.cc | 269 --------------------- ash/display/display_controller.h | 109 --------- ash/display/mouse_cursor_event_filter.cc | 53 ---- ash/display/mouse_cursor_event_filter.h | 44 ---- ash/display/multi_display_manager.cc | 247 ------------------- ash/display/multi_display_manager.h | 84 ------- ash/display/multi_display_manager_unittest.cc | 235 ------------------ ash/display/secondary_display_view.cc | 111 --------- ash/display/secondary_display_view.h | 25 -- ash/extended_desktop_unittest.cc | 50 ++-- ash/monitor/monitor_controller.cc | 269 +++++++++++++++++++++ ash/monitor/monitor_controller.h | 109 +++++++++ ash/monitor/mouse_cursor_event_filter.cc | 53 ++++ ash/monitor/mouse_cursor_event_filter.h | 44 ++++ ash/monitor/multi_monitor_manager.cc | 247 +++++++++++++++++++ ash/monitor/multi_monitor_manager.h | 84 +++++++ ash/monitor/multi_monitor_manager_unittest.cc | 235 ++++++++++++++++++ ash/monitor/secondary_monitor_view.cc | 111 +++++++++ ash/monitor/secondary_monitor_view.h | 25 ++ ash/root_window_controller_unittest.cc | 22 +- ash/screen_ash.cc | 14 +- ash/shell.cc | 62 ++--- ash/shell.h | 16 +- ash/shell_observer.h | 2 +- ash/test/ash_test_base.cc | 14 +- ash/test/ash_test_base.h | 8 +- ash/tooltips/tooltip_controller.cc | 14 +- ash/wm/base_layout_manager.cc | 12 +- ash/wm/base_layout_manager.h | 2 +- ash/wm/base_layout_manager_unittest.cc | 10 +- ash/wm/frame_painter.cc | 4 +- ash/wm/screen_dimmer.h | 2 +- ash/wm/shelf_layout_manager.cc | 6 +- ash/wm/shelf_layout_manager_unittest.cc | 24 +- ash/wm/stacking_controller.cc | 4 +- ash/wm/toplevel_window_event_filter_unittest.cc | 2 +- ash/wm/window_resizer.cc | 4 +- ash/wm/window_util.h | 2 +- ash/wm/workspace/snap_sizer.cc | 2 +- ash/wm/workspace/workspace_manager.cc | 2 +- ash/wm/workspace/workspace_window_resizer.cc | 6 +- .../workspace/workspace_window_resizer_unittest.cc | 14 +- 47 files changed, 1353 insertions(+), 1353 deletions(-) delete mode 100644 ash/display/display_controller.cc delete mode 100644 ash/display/display_controller.h delete mode 100644 ash/display/mouse_cursor_event_filter.cc delete mode 100644 ash/display/mouse_cursor_event_filter.h delete mode 100644 ash/display/multi_display_manager.cc delete mode 100644 ash/display/multi_display_manager.h delete mode 100644 ash/display/multi_display_manager_unittest.cc delete mode 100644 ash/display/secondary_display_view.cc delete mode 100644 ash/display/secondary_display_view.h create mode 100644 ash/monitor/monitor_controller.cc create mode 100644 ash/monitor/monitor_controller.h create mode 100644 ash/monitor/mouse_cursor_event_filter.cc create mode 100644 ash/monitor/mouse_cursor_event_filter.h create mode 100644 ash/monitor/multi_monitor_manager.cc create mode 100644 ash/monitor/multi_monitor_manager.h create mode 100644 ash/monitor/multi_monitor_manager_unittest.cc create mode 100644 ash/monitor/secondary_monitor_view.cc create mode 100644 ash/monitor/secondary_monitor_view.h (limited to 'ash') diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 29380da..287bcec 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -16,8 +16,8 @@ #include "ash/launcher/launcher_delegate.h" #include "ash/launcher/launcher_model.h" #include "ash/magnifier/magnification_controller.h" -#include "ash/display/display_controller.h" -#include "ash/display/multi_display_manager.h" +#include "ash/monitor/monitor_controller.h" +#include "ash/monitor/multi_monitor_manager.h" #include "ash/root_window_controller.h" #include "ash/screenshot_delegate.h" #include "ash/shell.h" @@ -44,7 +44,7 @@ #include "ui/oak/oak.h" #if defined(OS_CHROMEOS) -#include "chromeos/display/output_configurator.h" +#include "chromeos/monitor/output_configurator.h" #endif // defined(OS_CHROMEOS) namespace ash { @@ -585,17 +585,17 @@ bool AcceleratorController::PerformAction(int action, return HandleToggleDesktopBackgroundMode(); case TOGGLE_ROOT_WINDOW_FULL_SCREEN: return HandleToggleRootWindowFullScreen(); - case DISPLAY_ADD_REMOVE: + case MONITOR_ADD_REMOVE: if (DebugShortcutsEnabled()) - internal::MultiDisplayManager::AddRemoveDisplay(); + internal::MultiMonitorManager::AddRemoveMonitor(); return true; - case DISPLAY_CYCLE: + case MONITOR_CYCLE: if (DebugShortcutsEnabled()) - internal::MultiDisplayManager::CycleDisplay(); + internal::MultiMonitorManager::CycleMonitor(); return true; - case DISPLAY_TOGGLE_SCALE: + case MONITOR_TOGGLE_SCALE: if (DebugShortcutsEnabled()) - internal::MultiDisplayManager::ToggleDisplayScale(); + internal::MultiMonitorManager::ToggleMonitorScale(); return true; case MAGNIFY_SCREEN_ZOOM_IN: return HandleMagnifyScreen(1); diff --git a/ash/accelerators/accelerator_table.cc b/ash/accelerators/accelerator_table.cc index ba89019..3c40f73 100644 --- a/ash/accelerators/accelerator_table.cc +++ b/ash/accelerators/accelerator_table.cc @@ -123,10 +123,10 @@ const AcceleratorData kAcceleratorData[] = { // For testing on systems where Alt-Tab is already mapped. { true, ui::VKEY_W, ui::EF_ALT_DOWN, CYCLE_FORWARD_MRU }, { true, ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN, CYCLE_BACKWARD_MRU }, - { true, ui::VKEY_F4, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, DISPLAY_CYCLE }, - { true, ui::VKEY_F4, ui::EF_SHIFT_DOWN, DISPLAY_ADD_REMOVE }, + { true, ui::VKEY_F4, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, MONITOR_CYCLE }, + { true, ui::VKEY_F4, ui::EF_SHIFT_DOWN, MONITOR_ADD_REMOVE }, { true, ui::VKEY_HOME, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN, - DISPLAY_TOGGLE_SCALE }, + MONITOR_TOGGLE_SCALE }, #if !defined(NDEBUG) { true, ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN, PRINT_LAYER_HIERARCHY }, diff --git a/ash/accelerators/accelerator_table.h b/ash/accelerators/accelerator_table.h index 788de46..23961b5 100644 --- a/ash/accelerators/accelerator_table.h +++ b/ash/accelerators/accelerator_table.h @@ -67,9 +67,9 @@ enum AcceleratorAction { OPEN_FILE_MANAGER_DIALOG, OPEN_FILE_MANAGER_TAB, #endif - DISPLAY_ADD_REMOVE, - DISPLAY_CYCLE, - DISPLAY_TOGGLE_SCALE, + MONITOR_ADD_REMOVE, + MONITOR_CYCLE, + MONITOR_TOGGLE_SCALE, ROTATE_SCREEN, TOGGLE_DESKTOP_BACKGROUND_MODE, TOGGLE_ROOT_WINDOW_FULL_SCREEN, diff --git a/ash/ash.gyp b/ash/ash.gyp index 65537af..857581d 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -97,14 +97,14 @@ 'launcher/tabbed_launcher_button.h', 'magnifier/magnification_controller.cc', 'magnifier/magnification_controller.h', - 'display/display_controller.cc', - 'display/display_controller.h', - 'display/mouse_cursor_event_filter.cc', - 'display/mouse_cursor_event_filter.h', - 'display/multi_display_manager.cc', - 'display/multi_display_manager.h', - 'display/secondary_display_view.cc', - 'display/secondary_display_view.h', + 'monitor/monitor_controller.cc', + 'monitor/monitor_controller.h', + 'monitor/mouse_cursor_event_filter.cc', + 'monitor/mouse_cursor_event_filter.h', + 'monitor/multi_monitor_manager.cc', + 'monitor/multi_monitor_manager.h', + 'monitor/secondary_monitor_view.cc', + 'monitor/secondary_monitor_view.h', 'root_window_controller.cc', 'root_window_controller.h', 'screen_ash.cc', @@ -379,7 +379,6 @@ 'accelerators/accelerator_table_unittest.cc', 'accelerators/nested_dispatcher_controller_unittest.cc', 'dip_unittest.cc', - 'display/multi_display_manager_unittest.cc', 'drag_drop/drag_drop_controller_unittest.cc', 'extended_desktop_unittest.cc', 'focus_cycler_unittest.cc', @@ -388,6 +387,7 @@ 'launcher/launcher_navigator_unittest.cc', 'launcher/launcher_unittest.cc', 'launcher/launcher_view_unittest.cc', + 'monitor/multi_monitor_manager_unittest.cc', 'root_window_controller_unittest.cc', 'screensaver/screensaver_view_unittest.cc', 'shell_unittest.cc', diff --git a/ash/dip_unittest.cc b/ash/dip_unittest.cc index b710e4c..a6ebe14 100644 --- a/ash/dip_unittest.cc +++ b/ash/dip_unittest.cc @@ -28,7 +28,7 @@ namespace ash { typedef ash::test::AshTestBase DIPTest; #if defined(OS_WIN) -// Windows/Aura doesn't have DIP support in display yet. +// Windows/Aura doesn't have DIP support in monitor yet. #define MAYBE_WorkArea DISABLED_WorkArea #else #define MAYBE_WorkArea WorkArea @@ -36,7 +36,7 @@ typedef ash::test::AshTestBase DIPTest; // Test if the WM sets correct work area under different density. TEST_F(DIPTest, MAYBE_WorkArea) { - ChangeDisplayConfig(1.0f, gfx::Rect(0, 0, 1000, 900)); + ChangeMonitorConfig(1.0f, gfx::Rect(0, 0, 1000, 900)); aura::RootWindow* root = Shell::GetPrimaryRootWindow(); const gfx::Display display = gfx::Screen::GetDisplayNearestWindow(root); @@ -46,7 +46,7 @@ TEST_F(DIPTest, MAYBE_WorkArea) { EXPECT_EQ("0,0 1000x852", work_area.ToString()); EXPECT_EQ("0,0,48,0", display.bounds().InsetsFrom(work_area).ToString()); - ChangeDisplayConfig(2.0f, gfx::Rect(0, 0, 2000, 1800)); + ChangeMonitorConfig(2.0f, gfx::Rect(0, 0, 2000, 1800)); const gfx::Display display_2x = gfx::Screen::GetDisplayNearestWindow(root); diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc deleted file mode 100644 index 895532a..0000000 --- a/ash/display/display_controller.cc +++ /dev/null @@ -1,269 +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 "ash/display/display_controller.h" - -#include "ash/ash_switches.h" -#include "ash/display/multi_display_manager.h" -#include "ash/root_window_controller.h" -#include "ash/shell.h" -#include "ash/wm/window_util.h" -#include "base/command_line.h" -#include "ui/aura/env.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#include "ui/gfx/display.h" -#include "ui/gfx/screen.h" - -namespace ash { -namespace internal { -namespace { -// True if the extended desktop mode is enabled. -bool extended_desktop_enabled = false; - -// True if the virtual screen coordinates is enabled. -bool virtual_screen_coordinates_enabled = false; -} - -DisplayController::DisplayController() - : secondary_display_layout_(RIGHT) { - aura::Env::GetInstance()->display_manager()->AddObserver(this); -} - -DisplayController::~DisplayController() { - aura::Env::GetInstance()->display_manager()->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::const_reverse_iterator it = - root_windows_.rbegin(); it != root_windows_.rend(); ++it) { - internal::RootWindowController* controller = - wm::GetRootWindowController(it->second); - // RootWindow may not have RootWindowController in non - // extended desktop mode. - if (controller) - delete controller; - else - delete it->second; - } -} - -void DisplayController::InitPrimaryDisplay() { - aura::DisplayManager* display_manager = - aura::Env::GetInstance()->display_manager(); - const gfx::Display& display = display_manager->GetDisplayAt(0); - DCHECK_EQ(0, display.id()); - aura::RootWindow* root = AddRootWindowForDisplay(display); - root->SetHostBounds(display.bounds_in_pixel()); -} - -void DisplayController::InitSecondaryDisplays() { - aura::DisplayManager* display_manager = - aura::Env::GetInstance()->display_manager(); - for (size_t i = 1; i < display_manager->GetNumDisplays(); ++i) { - const gfx::Display& display = display_manager->GetDisplayAt(i); - aura::RootWindow* root = AddRootWindowForDisplay(display); - Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root); - } -} - -aura::RootWindow* DisplayController::GetPrimaryRootWindow() { - DCHECK(!root_windows_.empty()); - return root_windows_[0]; -} - -void DisplayController::CloseChildWindows() { - for (std::map::const_iterator it = - root_windows_.begin(); it != root_windows_.end(); ++it) { - aura::RootWindow* root_window = it->second; - internal::RootWindowController* controller = - wm::GetRootWindowController(root_window); - if (controller) { - controller->CloseChildWindows(); - } else { - while (!root_window->children().empty()) { - aura::Window* child = root_window->children()[0]; - delete child; - } - } - } -} - -std::vector DisplayController::GetAllRootWindows() { - std::vector windows; - for (std::map::const_iterator it = - root_windows_.begin(); it != root_windows_.end(); ++it) { - DCHECK(it->second); - if (wm::GetRootWindowController(it->second)) - windows.push_back(it->second); - } - return windows; -} - -std::vector -DisplayController::GetAllRootWindowControllers() { - std::vector controllers; - for (std::map::const_iterator it = - root_windows_.begin(); it != root_windows_.end(); ++it) { - internal::RootWindowController* controller = - wm::GetRootWindowController(it->second); - if (controller) - controllers.push_back(controller); - } - return controllers; -} - -void DisplayController::SetSecondaryDisplayLayout( - SecondaryDisplayLayout layout) { - secondary_display_layout_ = layout; -} - -bool DisplayController::WarpMouseCursorIfNecessary( - aura::Window* current_root, - const gfx::Point& location_in_root) { - if (root_windows_.size() < 2) - return false; - // Only 1 external display is supported in extended desktop mode. - DCHECK_EQ(2U, root_windows_.size()); - - bool in_primary = current_root == root_windows_[0]; - - std::map::iterator iter = root_windows_.begin(); - aura::RootWindow* alternate_root = iter->second != current_root ? - iter->second : (++iter)->second; - gfx::Rect alternate_bounds = alternate_root->bounds(); - gfx::Point alternate_point; - - gfx::Rect display_area( - gfx::Screen::GetDisplayNearestWindow(current_root).bounds()); - - // TODO(oshima): This is temporary code until the virtual screen - // coordinate is implemented. - if (location_in_root.x() <= display_area.x()) { - if (location_in_root.y() < alternate_bounds.height() && - ((in_primary && secondary_display_layout_ == LEFT) || - (!in_primary && secondary_display_layout_ == RIGHT))) { - alternate_point = gfx::Point( - alternate_bounds.right() - (location_in_root.x() - display_area.x()), - location_in_root.y()); - } else { - alternate_root = NULL; - } - } else if (location_in_root.x() >= display_area.right() - 1) { - if (location_in_root.y() < alternate_bounds.height() && - ((in_primary && secondary_display_layout_ == RIGHT) || - (!in_primary && secondary_display_layout_ == LEFT))) { - alternate_point = gfx::Point(location_in_root.x() - display_area.right(), - location_in_root.y()); - } else { - alternate_root = NULL; - } - } else if (location_in_root.y() < display_area.y()) { - if (location_in_root.x() < alternate_bounds.width() && - ((in_primary && secondary_display_layout_ == TOP) || - (!in_primary && secondary_display_layout_ == BOTTOM))) { - alternate_point = gfx::Point( - location_in_root.x(), - alternate_bounds.bottom() - - (location_in_root.y() - display_area.y())); - } else { - alternate_root = NULL; - } - } else if (location_in_root.y() >= display_area.bottom() - 1) { - if (location_in_root.x() < alternate_bounds.width() && - ((in_primary && secondary_display_layout_ == BOTTOM) || - (!in_primary && secondary_display_layout_ == TOP))) { - alternate_point = gfx::Point( - location_in_root.x(), location_in_root.y() - display_area.bottom()); - } else { - alternate_root = NULL; - } - } else { - alternate_root = NULL; - } - if (alternate_root) { - DCHECK_NE(alternate_root, current_root); - alternate_root->MoveCursorTo(alternate_point); - return true; - } - return false; -} - -void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { - root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel()); -} - -void DisplayController::OnDisplayAdded(const gfx::Display& display) { - if (root_windows_.empty()) { - DCHECK_EQ(0, display.id()); - root_windows_[display.id()] = Shell::GetPrimaryRootWindow(); - Shell::GetPrimaryRootWindow()->SetHostBounds(display.bounds_in_pixel()); - return; - } - aura::RootWindow* root = AddRootWindowForDisplay(display); - Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root); -} - -void DisplayController::OnDisplayRemoved(const gfx::Display& display) { - aura::RootWindow* root = root_windows_[display.id()]; - DCHECK(root); - // Primary display should never be removed by DisplayManager. - DCHECK(root != Shell::GetPrimaryRootWindow()); - // Display for root window will be deleted when the Primary RootWindow - // is deleted by the Shell. - if (root != Shell::GetPrimaryRootWindow()) { - root_windows_.erase(display.id()); - internal::RootWindowController* controller = - wm::GetRootWindowController(root); - if (controller) { - controller->MoveWindowsTo(Shell::GetPrimaryRootWindow()); - delete controller; - } else { - delete root; - } - } -} - -// static -bool DisplayController::IsExtendedDesktopEnabled(){ - return extended_desktop_enabled || - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAshExtendedDesktop); -} - -// static -void DisplayController::SetExtendedDesktopEnabled(bool enabled) { - extended_desktop_enabled = enabled; -} - -// static -bool DisplayController::IsVirtualScreenCoordinatesEnabled() { - return virtual_screen_coordinates_enabled || - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAshVirtualScreenCoordinates); -} - -// static -void DisplayController::SetVirtualScreenCoordinatesEnabled(bool enabled) { - virtual_screen_coordinates_enabled = enabled; -} - -aura::RootWindow* DisplayController::AddRootWindowForDisplay( - const gfx::Display& display) { - aura::RootWindow* root = aura::Env::GetInstance()->display_manager()-> - CreateRootWindowForDisplay(display); - root_windows_[display.id()] = root; - // Confine the cursor within the window if - // 1) Extended desktop is enabled or - // 2) the display is primary display and the host window - // is set to be fullscreen (this is old behavior). - if (IsExtendedDesktopEnabled() || - (aura::DisplayManager::use_fullscreen_host_window() && - display.id() == 0)) { - root->ConfineCursorToWindow(); - } - return root; -} - -} // namespace internal -} // namespace ash diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h deleted file mode 100644 index 1b66d01..0000000 --- a/ash/display/display_controller.h +++ /dev/null @@ -1,109 +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 ASH_DISPLAY_DISPLAY_CONTROLLER_H_ -#define ASH_DISPLAY_DISPLAY_CONTROLLER_H_ -#pragma once - -#include -#include - -#include "ash/ash_export.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "ui/aura/display_observer.h" -#include "ui/aura/display_manager.h" - -namespace aura { -class Display; -class RootWindow; -} - -namespace ash { -namespace internal { -class RootWindowController; - -// DisplayController owns and maintains RootWindows for each attached -// display, keeping them in sync with display configuration changes. -// TODO(oshima): Rename DisplayXXX to DisplayXXX. -class ASH_EXPORT DisplayController : public aura::DisplayObserver { - public: - // Layout options where the secondary display should be positioned. - enum SecondaryDisplayLayout { - TOP, - RIGHT, - BOTTOM, - LEFT - }; - - DisplayController(); - virtual ~DisplayController(); - - // Initializes primary display. - void InitPrimaryDisplay(); - - // Initialize secondary display. This is separated because in non - // extended desktop mode, this creates background widgets, which - // requires other controllers. - void InitSecondaryDisplays(); - - // Returns the root window for primary display. - aura::RootWindow* GetPrimaryRootWindow(); - - // Closes all child windows in the all root windows. - void CloseChildWindows(); - - // Returns all root windows. In non extended desktop mode, this - // returns the primary root window only. - std::vector GetAllRootWindows(); - - // Returns all oot window controllers. In non extended desktop - // mode, this return a RootWindowController for the primary root window only. - std::vector GetAllRootWindowControllers(); - - SecondaryDisplayLayout secondary_display_layout() const { - return secondary_display_layout_; - } - void SetSecondaryDisplayLayout(SecondaryDisplayLayout layout); - - // Warps the mouse cursor to an alternate root window when the - // |location_in_root|, which is the location of the mouse cursor, - // hits or exceeds the edge of the |root_window| and the mouse cursor - // is considered to be in an alternate display. Returns true if - // the cursor was moved. - bool WarpMouseCursorIfNecessary(aura::Window* root_window, - const gfx::Point& location_in_root); - - // aura::DisplayObserver overrides: - virtual void OnDisplayBoundsChanged( - const gfx::Display& display) OVERRIDE; - virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; - virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; - - // Is extended desktop enabled? - static bool IsExtendedDesktopEnabled(); - // Change the extended desktop mode. Used for testing. - static void SetExtendedDesktopEnabled(bool enabled); - - // Is virtual screen coordinates enabled? - static bool IsVirtualScreenCoordinatesEnabled(); - // Turns on/off the virtual screen coordinates. - static void SetVirtualScreenCoordinatesEnabled(bool enabled); - - private: - // Creates a root window for |display| and stores it in the |root_windows_| - // map. - aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display); - - std::map root_windows_; - - SecondaryDisplayLayout secondary_display_layout_; - - DISALLOW_COPY_AND_ASSIGN(DisplayController); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ diff --git a/ash/display/mouse_cursor_event_filter.cc b/ash/display/mouse_cursor_event_filter.cc deleted file mode 100644 index 0ab6f1c..0000000 --- a/ash/display/mouse_cursor_event_filter.cc +++ /dev/null @@ -1,53 +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 "ash/display/mouse_cursor_event_filter.h" - -#include "ash/display/display_controller.h" -#include "ui/aura/event.h" -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" - -namespace ash { -namespace internal { - -MouseCursorEventFilter::MouseCursorEventFilter( - DisplayController* display_controller) - : display_controller_(display_controller) { - DCHECK(display_controller_); -} - -MouseCursorEventFilter::~MouseCursorEventFilter() { -} - -bool MouseCursorEventFilter::PreHandleKeyEvent(aura::Window* target, - aura::KeyEvent* event) { - return false; -} - -bool MouseCursorEventFilter::PreHandleMouseEvent(aura::Window* target, - aura::MouseEvent* event) { - if (event->type() != ui::ET_MOUSE_MOVED) - return false; - aura::RootWindow* current_root = target->GetRootWindow(); - gfx::Point location_in_root(event->location()); - aura::Window::ConvertPointToWindow(target, current_root, &location_in_root); - return display_controller_->WarpMouseCursorIfNecessary( - current_root, location_in_root); -} - -ui::TouchStatus MouseCursorEventFilter::PreHandleTouchEvent( - aura::Window* target, - aura::TouchEvent* event) { - return ui::TOUCH_STATUS_UNKNOWN; -} - -ui::GestureStatus MouseCursorEventFilter::PreHandleGestureEvent( - aura::Window* target, - aura::GestureEvent* event) { - return ui::GESTURE_STATUS_UNKNOWN; -} - -} // namespace internal -} // namespace ash diff --git a/ash/display/mouse_cursor_event_filter.h b/ash/display/mouse_cursor_event_filter.h deleted file mode 100644 index a89a6b7..0000000 --- a/ash/display/mouse_cursor_event_filter.h +++ /dev/null @@ -1,44 +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 ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H -#define ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H -#pragma once - -#include "ash/ash_export.h" -#include "base/compiler_specific.h" -#include "ui/aura/event_filter.h" - -namespace ash { -namespace internal { -class DisplayController; - -// An event filter that controls mouse location in extended desktop -// environment. -class ASH_EXPORT MouseCursorEventFilter : public aura::EventFilter { - public: - MouseCursorEventFilter(DisplayController* display_controller); - virtual ~MouseCursorEventFilter(); - - // Overridden from aura::EventFilter: - virtual bool PreHandleKeyEvent(aura::Window* target, - aura::KeyEvent* event) OVERRIDE; - virtual bool PreHandleMouseEvent(aura::Window* target, - aura::MouseEvent* event) OVERRIDE; - virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, - aura::TouchEvent* event) OVERRIDE; - virtual ui::GestureStatus PreHandleGestureEvent( - aura::Window* target, - aura::GestureEvent* event) OVERRIDE; - - private: - DisplayController* display_controller_; - - DISALLOW_COPY_AND_ASSIGN(MouseCursorEventFilter); -}; - -} // namespace internal -} // namespace ash - -#endif // ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H diff --git a/ash/display/multi_display_manager.cc b/ash/display/multi_display_manager.cc deleted file mode 100644 index 54b3d74..0000000 --- a/ash/display/multi_display_manager.cc +++ /dev/null @@ -1,247 +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 "ash/display/multi_display_manager.h" - -#include -#include - -#include "base/command_line.h" -#include "base/stl_util.h" -#include "base/string_split.h" -#include "ui/aura/aura_switches.h" -#include "ui/aura/env.h" -#include "ui/aura/root_window.h" -#include "ui/aura/root_window_host.h" -#include "ui/aura/window_property.h" -#include "ui/gfx/display.h" -#include "ui/gfx/rect.h" - -DECLARE_WINDOW_PROPERTY_TYPE(int); - -namespace ash { -namespace internal { -namespace { - -gfx::Display& GetInvalidDisplay() { - static gfx::Display* invalid_display = new gfx::Display(); - return *invalid_display; -} - -} // namespace - -using aura::RootWindow; -using aura::Window; -using std::string; -using std::vector; - -DEFINE_WINDOW_PROPERTY_KEY(int, kDisplayIdKey, -1); - -MultiDisplayManager::MultiDisplayManager() { - Init(); -} - -MultiDisplayManager::~MultiDisplayManager() { -} - -// static -void MultiDisplayManager::AddRemoveDisplay() { - MultiDisplayManager* manager = static_cast( - aura::Env::GetInstance()->display_manager()); - manager->AddRemoveDisplayImpl(); -} - -void MultiDisplayManager::CycleDisplay() { - MultiDisplayManager* manager = static_cast( - aura::Env::GetInstance()->display_manager()); - manager->CycleDisplayImpl(); -} - - void MultiDisplayManager::ToggleDisplayScale() { - MultiDisplayManager* manager = static_cast( - aura::Env::GetInstance()->display_manager()); - manager->ScaleDisplayImpl(); -} - -void MultiDisplayManager::OnNativeDisplaysChanged( - const std::vector& new_displays) { - size_t min = std::min(displays_.size(), new_displays.size()); - - // For m19, we only care about 1st display as primary, and - // don't differentiate the rest of displays as all secondary - // displays have the same content. ID for primary display stays the same - // because we never remove it, we don't update IDs for other displays - // , for now, because they're the same. - // TODO(oshima): Fix this so that we can differentiate outputs - // and keep a content on one display stays on the same display - // when a display is added or removed. - for (size_t i = 0; i < min; ++i) { - gfx::Display& current_display = displays_[i]; - const gfx::Display& new_display = new_displays[i]; - if (current_display.bounds_in_pixel() != new_display.bounds_in_pixel() || - current_display.device_scale_factor() != - new_display.device_scale_factor()) { - current_display.SetScaleAndBounds(new_display.device_scale_factor(), - new_display.bounds_in_pixel()); - NotifyBoundsChanged(current_display); - } - } - - if (displays_.size() < new_displays.size()) { - // New displays added - for (size_t i = min; i < new_displays.size(); ++i) { - const gfx::Display& new_display = new_displays[i]; - displays_.push_back(gfx::Display(new_display.id())); - gfx::Display& display = displays_.back(); - // Force the primary display's ID to be 0. - if (i == 0) - display.set_id(0); - display.SetScaleAndBounds(new_display.device_scale_factor(), - new_display.bounds_in_pixel()); - NotifyDisplayAdded(display); - } - } else { - // Displays are removed. We keep the display for the primary - // display (at index 0) because it needs the display information - // even if it doesn't exit. - while (displays_.size() > new_displays.size() && displays_.size() > 1) { - Displays::reverse_iterator iter = displays_.rbegin(); - NotifyDisplayRemoved(*iter); - displays_.erase(iter.base() - 1); - } - } -} - -RootWindow* MultiDisplayManager::CreateRootWindowForDisplay( - const gfx::Display& display) { - RootWindow* root_window = new RootWindow(display.bounds_in_pixel()); - // No need to remove RootWindowObserver because - // the DisplayManager object outlives RootWindow objects. - root_window->AddRootWindowObserver(this); - root_window->SetProperty(kDisplayIdKey, display.id()); - root_window->Init(); - return root_window; -} - -const gfx::Display& MultiDisplayManager::GetDisplayAt(size_t index) { - return index < displays_.size() ? displays_[index] : GetInvalidDisplay(); -} - -size_t MultiDisplayManager::GetNumDisplays() const { - return displays_.size(); -} - -const gfx::Display& MultiDisplayManager::GetDisplayNearestWindow( - const Window* window) const { - if (!window) { - MultiDisplayManager* manager = const_cast(this); - return manager->GetDisplayAt(0); - } - const RootWindow* root = window->GetRootWindow(); - MultiDisplayManager* manager = const_cast(this); - return root ? manager->FindDisplayForRootWindow(root) : GetInvalidDisplay(); -} - -const gfx::Display& MultiDisplayManager::GetDisplayNearestPoint( - const gfx::Point& point) const { - // TODO(oshima): For m19, mouse is constrained within - // the primary window. - MultiDisplayManager* manager = const_cast(this); - return manager->GetDisplayAt(0); -} - -void MultiDisplayManager::OnRootWindowResized(const aura::RootWindow* root, - const gfx::Size& old_size) { - if (!use_fullscreen_host_window()) { - gfx::Display& display = FindDisplayForRootWindow(root); - display.SetSize(root->GetHostSize()); - NotifyBoundsChanged(display); - } -} - -bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow( - const aura::Window* window, - const gfx::Insets& insets) { - const RootWindow* root = window->GetRootWindow(); - gfx::Display& display = FindDisplayForRootWindow(root); - gfx::Rect old_work_area = display.work_area(); - display.UpdateWorkAreaFromInsets(insets); - return old_work_area != display.work_area(); -} - -void MultiDisplayManager::Init() { - // TODO(oshima): Move this logic to DisplayChangeObserver. - const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - switches::kAuraHostWindowSize); - vector parts; - base::SplitString(size_str, ',', &parts); - for (vector::const_iterator iter = parts.begin(); - iter != parts.end(); ++iter) { - displays_.push_back(CreateDisplayFromSpec(*iter)); - } - if (displays_.empty()) - displays_.push_back(CreateDisplayFromSpec("" /* default */)); - // Force the 1st display to be the primary display (id == 0). - displays_[0].set_id(0); -} - -void MultiDisplayManager::AddRemoveDisplayImpl() { - std::vector new_displays; - if (displays_.size() > 1) { - // Remove if there is more than one display. - int count = displays_.size() - 1; - for (Displays::const_iterator iter = displays_.begin(); count-- > 0; ++iter) - new_displays.push_back(*iter); - } else { - // Add if there is only one display. - new_displays.push_back(displays_[0]); - new_displays.push_back(CreateDisplayFromSpec("50+50-1280x768")); - } - if (new_displays.size()) - OnNativeDisplaysChanged(new_displays); -} - -void MultiDisplayManager::CycleDisplayImpl() { - if (displays_.size() > 1) { - std::vector new_displays; - for (Displays::const_iterator iter = displays_.begin() + 1; - iter != displays_.end(); ++iter) { - gfx::Display display = *iter; - new_displays.push_back(display); - } - new_displays.push_back(displays_.front()); - OnNativeDisplaysChanged(new_displays); - } -} - -void MultiDisplayManager::ScaleDisplayImpl() { - if (displays_.size() > 0) { - std::vector new_displays; - for (Displays::const_iterator iter = displays_.begin(); - iter != displays_.end(); ++iter) { - gfx::Display display = *iter; - float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f; - display.SetScaleAndBounds( - factor, gfx::Rect(display.bounds_in_pixel().origin(), - display.size().Scale(factor))); - new_displays.push_back(display); - } - OnNativeDisplaysChanged(new_displays); - } -} - -gfx::Display& MultiDisplayManager::FindDisplayForRootWindow( - const aura::RootWindow* root_window) { - int id = root_window->GetProperty(kDisplayIdKey); - for (Displays::iterator iter = displays_.begin(); - iter != displays_.end(); ++iter) { - if ((*iter).id() == id) - return *iter; - } - DLOG(FATAL) << "Could not find display by id:" << id; - return GetInvalidDisplay(); -} - -} // namespace internal -} // namespace ash diff --git a/ash/display/multi_display_manager.h b/ash/display/multi_display_manager.h deleted file mode 100644 index 3aae410..0000000 --- a/ash/display/multi_display_manager.h +++ /dev/null @@ -1,84 +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 ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_ -#define ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_ -#pragma once - -#include - -#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" - -namespace gfx { -class Insets; -class Display; -} - -namespace ash { -namespace internal { - -// MultiDisplayManager 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 { - public: - MultiDisplayManager(); - virtual ~MultiDisplayManager(); - - // Used to emulate display change when run in a desktop environment instead - // of on a device. - static void AddRemoveDisplay(); - static void CycleDisplay(); - static void ToggleDisplayScale(); - - bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, - const gfx::Insets& insets); - - // DisplayManager overrides: - virtual void OnNativeDisplaysChanged( - const std::vector& displays) OVERRIDE; - virtual aura::RootWindow* CreateRootWindowForDisplay( - const gfx::Display& display) OVERRIDE; - virtual const 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; - - // RootWindowObserver overrides: - virtual void OnRootWindowResized(const aura::RootWindow* root, - const gfx::Size& new_size) OVERRIDE; - - private: - FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); - typedef std::vector Displays; - - void Init(); - void AddRemoveDisplayImpl(); - void CycleDisplayImpl(); - void ScaleDisplayImpl(); - gfx::Display& FindDisplayForRootWindow(const aura::RootWindow* root); - - Displays displays_; - - DISALLOW_COPY_AND_ASSIGN(MultiDisplayManager); -}; - -extern const aura::WindowProperty* const kDisplayIdKey; - -} // namespace internal -} // namespace ash - -#endif // ASH_DISPLAY_MULTI_DISPLAY_MANAGER_H_ diff --git a/ash/display/multi_display_manager_unittest.cc b/ash/display/multi_display_manager_unittest.cc deleted file mode 100644 index b1adc53..0000000 --- a/ash/display/multi_display_manager_unittest.cc +++ /dev/null @@ -1,235 +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 "ash/display/multi_display_manager.h" - -#include "ash/shell.h" -#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.h" - -namespace ash { -namespace test { - -using std::vector; -using std::string; - -class MultiDisplayManagerTest : public test::AshTestBase, - public aura::DisplayObserver, - public aura::WindowObserver { - public: - MultiDisplayManagerTest() - : removed_count_(0U), - root_window_destroyed_(false) { - } - virtual ~MultiDisplayManagerTest() {} - - virtual void SetUp() OVERRIDE { - AshTestBase::SetUp(); - display_manager()->AddObserver(this); - Shell::GetPrimaryRootWindow()->AddObserver(this); - } - virtual void TearDown() OVERRIDE { - Shell::GetPrimaryRootWindow()->RemoveObserver(this); - display_manager()->RemoveObserver(this); - AshTestBase::TearDown(); - } - - aura::DisplayManager* display_manager() { - return aura::Env::GetInstance()->display_manager(); - } - const vector& changed() const { return changed_; } - const vector& added() const { return added_; } - - string GetCountSummary() const { - return StringPrintf("%"PRIuS" %"PRIuS" %"PRIuS, - changed_.size(), added_.size(), removed_count_); - } - - void reset() { - changed_.clear(); - added_.clear(); - removed_count_ = 0U; - root_window_destroyed_ = false; - } - - bool root_window_destroyed() const { - return root_window_destroyed_; - } - - // aura::DisplayObserver overrides: - virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { - changed_.push_back(display); - } - virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { - added_.push_back(new_display); - } - virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { - ++removed_count_; - } - - // aura::WindowObserver overrides: - virtual void OnWindowDestroying(aura::Window* window) { - ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); - root_window_destroyed_ = true; - } - - private: - vector changed_; - vector added_; - size_t removed_count_; - bool root_window_destroyed_; - - DISALLOW_COPY_AND_ASSIGN(MultiDisplayManagerTest); -}; - -TEST_F(MultiDisplayManagerTest, NativeDisplayTest) { - aura::DisplayManager::set_use_fullscreen_host_window(true); - - EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - - // Update primary and add seconary. - UpdateDisplay("0+0-500x500,0+501-400x400"); - EXPECT_EQ(2U, display_manager()->GetNumDisplays()); - EXPECT_EQ("1 1 0", GetCountSummary()); - EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id()); - EXPECT_EQ(display_manager()->GetDisplayAt(1).id(), added()[0].id()); - EXPECT_EQ("0,0 500x500", changed()[0].bounds().ToString()); - EXPECT_EQ("0,0 400x400", added()[0].bounds().ToString()); - EXPECT_EQ("0,501 400x400", added()[0].bounds_in_pixel().ToString()); - reset(); - - // Delete secondary. - UpdateDisplay("0+0-500x500"); - EXPECT_EQ("0 0 1", GetCountSummary()); - reset(); - - // Change primary. - UpdateDisplay("0+0-1000x600"); - EXPECT_EQ("1 0 0", GetCountSummary()); - EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id()); - EXPECT_EQ("0,0 1000x600", changed()[0].bounds().ToString()); - reset(); - - // Add secondary. - UpdateDisplay("0+0-1000x600,1001+0-600x400"); - EXPECT_EQ(2U, display_manager()->GetNumDisplays()); - EXPECT_EQ("0 1 0", GetCountSummary()); - EXPECT_EQ(display_manager()->GetDisplayAt(1).id(), added()[0].id()); - EXPECT_EQ("0,0 600x400", added()[0].bounds().ToString()); - EXPECT_EQ("1001,0 600x400", added()[0].bounds_in_pixel().ToString()); - reset(); - - // Secondary removed, primary changed. - UpdateDisplay("0+0-800x300"); - EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - EXPECT_EQ("1 0 1", GetCountSummary()); - EXPECT_EQ(display_manager()->GetDisplayAt(0).id(), changed()[0].id()); - EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString()); - reset(); - - // # of display can go to zero when screen is off. - const vector empty; - display_manager()->OnNativeDisplaysChanged(empty); - EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - EXPECT_EQ("0 0 0", GetCountSummary()); - EXPECT_FALSE(root_window_destroyed()); - // Display configuration stays the same - EXPECT_EQ("0,0 800x300", - display_manager()->GetDisplayAt(0).bounds().ToString()); - reset(); - - // Connect to display again - UpdateDisplay("100+100-500x400"); - EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - EXPECT_EQ("1 0 0", GetCountSummary()); - EXPECT_FALSE(root_window_destroyed()); - EXPECT_EQ("0,0 500x400", changed()[0].bounds().ToString()); - EXPECT_EQ("100,100 500x400", changed()[0].bounds_in_pixel().ToString()); - reset(); - - // Go back to zero and wake up with multiple displays. - display_manager()->OnNativeDisplaysChanged(empty); - EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - EXPECT_FALSE(root_window_destroyed()); - reset(); - - // Add secondary. - UpdateDisplay("0+0-1000x600,1000+0-600x400"); - EXPECT_EQ(2U, display_manager()->GetNumDisplays()); - EXPECT_EQ("0,0 1000x600", - display_manager()->GetDisplayAt(0).bounds().ToString()); - EXPECT_EQ("0,0 600x400", - display_manager()->GetDisplayAt(1).bounds().ToString()); - EXPECT_EQ("1000,0 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, EmulatorTest) { - EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - - internal::MultiDisplayManager::AddRemoveDisplay(); - // Update primary and add seconary. - EXPECT_EQ(2U, display_manager()->GetNumDisplays()); -#if defined(OS_WIN) - // TODO(oshima): Windows receives resize event for some reason. - EXPECT_EQ("1 1 0", GetCountSummary()); -#else - EXPECT_EQ("0 1 0", GetCountSummary()); -#endif - reset(); - - internal::MultiDisplayManager::CycleDisplay(); - EXPECT_EQ(2U, display_manager()->GetNumDisplays()); - // Observer gets called twice in this mode because - // it gets notified both from |OnNativeDisplayChagned| - // and from |RootWindowObserver|, which is the consequence of - // |SetHostSize()|. - EXPECT_EQ("4 0 0", GetCountSummary()); - reset(); - - internal::MultiDisplayManager::AddRemoveDisplay(); - EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - EXPECT_EQ("0 0 1", GetCountSummary()); - reset(); - - internal::MultiDisplayManager::CycleDisplay(); - EXPECT_EQ(1U, display_manager()->GetNumDisplays()); - EXPECT_EQ("0 0 0", GetCountSummary()); - reset(); -} - -// TODO(oshima): Device scale factor is supported on chromeos only for now. -#if defined(OS_CHROMEOS) -#define MAYBE_TestDeviceScaleOnlyChange TestDeviceScaleOnlyChange -#else -#define MAYBE_TestDeviceScaleOnlyChange DISABLED_TestDeviceScaleOnlyChange -#endif - -TEST_F(MultiDisplayManagerTest, MAYBE_TestDeviceScaleOnlyChange) { - aura::DisplayManager::set_use_fullscreen_host_window(true); - UpdateDisplay("0+0-1000x600"); - EXPECT_EQ(1, - Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor()); - EXPECT_EQ("1000x600", - Shell::GetPrimaryRootWindow()->bounds().size().ToString()); - UpdateDisplay("0+0-1000x600*2"); - EXPECT_EQ(2, - Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor()); - EXPECT_EQ("500x300", - Shell::GetPrimaryRootWindow()->bounds().size().ToString()); - aura::DisplayManager::set_use_fullscreen_host_window(false); -} - -} // namespace test -} // namespace ash diff --git a/ash/display/secondary_display_view.cc b/ash/display/secondary_display_view.cc deleted file mode 100644 index ea8963e..0000000 --- a/ash/display/secondary_display_view.cc +++ /dev/null @@ -1,111 +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 "ash/display/secondary_display_view.h" - -#include "grit/ash_strings.h" -#include "grit/ui_resources.h" -#include "third_party/skia/include/core/SkColor.h" -#include "ui/aura/window.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/views/background.h" -#include "ui/views/controls/image_view.h" -#include "ui/views/controls/label.h" -#include "ui/views/view.h" -#include "ui/views/widget/widget.h" -#include "ui/views/widget/widget_delegate.h" - -namespace ash { -namespace { - -// Colors for the background, the message text and the shortcut text. -const SkColor kBackgroundColor = SkColorSetRGB(0x33, 0x33, 0x33); -const SkColor kTextColor = SkColorSetRGB(127, 127, 127); - -// A view to be displayed on secondary display. -class SecondaryDisplayView : public views::WidgetDelegateView { - public: - SecondaryDisplayView() { - Init(); - } - virtual ~SecondaryDisplayView() { - } - - void Init() { - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - - set_background(views::Background::CreateSolidBackground(kBackgroundColor)); - message_ = new views::Label( - l10n_util::GetStringUTF16(IDS_ASH_SECONDARY_MONITOR)); - message_->SetAutoColorReadabilityEnabled(false); - message_->SetFont(rb.GetFont(ui::ResourceBundle::LargeFont)); - message_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); - message_->SetEnabledColor(kTextColor); - AddChildView(message_); - - shortcut_text_ = new views::Label( - l10n_util::GetStringUTF16(IDS_ASH_SECONDARY_MONITOR_SHORTCUT)); - shortcut_text_->SetAutoColorReadabilityEnabled(false); - shortcut_text_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); - shortcut_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); - shortcut_text_->SetEnabledColor(kTextColor); - AddChildView(shortcut_text_); - - shortcut_image_ = new views::ImageView(); - shortcut_image_->SetImage(rb.GetImageSkiaNamed(IDR_AURA_SWITCH_MONITOR)); - AddChildView(shortcut_image_); - } - - virtual void Layout() { - const int kMessagePositionTopMargin = 40; - const int kShortcutPositionBottomMargin = 40; - const int kShortcutMargin = 4; // margin between text and image. - gfx::Rect b = bounds(); - - int msg_height = message_->GetHeightForWidth(b.width()); - message_->SetBounds( - 0, kMessagePositionTopMargin, bounds().width(), msg_height); - - // TODO(oshima): Figure out what to do for RTL. - // Align the shortcut text & image to the center. - gfx::Size text_size = shortcut_text_->GetPreferredSize(); - gfx::Size image_size = shortcut_image_->GetPreferredSize(); - int height = std::max(text_size.height(), image_size.height()); - int y = b.height() - kShortcutPositionBottomMargin - height; - int x = (b.width() - - (text_size.width() + kShortcutMargin + image_size.width())) / 2; - shortcut_text_->SetBounds(x, y + (height - text_size.height()) / 2, - text_size.width(), text_size.height()); - shortcut_image_->SetBounds( - x + text_size.width() + kShortcutMargin, - y + (height - image_size.height()) / 2, - image_size.width(), image_size.height()); - } - - private: - views::Label* message_; - views::Label* shortcut_text_; - views::ImageView* shortcut_image_; - - DISALLOW_COPY_AND_ASSIGN(SecondaryDisplayView); -}; - -} // namespace - -views::Widget* CreateSecondaryDisplayWidget(aura::Window* parent) { - views::Widget* desktop_widget = new views::Widget; - views::Widget::InitParams params( - views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); - SecondaryDisplayView* view = new SecondaryDisplayView(); - params.delegate = view; - params.parent = parent; - desktop_widget->Init(params); - desktop_widget->SetContentsView(view); - desktop_widget->Show(); - desktop_widget->GetNativeView()->SetName("SecondaryDisplay"); - return desktop_widget; -} - -} // namespace ash diff --git a/ash/display/secondary_display_view.h b/ash/display/secondary_display_view.h deleted file mode 100644 index 60db1e0..0000000 --- a/ash/display/secondary_display_view.h +++ /dev/null @@ -1,25 +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 ASH_DISPLAY_SECONDARY_DISPLAY_VIEW_H_ -#define ASH_DISPLAY_SECONDARY_DISPLAY_VIEW_H_ -#pragma once - -namespace aura { -class Window; -} - -namespace views { -class Widget; -} - -namespace ash { - -// Creates the widget that hosts the static message displayed on the -// secondary display. -views::Widget* CreateSecondaryDisplayWidget(aura::Window* parent); - -} // namespace ash - -#endif // ASH_DISPLAY_SECONDARY_DISPLAY_VIEW_H_ diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index 9a70acc..8469eb5 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/display/display_controller.h" -#include "ash/display/multi_display_manager.h" +#include "ash/monitor/monitor_controller.h" +#include "ash/monitor/multi_monitor_manager.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/wm/window_cycle_controller.h" @@ -58,19 +58,19 @@ class ExtendedDesktopTest : public test::AshTestBase { virtual ~ExtendedDesktopTest() {} virtual void SetUp() OVERRIDE { - internal::DisplayController::SetExtendedDesktopEnabled(true); + internal::MonitorController::SetExtendedDesktopEnabled(true); AshTestBase::SetUp(); } virtual void TearDown() OVERRIDE { AshTestBase::TearDown(); - internal::DisplayController::SetExtendedDesktopEnabled(false); + internal::MonitorController::SetExtendedDesktopEnabled(false); } protected: - internal::MultiDisplayManager* display_manager() { - return static_cast( - aura::Env::GetInstance()->display_manager()); + internal::MultiMonitorManager* monitor_manager() { + return static_cast( + aura::Env::GetInstance()->monitor_manager()); } private: @@ -80,7 +80,7 @@ class ExtendedDesktopTest : public test::AshTestBase { // Test conditions that root windows in extended desktop mode // must satisfy. TEST_F(ExtendedDesktopTest, Basic) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateMonitor("0+0-1000x600,1001+0-600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); // All root windows must have the root window controller. @@ -99,7 +99,7 @@ TEST_F(ExtendedDesktopTest, Basic) { } TEST_F(ExtendedDesktopTest, Activation) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateMonitor("0+0-1000x600,1001+0-600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); // Move the active root window to the secondary. @@ -134,7 +134,7 @@ TEST_F(ExtendedDesktopTest, Activation) { } TEST_F(ExtendedDesktopTest, SystemModal) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateMonitor("0+0-1000x600,1001+0-600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); Shell::GetInstance()->set_active_root_window(root_windows[0]); @@ -153,7 +153,7 @@ TEST_F(ExtendedDesktopTest, SystemModal) { EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow()); EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow()); - // Clicking a widget on widget_on_1st display should not change activation. + // Clicking a widget on widget_on_1st monitor should not change activation. aura::test::EventGenerator generator_1st(root_windows[0]); generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); generator_1st.ClickLeftButton(); @@ -169,7 +169,7 @@ TEST_F(ExtendedDesktopTest, SystemModal) { } TEST_F(ExtendedDesktopTest, TestCursor) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateMonitor("0+0-1000x600,1001+0-600x400"); Shell::GetInstance()->ShowCursor(false); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); EXPECT_FALSE(root_windows[0]->cursor_shown()); @@ -186,8 +186,8 @@ TEST_F(ExtendedDesktopTest, TestCursor) { } TEST_F(ExtendedDesktopTest, CycleWindows) { - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); - UpdateDisplay("0+0-700x500,0+0-500x500"); + internal::MonitorController::SetVirtualScreenCoordinatesEnabled(true); + UpdateMonitor("0+0-700x500,0+0-500x500"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); // Emulate virtual screen coordinate system. root_windows[0]->SetBounds(gfx::Rect(0, 0, 700, 500)); @@ -235,12 +235,12 @@ TEST_F(ExtendedDesktopTest, CycleWindows) { EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); + internal::MonitorController::SetVirtualScreenCoordinatesEnabled(false); } TEST_F(ExtendedDesktopTest, GetRootWindowAt) { - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); - UpdateDisplay("0+0-700x500,0+0-500x500"); + internal::MonitorController::SetVirtualScreenCoordinatesEnabled(true); + UpdateMonitor("0+0-700x500,0+0-500x500"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); // Emulate virtual screen coordinate system. root_windows[0]->SetBounds(gfx::Rect(500, 0, 700, 500)); @@ -257,12 +257,12 @@ TEST_F(ExtendedDesktopTest, GetRootWindowAt) { // Out of range point should return the primary root window EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(-100, 0))); EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(1201, 100))); - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); + internal::MonitorController::SetVirtualScreenCoordinatesEnabled(false); } TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); - UpdateDisplay("0+0-700x500,0+0-500x500"); + internal::MonitorController::SetVirtualScreenCoordinatesEnabled(true); + UpdateMonitor("0+0-700x500,0+0-500x500"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); // Emulate virtual screen coordinate system. root_windows[0]->SetBounds(gfx::Rect(500, 0, 700, 500)); @@ -297,11 +297,11 @@ TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { Shell::GetRootWindowMatching(gfx::Rect(-100, -300, 50, 50))); EXPECT_EQ(root_windows[0], Shell::GetRootWindowMatching(gfx::Rect(0, 2000, 50, 50))); - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); + internal::MonitorController::SetVirtualScreenCoordinatesEnabled(false); } TEST_F(ExtendedDesktopTest, Capture) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateMonitor("0+0-1000x600,1001+0-600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); aura::test::EventCountDelegate r1_d1; @@ -353,13 +353,13 @@ namespace internal { // Test if the Window::ConvertPointToWindow works across root windows. // TODO(oshima): Move multiple display suport and this test to aura. TEST_F(ExtendedDesktopTest, ConvertPoint) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateMonitor("0+0-1000x600,1001+0-600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); gfx::Display& display_1 = - display_manager()->FindDisplayForRootWindow(root_windows[0]); + monitor_manager()->FindDisplayForRootWindow(root_windows[0]); EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); gfx::Display& display_2 = - display_manager()->FindDisplayForRootWindow(root_windows[1]); + monitor_manager()->FindDisplayForRootWindow(root_windows[1]); Shell::GetInstance()->set_active_root_window(root_windows[0]); aura::Window* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); diff --git a/ash/monitor/monitor_controller.cc b/ash/monitor/monitor_controller.cc new file mode 100644 index 0000000..b8e1e04 --- /dev/null +++ b/ash/monitor/monitor_controller.cc @@ -0,0 +1,269 @@ +// 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 "ash/monitor/monitor_controller.h" + +#include "ash/ash_switches.h" +#include "ash/monitor/multi_monitor_manager.h" +#include "ash/root_window_controller.h" +#include "ash/shell.h" +#include "ash/wm/window_util.h" +#include "base/command_line.h" +#include "ui/aura/env.h" +#include "ui/aura/root_window.h" +#include "ui/aura/window.h" +#include "ui/gfx/display.h" +#include "ui/gfx/screen.h" + +namespace ash { +namespace internal { +namespace { +// True if the extended desktop mode is enabled. +bool extended_desktop_enabled = false; + +// True if the virtual screen coordinates is enabled. +bool virtual_screen_coordinates_enabled = false; +} + +MonitorController::MonitorController() + : secondary_display_layout_(RIGHT) { + aura::Env::GetInstance()->monitor_manager()->AddObserver(this); +} + +MonitorController::~MonitorController() { + aura::Env::GetInstance()->monitor_manager()->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::const_reverse_iterator it = + root_windows_.rbegin(); it != root_windows_.rend(); ++it) { + internal::RootWindowController* controller = + wm::GetRootWindowController(it->second); + // RootWindow may not have RootWindowController in non + // extended desktop mode. + if (controller) + delete controller; + else + delete it->second; + } +} + +void MonitorController::InitPrimaryDisplay() { + aura::MonitorManager* monitor_manager = + aura::Env::GetInstance()->monitor_manager(); + const gfx::Display& display = monitor_manager->GetDisplayAt(0); + DCHECK_EQ(0, display.id()); + aura::RootWindow* root = AddRootWindowForDisplay(display); + root->SetHostBounds(display.bounds_in_pixel()); +} + +void MonitorController::InitSecondaryDisplays() { + aura::MonitorManager* monitor_manager = + aura::Env::GetInstance()->monitor_manager(); + for (size_t i = 1; i < monitor_manager->GetNumDisplays(); ++i) { + const gfx::Display& display = monitor_manager->GetDisplayAt(i); + aura::RootWindow* root = AddRootWindowForDisplay(display); + Shell::GetInstance()->InitRootWindowForSecondaryMonitor(root); + } +} + +aura::RootWindow* MonitorController::GetPrimaryRootWindow() { + DCHECK(!root_windows_.empty()); + return root_windows_[0]; +} + +void MonitorController::CloseChildWindows() { + for (std::map::const_iterator it = + root_windows_.begin(); it != root_windows_.end(); ++it) { + aura::RootWindow* root_window = it->second; + internal::RootWindowController* controller = + wm::GetRootWindowController(root_window); + if (controller) { + controller->CloseChildWindows(); + } else { + while (!root_window->children().empty()) { + aura::Window* child = root_window->children()[0]; + delete child; + } + } + } +} + +std::vector MonitorController::GetAllRootWindows() { + std::vector windows; + for (std::map::const_iterator it = + root_windows_.begin(); it != root_windows_.end(); ++it) { + DCHECK(it->second); + if (wm::GetRootWindowController(it->second)) + windows.push_back(it->second); + } + return windows; +} + +std::vector +MonitorController::GetAllRootWindowControllers() { + std::vector controllers; + for (std::map::const_iterator it = + root_windows_.begin(); it != root_windows_.end(); ++it) { + internal::RootWindowController* controller = + wm::GetRootWindowController(it->second); + if (controller) + controllers.push_back(controller); + } + return controllers; +} + +void MonitorController::SetSecondaryDisplayLayout( + SecondaryDisplayLayout layout) { + secondary_display_layout_ = layout; +} + +bool MonitorController::WarpMouseCursorIfNecessary( + aura::Window* current_root, + const gfx::Point& location_in_root) { + if (root_windows_.size() < 2) + return false; + // Only 1 external display is supported in extended desktop mode. + DCHECK_EQ(2U, root_windows_.size()); + + bool in_primary = current_root == root_windows_[0]; + + std::map::iterator iter = root_windows_.begin(); + aura::RootWindow* alternate_root = iter->second != current_root ? + iter->second : (++iter)->second; + gfx::Rect alternate_bounds = alternate_root->bounds(); + gfx::Point alternate_point; + + gfx::Rect display_area( + gfx::Screen::GetDisplayNearestWindow(current_root).bounds()); + + // TODO(oshima): This is temporary code until the virtual screen + // coordinate is implemented. + if (location_in_root.x() <= display_area.x()) { + if (location_in_root.y() < alternate_bounds.height() && + ((in_primary && secondary_display_layout_ == LEFT) || + (!in_primary && secondary_display_layout_ == RIGHT))) { + alternate_point = gfx::Point( + alternate_bounds.right() - (location_in_root.x() - display_area.x()), + location_in_root.y()); + } else { + alternate_root = NULL; + } + } else if (location_in_root.x() >= display_area.right() - 1) { + if (location_in_root.y() < alternate_bounds.height() && + ((in_primary && secondary_display_layout_ == RIGHT) || + (!in_primary && secondary_display_layout_ == LEFT))) { + alternate_point = gfx::Point(location_in_root.x() - display_area.right(), + location_in_root.y()); + } else { + alternate_root = NULL; + } + } else if (location_in_root.y() < display_area.y()) { + if (location_in_root.x() < alternate_bounds.width() && + ((in_primary && secondary_display_layout_ == TOP) || + (!in_primary && secondary_display_layout_ == BOTTOM))) { + alternate_point = gfx::Point( + location_in_root.x(), + alternate_bounds.bottom() - + (location_in_root.y() - display_area.y())); + } else { + alternate_root = NULL; + } + } else if (location_in_root.y() >= display_area.bottom() - 1) { + if (location_in_root.x() < alternate_bounds.width() && + ((in_primary && secondary_display_layout_ == BOTTOM) || + (!in_primary && secondary_display_layout_ == TOP))) { + alternate_point = gfx::Point( + location_in_root.x(), location_in_root.y() - display_area.bottom()); + } else { + alternate_root = NULL; + } + } else { + alternate_root = NULL; + } + if (alternate_root) { + DCHECK_NE(alternate_root, current_root); + alternate_root->MoveCursorTo(alternate_point); + return true; + } + return false; +} + +void MonitorController::OnDisplayBoundsChanged(const gfx::Display& display) { + root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel()); +} + +void MonitorController::OnDisplayAdded(const gfx::Display& display) { + if (root_windows_.empty()) { + DCHECK_EQ(0, display.id()); + root_windows_[display.id()] = Shell::GetPrimaryRootWindow(); + Shell::GetPrimaryRootWindow()->SetHostBounds(display.bounds_in_pixel()); + return; + } + aura::RootWindow* root = AddRootWindowForDisplay(display); + Shell::GetInstance()->InitRootWindowForSecondaryMonitor(root); +} + +void MonitorController::OnDisplayRemoved(const gfx::Display& display) { + aura::RootWindow* root = root_windows_[display.id()]; + DCHECK(root); + // Primary monitor should never be removed by MonitorManager. + DCHECK(root != Shell::GetPrimaryRootWindow()); + // Monitor for root window will be deleted when the Primary RootWindow + // is deleted by the Shell. + if (root != Shell::GetPrimaryRootWindow()) { + root_windows_.erase(display.id()); + internal::RootWindowController* controller = + wm::GetRootWindowController(root); + if (controller) { + controller->MoveWindowsTo(Shell::GetPrimaryRootWindow()); + delete controller; + } else { + delete root; + } + } +} + +// static +bool MonitorController::IsExtendedDesktopEnabled(){ + return extended_desktop_enabled || + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAshExtendedDesktop); +} + +// static +void MonitorController::SetExtendedDesktopEnabled(bool enabled) { + extended_desktop_enabled = enabled; +} + +// static +bool MonitorController::IsVirtualScreenCoordinatesEnabled() { + return virtual_screen_coordinates_enabled || + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kAshVirtualScreenCoordinates); +} + +// static +void MonitorController::SetVirtualScreenCoordinatesEnabled(bool enabled) { + virtual_screen_coordinates_enabled = enabled; +} + +aura::RootWindow* MonitorController::AddRootWindowForDisplay( + const gfx::Display& display) { + aura::RootWindow* root = aura::Env::GetInstance()->monitor_manager()-> + CreateRootWindowForMonitor(display); + root_windows_[display.id()] = root; + // Confine the cursor within the window if + // 1) Extended desktop is enabled or + // 2) the display is primary monitor and the host window + // is set to be fullscreen (this is old behavior). + if (IsExtendedDesktopEnabled() || + (aura::MonitorManager::use_fullscreen_host_window() && + display.id() == 0)) { + root->ConfineCursorToWindow(); + } + return root; +} + +} // namespace internal +} // namespace ash diff --git a/ash/monitor/monitor_controller.h b/ash/monitor/monitor_controller.h new file mode 100644 index 0000000..72afa42 --- /dev/null +++ b/ash/monitor/monitor_controller.h @@ -0,0 +1,109 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_MONITOR_MONITOR_CONTROLLER_H_ +#define ASH_MONITOR_MONITOR_CONTROLLER_H_ +#pragma once + +#include +#include + +#include "ash/ash_export.h" +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "ui/aura/display_observer.h" +#include "ui/aura/monitor_manager.h" + +namespace aura { +class Display; +class RootWindow; +} + +namespace ash { +namespace internal { +class RootWindowController; + +// MonitorController owns and maintains RootWindows for each attached +// display, keeping them in sync with display configuration changes. +// TODO(oshima): Rename MonitorXXX to DisplayXXX. +class ASH_EXPORT MonitorController : public aura::DisplayObserver { + public: + // Layout options where the secondary monitor should be positioned. + enum SecondaryDisplayLayout { + TOP, + RIGHT, + BOTTOM, + LEFT + }; + + MonitorController(); + virtual ~MonitorController(); + + // Initializes primary display. + void InitPrimaryDisplay(); + + // Initialize secondary display. This is separated because in non + // extended desktop mode, this creates background widgets, which + // requires other controllers. + void InitSecondaryDisplays(); + + // Returns the root window for primary display. + aura::RootWindow* GetPrimaryRootWindow(); + + // Closes all child windows in the all root windows. + void CloseChildWindows(); + + // Returns all root windows. In non extended desktop mode, this + // returns the primary root window only. + std::vector GetAllRootWindows(); + + // Returns all oot window controllers. In non extended desktop + // mode, this return a RootWindowController for the primary root window only. + std::vector GetAllRootWindowControllers(); + + SecondaryDisplayLayout secondary_display_layout() const { + return secondary_display_layout_; + } + void SetSecondaryDisplayLayout(SecondaryDisplayLayout layout); + + // Warps the mouse cursor to an alternate root window when the + // |location_in_root|, which is the location of the mouse cursor, + // hits or exceeds the edge of the |root_window| and the mouse cursor + // is considered to be in an alternate display. Returns true if + // the cursor was moved. + bool WarpMouseCursorIfNecessary(aura::Window* root_window, + const gfx::Point& location_in_root); + + // aura::DisplayObserver overrides: + virtual void OnDisplayBoundsChanged( + const gfx::Display& display) OVERRIDE; + virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; + virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; + + // Is extended desktop enabled? + static bool IsExtendedDesktopEnabled(); + // Change the extended desktop mode. Used for testing. + static void SetExtendedDesktopEnabled(bool enabled); + + // Is virtual screen coordinates enabled? + static bool IsVirtualScreenCoordinatesEnabled(); + // Turns on/off the virtual screen coordinates. + static void SetVirtualScreenCoordinatesEnabled(bool enabled); + + private: + // Creates a root window for |display| and stores it in the |root_windows_| + // map. + aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display); + + std::map root_windows_; + + SecondaryDisplayLayout secondary_display_layout_; + + DISALLOW_COPY_AND_ASSIGN(MonitorController); +}; + +} // namespace internal +} // namespace ash + +#endif // ASH_MONITOR_MONITOR_CONTROLLER_H_ diff --git a/ash/monitor/mouse_cursor_event_filter.cc b/ash/monitor/mouse_cursor_event_filter.cc new file mode 100644 index 0000000..0c451d1 --- /dev/null +++ b/ash/monitor/mouse_cursor_event_filter.cc @@ -0,0 +1,53 @@ +// 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 "ash/monitor/mouse_cursor_event_filter.h" + +#include "ash/monitor/monitor_controller.h" +#include "ui/aura/event.h" +#include "ui/aura/root_window.h" +#include "ui/aura/window.h" + +namespace ash { +namespace internal { + +MouseCursorEventFilter::MouseCursorEventFilter( + MonitorController* monitor_controller) + : monitor_controller_(monitor_controller) { + DCHECK(monitor_controller_); +} + +MouseCursorEventFilter::~MouseCursorEventFilter() { +} + +bool MouseCursorEventFilter::PreHandleKeyEvent(aura::Window* target, + aura::KeyEvent* event) { + return false; +} + +bool MouseCursorEventFilter::PreHandleMouseEvent(aura::Window* target, + aura::MouseEvent* event) { + if (event->type() != ui::ET_MOUSE_MOVED) + return false; + aura::RootWindow* current_root = target->GetRootWindow(); + gfx::Point location_in_root(event->location()); + aura::Window::ConvertPointToWindow(target, current_root, &location_in_root); + return monitor_controller_->WarpMouseCursorIfNecessary( + current_root, location_in_root); +} + +ui::TouchStatus MouseCursorEventFilter::PreHandleTouchEvent( + aura::Window* target, + aura::TouchEvent* event) { + return ui::TOUCH_STATUS_UNKNOWN; +} + +ui::GestureStatus MouseCursorEventFilter::PreHandleGestureEvent( + aura::Window* target, + aura::GestureEvent* event) { + return ui::GESTURE_STATUS_UNKNOWN; +} + +} // namespace internal +} // namespace ash diff --git a/ash/monitor/mouse_cursor_event_filter.h b/ash/monitor/mouse_cursor_event_filter.h new file mode 100644 index 0000000..682547a --- /dev/null +++ b/ash/monitor/mouse_cursor_event_filter.h @@ -0,0 +1,44 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_MONITOR_MOUSE_CURSOR_EVENT_FILTER_H +#define ASH_MONITOR_MOUSE_CURSOR_EVENT_FILTER_H +#pragma once + +#include "ash/ash_export.h" +#include "base/compiler_specific.h" +#include "ui/aura/event_filter.h" + +namespace ash { +namespace internal { +class MonitorController; + +// An event filter that controls mouse location in extended desktop +// environment. +class ASH_EXPORT MouseCursorEventFilter : public aura::EventFilter { + public: + MouseCursorEventFilter(MonitorController* monitor_controller); + virtual ~MouseCursorEventFilter(); + + // Overridden from aura::EventFilter: + virtual bool PreHandleKeyEvent(aura::Window* target, + aura::KeyEvent* event) OVERRIDE; + virtual bool PreHandleMouseEvent(aura::Window* target, + aura::MouseEvent* event) OVERRIDE; + virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, + aura::TouchEvent* event) OVERRIDE; + virtual ui::GestureStatus PreHandleGestureEvent( + aura::Window* target, + aura::GestureEvent* event) OVERRIDE; + + private: + MonitorController* monitor_controller_; + + DISALLOW_COPY_AND_ASSIGN(MouseCursorEventFilter); +}; + +} // namespace internal +} // namespace ash + +#endif // ASH_MONITOR_MOUSE_CURSOR_EVENT_FILTER_H diff --git a/ash/monitor/multi_monitor_manager.cc b/ash/monitor/multi_monitor_manager.cc new file mode 100644 index 0000000..70bf90d --- /dev/null +++ b/ash/monitor/multi_monitor_manager.cc @@ -0,0 +1,247 @@ +// 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 "ash/monitor/multi_monitor_manager.h" + +#include +#include + +#include "base/command_line.h" +#include "base/stl_util.h" +#include "base/string_split.h" +#include "ui/aura/aura_switches.h" +#include "ui/aura/env.h" +#include "ui/aura/root_window.h" +#include "ui/aura/root_window_host.h" +#include "ui/aura/window_property.h" +#include "ui/gfx/display.h" +#include "ui/gfx/rect.h" + +DECLARE_WINDOW_PROPERTY_TYPE(int); + +namespace ash { +namespace internal { +namespace { + +gfx::Display& GetInvalidDisplay() { + static gfx::Display* invalid_display = new gfx::Display(); + return *invalid_display; +} + +} // namespace + +using aura::RootWindow; +using aura::Window; +using std::string; +using std::vector; + +DEFINE_WINDOW_PROPERTY_KEY(int, kMonitorIdKey, -1); + +MultiMonitorManager::MultiMonitorManager() { + Init(); +} + +MultiMonitorManager::~MultiMonitorManager() { +} + +// static +void MultiMonitorManager::AddRemoveMonitor() { + MultiMonitorManager* manager = static_cast( + aura::Env::GetInstance()->monitor_manager()); + manager->AddRemoveMonitorImpl(); +} + +void MultiMonitorManager::CycleMonitor() { + MultiMonitorManager* manager = static_cast( + aura::Env::GetInstance()->monitor_manager()); + manager->CycleMonitorImpl(); +} + + void MultiMonitorManager::ToggleMonitorScale() { + MultiMonitorManager* manager = static_cast( + aura::Env::GetInstance()->monitor_manager()); + manager->ScaleMonitorImpl(); +} + +void MultiMonitorManager::OnNativeMonitorsChanged( + const std::vector& new_displays) { + size_t min = std::min(displays_.size(), new_displays.size()); + + // For m19, we only care about 1st monitor as primary, and + // don't differentiate the rest of monitors as all secondary + // monitors have the same content. ID for primary monitor stays the same + // because we never remove it, we don't update IDs for other monitors + // , for now, because they're the same. + // TODO(oshima): Fix this so that we can differentiate outputs + // and keep a content on one monitor stays on the same monitor + // when a monitor is added or removed. + for (size_t i = 0; i < min; ++i) { + gfx::Display& current_display = displays_[i]; + const gfx::Display& new_display = new_displays[i]; + if (current_display.bounds_in_pixel() != new_display.bounds_in_pixel() || + current_display.device_scale_factor() != + new_display.device_scale_factor()) { + current_display.SetScaleAndBounds(new_display.device_scale_factor(), + new_display.bounds_in_pixel()); + NotifyBoundsChanged(current_display); + } + } + + if (displays_.size() < new_displays.size()) { + // New monitors added + for (size_t i = min; i < new_displays.size(); ++i) { + const gfx::Display& new_display = new_displays[i]; + displays_.push_back(gfx::Display(new_display.id())); + gfx::Display& display = displays_.back(); + // Force the primary display's ID to be 0. + if (i == 0) + display.set_id(0); + display.SetScaleAndBounds(new_display.device_scale_factor(), + new_display.bounds_in_pixel()); + NotifyDisplayAdded(display); + } + } else { + // Monitors are removed. We keep the monitor for the primary + // monitor (at index 0) because it needs the monitor information + // even if it doesn't exit. + while (displays_.size() > new_displays.size() && displays_.size() > 1) { + Displays::reverse_iterator iter = displays_.rbegin(); + NotifyDisplayRemoved(*iter); + displays_.erase(iter.base() - 1); + } + } +} + +RootWindow* MultiMonitorManager::CreateRootWindowForMonitor( + const gfx::Display& display) { + RootWindow* root_window = new RootWindow(display.bounds_in_pixel()); + // No need to remove RootWindowObserver because + // the MonitorManager object outlives RootWindow objects. + root_window->AddRootWindowObserver(this); + root_window->SetProperty(kMonitorIdKey, display.id()); + root_window->Init(); + return root_window; +} + +const gfx::Display& MultiMonitorManager::GetDisplayAt(size_t index) { + return index < displays_.size() ? displays_[index] : GetInvalidDisplay(); +} + +size_t MultiMonitorManager::GetNumDisplays() const { + return displays_.size(); +} + +const gfx::Display& MultiMonitorManager::GetDisplayNearestWindow( + const Window* window) const { + if (!window) { + MultiMonitorManager* manager = const_cast(this); + return manager->GetDisplayAt(0); + } + const RootWindow* root = window->GetRootWindow(); + MultiMonitorManager* manager = const_cast(this); + return root ? manager->FindDisplayForRootWindow(root) : GetInvalidDisplay(); +} + +const gfx::Display& MultiMonitorManager::GetDisplayNearestPoint( + const gfx::Point& point) const { + // TODO(oshima): For m19, mouse is constrained within + // the primary window. + MultiMonitorManager* manager = const_cast(this); + return manager->GetDisplayAt(0); +} + +void MultiMonitorManager::OnRootWindowResized(const aura::RootWindow* root, + const gfx::Size& old_size) { + if (!use_fullscreen_host_window()) { + gfx::Display& display = FindDisplayForRootWindow(root); + display.SetSize(root->GetHostSize()); + NotifyBoundsChanged(display); + } +} + +bool MultiMonitorManager::UpdateWorkAreaOfMonitorNearestWindow( + const aura::Window* window, + const gfx::Insets& insets) { + const RootWindow* root = window->GetRootWindow(); + gfx::Display& display = FindDisplayForRootWindow(root); + gfx::Rect old_work_area = display.work_area(); + display.UpdateWorkAreaFromInsets(insets); + return old_work_area != display.work_area(); +} + +void MultiMonitorManager::Init() { + // TODO(oshima): Move this logic to MonitorChangeObserver. + const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( + switches::kAuraHostWindowSize); + vector parts; + base::SplitString(size_str, ',', &parts); + for (vector::const_iterator iter = parts.begin(); + iter != parts.end(); ++iter) { + displays_.push_back(CreateMonitorFromSpec(*iter)); + } + if (displays_.empty()) + displays_.push_back(CreateMonitorFromSpec("" /* default */)); + // Force the 1st display to be the primary display (id == 0). + displays_[0].set_id(0); +} + +void MultiMonitorManager::AddRemoveMonitorImpl() { + std::vector new_displays; + if (displays_.size() > 1) { + // Remove if there is more than one display. + int count = displays_.size() - 1; + for (Displays::const_iterator iter = displays_.begin(); count-- > 0; ++iter) + new_displays.push_back(*iter); + } else { + // Add if there is only one display. + new_displays.push_back(displays_[0]); + new_displays.push_back(CreateMonitorFromSpec("50+50-1280x768")); + } + if (new_displays.size()) + OnNativeMonitorsChanged(new_displays); +} + +void MultiMonitorManager::CycleMonitorImpl() { + if (displays_.size() > 1) { + std::vector new_displays; + for (Displays::const_iterator iter = displays_.begin() + 1; + iter != displays_.end(); ++iter) { + gfx::Display display = *iter; + new_displays.push_back(display); + } + new_displays.push_back(displays_.front()); + OnNativeMonitorsChanged(new_displays); + } +} + +void MultiMonitorManager::ScaleMonitorImpl() { + if (displays_.size() > 0) { + std::vector new_displays; + for (Displays::const_iterator iter = displays_.begin(); + iter != displays_.end(); ++iter) { + gfx::Display display = *iter; + float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f; + display.SetScaleAndBounds( + factor, gfx::Rect(display.bounds_in_pixel().origin(), + display.size().Scale(factor))); + new_displays.push_back(display); + } + OnNativeMonitorsChanged(new_displays); + } +} + +gfx::Display& MultiMonitorManager::FindDisplayForRootWindow( + const aura::RootWindow* root_window) { + int id = root_window->GetProperty(kMonitorIdKey); + for (Displays::iterator iter = displays_.begin(); + iter != displays_.end(); ++iter) { + if ((*iter).id() == id) + return *iter; + } + DLOG(FATAL) << "Could not find display by id:" << id; + return GetInvalidDisplay(); +} + +} // namespace internal +} // namespace ash diff --git a/ash/monitor/multi_monitor_manager.h b/ash/monitor/multi_monitor_manager.h new file mode 100644 index 0000000..3849dfe --- /dev/null +++ b/ash/monitor/multi_monitor_manager.h @@ -0,0 +1,84 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_MONITOR_MULTI_MONITOR_MANAGER_H_ +#define ASH_MONITOR_MULTI_MONITOR_MANAGER_H_ +#pragma once + +#include + +#include "ash/ash_export.h" +#include "base/compiler_specific.h" +#include "base/gtest_prod_util.h" +#include "ui/aura/monitor_manager.h" +#include "ui/aura/root_window_observer.h" +#include "ui/aura/window.h" + +namespace gfx { +class Insets; +class Display; +} + +namespace ash { +namespace internal { + +// MultiMonitorManager maintains the current monitor 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 MultiMonitorManager : public aura::MonitorManager, + public aura::RootWindowObserver { + public: + MultiMonitorManager(); + virtual ~MultiMonitorManager(); + + // Used to emulate monitor change when run in a desktop environment instead + // of on a device. + static void AddRemoveMonitor(); + static void CycleMonitor(); + static void ToggleMonitorScale(); + + bool UpdateWorkAreaOfMonitorNearestWindow(const aura::Window* window, + const gfx::Insets& insets); + + // MonitorManager overrides: + virtual void OnNativeMonitorsChanged( + const std::vector& displays) OVERRIDE; + virtual aura::RootWindow* CreateRootWindowForMonitor( + const gfx::Display& display) OVERRIDE; + virtual const 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; + + // RootWindowObserver overrides: + virtual void OnRootWindowResized(const aura::RootWindow* root, + const gfx::Size& new_size) OVERRIDE; + + private: + FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); + typedef std::vector Displays; + + void Init(); + void AddRemoveMonitorImpl(); + void CycleMonitorImpl(); + void ScaleMonitorImpl(); + gfx::Display& FindDisplayForRootWindow(const aura::RootWindow* root); + + Displays displays_; + + DISALLOW_COPY_AND_ASSIGN(MultiMonitorManager); +}; + +extern const aura::WindowProperty* const kMonitorIdKey; + +} // namespace internal +} // namespace ash + +#endif // ASH_MONITOR_MULTI_MONITOR_MANAGER_H_ diff --git a/ash/monitor/multi_monitor_manager_unittest.cc b/ash/monitor/multi_monitor_manager_unittest.cc new file mode 100644 index 0000000..94a28cd --- /dev/null +++ b/ash/monitor/multi_monitor_manager_unittest.cc @@ -0,0 +1,235 @@ +// 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 "ash/monitor/multi_monitor_manager.h" + +#include "ash/shell.h" +#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.h" + +namespace ash { +namespace test { + +using std::vector; +using std::string; + +class MultiMonitorManagerTest : public test::AshTestBase, + public aura::DisplayObserver, + public aura::WindowObserver { + public: + MultiMonitorManagerTest() + : removed_count_(0U), + root_window_destroyed_(false) { + } + virtual ~MultiMonitorManagerTest() {} + + virtual void SetUp() OVERRIDE { + AshTestBase::SetUp(); + monitor_manager()->AddObserver(this); + Shell::GetPrimaryRootWindow()->AddObserver(this); + } + virtual void TearDown() OVERRIDE { + Shell::GetPrimaryRootWindow()->RemoveObserver(this); + monitor_manager()->RemoveObserver(this); + AshTestBase::TearDown(); + } + + aura::MonitorManager* monitor_manager() { + return aura::Env::GetInstance()->monitor_manager(); + } + const vector& changed() const { return changed_; } + const vector& added() const { return added_; } + + string GetCountSummary() const { + return StringPrintf("%"PRIuS" %"PRIuS" %"PRIuS, + changed_.size(), added_.size(), removed_count_); + } + + void reset() { + changed_.clear(); + added_.clear(); + removed_count_ = 0U; + root_window_destroyed_ = false; + } + + bool root_window_destroyed() const { + return root_window_destroyed_; + } + + // aura::DisplayObserver overrides: + virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE { + changed_.push_back(display); + } + virtual void OnDisplayAdded(const gfx::Display& new_display) OVERRIDE { + added_.push_back(new_display); + } + virtual void OnDisplayRemoved(const gfx::Display& old_display) OVERRIDE { + ++removed_count_; + } + + // aura::WindowObserver overrides: + virtual void OnWindowDestroying(aura::Window* window) { + ASSERT_EQ(Shell::GetPrimaryRootWindow(), window); + root_window_destroyed_ = true; + } + + private: + vector changed_; + vector added_; + size_t removed_count_; + bool root_window_destroyed_; + + DISALLOW_COPY_AND_ASSIGN(MultiMonitorManagerTest); +}; + +TEST_F(MultiMonitorManagerTest, NativeMonitorTest) { + aura::MonitorManager::set_use_fullscreen_host_window(true); + + EXPECT_EQ(1U, monitor_manager()->GetNumDisplays()); + + // Update primary and add seconary. + UpdateMonitor("0+0-500x500,0+501-400x400"); + EXPECT_EQ(2U, monitor_manager()->GetNumDisplays()); + EXPECT_EQ("1 1 0", GetCountSummary()); + EXPECT_EQ(monitor_manager()->GetDisplayAt(0).id(), changed()[0].id()); + EXPECT_EQ(monitor_manager()->GetDisplayAt(1).id(), added()[0].id()); + EXPECT_EQ("0,0 500x500", changed()[0].bounds().ToString()); + EXPECT_EQ("0,0 400x400", added()[0].bounds().ToString()); + EXPECT_EQ("0,501 400x400", added()[0].bounds_in_pixel().ToString()); + reset(); + + // Delete secondary. + UpdateMonitor("0+0-500x500"); + EXPECT_EQ("0 0 1", GetCountSummary()); + reset(); + + // Change primary. + UpdateMonitor("0+0-1000x600"); + EXPECT_EQ("1 0 0", GetCountSummary()); + EXPECT_EQ(monitor_manager()->GetDisplayAt(0).id(), changed()[0].id()); + EXPECT_EQ("0,0 1000x600", changed()[0].bounds().ToString()); + reset(); + + // Add secondary. + UpdateMonitor("0+0-1000x600,1001+0-600x400"); + EXPECT_EQ(2U, monitor_manager()->GetNumDisplays()); + EXPECT_EQ("0 1 0", GetCountSummary()); + EXPECT_EQ(monitor_manager()->GetDisplayAt(1).id(), added()[0].id()); + EXPECT_EQ("0,0 600x400", added()[0].bounds().ToString()); + EXPECT_EQ("1001,0 600x400", added()[0].bounds_in_pixel().ToString()); + reset(); + + // Secondary removed, primary changed. + UpdateMonitor("0+0-800x300"); + EXPECT_EQ(1U, monitor_manager()->GetNumDisplays()); + EXPECT_EQ("1 0 1", GetCountSummary()); + EXPECT_EQ(monitor_manager()->GetDisplayAt(0).id(), changed()[0].id()); + EXPECT_EQ("0,0 800x300", changed()[0].bounds().ToString()); + reset(); + + // # of display can go to zero when screen is off. + const vector empty; + monitor_manager()->OnNativeMonitorsChanged(empty); + EXPECT_EQ(1U, monitor_manager()->GetNumDisplays()); + EXPECT_EQ("0 0 0", GetCountSummary()); + EXPECT_FALSE(root_window_destroyed()); + // Monitor configuration stays the same + EXPECT_EQ("0,0 800x300", + monitor_manager()->GetDisplayAt(0).bounds().ToString()); + reset(); + + // Connect to monitor again + UpdateMonitor("100+100-500x400"); + EXPECT_EQ(1U, monitor_manager()->GetNumDisplays()); + EXPECT_EQ("1 0 0", GetCountSummary()); + EXPECT_FALSE(root_window_destroyed()); + EXPECT_EQ("0,0 500x400", changed()[0].bounds().ToString()); + EXPECT_EQ("100,100 500x400", changed()[0].bounds_in_pixel().ToString()); + reset(); + + // Go back to zero and wake up with multiple monitors. + monitor_manager()->OnNativeMonitorsChanged(empty); + EXPECT_EQ(1U, monitor_manager()->GetNumDisplays()); + EXPECT_FALSE(root_window_destroyed()); + reset(); + + // Add secondary. + UpdateMonitor("0+0-1000x600,1000+0-600x400"); + EXPECT_EQ(2U, monitor_manager()->GetNumDisplays()); + EXPECT_EQ("0,0 1000x600", + monitor_manager()->GetDisplayAt(0).bounds().ToString()); + EXPECT_EQ("0,0 600x400", + monitor_manager()->GetDisplayAt(1).bounds().ToString()); + EXPECT_EQ("1000,0 600x400", + monitor_manager()->GetDisplayAt(1).bounds_in_pixel().ToString()); + reset(); + + aura::MonitorManager::set_use_fullscreen_host_window(false); +} + +// Test in emulation mode (use_fullscreen_host_window=false) +TEST_F(MultiMonitorManagerTest, EmulatorTest) { + EXPECT_EQ(1U, monitor_manager()->GetNumDisplays()); + + internal::MultiMonitorManager::AddRemoveMonitor(); + // Update primary and add seconary. + EXPECT_EQ(2U, monitor_manager()->GetNumDisplays()); +#if defined(OS_WIN) + // TODO(oshima): Windows receives resize event for some reason. + EXPECT_EQ("1 1 0", GetCountSummary()); +#else + EXPECT_EQ("0 1 0", GetCountSummary()); +#endif + reset(); + + internal::MultiMonitorManager::CycleMonitor(); + EXPECT_EQ(2U, monitor_manager()->GetNumDisplays()); + // Observer gets called twice in this mode because + // it gets notified both from |OnNativeMonitorChagned| + // and from |RootWindowObserver|, which is the consequence of + // |SetHostSize()|. + EXPECT_EQ("4 0 0", GetCountSummary()); + reset(); + + internal::MultiMonitorManager::AddRemoveMonitor(); + EXPECT_EQ(1U, monitor_manager()->GetNumDisplays()); + EXPECT_EQ("0 0 1", GetCountSummary()); + reset(); + + internal::MultiMonitorManager::CycleMonitor(); + EXPECT_EQ(1U, monitor_manager()->GetNumDisplays()); + EXPECT_EQ("0 0 0", GetCountSummary()); + reset(); +} + +// TODO(oshima): Device scale factor is supported on chromeos only for now. +#if defined(OS_CHROMEOS) +#define MAYBE_TestDeviceScaleOnlyChange TestDeviceScaleOnlyChange +#else +#define MAYBE_TestDeviceScaleOnlyChange DISABLED_TestDeviceScaleOnlyChange +#endif + +TEST_F(MultiMonitorManagerTest, MAYBE_TestDeviceScaleOnlyChange) { + aura::MonitorManager::set_use_fullscreen_host_window(true); + UpdateMonitor("0+0-1000x600"); + EXPECT_EQ(1, + Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor()); + EXPECT_EQ("1000x600", + Shell::GetPrimaryRootWindow()->bounds().size().ToString()); + UpdateMonitor("0+0-1000x600*2"); + EXPECT_EQ(2, + Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor()); + EXPECT_EQ("500x300", + Shell::GetPrimaryRootWindow()->bounds().size().ToString()); + aura::MonitorManager::set_use_fullscreen_host_window(false); +} + +} // namespace test +} // namespace ash diff --git a/ash/monitor/secondary_monitor_view.cc b/ash/monitor/secondary_monitor_view.cc new file mode 100644 index 0000000..ad9b250 --- /dev/null +++ b/ash/monitor/secondary_monitor_view.cc @@ -0,0 +1,111 @@ +// 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 "ash/monitor/secondary_monitor_view.h" + +#include "grit/ash_strings.h" +#include "grit/ui_resources.h" +#include "third_party/skia/include/core/SkColor.h" +#include "ui/aura/window.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/views/background.h" +#include "ui/views/controls/image_view.h" +#include "ui/views/controls/label.h" +#include "ui/views/view.h" +#include "ui/views/widget/widget.h" +#include "ui/views/widget/widget_delegate.h" + +namespace ash { +namespace { + +// Colors for the background, the message text and the shortcut text. +const SkColor kBackgroundColor = SkColorSetRGB(0x33, 0x33, 0x33); +const SkColor kTextColor = SkColorSetRGB(127, 127, 127); + +// A view to be displayed on secondary monitor. +class SecondaryMonitorView : public views::WidgetDelegateView { + public: + SecondaryMonitorView() { + Init(); + } + virtual ~SecondaryMonitorView() { + } + + void Init() { + ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); + + set_background(views::Background::CreateSolidBackground(kBackgroundColor)); + message_ = new views::Label( + l10n_util::GetStringUTF16(IDS_ASH_SECONDARY_MONITOR)); + message_->SetAutoColorReadabilityEnabled(false); + message_->SetFont(rb.GetFont(ui::ResourceBundle::LargeFont)); + message_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); + message_->SetEnabledColor(kTextColor); + AddChildView(message_); + + shortcut_text_ = new views::Label( + l10n_util::GetStringUTF16(IDS_ASH_SECONDARY_MONITOR_SHORTCUT)); + shortcut_text_->SetAutoColorReadabilityEnabled(false); + shortcut_text_->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); + shortcut_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); + shortcut_text_->SetEnabledColor(kTextColor); + AddChildView(shortcut_text_); + + shortcut_image_ = new views::ImageView(); + shortcut_image_->SetImage(rb.GetImageSkiaNamed(IDR_AURA_SWITCH_MONITOR)); + AddChildView(shortcut_image_); + } + + virtual void Layout() { + const int kMessagePositionTopMargin = 40; + const int kShortcutPositionBottomMargin = 40; + const int kShortcutMargin = 4; // margin between text and image. + gfx::Rect b = bounds(); + + int msg_height = message_->GetHeightForWidth(b.width()); + message_->SetBounds( + 0, kMessagePositionTopMargin, bounds().width(), msg_height); + + // TODO(oshima): Figure out what to do for RTL. + // Align the shortcut text & image to the center. + gfx::Size text_size = shortcut_text_->GetPreferredSize(); + gfx::Size image_size = shortcut_image_->GetPreferredSize(); + int height = std::max(text_size.height(), image_size.height()); + int y = b.height() - kShortcutPositionBottomMargin - height; + int x = (b.width() - + (text_size.width() + kShortcutMargin + image_size.width())) / 2; + shortcut_text_->SetBounds(x, y + (height - text_size.height()) / 2, + text_size.width(), text_size.height()); + shortcut_image_->SetBounds( + x + text_size.width() + kShortcutMargin, + y + (height - image_size.height()) / 2, + image_size.width(), image_size.height()); + } + + private: + views::Label* message_; + views::Label* shortcut_text_; + views::ImageView* shortcut_image_; + + DISALLOW_COPY_AND_ASSIGN(SecondaryMonitorView); +}; + +} // namespace + +views::Widget* CreateSecondaryMonitorWidget(aura::Window* parent) { + views::Widget* desktop_widget = new views::Widget; + views::Widget::InitParams params( + views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); + SecondaryMonitorView* view = new SecondaryMonitorView(); + params.delegate = view; + params.parent = parent; + desktop_widget->Init(params); + desktop_widget->SetContentsView(view); + desktop_widget->Show(); + desktop_widget->GetNativeView()->SetName("SecondaryMonitor"); + return desktop_widget; +} + +} // namespace ash diff --git a/ash/monitor/secondary_monitor_view.h b/ash/monitor/secondary_monitor_view.h new file mode 100644 index 0000000..cca03d2 --- /dev/null +++ b/ash/monitor/secondary_monitor_view.h @@ -0,0 +1,25 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_MONITOR_SECONDARY_MONITOR_VIEW_H_ +#define ASH_MONITOR_SECONDARY_MONITOR_VIEW_H_ +#pragma once + +namespace aura { +class Window; +} + +namespace views { +class Widget; +} + +namespace ash { + +// Creates the widget that hosts the static message displayed on the +// secondary monitor. +views::Widget* CreateSecondaryMonitorWidget(aura::Window* parent); + +} // namespace ash + +#endif // ASH_MONITOR_SECONDARY_MONITOR_VIEW_H_ diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc index 8fd4acc..050f760 100644 --- a/ash/root_window_controller_unittest.cc +++ b/ash/root_window_controller_unittest.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/display/display_controller.h" -#include "ash/display/multi_display_manager.h" +#include "ash/monitor/monitor_controller.h" +#include "ash/monitor/multi_monitor_manager.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/test/ash_test_base.h" @@ -67,15 +67,15 @@ class RootWindowControllerTest : public test::AshTestBase { virtual ~RootWindowControllerTest() {} virtual void SetUp() OVERRIDE { - internal::DisplayController::SetExtendedDesktopEnabled(true); - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); + internal::MonitorController::SetExtendedDesktopEnabled(true); + internal::MonitorController::SetVirtualScreenCoordinatesEnabled(true); AshTestBase::SetUp(); } virtual void TearDown() OVERRIDE { AshTestBase::TearDown(); - internal::DisplayController::SetExtendedDesktopEnabled(false); - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); + internal::MonitorController::SetExtendedDesktopEnabled(false); + internal::MonitorController::SetVirtualScreenCoordinatesEnabled(false); } private: @@ -83,7 +83,7 @@ class RootWindowControllerTest : public test::AshTestBase { }; TEST_F(RootWindowControllerTest, MoveWindows_Basic) { - UpdateDisplay("0+0-600x600,600+0-500x500"); + UpdateMonitor("0+0-600x600,600+0-500x500"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); // Emulate virtual screen coordinate system. root_windows[0]->SetBounds(gfx::Rect(0, 0, 600, 600)); @@ -114,12 +114,12 @@ TEST_F(RootWindowControllerTest, MoveWindows_Basic) { EXPECT_EQ("500x500", fullscreen->GetWindowScreenBounds().size().ToString()); #endif - UpdateDisplay("0+0-600x600"); + UpdateMonitor("0+0-600x600"); EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); EXPECT_EQ("100x100", normal->GetWindowScreenBounds().size().ToString()); - // Maximized area on primary display has 2px (given as + // Maximized area on primary monitor has 2px (given as // kAutoHideSize in shelf_layout_manager.cc) inset at the bottom. EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); EXPECT_EQ("600x598", maximized->GetWindowScreenBounds().size().ToString()); @@ -133,7 +133,7 @@ TEST_F(RootWindowControllerTest, MoveWindows_Basic) { } TEST_F(RootWindowControllerTest, MoveWindows_Modal) { - UpdateDisplay("0+0-500x500,500+0-500x500"); + UpdateMonitor("0+0-500x500,500+0-500x500"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); // Emulate virtual screen coordinate system. @@ -154,7 +154,7 @@ TEST_F(RootWindowControllerTest, MoveWindows_Modal) { generator_1st.ClickLeftButton(); EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); - UpdateDisplay("0+0-500x500"); + UpdateMonitor("0+0-500x500"); EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); generator_1st.ClickLeftButton(); diff --git a/ash/screen_ash.cc b/ash/screen_ash.cc index c98996a..e444ebf 100644 --- a/ash/screen_ash.cc +++ b/ash/screen_ash.cc @@ -8,7 +8,7 @@ #include "ash/wm/shelf_layout_manager.h" #include "base/logging.h" #include "ui/aura/env.h" -#include "ui/aura/display_manager.h" +#include "ui/aura/monitor_manager.h" #include "ui/aura/root_window.h" #include "ui/gfx/display.h" #include "ui/gfx/screen.h" @@ -16,8 +16,8 @@ namespace ash { namespace { -aura::DisplayManager* GetDisplayManager() { - return aura::Env::GetInstance()->display_manager(); +aura::MonitorManager* GetMonitorManager() { + return aura::Env::GetInstance()->monitor_manager(); } } // namespace @@ -55,19 +55,19 @@ gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPoint() { } int ScreenAsh::GetNumDisplays() { - return GetDisplayManager()->GetNumDisplays(); + return GetMonitorManager()->GetNumDisplays(); } gfx::Display ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window) const { - return GetDisplayManager()->GetDisplayNearestWindow(window); + return GetMonitorManager()->GetDisplayNearestWindow(window); } gfx::Display ScreenAsh::GetDisplayNearestPoint(const gfx::Point& point) const { - return GetDisplayManager()->GetDisplayNearestPoint(point); + return GetMonitorManager()->GetDisplayNearestPoint(point); } gfx::Display ScreenAsh::GetPrimaryDisplay() const { - return GetDisplayManager()->GetDisplayAt(0); + return GetMonitorManager()->GetDisplayAt(0); } } // namespace ash diff --git a/ash/shell.cc b/ash/shell.cc index 35eee4b..d84b700 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -17,10 +17,10 @@ #include "ash/high_contrast/high_contrast_controller.h" #include "ash/launcher/launcher.h" #include "ash/magnifier/magnification_controller.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/secondary_display_view.h" +#include "ash/monitor/monitor_controller.h" +#include "ash/monitor/mouse_cursor_event_filter.h" +#include "ash/monitor/multi_monitor_manager.h" +#include "ash/monitor/secondary_monitor_view.h" #include "ash/root_window_controller.h" #include "ash/screen_ash.h" #include "ash/shell_context_menu.h" @@ -73,7 +73,7 @@ #include "ui/aura/env.h" #include "ui/aura/focus_manager.h" #include "ui/aura/layout_manager.h" -#include "ui/aura/display_manager.h" +#include "ui/aura/monitor_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/shared/compound_event_filter.h" #include "ui/aura/shared/input_method_event_filter.h" @@ -97,7 +97,7 @@ #endif #if defined(OS_CHROMEOS) -#include "chromeos/display/output_configurator.h" +#include "chromeos/monitor/output_configurator.h" #include "ui/aura/dispatcher_linux.h" #endif // defined(OS_CHROMEOS) @@ -223,7 +223,7 @@ Shell::~Shell() { app_list_controller_.reset(); // Destroy all child windows including widgets. - display_controller_->CloseChildWindows(); + monitor_controller_->CloseChildWindows(); // These need a valid Shell instance to clean up properly, so explicitly // delete them before invalidating the instance. @@ -241,7 +241,7 @@ Shell::~Shell() { visibility_controller_.reset(); // This also deletes all RootWindows. - display_controller_.reset(); + monitor_controller_.reset(); // Launcher widget has a InputMethodBridge that references to // input_method_filter_'s input_method_. So explicitly release launcher_ @@ -268,8 +268,8 @@ Shell::~Shell() { // static Shell* Shell::CreateInstance(ShellDelegate* delegate) { CHECK(!instance_); - aura::Env::GetInstance()->SetDisplayManager( - new internal::MultiDisplayManager()); + aura::Env::GetInstance()->SetMonitorManager( + new internal::MultiMonitorManager()); instance_ = new Shell(delegate); instance_->Init(); return instance_; @@ -299,13 +299,13 @@ internal::RootWindowController* Shell::GetPrimaryRootWindowController() { // static Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { - return Shell::GetInstance()->display_controller()-> + return Shell::GetInstance()->monitor_controller()-> GetAllRootWindowControllers(); } // static aura::RootWindow* Shell::GetPrimaryRootWindow() { - return GetInstance()->display_controller()->GetPrimaryRootWindow(); + return GetInstance()->monitor_controller()->GetPrimaryRootWindow(); } // static @@ -315,7 +315,7 @@ aura::RootWindow* Shell::GetActiveRootWindow() { // static aura::RootWindow* Shell::GetRootWindowAt(const gfx::Point& point) { - if (!internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) + if (!internal::MonitorController::IsVirtualScreenCoordinatesEnabled()) return GetPrimaryRootWindow(); RootWindowList root_windows = GetAllRootWindows(); for (RootWindowList::const_iterator iter = root_windows.begin(); @@ -331,7 +331,7 @@ aura::RootWindow* Shell::GetRootWindowAt(const gfx::Point& point) { // static aura::RootWindow* Shell::GetRootWindowMatching(const gfx::Rect& rect) { - if (!internal::DisplayController::IsVirtualScreenCoordinatesEnabled()) + if (!internal::MonitorController::IsVirtualScreenCoordinatesEnabled()) return GetPrimaryRootWindow(); if (rect.IsEmpty()) return GetRootWindowAt(rect.origin()); @@ -354,7 +354,7 @@ aura::RootWindow* Shell::GetRootWindowMatching(const gfx::Rect& rect) { // static Shell::RootWindowList Shell::GetAllRootWindows() { - return Shell::GetInstance()->display_controller()-> + return Shell::GetInstance()->monitor_controller()-> GetAllRootWindows(); } @@ -390,9 +390,9 @@ void Shell::Init() { activation_controller_.reset( new internal::ActivationController(focus_manager_.get())); - display_controller_.reset(new internal::DisplayController); - display_controller_->InitPrimaryDisplay(); - aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); + monitor_controller_.reset(new internal::MonitorController); + monitor_controller_->InitPrimaryDisplay(); + aura::RootWindow* root_window = monitor_controller_->GetPrimaryRootWindow(); active_root_window_ = root_window; #if !defined(OS_MACOSX) @@ -457,9 +457,9 @@ void Shell::Init() { magnification_controller_.reset( internal::MagnificationController::CreateInstance()); - if (internal::DisplayController::IsExtendedDesktopEnabled()) { + if (internal::MonitorController::IsExtendedDesktopEnabled()) { mouse_cursor_filter_.reset( - new internal::MouseCursorEventFilter(display_controller_.get())); + new internal::MouseCursorEventFilter(monitor_controller_.get())); AddEnvEventFilter(mouse_cursor_filter_.get()); } @@ -511,7 +511,7 @@ void Shell::Init() { power_button_controller_.reset(new PowerButtonController); AddShellObserver(power_button_controller_.get()); - display_controller_->InitSecondaryDisplays(); + monitor_controller_->InitSecondaryDisplays(); if (initially_hide_cursor_) aura::Env::GetInstance()->cursor_manager()->ShowCursor(false); @@ -580,15 +580,15 @@ void Shell::RotateFocus(Direction direction) { internal::FocusCycler::BACKWARD); } -void Shell::SetDisplayWorkAreaInsets(Window* contains, +void Shell::SetMonitorWorkAreaInsets(Window* contains, const gfx::Insets& insets) { - internal::MultiDisplayManager* display_manager = - static_cast( - aura::Env::GetInstance()->display_manager()); - if (!display_manager->UpdateWorkAreaOfDisplayNearestWindow(contains, insets)) + internal::MultiMonitorManager* monitor_manager = + static_cast( + aura::Env::GetInstance()->monitor_manager()); + if (!monitor_manager->UpdateWorkAreaOfMonitorNearestWindow(contains, insets)) return; FOR_EACH_OBSERVER(ShellObserver, observers_, - OnDisplayWorkAreaInsetsChanged()); + OnMonitorWorkAreaInsetsChanged()); } void Shell::OnLoginStateChanged(user::LoginStatus status) { @@ -671,9 +671,9 @@ int Shell::GetGridSize() const { workspace_manager()->grid_size(); } -void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { +void Shell::InitRootWindowForSecondaryMonitor(aura::RootWindow* root) { root->set_focus_manager(focus_manager_.get()); - if (internal::DisplayController::IsExtendedDesktopEnabled()) { + if (internal::MonitorController::IsExtendedDesktopEnabled()) { internal::RootWindowController* controller = new internal::RootWindowController(root); controller->CreateContainers(); @@ -687,11 +687,11 @@ void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { root->SetFocusWhenShown(false); root->SetLayoutManager(new internal::RootWindowLayoutManager(root)); aura::Window* container = new aura::Window(NULL); - container->SetName("SecondaryDisplayContainer"); + container->SetName("SecondaryMonitorContainer"); container->Init(ui::LAYER_NOT_DRAWN); root->AddChild(container); container->SetLayoutManager(new internal::BaseLayoutManager(root)); - CreateSecondaryDisplayWidget(container); + CreateSecondaryMonitorWidget(container); container->Show(); root->layout_manager()->OnWindowResized(); root->ShowRootWindow(); diff --git a/ash/shell.h b/ash/shell.h index be0a59c..1a0391d 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -83,7 +83,7 @@ class DragDropController; class FocusCycler; class KeyRewriterEventFilter; class MagnificationController; -class DisplayController; +class MonitorController; class MouseCursorEventFilter; class PanelLayoutManager; class PartialScreenshotEventFilter; @@ -219,11 +219,11 @@ class ASH_EXPORT Shell : aura::CursorDelegate { // Rotates focus through containers that can receive focus. void RotateFocus(Direction direction); - // Sets the work area insets of the display that contains |window|, + // Sets the work area insets of the monitor that contains |window|, // this notifies observers too. // TODO(sky): this no longer really replicates what happens and is unreliable. // Remove this. - void SetDisplayWorkAreaInsets(aura::Window* window, + void SetMonitorWorkAreaInsets(aura::Window* window, const gfx::Insets& insets); // Called when the user logs in. @@ -279,8 +279,8 @@ class ASH_EXPORT Shell : aura::CursorDelegate { internal::FocusCycler* focus_cycler() { return focus_cycler_.get(); } - internal::DisplayController* display_controller() { - return display_controller_.get(); + internal::MonitorController* monitor_controller() { + return monitor_controller_.get(); } ShellDelegate* delegate() { return delegate_.get(); } @@ -346,8 +346,8 @@ class ASH_EXPORT Shell : aura::CursorDelegate { browser_context_ = browser_context; } - // Initializes the root window to be used for a secondary display. - void InitRootWindowForSecondaryDisplay(aura::RootWindow* root); + // Initializes the root window to be used for a secondary monitor. + void InitRootWindowForSecondaryMonitor(aura::RootWindow* root); #if defined(OS_CHROMEOS) chromeos::OutputConfigurator* output_configurator() { @@ -429,7 +429,7 @@ class ASH_EXPORT Shell : aura::CursorDelegate { scoped_ptr video_detector_; scoped_ptr window_cycle_controller_; scoped_ptr focus_cycler_; - scoped_ptr display_controller_; + scoped_ptr monitor_controller_; scoped_ptr high_contrast_controller_; scoped_ptr magnification_controller_; scoped_ptr focus_manager_; diff --git a/ash/shell_observer.h b/ash/shell_observer.h index 3230bb3..4b73efb 100644 --- a/ash/shell_observer.h +++ b/ash/shell_observer.h @@ -14,7 +14,7 @@ namespace ash { class ASH_EXPORT ShellObserver { public: // Invoked after the screen's work area insets changes. - virtual void OnDisplayWorkAreaInsetsChanged() {} + virtual void OnMonitorWorkAreaInsetsChanged() {} // Invoked when the user logs in. virtual void OnLoginStateChanged(user::LoginStatus status) {} diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 45996b2..5b92cd8 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -12,7 +12,7 @@ #include "base/string_split.h" #include "content/public/test/web_contents_tester.h" #include "ui/aura/env.h" -#include "ui/aura/display_manager.h" +#include "ui/aura/monitor_manager.h" #include "ui/aura/root_window.h" #include "ui/base/ime/text_input_test_support.h" #include "ui/compositor/layer_animator.h" @@ -30,7 +30,7 @@ std::vector CreateDisplaysFromString( base::SplitString(specs, ',', &parts); for (std::vector::const_iterator iter = parts.begin(); iter != parts.end(); ++iter) { - displays.push_back(aura::DisplayManager::CreateDisplayFromSpec(*iter)); + displays.push_back(aura::MonitorManager::CreateMonitorFromSpec(*iter)); } return displays; } @@ -72,20 +72,20 @@ void AshTestBase::TearDown() { ui::TextInputTestSupport::Shutdown(); } -void AshTestBase::ChangeDisplayConfig(float scale, +void AshTestBase::ChangeMonitorConfig(float scale, const gfx::Rect& bounds_in_pixel) { gfx::Display display = gfx::Display(gfx::Screen::GetPrimaryDisplay().id()); display.SetScaleAndBounds(scale, bounds_in_pixel); std::vector displays; displays.push_back(display); - aura::Env::GetInstance()->display_manager()->OnNativeDisplaysChanged( + aura::Env::GetInstance()->monitor_manager()->OnNativeMonitorsChanged( displays); } -void AshTestBase::UpdateDisplay(const std::string& display_specs) { +void AshTestBase::UpdateMonitor(const std::string& display_specs) { std::vector displays = CreateDisplaysFromString(display_specs); - aura::Env::GetInstance()->display_manager()-> - OnNativeDisplaysChanged(displays); + aura::Env::GetInstance()->monitor_manager()-> + OnNativeMonitorsChanged(displays); } void AshTestBase::RunAllPendingInMessageLoop() { diff --git a/ash/test/ash_test_base.h b/ash/test/ash_test_base.h index e26d2c3..559b370 100644 --- a/ash/test/ash_test_base.h +++ b/ash/test/ash_test_base.h @@ -36,16 +36,16 @@ class AshTestBase : public testing::Test { virtual void SetUp() OVERRIDE; virtual void TearDown() OVERRIDE; - // Change the primary display's configuration to use |bounds| + // Change the primary monitor's configuration to use |bounds| // and |scale|. - void ChangeDisplayConfig(float scale, const gfx::Rect& bounds); + void ChangeMonitorConfig(float scale, const gfx::Rect& bounds); // 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 refer to the comment in - // | aura::DisplayManager::CreateDisplayFromSpec| for the format of + // | aura::MonitorManager::CreateMonitorFromSpec| for the format of // the display spec. - void UpdateDisplay(const std::string& display_specs); + void UpdateMonitor(const std::string& display_specs); protected: void RunAllPendingInMessageLoop(); diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc index 4798cd33..64ca6f0 100644 --- a/ash/tooltips/tooltip_controller.cc +++ b/ash/tooltips/tooltip_controller.cc @@ -66,9 +66,9 @@ gfx::Font GetDefaultFont() { int GetMaxWidth(int x, int y) { // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure // out a way to merge. - gfx::Rect display_bounds = + gfx::Rect monitor_bounds = gfx::Screen::GetDisplayNearestPoint(gfx::Point(x, y)).bounds(); - return (display_bounds.width() + 1) / 2; + return (monitor_bounds.width() + 1) / 2; } // Creates a widget of type TYPE_TOOLTIP @@ -155,22 +155,22 @@ class TooltipController::Tooltip { tooltip_height); tooltip_rect.Offset(kCursorOffsetX, kCursorOffsetY); - gfx::Rect display_bounds = + gfx::Rect monitor_bounds = gfx::Screen::GetDisplayNearestPoint(tooltip_rect.origin()).bounds(); // If tooltip is out of bounds on the x axis, we simply shift it // horizontally by the offset. - if (tooltip_rect.right() > display_bounds.right()) { - int h_offset = tooltip_rect.right() - display_bounds.right(); + if (tooltip_rect.right() > monitor_bounds.right()) { + int h_offset = tooltip_rect.right() - monitor_bounds.right(); tooltip_rect.Offset(-h_offset, 0); } // If tooltip is out of bounds on the y axis, we flip it to appear above the // mouse cursor instead of below. - if (tooltip_rect.bottom() > display_bounds.bottom()) + if (tooltip_rect.bottom() > monitor_bounds.bottom()) tooltip_rect.set_y(mouse_pos.y() - tooltip_height); - widget_->SetBounds(tooltip_rect.AdjustToFit(display_bounds)); + widget_->SetBounds(tooltip_rect.AdjustToFit(monitor_bounds)); } }; diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc index 29d39a0d..4e39fff 100644 --- a/ash/wm/base_layout_manager.cc +++ b/ash/wm/base_layout_manager.cc @@ -120,7 +120,7 @@ void BaseLayoutManager::OnRootWindowResized(const aura::RootWindow* root, ///////////////////////////////////////////////////////////////////////////// // BaseLayoutManager, ash::ShellObserver overrides: -void BaseLayoutManager::OnDisplayWorkAreaInsetsChanged() { +void BaseLayoutManager::OnMonitorWorkAreaInsetsChanged() { AdjustWindowSizesForScreenChange(); } @@ -222,8 +222,8 @@ void BaseLayoutManager::MaybeAnimateToBounds(aura::Window* window, } void BaseLayoutManager::AdjustWindowSizesForScreenChange() { - // If a user plugs an external display into a laptop running Aura the - // display size will change. Maximized windows need to resize to match. + // If a user plugs an external monitor into a laptop running Aura the + // monitor size will change. Maximized windows need to resize to match. // We also do this when developers running Aura on a desktop manually resize // the host window. // We also need to do this when the work area insets changes. @@ -238,10 +238,10 @@ void BaseLayoutManager::AdjustWindowSizesForScreenChange() { window, gfx::Screen::GetDisplayNearestWindow(window).bounds()); } else { // The work area may be smaller than the full screen. - gfx::Rect display_rect = + gfx::Rect monitor_rect = gfx::Screen::GetDisplayNearestWindow(window).work_area(); - // Put as much of the window as possible within the display area. - window->SetBounds(window->bounds().AdjustToFit(display_rect)); + // Put as much of the window as possible within the monitor area. + window->SetBounds(window->bounds().AdjustToFit(monitor_rect)); } } } diff --git a/ash/wm/base_layout_manager.h b/ash/wm/base_layout_manager.h index 8ba5f5c..becf24a 100644 --- a/ash/wm/base_layout_manager.h +++ b/ash/wm/base_layout_manager.h @@ -57,7 +57,7 @@ class ASH_EXPORT BaseLayoutManager : public aura::LayoutManager, const gfx::Size& old_size) OVERRIDE; // ash::ShellObserver overrides: - virtual void OnDisplayWorkAreaInsetsChanged() OVERRIDE; + virtual void OnMonitorWorkAreaInsetsChanged() OVERRIDE; // WindowObserver overrides: virtual void OnWindowPropertyChanged(aura::Window* window, diff --git a/ash/wm/base_layout_manager_unittest.cc b/ash/wm/base_layout_manager_unittest.cc index 2de08af..626aa66 100644 --- a/ash/wm/base_layout_manager_unittest.cc +++ b/ash/wm/base_layout_manager_unittest.cc @@ -29,7 +29,7 @@ class BaseLayoutManagerTest : public test::AshTestBase { virtual void SetUp() OVERRIDE { test::AshTestBase::SetUp(); - Shell::GetInstance()->SetDisplayWorkAreaInsets( + Shell::GetInstance()->SetMonitorWorkAreaInsets( Shell::GetPrimaryRootWindow(), gfx::Insets(1, 2, 3, 4)); Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); @@ -53,7 +53,7 @@ TEST_F(BaseLayoutManagerTest, Maximize) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr window(CreateTestWindow(bounds)); window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); - // Maximized window fills the work area, not the whole display. + // Maximized window fills the work area, not the whole monitor. EXPECT_EQ(ScreenAsh::GetMaximizedWindowBounds(window.get()).ToString(), window->bounds().ToString()); window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); @@ -93,7 +93,7 @@ TEST_F(BaseLayoutManagerTest, Fullscreen) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr window(CreateTestWindow(bounds)); window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); - // Fullscreen window fills the whole display. + // Fullscreen window fills the whole monitor. EXPECT_EQ( gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), window->bounds().ToString()); @@ -105,12 +105,12 @@ TEST_F(BaseLayoutManagerTest, Fullscreen) { TEST_F(BaseLayoutManagerTest, FullscreenRootWindowResize) { gfx::Rect bounds(100, 100, 200, 200); scoped_ptr window(CreateTestWindow(bounds)); - // Fullscreen window fills the whole display. + // Fullscreen window fills the whole monitor. window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); EXPECT_EQ( gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), window->bounds().ToString()); - // Enlarge the root window. We should still match the display size. + // Enlarge the root window. We should still match the monitor size. Shell::GetPrimaryRootWindow()->SetHostSize(gfx::Size(800, 600)); EXPECT_EQ( gfx::Screen::GetDisplayNearestWindow(window.get()).bounds().ToString(), diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc index 98e0007..617b22ea 100644 --- a/ash/wm/frame_painter.cc +++ b/ash/wm/frame_painter.cc @@ -376,8 +376,8 @@ void FramePainter::PaintHeader(views::NonClientFrameView* view, // We don't need the extra lightness in the edges when we're at the top edge // of the screen. - // TODO(oshima): This will not work under multi-display, need to add method - // like GetWindowBoundsInDisplay(). + // TODO(oshima): This will not work under multi-monitor, need to add method + // like GetWindowBoundsInMonitor(). if (frame_->GetWindowScreenBounds().y() == 0) return; diff --git a/ash/wm/screen_dimmer.h b/ash/wm/screen_dimmer.h index 46bed1f..daa60ea0 100644 --- a/ash/wm/screen_dimmer.h +++ b/ash/wm/screen_dimmer.h @@ -24,7 +24,7 @@ namespace ash { namespace internal { // ScreenDimmer displays a partially-opaque layer above everything -// else in the root window to darken the display. It shouldn't be used +// else in the root window to darken the monitor. It shouldn't be used // for long-term brightness adjustments due to performance // considerations -- it's only intended for cases where we want to // briefly dim the screen (e.g. to indicate to the user that we're diff --git a/ash/wm/shelf_layout_manager.cc b/ash/wm/shelf_layout_manager.cc index 156fad1..3c3246f 100644 --- a/ash/wm/shelf_layout_manager.cc +++ b/ash/wm/shelf_layout_manager.cc @@ -206,7 +206,7 @@ bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { } gfx::Rect ShelfLayoutManager::GetIdealBounds() { - // TODO: this is wrong. Figure out what display shelf is on and everything + // TODO: this is wrong. Figure out what monitor shelf is on and everything // should be based on it. gfx::Rect bounds( gfx::Screen::GetDisplayNearestWindow(status_->GetNativeView()).bounds()); @@ -239,7 +239,7 @@ void ShelfLayoutManager::LayoutShelf() { } GetLayer(status_)->SetOpacity(target_bounds.opacity); status_->SetBounds(target_bounds.status_bounds); - Shell::GetInstance()->SetDisplayWorkAreaInsets( + Shell::GetInstance()->SetMonitorWorkAreaInsets( Shell::GetPrimaryRootWindow(), target_bounds.work_area_insets); UpdateHitTestBounds(); @@ -384,7 +384,7 @@ void ShelfLayoutManager::SetState(VisibilityState visibility_state) { status_animation_setter.SetTweenType(ui::Tween::EASE_OUT); GetLayer(status_)->SetBounds(target_bounds.status_bounds); GetLayer(status_)->SetOpacity(target_bounds.opacity); - Shell::GetInstance()->SetDisplayWorkAreaInsets( + Shell::GetInstance()->SetMonitorWorkAreaInsets( Shell::GetPrimaryRootWindow(), target_bounds.work_area_insets); UpdateHitTestBounds(); diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc index 898cc2a..ff61d3f 100644 --- a/ash/wm/shelf_layout_manager_unittest.cc +++ b/ash/wm/shelf_layout_manager_unittest.cc @@ -14,7 +14,7 @@ #include "ash/test/ash_test_base.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/env.h" -#include "ui/aura/display_manager.h" +#include "ui/aura/monitor_manager.h" #include "ui/aura/root_window.h" #include "ui/aura/test/event_generator.h" #include "ui/aura/window.h" @@ -92,8 +92,8 @@ TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); int shelf_height = shelf->GetIdealBounds().height(); - const aura::DisplayManager* manager = - aura::Env::GetInstance()->display_manager(); + const aura::MonitorManager* manager = + aura::Env::GetInstance()->monitor_manager(); const gfx::Display& display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); ASSERT_NE(-1, display.id()); @@ -144,8 +144,8 @@ TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { shelf->LayoutShelf(); EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); - const aura::DisplayManager* manager = - aura::Env::GetInstance()->display_manager(); + const aura::MonitorManager* manager = + aura::Env::GetInstance()->monitor_manager(); const gfx::Display& display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); @@ -326,25 +326,25 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { widget->Init(params); widget->Show(); aura::Window* window = widget->GetNativeWindow(); - gfx::Rect display_bounds( + gfx::Rect monitor_bounds( gfx::Screen::GetDisplayNearestWindow(window).bounds()); - EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, + EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, shelf->GetMaximizedWindowBounds(window).bottom()); EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE, shelf->visibility_state()); - EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, + EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, shelf->GetMaximizedWindowBounds(window).bottom()); shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT); EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); - EXPECT_EQ(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, + EXPECT_EQ(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, shelf->GetMaximizedWindowBounds(window).bottom()); shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); EXPECT_EQ(ShelfLayoutManager::VISIBLE, shelf->visibility_state()); - EXPECT_GT(display_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, + EXPECT_GT(monitor_bounds.bottom() - ShelfLayoutManager::kAutoHideSize, shelf->GetMaximizedWindowBounds(window).bottom()); widget->Maximize(); @@ -498,8 +498,8 @@ TEST_F(ShelfLayoutManagerTest, SetAlignment) { shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); gfx::Rect launcher_bounds(shelf->launcher_widget()->GetWindowScreenBounds()); - const aura::DisplayManager* manager = - aura::Env::GetInstance()->display_manager(); + const aura::MonitorManager* manager = + aura::Env::GetInstance()->monitor_manager(); gfx::Display display = manager->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); ASSERT_NE(-1, display.id()); diff --git a/ash/wm/stacking_controller.cc b/ash/wm/stacking_controller.cc index 6d44525..368c9b5 100644 --- a/ash/wm/stacking_controller.cc +++ b/ash/wm/stacking_controller.cc @@ -4,7 +4,7 @@ #include "ash/wm/stacking_controller.h" -#include "ash/display/display_controller.h" +#include "ash/monitor/monitor_controller.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/always_on_top_controller.h" @@ -23,7 +23,7 @@ namespace { // that matches the window's bound will be used. Otherwise, it'll // return the active root window. aura::RootWindow* FindContainerRoot(const gfx::Rect& bounds) { - if (!DisplayController::IsVirtualScreenCoordinatesEnabled() || + if (!MonitorController::IsVirtualScreenCoordinatesEnabled() || (bounds.origin().x() == 0 && bounds.origin().y() == 0 && bounds.IsEmpty())) { return Shell::GetActiveRootWindow(); diff --git a/ash/wm/toplevel_window_event_filter_unittest.cc b/ash/wm/toplevel_window_event_filter_unittest.cc index ca9aeeb..fc8984b 100644 --- a/ash/wm/toplevel_window_event_filter_unittest.cc +++ b/ash/wm/toplevel_window_event_filter_unittest.cc @@ -402,7 +402,7 @@ TEST_F(ToplevelWindowEventFilterTest, DontDragToNegativeY) { EXPECT_EQ(100, target->bounds().height()); } -// Verifies we don't let windows go bigger than the display width. +// Verifies we don't let windows go bigger than the monitor width. TEST_F(ToplevelWindowEventFilterTest, DontGotWiderThanScreen) { scoped_ptr target(CreateWindow(HTRIGHT)); gfx::Rect work_area = diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc index df28ec7..7e62d23 100644 --- a/ash/wm/window_resizer.cc +++ b/ash/wm/window_resizer.cc @@ -292,7 +292,7 @@ int WindowResizer::GetWidthForDrag(const Details& details, *delta_x = -x_multiplier * (details.initial_bounds.width() - min_width); } - // And don't let the window go bigger than the display. + // And don't let the window go bigger than the monitor. int max_width = gfx::Screen::GetDisplayNearestWindow(details.window).bounds().width(); if (width > max_width) { @@ -326,7 +326,7 @@ int WindowResizer::GetHeightForDrag(const Details& details, *delta_y = -y_multiplier * (details.initial_bounds.height() - min_height); } - // And don't let the window go bigger than the display. + // And don't let the window go bigger than the monitor. int max_height = gfx::Screen::GetDisplayNearestWindow(details.window).bounds().height(); if (height > max_height) { diff --git a/ash/wm/window_util.h b/ash/wm/window_util.h index 2f611b8..e0bd718 100644 --- a/ash/wm/window_util.h +++ b/ash/wm/window_util.h @@ -56,7 +56,7 @@ ASH_EXPORT void MinimizeWindow(aura::Window* window); // Restores |window|, which must not be NULL. ASH_EXPORT void RestoreWindow(aura::Window* window); -// Moves the window to the center of the display. +// Moves the window to the center of the monitor. ASH_EXPORT void CenterWindow(aura::Window* window); } // namespace wm diff --git a/ash/wm/workspace/snap_sizer.cc b/ash/wm/workspace/snap_sizer.cc index c303f1d..092ba697 100644 --- a/ash/wm/workspace/snap_sizer.cc +++ b/ash/wm/workspace/snap_sizer.cc @@ -129,7 +129,7 @@ gfx::Rect SnapSizer::GetTargetBoundsForPercent(int percent_index) const { } bool SnapSizer::AlongEdge(int x) const { - // TODO: need to support multi-display. + // TODO: need to support multi-monitor. gfx::Rect area(gfx::Screen::GetDisplayNearestWindow(window_).bounds()); return (x <= area.x()) || (x >= area.right() - 1); } diff --git a/ash/wm/workspace/workspace_manager.cc b/ash/wm/workspace/workspace_manager.cc index 016244a..1eccfe6 100644 --- a/ash/wm/workspace/workspace_manager.cc +++ b/ash/wm/workspace/workspace_manager.cc @@ -141,7 +141,7 @@ WorkspaceManager::WindowState WorkspaceManager::GetWindowState() { if (!shelf_ || !active_workspace_) return WINDOW_STATE_DEFAULT; - // TODO: this code needs to be made multi-display aware. + // TODO: this code needs to be made multi-monitor aware. gfx::Rect shelf_bounds(shelf_->GetIdealBounds()); const aura::Window::Windows& windows(contents_view_->children()); bool window_overlaps_launcher = false; diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc index 26d957c..9b52030 100644 --- a/ash/wm/workspace/workspace_window_resizer.cc +++ b/ash/wm/workspace/workspace_window_resizer.cc @@ -286,7 +286,7 @@ void WorkspaceWindowResizer::AdjustBoundsForMainWindow( if (bounds->y() > max_y) bounds->set_y(max_y); - // Don't allow dragging above the top of the display. + // Don't allow dragging above the top of the monitor. if (bounds->y() <= work_area.y()) bounds->set_y(work_area.y()); @@ -419,8 +419,8 @@ void WorkspaceWindowResizer::RestackWindows() { WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType( const gfx::Point& location) const { - // TODO: this likely only wants total display area, not the area of a single - // display. + // TODO: this likely only wants total monitor area, not the area of a single + // monitor. gfx::Rect area( gfx::Screen::GetDisplayNearestWindow(details_.window).bounds()); if (location.x() <= area.x()) diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc index eed78ae..d3654c0 100644 --- a/ash/wm/workspace/workspace_window_resizer_unittest.cc +++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc @@ -55,7 +55,7 @@ class WorkspaceWindowResizerTest : public test::AshTestBase { gfx::Rect root_bounds(root->bounds()); EXPECT_EQ(kRootHeight, root_bounds.height()); - Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); + Shell::GetInstance()->SetMonitorWorkAreaInsets(root, gfx::Insets()); window_.reset(new aura::Window(&delegate_)); window_->Init(ui::LAYER_NOT_DRAWN); window_->SetParent(root); @@ -347,13 +347,13 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) { // Assertions around attached window resize dragging from the bottom with 3 // windows. // TODO(oshima): Host window doesn't get a resize event after -// SetHostSize on Windows trybot, which gives wrong work/display area. +// SetHostSize on Windows trybot, which gives wrong work/monitor area. TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) { aura::RootWindow* root = Shell::GetPrimaryRootWindow(); root->SetHostSize(gfx::Size(600, 800)); LOG(ERROR) << "=== Calling OnHostResized, 600x800"; - Shell::GetInstance()->SetDisplayWorkAreaInsets(root, gfx::Insets()); + Shell::GetInstance()->SetMonitorWorkAreaInsets(root, gfx::Insets()); window_->SetBounds(gfx::Rect( 300, 100, 300, 200)); window2_->SetBounds(gfx::Rect(300, 300, 200, 150)); @@ -496,7 +496,7 @@ TEST_F(WorkspaceWindowResizerTest, RestackAttached) { // Makes sure we don't allow dragging below the work area. TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { - Shell::GetInstance()->SetDisplayWorkAreaInsets( + Shell::GetInstance()->SetMonitorWorkAreaInsets( Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 10, 0)); window_->SetBounds(gfx::Rect(100, 200, 300, 400)); @@ -513,7 +513,7 @@ TEST_F(WorkspaceWindowResizerTest, DontDragOffBottom) { // Makes sure we don't allow dragging off the top of the work area. TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { - Shell::GetInstance()->SetDisplayWorkAreaInsets( + Shell::GetInstance()->SetMonitorWorkAreaInsets( Shell::GetPrimaryRootWindow(), gfx::Insets(10, 0, 0, 0)); window_->SetBounds(gfx::Rect(100, 200, 300, 400)); @@ -526,7 +526,7 @@ TEST_F(WorkspaceWindowResizerTest, DontDragOffTop) { } TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { - Shell::GetInstance()->SetDisplayWorkAreaInsets( + Shell::GetInstance()->SetMonitorWorkAreaInsets( Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); window_->SetBounds(gfx::Rect(100, 200, 300, 380)); @@ -595,7 +595,7 @@ TEST_F(WorkspaceWindowResizerTest, SnapToEdge) { // the work area. TEST_F(WorkspaceWindowResizerTest, TallWindow) { aura::RootWindow* root = Shell::GetPrimaryRootWindow(); - Shell::GetInstance()->SetDisplayWorkAreaInsets( + Shell::GetInstance()->SetMonitorWorkAreaInsets( root, gfx::Insets(0, 0, 50, 0)); window_->SetBounds(gfx::Rect(0, 0, 320, 560)); SetGridSize(16); -- cgit v1.1