diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-17 18:24:33 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-17 18:24:33 +0000 |
commit | 55ad8c14c31df30801d8422e81b78322f95c0526 (patch) | |
tree | c0fe47685194fd2137c658944589c439d93b0c8b | |
parent | f3eccd0dfd02eb6b32c1a233e28439fc1a241d65 (diff) | |
download | chromium_src-55ad8c14c31df30801d8422e81b78322f95c0526.zip chromium_src-55ad8c14c31df30801d8422e81b78322f95c0526.tar.gz chromium_src-55ad8c14c31df30801d8422e81b78322f95c0526.tar.bz2 |
Screen cleanup:
* Split ScreenAsh to ScreenUtil (set of utility functions) and the screen implementation.
* moved screen_ash from Shell to DisplayManager. Ash specific imp is now hidden in DisplayManager.
* Shell now creates a separate screen object which simply keeps the list of displays for shutdown. This allow all screen operation valid during shutdown.
BUG=None
TBR=hongbo.min@intel.com,sky@chromium.org
Review URL: https://codereview.chromium.org/138003007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245562 0039d316-1c4b-4281-b951-d872f2087c98
78 files changed, 907 insertions, 675 deletions
diff --git a/ash/accelerators/accelerator_controller_unittest.cc b/ash/accelerators/accelerator_controller_unittest.cc index 189db90..5ab57f8 100644 --- a/ash/accelerators/accelerator_controller_unittest.cc +++ b/ash/accelerators/accelerator_controller_unittest.cc @@ -9,7 +9,6 @@ #include "ash/caps_lock_delegate.h" #include "ash/display/display_manager.h" #include "ash/ime_control_delegate.h" -#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/system/brightness_control_delegate.h" @@ -28,6 +27,7 @@ #include "ui/aura/test/test_windows.h" #include "ui/aura/window.h" #include "ui/events/event.h" +#include "ui/gfx/screen.h" #if defined(USE_X11) #include <X11/Xlib.h> diff --git a/ash/ash.gyp b/ash/ash.gyp index 439d41d..9a1b948 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -127,6 +127,8 @@ 'display/resolution_notification_controller.h', 'display/root_window_transformers.cc', 'display/root_window_transformers.h', + 'display/screen_ash.cc', + 'display/screen_ash.h', 'display/screen_position_controller.cc', 'display/screen_position_controller.h', 'display/shared_display_edge_indicator.cc', @@ -185,8 +187,8 @@ 'rotator/screen_rotation.h', 'scoped_target_root_window.cc', 'scoped_target_root_window.h', - 'screen_ash.cc', - 'screen_ash.h', + 'screen_util.cc', + 'screen_util.h', 'screenshot_delegate.h', 'session_state_delegate.h', 'session_state_observer.cc', @@ -845,7 +847,7 @@ 'keyboard_overlay/keyboard_overlay_view_unittest.cc', 'magnifier/magnification_controller_unittest.cc', 'root_window_controller_unittest.cc', - 'screen_ash_unittest.cc', + 'screen_util_unittest.cc', 'screensaver/screensaver_view_unittest.cc', 'session_state_delegate_stub.cc', 'session_state_delegate_stub.h', diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc index 343db545..7b7cc58 100644 --- a/ash/display/display_controller.cc +++ b/ash/display/display_controller.cc @@ -17,16 +17,14 @@ #include "ash/host/root_window_host_factory.h" #include "ash/root_window_controller.h" #include "ash/root_window_settings.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_delegate.h" #include "ash/wm/coordinate_conversion.h" #include "base/command_line.h" #include "base/strings/stringprintf.h" -#include "third_party/skia/include/utils/SkMatrix44.h" #include "ui/aura/client/activation_client.h" #include "ui/aura/client/capture_client.h" -#include "ui/aura/client/cursor_client.h" #include "ui/aura/client/focus_client.h" #include "ui/aura/client/screen_position_client.h" #include "ui/aura/root_window.h" @@ -35,7 +33,6 @@ #include "ui/aura/window_property.h" #include "ui/aura/window_tracker.h" #include "ui/compositor/compositor.h" -#include "ui/compositor/dip_util.h" #include "ui/gfx/display.h" #include "ui/gfx/screen.h" @@ -63,10 +60,6 @@ namespace { // during the shutdown instead of always keeping two display instances // (one here and another one in display_manager) in sync, which is error prone. int64 primary_display_id = gfx::Display::kInvalidDisplayID; -gfx::Display* primary_display_for_shutdown = NULL; -// Keeps the number of displays during the shutdown after -// ash::Shell:: is deleted. -int num_displays_for_shutdown = -1; // Specifies how long the display change should have been disabled // after each display change operations. @@ -235,13 +228,9 @@ DisplayController::DisplayController() // Reset primary display to make sure that tests don't use // stale display info from previous tests. primary_display_id = gfx::Display::kInvalidDisplayID; - delete primary_display_for_shutdown; - primary_display_for_shutdown = NULL; - num_displays_for_shutdown = -1; } DisplayController::~DisplayController() { - DCHECK(primary_display_for_shutdown); } void DisplayController::Start() { @@ -263,11 +252,6 @@ void DisplayController::Shutdown() { mirror_window_controller_.reset(); virtual_keyboard_window_controller_.reset(); - DCHECK(!primary_display_for_shutdown); - primary_display_for_shutdown = new gfx::Display( - GetDisplayManager()->GetDisplayForId(primary_display_id)); - num_displays_for_shutdown = GetDisplayManager()->GetNumDisplays(); - Shell::GetScreen()->RemoveObserver(this); // Delete all root window controllers, which deletes root window // from the last so that the primary root window gets deleted last. @@ -280,21 +264,6 @@ void DisplayController::Shutdown() { } } -// static -const gfx::Display& DisplayController::GetPrimaryDisplay() { - DCHECK_NE(primary_display_id, gfx::Display::kInvalidDisplayID); - if (primary_display_for_shutdown) - return *primary_display_for_shutdown; - return GetDisplayManager()->GetDisplayForId(primary_display_id); -} - -// static -int DisplayController::GetNumDisplays() { - if (num_displays_for_shutdown >= 0) - return num_displays_for_shutdown; - return GetDisplayManager()->GetNumDisplays(); -} - void DisplayController::InitPrimaryDisplay() { const gfx::Display& primary_candidate = GetDisplayManager()->GetPrimaryDisplayCandidate(); @@ -322,6 +291,11 @@ void DisplayController::RemoveObserver(Observer* observer) { observers_.RemoveObserver(observer); } +// static +int64 DisplayController::GetPrimaryDisplayId() { + return primary_display_id; +} + aura::Window* DisplayController::GetPrimaryRootWindow() { DCHECK(!root_windows_.empty()); return root_windows_[primary_display_id]; @@ -418,10 +392,10 @@ void DisplayController::SwapPrimaryDisplay() { &DisplayController::OnFadeOutForSwapDisplayFinished, base::Unretained(this))); } else { - SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); + SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); } #else - SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); + SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); #endif } } @@ -461,7 +435,7 @@ void DisplayController::SetPrimaryDisplay( if (!non_primary_root) return; - gfx::Display old_primary_display = GetPrimaryDisplay(); + gfx::Display old_primary_display = Shell::GetScreen()->GetPrimaryDisplay(); // Swap root windows between current and new primary display. aura::Window* primary_root = root_windows_[primary_display_id]; @@ -490,7 +464,7 @@ void DisplayController::SetPrimaryDisplay( display_info_list.push_back(display_manager->GetDisplayInfo( primary_display_id)); display_info_list.push_back(display_manager->GetDisplayInfo( - ScreenAsh::GetSecondaryDisplay().id())); + ScreenUtil::GetSecondaryDisplay().id())); GetDisplayManager()->set_force_bounds_changed(true); GetDisplayManager()->UpdateDisplays(display_info_list); GetDisplayManager()->set_force_bounds_changed(false); @@ -553,70 +527,6 @@ bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); } -const gfx::Display& DisplayController::GetDisplayNearestWindow( - const aura::Window* window) const { - if (!window) - return GetPrimaryDisplay(); - const aura::Window* root_window = window->GetRootWindow(); - if (!root_window) - return GetPrimaryDisplay(); - int64 id = internal::GetRootWindowSettings(root_window)->display_id; - // if id is |kInvaildDisplayID|, it's being deleted. - DCHECK(id != gfx::Display::kInvalidDisplayID); - - internal::DisplayManager* display_manager = GetDisplayManager(); - // RootWindow needs Display to determine its device scale factor - // for non desktop display. - if (display_manager->non_desktop_display().id() == id) - return display_manager->non_desktop_display(); - return display_manager->GetDisplayForId(id); -} - -const gfx::Display& DisplayController::GetDisplayNearestPoint( - const gfx::Point& point) const { - const gfx::Display& display = - GetDisplayManager()->FindDisplayContainingPoint(point); - if (display.is_valid()) - return display; - - // Fallback to the display that has the shortest Manhattan distance from - // the |point|. This is correct in the only areas that matter, namely in the - // corners between the physical screens. - int min_distance = INT_MAX; - const gfx::Display* nearest_display = NULL; - for (size_t i = 0; i < GetDisplayManager()->GetNumDisplays(); ++i) { - const gfx::Display& display = GetDisplayManager()->GetDisplayAt(i); - int distance = display.bounds().ManhattanDistanceToPoint(point); - if (distance < min_distance) { - min_distance = distance; - nearest_display = &display; - } - } - // There should always be at least one display that is less than INT_MAX away. - DCHECK(nearest_display); - return *nearest_display; -} - -const gfx::Display& DisplayController::GetDisplayMatching( - const gfx::Rect& rect) const { - if (rect.IsEmpty()) - return GetDisplayNearestPoint(rect.origin()); - - int max_area = 0; - const gfx::Display* matching = NULL; - for (size_t i = 0; i < GetDisplayManager()->GetNumDisplays(); ++i) { - const gfx::Display& display = GetDisplayManager()->GetDisplayAt(i); - gfx::Rect intersect = gfx::IntersectRects(display.bounds(), rect); - int area = intersect.width() * intersect.height(); - if (area > max_area) { - max_area = area; - matching = &display; - } - } - // Fallback to the primary display if there is no matching display. - return matching ? *matching : GetPrimaryDisplay(); -} - void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { const internal::DisplayInfo& display_info = GetDisplayManager()->GetDisplayInfo(display.id()); @@ -669,7 +579,7 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) { return; } DCHECK_EQ(1U, root_windows_.size()); - primary_display_id = ScreenAsh::GetSecondaryDisplay().id(); + primary_display_id = ScreenUtil::GetSecondaryDisplay().id(); aura::Window* primary_root = root_to_delete; // Delete the other root instead. @@ -695,8 +605,10 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) { } void DisplayController::OnWindowTreeHostResized(const aura::RootWindow* root) { + gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( + const_cast<aura::Window*>(root->window())); + internal::DisplayManager* display_manager = GetDisplayManager(); - gfx::Display display = GetDisplayNearestWindow(root->window()); if (display_manager->UpdateDisplayBounds( display.id(), root->host()->GetBounds())) { @@ -728,9 +640,9 @@ void DisplayController::CloseNonDesktopDisplay() { void DisplayController::PreDisplayConfigurationChange(bool clear_focus) { FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); focus_activation_store_->Store(clear_focus); - - gfx::Point point_in_screen = Shell::GetScreen()->GetCursorScreenPoint(); - gfx::Display display = GetDisplayNearestPoint(point_in_screen); + gfx::Screen* screen = Shell::GetScreen(); + gfx::Point point_in_screen = screen->GetCursorScreenPoint(); + gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen); aura::Window* root_window = GetRootWindowForDisplayId(display.id()); aura::client::ScreenPositionClient* client = @@ -763,7 +675,8 @@ void DisplayController::PostDisplayConfigurationChange() { // ignored. Happens when a) default layout's primary id // doesn't exist, or b) the primary_id has already been // set to the same and didn't update it. - layout_store->UpdatePrimaryDisplayId(pair, GetPrimaryDisplay().id()); + layout_store->UpdatePrimaryDisplayId( + pair, Shell::GetScreen()->GetPrimaryDisplay().id()); } } FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); @@ -806,7 +719,7 @@ aura::RootWindow* DisplayController::AddRootWindowForDisplay( void DisplayController::OnFadeOutForSwapDisplayFinished() { #if defined(OS_CHROMEOS) && defined(USE_X11) - SetPrimaryDisplay(ScreenAsh::GetSecondaryDisplay()); + SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); Shell::GetInstance()->output_configurator_animation()->StartFadeInAnimation(); #endif } diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h index dcc78ed..839e70b 100644 --- a/ash/display/display_controller.h +++ b/ash/display/display_controller.h @@ -72,13 +72,9 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, void Start(); void Shutdown(); - // Returns primary display. This is safe to use after ash::Shell is - // deleted. - static const gfx::Display& GetPrimaryDisplay(); - - // Returns the number of display. This is safe to use after - // ash::Shell is deleted. - static int GetNumDisplays(); + // Returns primary display's ID. + // TODO(oshima): Move this out from DisplayController; + static int64 GetPrimaryDisplayId(); internal::MirrorWindowController* mirror_window_controller() { return mirror_window_controller_.get(); @@ -142,19 +138,6 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, // Sets the work area's |insets| to the display assigned to |window|. bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, const gfx::Insets& insets); - - // Returns the display object nearest given |point|. - const gfx::Display& GetDisplayNearestPoint( - const gfx::Point& point) const; - - // Returns the display object nearest given |window|. - const gfx::Display& GetDisplayNearestWindow( - const aura::Window* window) const; - - // Returns the display that most closely intersects |match_rect|. - const gfx::Display& GetDisplayMatching( - const gfx::Rect& match_rect)const; - // aura::DisplayObserver overrides: virtual void OnDisplayBoundsChanged( const gfx::Display& display) OVERRIDE; diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc index ffcd6b0..9b85654 100644 --- a/ash/display/display_controller_unittest.cc +++ b/ash/display/display_controller_unittest.cc @@ -8,7 +8,7 @@ #include "ash/display/display_info.h" #include "ash/display/display_layout_store.h" #include "ash/display/display_manager.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" @@ -324,7 +324,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) { EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); gfx::Insets insets(5, 5, 5, 5); - int64 secondary_display_id = ScreenAsh::GetSecondaryDisplay().id(); + int64 secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); Shell::GetInstance()->display_manager()->UpdateWorkAreaOfDisplay( secondary_display_id, insets); @@ -520,7 +520,7 @@ TEST_F(DisplayControllerTest, BoundsUpdated) { Shell::GetInstance()->display_manager(); gfx::Insets insets(5, 5, 5, 5); display_manager->UpdateWorkAreaOfDisplay( - ScreenAsh::GetSecondaryDisplay().id(), insets); + ScreenUtil::GetSecondaryDisplay().id(), insets); EXPECT_EQ("0,0 200x200", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("0,200 300x300", GetSecondaryDisplay().bounds().ToString()); @@ -604,7 +604,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) { UpdateDisplay("200x200,300x300"); gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); + gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); DisplayLayout display_layout(DisplayLayout::RIGHT, 50); display_manager->SetLayoutForCurrentDisplays(display_layout); @@ -640,7 +640,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) { EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id()); + EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint( gfx::Point(-100, -100)).id()); @@ -658,7 +658,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) { // Test if the bounds are correctly swapped. gfx::Display swapped_primary = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display swapped_secondary = ScreenAsh::GetSecondaryDisplay(); + gfx::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); EXPECT_EQ("0,0 300x253", swapped_primary.work_area().ToString()); EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); @@ -698,7 +698,7 @@ TEST_F(DisplayControllerTest, FindNearestDisplay) { display_manager->SetLayoutForCurrentDisplays(display_layout); gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); + gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); EXPECT_NE(primary_display.id(), secondary_display.id()); aura::Window* primary_root = display_controller->GetRootWindowForDisplayId(primary_display.id()); @@ -741,7 +741,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryForLegacyShelfLayout) { UpdateDisplay("200x200,300x300"); gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); + gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); DisplayLayout display_layout(DisplayLayout::RIGHT, 50); display_manager->SetLayoutForCurrentDisplays(display_layout); @@ -777,7 +777,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryForLegacyShelfLayout) { EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id()); + EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint( gfx::Point(-100, -100)).id()); @@ -795,7 +795,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryForLegacyShelfLayout) { // Test if the bounds are correctly swapped. gfx::Display swapped_primary = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display swapped_secondary = ScreenAsh::GetSecondaryDisplay(); + gfx::Display swapped_secondary = ScreenUtil::GetSecondaryDisplay(); EXPECT_EQ("0,0 300x300", swapped_primary.bounds().ToString()); EXPECT_EQ("0,0 300x252", swapped_primary.work_area().ToString()); EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString()); @@ -832,7 +832,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { UpdateDisplay("200x200,300x300"); gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); + gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); DisplayLayout display_layout(DisplayLayout::RIGHT, 50); display_manager->SetLayoutForCurrentDisplays(display_layout); @@ -858,7 +858,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { display_controller->SetPrimaryDisplayId(secondary_display.id()); EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id()); + EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_LT(0, observer.CountAndReset()); EXPECT_EQ( @@ -909,7 +909,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id()); + EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_EQ( primary_root, display_controller->GetRootWindowForDisplayId(secondary_display.id())); @@ -935,7 +935,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ(third_display_info.id(), ScreenAsh::GetSecondaryDisplay().id()); + EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_EQ( primary_root, display_controller->GetRootWindowForDisplayId(primary_display.id())); @@ -954,7 +954,7 @@ TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) { UpdateDisplay("200x200,200x200*2"); gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); - gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay(); + gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); aura::Window* primary_root = display_controller->GetRootWindowForDisplayId(primary_display.id()); @@ -1018,7 +1018,7 @@ TEST_F(DisplayControllerTest, OverscanInsets) { EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("80,0 150x200", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); aura::test::EventGenerator generator(root_windows[0]); generator.MoveMouseToInHost(20, 25); @@ -1027,7 +1027,7 @@ TEST_F(DisplayControllerTest, OverscanInsets) { display_controller->SetOverscanInsets(display1.id(), gfx::Insets()); EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString()); EXPECT_EQ("120,0 150x200", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator.MoveMouseToInHost(30, 20); EXPECT_EQ("30,20", event_handler.GetLocationAndReset()); @@ -1061,14 +1061,14 @@ TEST_F(DisplayControllerTest, Rotate) { UpdateDisplay("120x200,300x400*2"); gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); - int64 display2_id = ScreenAsh::GetSecondaryDisplay().id(); + int64 display2_id = ScreenUtil::GetSecondaryDisplay().id(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); aura::test::EventGenerator generator1(root_windows[0]); EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("120,0 150x200", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator1.MoveMouseToInHost(50, 40); EXPECT_EQ("50,40", event_handler.GetLocationAndReset()); EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); @@ -1079,7 +1079,7 @@ TEST_F(DisplayControllerTest, Rotate) { EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("200,0 150x200", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator1.MoveMouseToInHost(50, 40); EXPECT_EQ("40,69", event_handler.GetLocationAndReset()); EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); @@ -1088,14 +1088,14 @@ TEST_F(DisplayControllerTest, Rotate) { DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); display_manager->SetLayoutForCurrentDisplays(display_layout); EXPECT_EQ("50,120 150x200", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270); EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("50,120 200x150", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); @@ -1110,7 +1110,7 @@ TEST_F(DisplayControllerTest, Rotate) { EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); // Dislay must share at least 100, so the x's offset becomes 20. EXPECT_EQ("20,200 200x150", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); @@ -1133,7 +1133,7 @@ TEST_F(DisplayControllerTest, ScaleRootWindow) { gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); gfx::Display::SetInternalDisplayId(display1.id()); - gfx::Display display2 = ScreenAsh::GetSecondaryDisplay(); + gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); @@ -1149,7 +1149,7 @@ TEST_F(DisplayControllerTest, ScaleRootWindow) { Shell::GetInstance()->display_manager(); display_manager->SetDisplayUIScale(display1.id(), 1.25f); display1 = Shell::GetScreen()->GetPrimaryDisplay(); - display2 = ScreenAsh::GetSecondaryDisplay(); + display2 = ScreenUtil::GetSecondaryDisplay(); EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); EXPECT_EQ("375,0 500x300", display2.bounds().ToString()); diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index 2731144..9bb154e 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -11,7 +11,8 @@ #include "ash/ash_switches.h" #include "ash/display/display_layout_store.h" -#include "ash/screen_ash.h" +#include "ash/display/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "base/auto_reset.h" #include "base/command_line.h" @@ -48,6 +49,10 @@ typedef std::vector<DisplayInfo> DisplayInfoList; namespace { +// We need to keep this in order for unittests to tell if +// the object in gfx::Screen::GetScreenByType is for shutdown. +gfx::Screen* screen_for_shutdown = NULL; + // The number of pixels to overlap between the primary and secondary displays, // in case that the offset value is too large. const int kMinimumOverlapForInvalidOffset = 100; @@ -143,6 +148,8 @@ using std::vector; DisplayManager::DisplayManager() : delegate_(NULL), + screen_ash_(new ScreenAsh), + screen_(screen_ash_.get()), layout_store_(new DisplayLayoutStore), first_display_id_(gfx::Display::kInvalidDisplayID), num_connected_displays_(0), @@ -153,6 +160,13 @@ DisplayManager::DisplayManager() #if defined(OS_CHROMEOS) change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS(); #endif + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, + screen_ash_.get()); + if (gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE) == + screen_for_shutdown) { + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, + screen_ash_.get()); + } } DisplayManager::~DisplayManager() { @@ -302,7 +316,7 @@ void DisplayManager::SetLayoutForCurrentDisplays( DCHECK_EQ(2U, GetNumDisplays()); if (GetNumDisplays() < 2) return; - const gfx::Display& primary = Shell::GetScreen()->GetPrimaryDisplay(); + const gfx::Display& primary = screen_->GetPrimaryDisplay(); const DisplayIdPair pair = GetCurrentDisplayIdPair(); // Invert if the primary was swapped. DisplayLayout to_set = pair.first == primary.id() ? @@ -322,13 +336,12 @@ void DisplayManager::SetLayoutForCurrentDisplays( const DisplayLayout layout = GetCurrentDisplayLayout(); UpdateDisplayBoundsForLayoutById( layout, primary, - ScreenAsh::GetSecondaryDisplay().id()); + ScreenUtil::GetSecondaryDisplay().id()); - //UpdateCurrentDisplayBoundsForLayout(); // Primary's bounds stay the same. Just notify bounds change // on the secondary. - Shell::GetInstance()->screen()->NotifyBoundsChanged( - ScreenAsh::GetSecondaryDisplay()); + screen_ash_->NotifyBoundsChanged( + ScreenUtil::GetSecondaryDisplay()); if (delegate_) delegate_->PostDisplayConfigurationChange(); } @@ -751,7 +764,7 @@ void DisplayManager::UpdateDisplays( for (DisplayList::const_reverse_iterator iter = removed_displays.rbegin(); iter != removed_displays.rend(); ++iter) { - Shell::GetInstance()->screen()->NotifyDisplayRemoved(displays_.back()); + screen_ash_->NotifyDisplayRemoved(displays_.back()); displays_.pop_back(); } // Close the non desktop window here to avoid creating two compositor on @@ -760,7 +773,7 @@ void DisplayManager::UpdateDisplays( non_desktop_display_updater.reset(); for (std::vector<size_t>::iterator iter = added_display_indices.begin(); iter != added_display_indices.end(); ++iter) { - Shell::GetInstance()->screen()->NotifyDisplayAdded(displays_[*iter]); + screen_ash_->NotifyDisplayAdded(displays_[*iter]); } // Create the non destkop window after all displays are added so that // it can mirror the display newly added. This can happen when switching @@ -768,7 +781,7 @@ void DisplayManager::UpdateDisplays( non_desktop_display_updater.reset(); for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); iter != changed_display_indices.end(); ++iter) { - Shell::GetInstance()->screen()->NotifyBoundsChanged(displays_[*iter]); + screen_ash_->NotifyBoundsChanged(displays_[*iter]); } if (delegate_) delegate_->PostDisplayConfigurationChange(); @@ -915,7 +928,7 @@ bool DisplayManager::UpdateDisplayBounds(int64 display_id, return false; gfx::Display* display = FindDisplayForId(display_id); display->SetSize(display_info_[display_id].size_in_pixel()); - Shell::GetInstance()->screen()->NotifyBoundsChanged(*display); + screen_ash_->NotifyBoundsChanged(*display); return true; } return false; @@ -925,6 +938,20 @@ void DisplayManager::CreateMirrorWindowIfAny() { NonDesktopDisplayUpdater updater(this, delegate_); } +void DisplayManager::CreateScreenForShutdown() const { + bool native_is_ash = + gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE) == + screen_ash_.get(); + delete screen_for_shutdown; + screen_for_shutdown = screen_ash_->CloneForShutdown(); + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, + screen_for_shutdown); + if (native_is_ash) { + gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, + screen_for_shutdown); + } +} + gfx::Display* DisplayManager::FindDisplayForId(int64 id) { for (DisplayList::iterator iter = displays_.begin(); iter != displays_.end(); ++iter) { diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h index 4e03f33..3450a5d 100644 --- a/ash/display/display_manager.h +++ b/ash/display/display_manager.h @@ -24,11 +24,13 @@ namespace gfx { class Display; class Insets; class Rect; +class Screen; } namespace ash { class AcceleratorControllerTest; class DisplayController; +class ScreenAsh; namespace test { class DisplayManagerTestApi; @@ -98,6 +100,10 @@ class ASH_EXPORT DisplayManager return layout_store_.get(); } + gfx::Screen* screen() { + return screen_; + } + void set_delegate(Delegate* delegate) { delegate_ = delegate; } // When set to true, the MonitorManager calls OnDisplayBoundsChanged @@ -265,6 +271,9 @@ class ASH_EXPORT DisplayManager // This is used only for bootstrap. void CreateMirrorWindowIfAny(); + // Create a screen instance to be used during shutdown. + void CreateScreenForShutdown() const; + private: FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged); @@ -313,6 +322,10 @@ private: Delegate* delegate_; // not owned. + scoped_ptr<ScreenAsh> screen_ash_; + // This is to have an accessor without ScreenAsh definition. + gfx::Screen* screen_; + scoped_ptr<DisplayLayoutStore> layout_store_; int64 first_display_id_; diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index 9ada6a8..ec8d35b 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc @@ -6,7 +6,7 @@ #include "ash/display/display_controller.h" #include "ash/display/display_layout_store.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/display_manager_test_api.h" @@ -20,6 +20,8 @@ #include "ui/aura/window_observer.h" #include "ui/gfx/display_observer.h" #include "ui/gfx/display.h" +#include "ui/gfx/screen.h" +#include "ui/gfx/screen_type_delegate.h" namespace ash { namespace internal { @@ -273,7 +275,7 @@ TEST_F(DisplayManagerTest, OverscanInsetsTest) { EXPECT_EQ("13,12,11,10", updated_display_info2.overscan_insets_in_dip().ToString()); EXPECT_EQ("500,0 378x376", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); // Make sure that SetOverscanInsets() is idempotent. display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); @@ -340,11 +342,11 @@ TEST_F(DisplayManagerTest, OverscanInsetsTest) { // Make sure switching primary display applies the overscan offset only once. ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay( - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); EXPECT_EQ("-500,0 500x500", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); EXPECT_EQ("0,0 500x500", - GetDisplayInfo(ScreenAsh::GetSecondaryDisplay()). + GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()). bounds_in_native().ToString()); EXPECT_EQ("0,501 400x400", GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). @@ -655,7 +657,7 @@ TEST_F(DisplayManagerTest, MAYBE_EnsurePointerInDisplays_2ndOnLeft) { aura::Window::Windows root_windows = Shell::GetAllRootWindows(); EXPECT_EQ("-300,0 300x300", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); aura::Env* env = aura::Env::GetInstance(); @@ -1181,5 +1183,34 @@ TEST_F(DisplayManagerTest, MAYBE_UpdateDisplayWithHostOrigin) { EXPECT_EQ("200x300", dispatcher1->host()->GetBounds().size().ToString()); } + +class ScreenShutdownTest : public test::AshTestBase { + public: + ScreenShutdownTest() { + } + virtual ~ScreenShutdownTest() {} + + virtual void TearDown() OVERRIDE { + gfx::Screen* orig_screen = + gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + AshTestBase::TearDown(); + gfx::Screen* screen = + gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); + EXPECT_NE(orig_screen, screen); + EXPECT_EQ(2, screen->GetNumDisplays()); + EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); + std::vector<gfx::Display> all = screen->GetAllDisplays(); + EXPECT_EQ("500x300", all[0].size().ToString()); + EXPECT_EQ("800x400", all[1].size().ToString()); + } + + private: + DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); +}; + +TEST_F(DisplayManagerTest, ScreenAfterShutdown) { + UpdateDisplay("500x300,800x400"); +} + } // namespace internal } // namespace ash diff --git a/ash/display/event_transformation_handler.cc b/ash/display/event_transformation_handler.cc index aaac56c..0c869f8 100644 --- a/ash/display/event_transformation_handler.cc +++ b/ash/display/event_transformation_handler.cc @@ -6,7 +6,6 @@ #include <cmath> -#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/wm/coordinate_conversion.h" #include "ash/wm/window_util.h" diff --git a/ash/display/mouse_cursor_event_filter.cc b/ash/display/mouse_cursor_event_filter.cc index ebac900..bc1368f 100644 --- a/ash/display/mouse_cursor_event_filter.cc +++ b/ash/display/mouse_cursor_event_filter.cc @@ -8,7 +8,7 @@ #include "ash/display/display_manager.h" #include "ash/display/mirror_window_controller.h" #include "ash/display/shared_display_edge_indicator.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/wm/coordinate_conversion.h" #include "ash/wm/window_util.h" @@ -176,7 +176,7 @@ void MouseCursorEventFilter::UpdateHorizontalIndicatorWindowBounds() { // instead of using reference. const gfx::Rect primary_bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); - const gfx::Rect secondary_bounds = ScreenAsh::GetSecondaryDisplay().bounds(); + const gfx::Rect secondary_bounds = ScreenUtil::GetSecondaryDisplay().bounds(); DisplayLayout::Position position = Shell::GetInstance()-> display_manager()->GetCurrentDisplayLayout().position; @@ -205,7 +205,7 @@ void MouseCursorEventFilter::UpdateVerticalIndicatorWindowBounds() { // instead of using reference. const gfx::Rect primary_bounds = Shell::GetScreen()->GetPrimaryDisplay().bounds(); - const gfx::Rect secondary_bounds = ScreenAsh::GetSecondaryDisplay().bounds(); + const gfx::Rect secondary_bounds = ScreenUtil::GetSecondaryDisplay().bounds(); DisplayLayout::Position position = Shell::GetInstance()-> display_manager()->GetCurrentDisplayLayout().position; diff --git a/ash/display/resolution_notification_controller_unittest.cc b/ash/display/resolution_notification_controller_unittest.cc index 0ec8852..e167c61 100644 --- a/ash/display/resolution_notification_controller_unittest.cc +++ b/ash/display/resolution_notification_controller_unittest.cc @@ -5,7 +5,7 @@ #include "ash/display/resolution_notification_controller.h" #include "ash/display/display_manager.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "base/bind.h" @@ -107,7 +107,7 @@ TEST_F(ResolutionNotificationControllerTest, Basic) { return; UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200"); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::internal::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); ASSERT_EQ(0, accept_count()); @@ -115,7 +115,7 @@ TEST_F(ResolutionNotificationControllerTest, Basic) { // Changes the resolution and apply the result. SetDisplayResolutionAndNotify( - ScreenAsh::GetSecondaryDisplay(), gfx::Size(200, 200)); + ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); EXPECT_TRUE(IsNotificationVisible()); EXPECT_FALSE(controller()->DoesNotificationTimeout()); gfx::Size resolution; @@ -137,7 +137,7 @@ TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) { return; UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200"); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::internal::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); ASSERT_EQ(0, accept_count()); @@ -145,7 +145,7 @@ TEST_F(ResolutionNotificationControllerTest, ClickMeansAccept) { // Changes the resolution and apply the result. SetDisplayResolutionAndNotify( - ScreenAsh::GetSecondaryDisplay(), gfx::Size(200, 200)); + ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); EXPECT_TRUE(IsNotificationVisible()); EXPECT_FALSE(controller()->DoesNotificationTimeout()); gfx::Size resolution; @@ -204,7 +204,7 @@ TEST_F(ResolutionNotificationControllerTest, Close) { return; UpdateDisplay("100x100,150x150#150x150|200x200"); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::internal::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); ASSERT_EQ(0, accept_count()); @@ -212,7 +212,7 @@ TEST_F(ResolutionNotificationControllerTest, Close) { // Changes the resolution and apply the result. SetDisplayResolutionAndNotify( - ScreenAsh::GetSecondaryDisplay(), gfx::Size(200, 200)); + ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); EXPECT_TRUE(IsNotificationVisible()); EXPECT_FALSE(controller()->DoesNotificationTimeout()); gfx::Size resolution; @@ -256,11 +256,11 @@ TEST_F(ResolutionNotificationControllerTest, DisplayDisconnected) { return; UpdateDisplay("300x300#300x300|200x200,200x200#250x250|200x200|100x100"); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::internal::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); SetDisplayResolutionAndNotify( - ScreenAsh::GetSecondaryDisplay(), gfx::Size(100, 100)); + ScreenUtil::GetSecondaryDisplay(), gfx::Size(100, 100)); ASSERT_TRUE(IsNotificationVisible()); // Disconnects the secondary display and verifies it doesn't cause crashes. @@ -279,12 +279,12 @@ TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) { return; UpdateDisplay("300x300#300x300|200x200,250x250#250x250|200x200"); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::internal::DisplayManager* display_manager = ash::Shell::GetInstance()->display_manager(); SetDisplayResolutionAndNotify( - ScreenAsh::GetSecondaryDisplay(), gfx::Size(200, 200)); + ScreenUtil::GetSecondaryDisplay(), gfx::Size(200, 200)); EXPECT_TRUE(IsNotificationVisible()); EXPECT_FALSE(controller()->DoesNotificationTimeout()); gfx::Size resolution; @@ -295,7 +295,7 @@ TEST_F(ResolutionNotificationControllerTest, MultipleResolutionChange) { // Invokes SetDisplayResolutionAndNotify during the previous notification is // visible. SetDisplayResolutionAndNotify( - ScreenAsh::GetSecondaryDisplay(), gfx::Size(250, 250)); + ScreenUtil::GetSecondaryDisplay(), gfx::Size(250, 250)); EXPECT_FALSE( display_manager->GetSelectedResolutionForDisplayId(id2, &resolution)); diff --git a/ash/display/root_window_transformers_unittest.cc b/ash/display/root_window_transformers_unittest.cc index e3b5e85..9ace7df 100644 --- a/ash/display/root_window_transformers_unittest.cc +++ b/ash/display/root_window_transformers_unittest.cc @@ -7,7 +7,7 @@ #include "ash/display/display_info.h" #include "ash/display/display_manager.h" #include "ash/magnifier/magnification_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" @@ -143,7 +143,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { UpdateDisplay("120x200,300x400*2"); gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); - int64 display2_id = ScreenAsh::GetSecondaryDisplay().id(); + int64 display2_id = ScreenUtil::GetSecondaryDisplay().id(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); aura::test::EventGenerator generator1(root_windows[0]); @@ -154,7 +154,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("120,0 150x200", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator1.MoveMouseToInHost(40, 80); EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); EXPECT_EQ("50,90", @@ -173,7 +173,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("200,0 150x200", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator1.MoveMouseToInHost(39, 120); EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); EXPECT_EQ("110,70", @@ -185,7 +185,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); display_manager->SetLayoutForCurrentDisplays(display_layout); EXPECT_EQ("50,120 150x200", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270); @@ -196,7 +196,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("50,120 200x150", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator2.MoveMouseToInHost(172, 219); EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); EXPECT_EQ("145,200", @@ -215,7 +215,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); // Dislay must share at least 100, so the x's offset becomes 20. EXPECT_EQ("20,200 200x150", - ScreenAsh::GetSecondaryDisplay().bounds().ToString()); + ScreenUtil::GetSecondaryDisplay().bounds().ToString()); generator1.MoveMouseToInHost(39, 59); EXPECT_EQ("70,120", event_handler.GetLocationAndReset()); EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id())); @@ -236,7 +236,7 @@ TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); gfx::Display::SetInternalDisplayId(display1.id()); - gfx::Display display2 = ScreenAsh::GetSecondaryDisplay(); + gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); MagnificationController* magnifier = Shell::GetInstance()->magnification_controller(); @@ -257,7 +257,7 @@ TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { DisplayManager* display_manager = Shell::GetInstance()->display_manager(); display_manager->SetDisplayUIScale(display1.id(), 1.25); display1 = Shell::GetScreen()->GetPrimaryDisplay(); - display2 = ScreenAsh::GetSecondaryDisplay(); + display2 = ScreenUtil::GetSecondaryDisplay(); magnifier->SetEnabled(true); EXPECT_EQ(2.0f, magnifier->GetScale()); EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc new file mode 100644 index 0000000..7effb38 --- /dev/null +++ b/ash/display/screen_ash.cc @@ -0,0 +1,284 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/display/screen_ash.h" + +#include "ash/display/display_controller.h" +#include "ash/display/display_manager.h" +#include "ash/root_window_controller.h" +#include "ash/root_window_settings.h" +#include "ash/shelf/shelf_layout_manager.h" +#include "ash/shelf/shelf_widget.h" +#include "ash/shell.h" +#include "ash/wm/coordinate_conversion.h" +#include "base/logging.h" +#include "ui/aura/client/screen_position_client.h" +#include "ui/aura/env.h" +#include "ui/aura/root_window.h" +#include "ui/gfx/display.h" +#include "ui/gfx/screen.h" + +namespace ash { + +namespace { + +internal::DisplayManager* GetDisplayManager() { + return Shell::GetInstance()->display_manager(); +} + +gfx::Display FindDisplayNearestPoint(const std::vector<gfx::Display>& displays, + const gfx::Point& point) { + int min_distance = INT_MAX; + const gfx::Display* nearest_display = NULL; + for (std::vector<gfx::Display>::const_iterator iter = displays.begin(); + iter != displays.end(); ++iter) { + const gfx::Display& display = *iter; + int distance = display.bounds().ManhattanDistanceToPoint(point); + if (distance < min_distance) { + min_distance = distance; + nearest_display = &display; + } + } + // There should always be at least one display that is less than INT_MAX away. + DCHECK(nearest_display); + return *nearest_display; +} + +const gfx::Display* FindDisplayMatching( + const std::vector<gfx::Display>& displays, + const gfx::Rect& match_rect) { + int max_area = 0; + const gfx::Display* matching = NULL; + for (std::vector<gfx::Display>::const_iterator iter = displays.begin(); + iter != displays.end(); ++iter) { + const gfx::Display& display = *iter; + gfx::Rect intersect = gfx::IntersectRects(display.bounds(), match_rect); + int area = intersect.width() * intersect.height(); + if (area > max_area) { + max_area = area; + matching = &display; + } + } + return matching; +} + +class ScreenForShutdown : public gfx::Screen { + public: + explicit ScreenForShutdown(ScreenAsh* screen_ash) + : display_list_(screen_ash->GetAllDisplays()), + primary_display_(screen_ash->GetPrimaryDisplay()) { + } + + // gfx::Screen overrides: + virtual bool IsDIPEnabled() OVERRIDE { + return true; + } + virtual gfx::Point GetCursorScreenPoint() OVERRIDE { + return gfx::Point(); + } + virtual gfx::NativeWindow GetWindowUnderCursor() OVERRIDE { + return NULL; + } + virtual gfx::NativeWindow GetWindowAtScreenPoint( + const gfx::Point& point) OVERRIDE { + return NULL; + } + virtual int GetNumDisplays() const OVERRIDE { + return display_list_.size(); + } + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + return display_list_; + } + virtual gfx::Display GetDisplayNearestWindow(gfx::NativeView view) + const OVERRIDE { + return primary_display_; + } + virtual gfx::Display GetDisplayNearestPoint( + const gfx::Point& point) const OVERRIDE { + return FindDisplayNearestPoint(display_list_, point); + } + virtual gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) + const OVERRIDE { + const gfx::Display* matching = + FindDisplayMatching(display_list_, match_rect); + // Fallback to the primary display if there is no matching display. + return matching ? *matching : GetPrimaryDisplay(); + } + virtual gfx::Display GetPrimaryDisplay() const OVERRIDE { + return primary_display_; + } + virtual void AddObserver(gfx::DisplayObserver* observer) OVERRIDE { + NOTREACHED() << "Observer should not be added during shutdown"; + } + virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE { + } + + private: + const std::vector<gfx::Display> display_list_; + const gfx::Display primary_display_; + + DISALLOW_COPY_AND_ASSIGN(ScreenForShutdown); +}; + +} // namespace + +ScreenAsh::ScreenAsh() { +} + +ScreenAsh::~ScreenAsh() { +} + +// static +gfx::Display ScreenAsh::FindDisplayContainingPoint(const gfx::Point& point) { + return GetDisplayManager()->FindDisplayContainingPoint(point); +} + +// static +gfx::Rect ScreenAsh::GetMaximizedWindowBoundsInParent(aura::Window* window) { + if (internal::GetRootWindowController(window->GetRootWindow())->shelf()) + return GetDisplayWorkAreaBoundsInParent(window); + else + return GetDisplayBoundsInParent(window); +} + +// static +gfx::Rect ScreenAsh::GetDisplayBoundsInParent(aura::Window* window) { + return ConvertRectFromScreen( + window->parent(), + Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); +} + +// static +gfx::Rect ScreenAsh::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { + return ConvertRectFromScreen( + window->parent(), + Shell::GetScreen()->GetDisplayNearestWindow(window).work_area()); +} + +// static +gfx::Rect ScreenAsh::ConvertRectToScreen(aura::Window* window, + const gfx::Rect& rect) { + gfx::Point point = rect.origin(); + aura::client::GetScreenPositionClient(window->GetRootWindow())-> + ConvertPointToScreen(window, &point); + return gfx::Rect(point, rect.size()); +} + +// static +gfx::Rect ScreenAsh::ConvertRectFromScreen(aura::Window* window, + const gfx::Rect& rect) { + gfx::Point point = rect.origin(); + aura::client::GetScreenPositionClient(window->GetRootWindow())-> + ConvertPointFromScreen(window, &point); + return gfx::Rect(point, rect.size()); +} + +// static +const gfx::Display& ScreenAsh::GetSecondaryDisplay() { + internal::DisplayManager* display_manager = GetDisplayManager(); + CHECK_EQ(2U, display_manager->GetNumDisplays()); + return display_manager->GetDisplayAt(0).id() == + Shell::GetScreen()->GetPrimaryDisplay().id() ? + display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); +} + +// static +const gfx::Display& ScreenAsh::GetDisplayForId(int64 display_id) { + return GetDisplayManager()->GetDisplayForId(display_id); +} + +void ScreenAsh::NotifyBoundsChanged(const gfx::Display& display) { + FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_, + OnDisplayBoundsChanged(display)); +} + +void ScreenAsh::NotifyDisplayAdded(const gfx::Display& display) { + FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_, OnDisplayAdded(display)); +} + +void ScreenAsh::NotifyDisplayRemoved(const gfx::Display& display) { + FOR_EACH_OBSERVER( + gfx::DisplayObserver, observers_, OnDisplayRemoved(display)); +} + +bool ScreenAsh::IsDIPEnabled() { + return true; +} + +gfx::Point ScreenAsh::GetCursorScreenPoint() { + return aura::Env::GetInstance()->last_mouse_location(); +} + +gfx::NativeWindow ScreenAsh::GetWindowUnderCursor() { + return GetWindowAtScreenPoint(Shell::GetScreen()->GetCursorScreenPoint()); +} + +gfx::NativeWindow ScreenAsh::GetWindowAtScreenPoint(const gfx::Point& point) { + return wm::GetRootWindowAt(point)->GetTopWindowContainingPoint(point); +} + +int ScreenAsh::GetNumDisplays() const { + return GetDisplayManager()->GetNumDisplays(); +} + +std::vector<gfx::Display> ScreenAsh::GetAllDisplays() const { + return GetDisplayManager()->displays(); +} + +gfx::Display ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window) const { + if (!window) + return GetPrimaryDisplay(); + const aura::Window* root_window = window->GetRootWindow(); + if (!root_window) + return GetPrimaryDisplay(); + int64 id = internal::GetRootWindowSettings(root_window)->display_id; + // if id is |kInvaildDisplayID|, it's being deleted. + DCHECK(id != gfx::Display::kInvalidDisplayID); + + internal::DisplayManager* display_manager = GetDisplayManager(); + // RootWindow needs Display to determine its device scale factor + // for non desktop display. + if (display_manager->non_desktop_display().id() == id) + return display_manager->non_desktop_display(); + return display_manager->GetDisplayForId(id); +} + +gfx::Display ScreenAsh::GetDisplayNearestPoint(const gfx::Point& point) const { + const gfx::Display& display = + GetDisplayManager()->FindDisplayContainingPoint(point); + if (display.is_valid()) + return display; + // Fallback to the display that has the shortest Manhattan distance from + // the |point|. This is correct in the only areas that matter, namely in the + // corners between the physical screens. + return FindDisplayNearestPoint(GetDisplayManager()->displays(), point); +} + +gfx::Display ScreenAsh::GetDisplayMatching(const gfx::Rect& match_rect) const { + if (match_rect.IsEmpty()) + return GetDisplayNearestPoint(match_rect.origin()); + const gfx::Display* matching = + FindDisplayMatching(GetDisplayManager()->displays(), match_rect); + // Fallback to the primary display if there is no matching display. + return matching ? *matching : GetPrimaryDisplay(); +} + +gfx::Display ScreenAsh::GetPrimaryDisplay() const { + return GetDisplayManager()->GetDisplayForId( + DisplayController::GetPrimaryDisplayId()); +} + +void ScreenAsh::AddObserver(gfx::DisplayObserver* observer) { + observers_.AddObserver(observer); +} + +void ScreenAsh::RemoveObserver(gfx::DisplayObserver* observer) { + observers_.RemoveObserver(observer); +} + +gfx::Screen* ScreenAsh::CloneForShutdown() { + return new ScreenForShutdown(this); +} + +} // namespace ash diff --git a/ash/screen_ash.h b/ash/display/screen_ash.h index 6c07607..eb8cf75a 100644 --- a/ash/screen_ash.h +++ b/ash/display/screen_ash.h @@ -1,9 +1,9 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef ASH_SCREEN_ASH_H_ -#define ASH_SCREEN_ASH_H_ +#ifndef ASH_DISPLAY_SCREEN_ASH_H_ +#define ASH_DISPLAY_SCREEN_ASH_H_ #include "ash/ash_export.h" #include "base/compiler_specific.h" @@ -15,6 +15,9 @@ class Rect; } namespace ash { +namespace internal { +class DisplayManager; +} // Aura implementation of gfx::Screen. Implemented here to avoid circular // dependencies. @@ -56,12 +59,6 @@ class ASH_EXPORT ScreenAsh : public gfx::Screen { // invalid display if no such display is connected. static const gfx::Display& GetDisplayForId(int64 display_id); - // Notifies observers of display configuration changes. - void NotifyBoundsChanged(const gfx::Display& display); - void NotifyDisplayAdded(const gfx::Display& display); - void NotifyDisplayRemoved(const gfx::Display& display); - - protected: // gfx::Screen overrides: virtual bool IsDIPEnabled() OVERRIDE; virtual gfx::Point GetCursorScreenPoint() OVERRIDE; @@ -81,6 +78,17 @@ class ASH_EXPORT ScreenAsh : public gfx::Screen { virtual void RemoveObserver(gfx::DisplayObserver* observer) OVERRIDE; private: + friend class internal::DisplayManager; + + // Notifies observers of display configuration changes. + void NotifyBoundsChanged(const gfx::Display& display); + void NotifyDisplayAdded(const gfx::Display& display); + void NotifyDisplayRemoved(const gfx::Display& display); + + // Creates a screen that can be used during shutdown. + // It simply has a copy of the displays. + gfx::Screen* CloneForShutdown(); + ObserverList<gfx::DisplayObserver> observers_; DISALLOW_COPY_AND_ASSIGN(ScreenAsh); @@ -88,4 +96,4 @@ class ASH_EXPORT ScreenAsh : public gfx::Screen { } // namespace ash -#endif // ASH_SCREEN_ASH_H_ +#endif // ASH_DISPLAY_SCREEN_ASH_H_ diff --git a/ash/display/screen_position_controller_unittest.cc b/ash/display/screen_position_controller_unittest.cc index c020d5b..4f6f7d0 100644 --- a/ash/display/screen_position_controller_unittest.cc +++ b/ash/display/screen_position_controller_unittest.cc @@ -5,7 +5,7 @@ #include "ash/display/screen_position_controller.h" #include "ash/display/display_manager.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/shell_test_api.h" @@ -230,7 +230,7 @@ TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenRotate) { // Move |window_| to the 2nd. window_->SetBoundsInScreen(gfx::Rect(300, 20, 50, 50), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); aura::Window::Windows root_windows = Shell::GetInstance()->GetAllRootWindows(); EXPECT_EQ(root_windows[1], window_->GetRootWindow()); @@ -262,7 +262,7 @@ TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenUIScale) { // Move |window_| to the 2nd. window_->SetBoundsInScreen(gfx::Rect(300, 20, 50, 50), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); aura::Window::Windows root_windows = Shell::GetInstance()->GetAllRootWindows(); EXPECT_EQ(root_windows[1], window_->GetRootWindow()); diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index 1ba8297..6e02726 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -5,7 +5,7 @@ #include "ash/display/display_controller.h" #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/system/tray/system_tray.h" @@ -609,7 +609,7 @@ TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { TEST_F(ExtendedDesktopTest, ConvertPoint) { if (!SupportsMultipleDisplays()) return; - gfx::Screen* screen = Shell::GetInstance()->screen(); + gfx::Screen* screen = Shell::GetScreen(); UpdateDisplay("1000x600,600x400"); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); gfx::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]); @@ -727,7 +727,7 @@ TEST_F(ExtendedDesktopTest, StayInSameRootWindow) { aura::Window* window = aura::test::CreateTestWindowWithId( 100, settings_bubble_container); window->SetBoundsInScreen(gfx::Rect(150, 10, 50, 50), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); EXPECT_EQ(root_windows[0], window->GetRootWindow()); aura::Window* status_container = @@ -735,7 +735,7 @@ TEST_F(ExtendedDesktopTest, StayInSameRootWindow) { internal::kShellWindowId_StatusContainer); window = aura::test::CreateTestWindowWithId(100, status_container); window->SetBoundsInScreen(gfx::Rect(150, 10, 50, 50), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); EXPECT_EQ(root_windows[0], window->GetRootWindow()); } @@ -752,7 +752,7 @@ TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { widget1->Show(); EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); views::Widget* widget2 = CreateTestWidget( - ScreenAsh::GetSecondaryDisplay().bounds()); + ScreenUtil::GetSecondaryDisplay().bounds()); widget2->Show(); EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); diff --git a/ash/screen_ash.cc b/ash/screen_ash.cc deleted file mode 100644 index bbda5ad..0000000 --- a/ash/screen_ash.cc +++ /dev/null @@ -1,168 +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/screen_ash.h" - -#include "ash/display/display_controller.h" -#include "ash/display/display_manager.h" -#include "ash/root_window_controller.h" -#include "ash/shelf/shelf_layout_manager.h" -#include "ash/shelf/shelf_widget.h" -#include "ash/shell.h" -#include "ash/wm/coordinate_conversion.h" -#include "base/logging.h" -#include "ui/aura/client/screen_position_client.h" -#include "ui/aura/env.h" -#include "ui/aura/root_window.h" -#include "ui/gfx/display.h" -#include "ui/gfx/screen.h" - -namespace ash { - -namespace { -internal::DisplayManager* GetDisplayManager() { - return Shell::GetInstance()->display_manager(); -} - -DisplayController* GetDisplayController() { - return Shell::GetInstance()->display_controller(); -} -} // namespace - -ScreenAsh::ScreenAsh() { -} - -ScreenAsh::~ScreenAsh() { -} - -// static -gfx::Display ScreenAsh::FindDisplayContainingPoint(const gfx::Point& point) { - return GetDisplayManager()->FindDisplayContainingPoint(point); -} - -// static -gfx::Rect ScreenAsh::GetMaximizedWindowBoundsInParent(aura::Window* window) { - if (internal::GetRootWindowController(window->GetRootWindow())->shelf()) - return GetDisplayWorkAreaBoundsInParent(window); - else - return GetDisplayBoundsInParent(window); -} - -// static -gfx::Rect ScreenAsh::GetDisplayBoundsInParent(aura::Window* window) { - return ConvertRectFromScreen( - window->parent(), - Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); -} - -// static -gfx::Rect ScreenAsh::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { - return ConvertRectFromScreen( - window->parent(), - Shell::GetScreen()->GetDisplayNearestWindow(window).work_area()); -} - -// static -gfx::Rect ScreenAsh::ConvertRectToScreen(aura::Window* window, - const gfx::Rect& rect) { - gfx::Point point = rect.origin(); - aura::client::GetScreenPositionClient(window->GetRootWindow())-> - ConvertPointToScreen(window, &point); - return gfx::Rect(point, rect.size()); -} - -// static -gfx::Rect ScreenAsh::ConvertRectFromScreen(aura::Window* window, - const gfx::Rect& rect) { - gfx::Point point = rect.origin(); - aura::client::GetScreenPositionClient(window->GetRootWindow())-> - ConvertPointFromScreen(window, &point); - return gfx::Rect(point, rect.size()); -} - -// static -const gfx::Display& ScreenAsh::GetSecondaryDisplay() { - internal::DisplayManager* display_manager = GetDisplayManager(); - CHECK_EQ(2U, display_manager->GetNumDisplays()); - return display_manager->GetDisplayAt(0).id() == - DisplayController::GetPrimaryDisplay().id() ? - display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); -} - -// static -const gfx::Display& ScreenAsh::GetDisplayForId(int64 display_id) { - return GetDisplayManager()->GetDisplayForId(display_id); -} - -void ScreenAsh::NotifyBoundsChanged(const gfx::Display& display) { - FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_, - OnDisplayBoundsChanged(display)); -} - -void ScreenAsh::NotifyDisplayAdded(const gfx::Display& display) { - FOR_EACH_OBSERVER(gfx::DisplayObserver, observers_, OnDisplayAdded(display)); -} - -void ScreenAsh::NotifyDisplayRemoved(const gfx::Display& display) { - FOR_EACH_OBSERVER( - gfx::DisplayObserver, observers_, OnDisplayRemoved(display)); -} - -bool ScreenAsh::IsDIPEnabled() { - return true; -} - -gfx::Point ScreenAsh::GetCursorScreenPoint() { - return aura::Env::GetInstance()->last_mouse_location(); -} - -gfx::NativeWindow ScreenAsh::GetWindowUnderCursor() { - return GetWindowAtScreenPoint(Shell::GetScreen()->GetCursorScreenPoint()); -} - -gfx::NativeWindow ScreenAsh::GetWindowAtScreenPoint(const gfx::Point& point) { - return wm::GetRootWindowAt(point)->GetTopWindowContainingPoint(point); -} - -int ScreenAsh::GetNumDisplays() const { - return DisplayController::GetNumDisplays(); -} - -std::vector<gfx::Display> ScreenAsh::GetAllDisplays() const { - if (!Shell::HasInstance()) - return std::vector<gfx::Display>(1, GetPrimaryDisplay()); - return GetDisplayManager()->displays(); -} - -gfx::Display ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window) const { - if (!Shell::HasInstance()) - return GetPrimaryDisplay(); - return GetDisplayController()->GetDisplayNearestWindow(window); -} - -gfx::Display ScreenAsh::GetDisplayNearestPoint(const gfx::Point& point) const { - if (!Shell::HasInstance()) - return GetPrimaryDisplay(); - return GetDisplayController()->GetDisplayNearestPoint(point); -} - -gfx::Display ScreenAsh::GetDisplayMatching(const gfx::Rect& match_rect) const { - if (!Shell::HasInstance()) - return GetPrimaryDisplay(); - return GetDisplayController()->GetDisplayMatching(match_rect); -} - -gfx::Display ScreenAsh::GetPrimaryDisplay() const { - return DisplayController::GetPrimaryDisplay(); -} - -void ScreenAsh::AddObserver(gfx::DisplayObserver* observer) { - observers_.AddObserver(observer); -} - -void ScreenAsh::RemoveObserver(gfx::DisplayObserver* observer) { - observers_.RemoveObserver(observer); -} - -} // namespace ash diff --git a/ash/screen_util.cc b/ash/screen_util.cc new file mode 100644 index 0000000..371c371 --- /dev/null +++ b/ash/screen_util.cc @@ -0,0 +1,87 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/screen_util.h" + +#include "ash/display/display_controller.h" +#include "ash/display/display_manager.h" +#include "ash/root_window_controller.h" +#include "ash/shelf/shelf_layout_manager.h" +#include "ash/shelf/shelf_widget.h" +#include "ash/shell.h" +#include "ash/wm/coordinate_conversion.h" +#include "base/logging.h" +#include "ui/aura/client/screen_position_client.h" +#include "ui/aura/root_window.h" +#include "ui/gfx/display.h" +#include "ui/gfx/screen.h" + +namespace ash { + +namespace { +internal::DisplayManager* GetDisplayManager() { + return Shell::GetInstance()->display_manager(); +} +} + +// static +gfx::Display ScreenUtil::FindDisplayContainingPoint(const gfx::Point& point) { + return GetDisplayManager()->FindDisplayContainingPoint(point); +} + +// static +gfx::Rect ScreenUtil::GetMaximizedWindowBoundsInParent(aura::Window* window) { + if (internal::GetRootWindowController(window->GetRootWindow())->shelf()) + return GetDisplayWorkAreaBoundsInParent(window); + else + return GetDisplayBoundsInParent(window); +} + +// static +gfx::Rect ScreenUtil::GetDisplayBoundsInParent(aura::Window* window) { + return ConvertRectFromScreen( + window->parent(), + Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); +} + +// static +gfx::Rect ScreenUtil::GetDisplayWorkAreaBoundsInParent(aura::Window* window) { + return ConvertRectFromScreen( + window->parent(), + Shell::GetScreen()->GetDisplayNearestWindow(window).work_area()); +} + +// static +gfx::Rect ScreenUtil::ConvertRectToScreen(aura::Window* window, + const gfx::Rect& rect) { + gfx::Point point = rect.origin(); + aura::client::GetScreenPositionClient(window->GetRootWindow())-> + ConvertPointToScreen(window, &point); + return gfx::Rect(point, rect.size()); +} + +// static +gfx::Rect ScreenUtil::ConvertRectFromScreen(aura::Window* window, + const gfx::Rect& rect) { + gfx::Point point = rect.origin(); + aura::client::GetScreenPositionClient(window->GetRootWindow())-> + ConvertPointFromScreen(window, &point); + return gfx::Rect(point, rect.size()); +} + +// static +const gfx::Display& ScreenUtil::GetSecondaryDisplay() { + internal::DisplayManager* display_manager = GetDisplayManager(); + CHECK_EQ(2U, display_manager->GetNumDisplays()); + return display_manager->GetDisplayAt(0).id() == + Shell::GetScreen()->GetPrimaryDisplay().id() ? + display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0); +} + +// static +const gfx::Display& ScreenUtil::GetDisplayForId(int64 display_id) { + return GetDisplayManager()->GetDisplayForId(display_id); +} + +} // namespace ash diff --git a/ash/screen_util.h b/ash/screen_util.h new file mode 100644 index 0000000..856ef4d --- /dev/null +++ b/ash/screen_util.h @@ -0,0 +1,68 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_SCREEN_UTIL_H_ +#define ASH_SCREEN_UTIL_H_ + +#include "ash/ash_export.h" +#include "base/basictypes.h" + +namespace aura { +class Window; +} + +namespace gfx { +class Display; +class Rect; +class Point; +} + +namespace ash { + +class ASH_EXPORT ScreenUtil { + public: + // Finds the display that contains |point| in screeen coordinates. + // Returns invalid display if there is no display that can satisfy + // the condition. + static gfx::Display FindDisplayContainingPoint(const gfx::Point& point); + + // Returns the bounds for maximized windows in parent coordinates. + // Maximized windows trigger auto-hiding the shelf. + static gfx::Rect GetMaximizedWindowBoundsInParent(aura::Window* window); + + // Returns the display bounds in parent coordinates. + static gfx::Rect GetDisplayBoundsInParent(aura::Window* window); + + // Returns the display's work area bounds in parent coordinates. + static gfx::Rect GetDisplayWorkAreaBoundsInParent(aura::Window* window); + + // TODO(oshima): Move following two to wm/coordinate_conversion.h + // Converts |rect| from |window|'s coordinates to the virtual screen + // coordinates. + static gfx::Rect ConvertRectToScreen(aura::Window* window, + const gfx::Rect& rect); + + // Converts |rect| from virtual screen coordinates to the |window|'s + // coordinates. + static gfx::Rect ConvertRectFromScreen(aura::Window* window, + const gfx::Rect& rect); + + // Returns a gfx::Display object for secondary display. Returns + // invalid display if there is no secondary display connected. + static const gfx::Display& GetSecondaryDisplay(); + + // Returns a gfx::Display object for the specified id. Returns + // invalid display if no such display is connected. + static const gfx::Display& GetDisplayForId(int64 display_id); + +private: + ScreenUtil() {} + ~ScreenUtil() {} + + DISALLOW_COPY_AND_ASSIGN(ScreenUtil); +}; + +} // namespace ash + +#endif // ASH_SCREEN_UTIL_H_ diff --git a/ash/screen_ash_unittest.cc b/ash/screen_util_unittest.cc index 89b0ea8..74d31b6 100644 --- a/ash/screen_ash_unittest.cc +++ b/ash/screen_util_unittest.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/root_window_controller.h" #include "ash/shelf/shelf_layout_manager.h" @@ -19,9 +19,9 @@ namespace ash { namespace test { -typedef test::AshTestBase ScreenAshTest; +typedef test::AshTestBase ScreenUtilTest; -TEST_F(ScreenAshTest, Bounds) { +TEST_F(ScreenUtilTest, Bounds) { if (!SupportsMultipleDisplays()) return; @@ -38,32 +38,32 @@ TEST_F(ScreenAshTest, Bounds) { // Maximized bounds EXPECT_EQ("0,0 600x597", - ScreenAsh::GetMaximizedWindowBoundsInParent( + ScreenUtil::GetMaximizedWindowBoundsInParent( primary->GetNativeView()).ToString()); EXPECT_EQ("0,0 500x453", - ScreenAsh::GetMaximizedWindowBoundsInParent( + ScreenUtil::GetMaximizedWindowBoundsInParent( secondary->GetNativeView()).ToString()); // Display bounds EXPECT_EQ("0,0 600x600", - ScreenAsh::GetDisplayBoundsInParent( + ScreenUtil::GetDisplayBoundsInParent( primary->GetNativeView()).ToString()); EXPECT_EQ("0,0 500x500", - ScreenAsh::GetDisplayBoundsInParent( + ScreenUtil::GetDisplayBoundsInParent( secondary->GetNativeView()).ToString()); // Work area bounds EXPECT_EQ("0,0 600x597", - ScreenAsh::GetDisplayWorkAreaBoundsInParent( + ScreenUtil::GetDisplayWorkAreaBoundsInParent( primary->GetNativeView()).ToString()); EXPECT_EQ("0,0 500x453", - ScreenAsh::GetDisplayWorkAreaBoundsInParent( + ScreenUtil::GetDisplayWorkAreaBoundsInParent( secondary->GetNativeView()).ToString()); } // Test verifies a stable handling of secondary screen widget changes // (crbug.com/226132). -TEST_F(ScreenAshTest, StabilityTest) { +TEST_F(ScreenUtilTest, StabilityTest) { if (!SupportsMultipleDisplays()) return; @@ -80,7 +80,7 @@ TEST_F(ScreenAshTest, StabilityTest) { secondary->Close(); } -TEST_F(ScreenAshTest, ConvertRect) { +TEST_F(ScreenUtilTest, ConvertRect) { if (!SupportsMultipleDisplays()) return; @@ -95,20 +95,20 @@ TEST_F(ScreenAshTest, ConvertRect) { EXPECT_EQ( "0,0 100x100", - ScreenAsh::ConvertRectFromScreen( + ScreenUtil::ConvertRectFromScreen( primary->GetNativeView(), gfx::Rect(10, 10, 100, 100)).ToString()); EXPECT_EQ( "10,10 100x100", - ScreenAsh::ConvertRectFromScreen( + ScreenUtil::ConvertRectFromScreen( secondary->GetNativeView(), gfx::Rect(620, 20, 100, 100)).ToString()); EXPECT_EQ( "40,40 100x100", - ScreenAsh::ConvertRectToScreen( + ScreenUtil::ConvertRectToScreen( primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString()); EXPECT_EQ( "650,50 100x100", - ScreenAsh::ConvertRectToScreen( + ScreenUtil::ConvertRectToScreen( secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString()); } diff --git a/ash/shelf/shelf.cc b/ash/shelf/shelf.cc index e016875..51a90d1 100644 --- a/ash/shelf/shelf.cc +++ b/ash/shelf/shelf.cc @@ -9,7 +9,7 @@ #include "ash/focus_cycler.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf_delegate.h" #include "ash/shelf/shelf_item_delegate.h" #include "ash/shelf/shelf_item_delegate_manager.h" @@ -95,7 +95,7 @@ gfx::Rect Shelf::GetScreenBoundsOfItemIconForWindow(aura::Window* window) { void Shelf::UpdateIconPositionForWindow(aura::Window* window) { shelf_view_->UpdatePanelIconPosition( GetLauncherIDForWindow(window), - ScreenAsh::ConvertRectFromScreen( + ScreenUtil::ConvertRectFromScreen( shelf_widget()->GetNativeView(), window->GetBoundsInScreen()).CenterPoint()); } diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index a298a90..3f22fce 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc @@ -12,7 +12,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/session_state_delegate.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_bezel_event_filter.h" @@ -271,7 +271,7 @@ ShelfAlignment ShelfLayoutManager::GetAlignment() const { gfx::Rect ShelfLayoutManager::GetIdealBounds() { gfx::Rect bounds( - ScreenAsh::GetDisplayBoundsInParent(shelf_->GetNativeView())); + ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView())); int width = 0, height = 0; GetShelfSize(&width, &height); return SelectValueForShelfAlignment( @@ -674,7 +674,7 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity( status_animation_setter.AddObserver(observer); GetLayer(shelf_)->SetOpacity(target_bounds.opacity); - shelf_->SetBounds(ScreenAsh::ConvertRectToScreen( + shelf_->SetBounds(ScreenUtil::ConvertRectToScreen( shelf_->GetNativeView()->parent(), target_bounds.shelf_bounds_in_root)); @@ -688,7 +688,7 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity( status_bounds.set_y(status_bounds.y() + target_bounds.shelf_bounds_in_root.y()); shelf_->status_area_widget()->SetBounds( - ScreenAsh::ConvertRectToScreen( + ScreenUtil::ConvertRectToScreen( shelf_->status_area_widget()->GetNativeView()->parent(), status_bounds)); Shell::GetInstance()->SetDisplayWorkAreaInsets( diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc index 5c6d36b..9ed79d7 100644 --- a/ash/shelf/shelf_layout_manager_unittest.cc +++ b/ash/shelf/shelf_layout_manager_unittest.cc @@ -10,7 +10,6 @@ #include "ash/display/display_manager.h" #include "ash/focus_cycler.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" #include "ash/session_state_delegate.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_layout_manager_observer.h" diff --git a/ash/shell.cc b/ash/shell.cc index 6845d4a..5e81698 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -36,7 +36,6 @@ #include "ash/media_delegate.h" #include "ash/new_window_delegate.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" #include "ash/session_state_delegate.h" #include "ash/shelf/app_list_shelf_item_delegate.h" #include "ash/shelf/shelf_delegate.h" @@ -83,7 +82,6 @@ #include "ash/wm/workspace_controller.h" #include "base/bind.h" #include "base/command_line.h" -#include "base/debug/leak_annotations.h" #include "base/debug/trace_event.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/user_action_client.h" @@ -569,8 +567,7 @@ void Shell::SetGPUSupport(scoped_ptr<GPUSupport> gpu_support) { // Shell, private: Shell::Shell(ShellDelegate* delegate) - : screen_(new ScreenAsh), - target_root_window_(NULL), + : target_root_window_(NULL), scoped_target_root_window_(NULL), delegate_(delegate), window_positioner_(new WindowPositioner), @@ -586,11 +583,6 @@ Shell::Shell(ShellDelegate* delegate) gpu_support_(new DefaultGPUSupportImpl) { DCHECK(delegate_.get()); display_manager_.reset(new internal::DisplayManager); - - ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_); - if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)) - gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_); display_controller_.reset(new DisplayController); #if defined(OS_CHROMEOS) && defined(USE_X11) output_configurator_->Init(!gpu_support_->IsPanelFittingDisabled()); @@ -712,6 +704,7 @@ Shell::~Shell() { // This also deletes all RootWindows. Note that we invoke Shutdown() on // DisplayController before resetting |display_controller_|, since destruction // of its owned RootWindowControllers relies on the value. + display_manager_->CreateScreenForShutdown(); display_controller_->Shutdown(); display_controller_.reset(); screen_position_controller_.reset(); @@ -811,7 +804,7 @@ void Shell::Init() { resolution_notification_controller_.reset( new internal::ResolutionNotificationController); - cursor_manager_.SetDisplay(DisplayController::GetPrimaryDisplay()); + cursor_manager_.SetDisplay(GetScreen()->GetPrimaryDisplay()); nested_dispatcher_controller_.reset(new NestedDispatcherController); accelerator_controller_.reset(new AcceleratorController); diff --git a/ash/shell.h b/ash/shell.h index ff58e66..d2019f9 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -414,8 +414,6 @@ class ASH_EXPORT Shell return shelf_item_delegate_manager_.get(); } - ScreenAsh* screen() { return screen_; } - // Force the shelf to query for it's current visibility state. void UpdateShelfVisibility(); @@ -582,8 +580,6 @@ class ASH_EXPORT Shell // when the screen is initially created. static bool initially_hide_cursor_; - ScreenAsh* screen_; - // When no explicit target display/RootWindow is given, new windows are // created on |scoped_target_root_window_| , unless NULL in // which case they are created on |target_root_window_|. diff --git a/ash/shell/panel_window.cc b/ash/shell/panel_window.cc index 3e59680..8776be7 100644 --- a/ash/shell/panel_window.cc +++ b/ash/shell/panel_window.cc @@ -4,7 +4,7 @@ #include "ash/shell/panel_window.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/wm/panels/panel_frame_view.h" #include "base/strings/utf_string_conversions.h" @@ -46,7 +46,7 @@ views::Widget* PanelWindow::CreateWidget() { params().bounds.set_width(kDefaultWidth); if (params().bounds.height() == 0) params().bounds.set_height(kDefaultHeight); - params().bounds = ScreenAsh::ConvertRectToScreen( + params().bounds = ScreenUtil::ConvertRectToScreen( Shell::GetTargetRootWindow(), params().bounds); diff --git a/ash/shell/toplevel_window.cc b/ash/shell/toplevel_window.cc index 4223732..16fba79 100644 --- a/ash/shell/toplevel_window.cc +++ b/ash/shell/toplevel_window.cc @@ -5,7 +5,6 @@ #include "ash/shell/toplevel_window.h" #include "ash/display/display_controller.h" -#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/wm/window_positioner.h" #include "ash/wm/window_state.h" diff --git a/ash/system/chromeos/tray_display_unittest.cc b/ash/system/chromeos/tray_display_unittest.cc index 647c519..ab0f185 100644 --- a/ash/system/chromeos/tray_display_unittest.cc +++ b/ash/system/chromeos/tray_display_unittest.cc @@ -6,7 +6,7 @@ #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/system/tray/system_tray.h" #include "ash/test/ash_test_base.h" @@ -61,7 +61,7 @@ base::string16 GetFirstDisplayName() { base::string16 GetSecondDisplayName() { return base::UTF8ToUTF16( Shell::GetInstance()->display_manager()->GetDisplayNameForId( - ScreenAsh::GetSecondaryDisplay().id())); + ScreenUtil::GetSecondaryDisplay().id())); } base::string16 GetMirroredDisplayName() { @@ -263,7 +263,7 @@ TEST_F(TrayDisplayTest, InternalDisplayResized) { // Closed lid mode. display_manager->SetSoftwareMirroring(false); UpdateDisplay("400x400@1.5,200x200"); - gfx::Display::SetInternalDisplayId(ScreenAsh::GetSecondaryDisplay().id()); + gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id()); UpdateDisplay("400x400@1.5"); tray()->ShowDefaultView(BUBBLE_USE_EXISTING); EXPECT_TRUE(IsDisplayVisibleInTray()); @@ -286,7 +286,7 @@ TEST_F(TrayDisplayTest, ExternalDisplayResized) { // Extended UpdateDisplay("400x400,200x200@1.5"); - const gfx::Display& secondary_display = ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary_display = ScreenUtil::GetSecondaryDisplay(); tray()->ShowDefaultView(BUBBLE_USE_EXISTING); EXPECT_TRUE(IsDisplayVisibleInTray()); @@ -339,7 +339,7 @@ TEST_F(TrayDisplayTest, OverscanDisplay) { // reset the overscan. display_manager->SetOverscanInsets( - ScreenAsh::GetSecondaryDisplay().id(), gfx::Insets()); + ScreenUtil::GetSecondaryDisplay().id(), gfx::Insets()); headline = l10n_util::GetStringFUTF16( IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, l10n_util::GetStringFUTF16( @@ -496,7 +496,7 @@ TEST_F(TrayDisplayTest, DisplayNotifications) { // Enters closed lid mode. UpdateDisplay("400x400@1.5,200x200"); - gfx::Display::SetInternalDisplayId(ScreenAsh::GetSecondaryDisplay().id()); + gfx::Display::SetInternalDisplayId(ScreenUtil::GetSecondaryDisplay().id()); UpdateDisplay("400x400@1.5"); EXPECT_EQ(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISPLAY_DOCKED), GetDisplayNotificationText()); diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc index 37af49d..0ad7431 100644 --- a/ash/system/tray/tray_background_view.cc +++ b/ash/system/tray/tray_background_view.cc @@ -6,7 +6,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" @@ -580,7 +580,7 @@ gfx::Rect TrayBackgroundView::GetBubbleAnchorRect( rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment, rect.height() - kPaddingFromBottomOfScreenBottomAlignment, 0, 0); - rect = ScreenAsh::ConvertRectToScreen(target_root, rect); + rect = ScreenUtil::ConvertRectToScreen(target_root, rect); } return rect; } diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index 3e00bb8..fa0aa52 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -9,7 +9,6 @@ #include "ash/ash_switches.h" #include "ash/display/display_controller.h" -#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell/toplevel_window.h" #include "ash/test/ash_test_helper.h" diff --git a/ash/touch/touch_observer_hud_unittest.cc b/ash/touch/touch_observer_hud_unittest.cc index 90328a8..98fb385 100644 --- a/ash/touch/touch_observer_hud_unittest.cc +++ b/ash/touch/touch_observer_hud_unittest.cc @@ -7,7 +7,7 @@ #include "ash/ash_switches.h" #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/display_manager_test_api.h" @@ -49,7 +49,7 @@ class TouchHudTestBase : public test::AshTestBase { } const gfx::Display& GetSecondaryDisplay() { - return ScreenAsh::GetSecondaryDisplay(); + return ScreenUtil::GetSecondaryDisplay(); } void SetupSingleDisplay() { diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index d8c161d..560f004 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -6,7 +6,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" @@ -170,7 +170,7 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { gfx::Rect applist_button_bounds = Shelf::ForWindow(container)-> GetAppListButtonView()->GetBoundsInScreen(); // We need the location of the button within the local screen. - applist_button_bounds = ash::ScreenAsh::ConvertRectFromScreen( + applist_button_bounds = ScreenUtil::ConvertRectFromScreen( root_window, applist_button_bounds); view->InitAsBubbleAttachedToAnchor( @@ -196,7 +196,7 @@ void AppListController::SetVisible(bool visible, aura::Window* window) { // By setting us as DnD recipient, the app list knows that we can // handle items. if (!CommandLine::ForCurrentProcess()->HasSwitch( - ash::switches::kAshDisableDragAndDropAppListToLauncher)) { + switches::kAshDisableDragAndDropAppListToLauncher)) { SetDragAndDropHostOfCurrentAppList( Shelf::ForWindow(window)->GetDragAndDropHostForAppList()); } @@ -287,11 +287,11 @@ void AppListController::ProcessLocatedEvent(ui::LocatedEvent* event) { GetRootWindowController(target->GetRootWindow()); if (root_controller) { aura::Window* menu_container = root_controller->GetContainer( - ash::internal::kShellWindowId_MenuContainer); + internal::kShellWindowId_MenuContainer); if (menu_container->Contains(target)) return; aura::Window* keyboard_container = root_controller->GetContainer( - ash::internal::kShellWindowId_VirtualKeyboardContainer); + internal::kShellWindowId_VirtualKeyboardContainer); if (keyboard_container->Contains(target)) return; } diff --git a/ash/wm/base_layout_manager.cc b/ash/wm/base_layout_manager.cc index 55daac7..14f80d3 100644 --- a/ash/wm/base_layout_manager.cc +++ b/ash/wm/base_layout_manager.cc @@ -4,7 +4,7 @@ #include "ash/wm/base_layout_manager.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" @@ -49,7 +49,7 @@ gfx::Rect BaseLayoutManager::BoundsWithScreenEdgeVisible( aura::Window* window, const gfx::Rect& restore_bounds) { gfx::Rect max_bounds = - ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window); + ash::ScreenUtil::GetMaximizedWindowBoundsInParent(window); // If the restore_bounds are more than 1 grid step away from the size the // window would be when maximized, inset it. max_bounds.Inset(ash::internal::WorkspaceWindowResizer::kScreenEdgeInset, @@ -100,9 +100,9 @@ void BaseLayoutManager::SetChildBounds(aura::Window* child, wm::WindowState* window_state = wm::GetWindowState(child); // Some windows rely on this to set their initial bounds. if (window_state->IsMaximized()) - child_bounds = ScreenAsh::GetMaximizedWindowBoundsInParent(child); + child_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent(child); else if (window_state->IsFullscreen()) - child_bounds = ScreenAsh::GetDisplayBoundsInParent(child); + child_bounds = ScreenUtil::GetDisplayBoundsInParent(child); SetChildBoundsDirect(child, child_bounds); } @@ -221,14 +221,14 @@ void BaseLayoutManager::AdjustWindowBoundsForWorkAreaChange( aura::Window* window = window_state->window(); if (window_state->IsMaximized()) { SetChildBoundsDirect( - window, ScreenAsh::GetMaximizedWindowBoundsInParent(window)); + window, ScreenUtil::GetMaximizedWindowBoundsInParent(window)); } else if (window_state->IsFullscreen()) { SetChildBoundsDirect( - window, ScreenAsh::GetDisplayBoundsInParent(window)); + window, ScreenUtil::GetDisplayBoundsInParent(window)); } else { // The work area may be smaller than the full screen. gfx::Rect display_rect = - ScreenAsh::GetDisplayWorkAreaBoundsInParent(window); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); // Put as much of the window as possible within the display area. gfx::Rect bounds = window->bounds(); bounds.AdjustToFit(display_rect); @@ -263,14 +263,14 @@ void BaseLayoutManager::UpdateBoundsFromShowType( case wm::SHOW_TYPE_MAXIMIZED: SetChildBoundsDirect( - window, ScreenAsh::GetMaximizedWindowBoundsInParent(window)); + window, ScreenUtil::GetMaximizedWindowBoundsInParent(window)); break; case wm::SHOW_TYPE_FULLSCREEN: // Don't animate the full-screen window transition. // TODO(jamescook): Use animation here. Be sure the lock screen works. SetChildBoundsDirect(window, - ScreenAsh::GetDisplayBoundsInParent(window)); + ScreenUtil::GetDisplayBoundsInParent(window)); break; case wm::SHOW_TYPE_MINIMIZED: diff --git a/ash/wm/base_layout_manager_unittest.cc b/ash/wm/base_layout_manager_unittest.cc index f58c61f..b869648 100644 --- a/ash/wm/base_layout_manager_unittest.cc +++ b/ash/wm/base_layout_manager_unittest.cc @@ -4,7 +4,7 @@ #include "ash/wm/base_layout_manager.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/session_state_delegate.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" @@ -57,7 +57,7 @@ TEST_F(BaseLayoutManagerTest, Maximize) { window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); // Maximized window fills the work area, not the whole display. EXPECT_EQ( - ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString(), + ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), window->bounds().ToString()); window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); EXPECT_EQ(bounds.ToString(), window->bounds().ToString()); @@ -132,16 +132,16 @@ TEST_F(BaseLayoutManagerTest, MaximizeRootWindowResize) { scoped_ptr<aura::Window> window(CreateTestWindow(bounds)); window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); gfx::Rect initial_work_area_bounds = - ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()); + ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()); EXPECT_EQ(initial_work_area_bounds.ToString(), window->bounds().ToString()); // Enlarge the root window. We should still match the work area size. UpdateDisplay("900x700"); EXPECT_EQ( - ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString(), + ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), window->bounds().ToString()); EXPECT_NE( initial_work_area_bounds.ToString(), - ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString()); + ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString()); } // Tests normal->fullscreen->normal. @@ -218,7 +218,7 @@ TEST_F(BaseLayoutManagerTest, BoundsWithScreenEdgeVisible) { // It should have the default maximized window bounds, inset by the grid size. int grid_size = internal::WorkspaceWindowResizer::kScreenEdgeInset; gfx::Rect max_bounds = - ash::ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()); + ash::ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()); max_bounds.Inset(grid_size, grid_size); EXPECT_EQ(max_bounds.ToString(), window->bounds().ToString()); } @@ -292,16 +292,16 @@ TEST_F(BaseLayoutManagerTest, NotResizeWhenScreenIsLocked) { internal::ShelfLayoutManager::ForShelf(window.get()); shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); - window->SetBounds(ScreenAsh::GetMaximizedWindowBoundsInParent(window.get())); + window->SetBounds(ScreenUtil::GetMaximizedWindowBoundsInParent(window.get())); gfx::Rect window_bounds = window->bounds(); EXPECT_EQ( - ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString(), + ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), window_bounds.ToString()); Shell::GetInstance()->session_state_delegate()->LockScreen(); shelf->UpdateVisibilityState(); EXPECT_NE( - ScreenAsh::GetMaximizedWindowBoundsInParent(window.get()).ToString(), + ScreenUtil::GetMaximizedWindowBoundsInParent(window.get()).ToString(), window_bounds.ToString()); Shell::GetInstance()->session_state_delegate()->UnlockScreen(); diff --git a/ash/wm/caption_buttons/alternate_frame_size_button.cc b/ash/wm/caption_buttons/alternate_frame_size_button.cc index dc3a614..66ff4b1 100644 --- a/ash/wm/caption_buttons/alternate_frame_size_button.cc +++ b/ash/wm/caption_buttons/alternate_frame_size_button.cc @@ -5,7 +5,7 @@ #include "ash/wm/caption_buttons/alternate_frame_size_button.h" #include "ash/metrics/user_metrics_recorder.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/touch/touch_uma.h" #include "ash/wm/window_state.h" @@ -191,7 +191,7 @@ void AlternateFrameSizeButton::UpdatePressedButton( snap_type_ == SNAP_LEFT ? SnapSizer::LEFT_EDGE : SnapSizer::RIGHT_EDGE, SnapSizer::OTHER_INPUT); - phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen( + phantom_window_controller_->Show(ScreenUtil::ConvertRectToScreen( frame_->GetNativeView()->parent(), snap_sizer.target_bounds())); } else { diff --git a/ash/wm/caption_buttons/frame_maximize_button.cc b/ash/wm/caption_buttons/frame_maximize_button.cc index d2f24f0..03eaa81 100644 --- a/ash/wm/caption_buttons/frame_maximize_button.cc +++ b/ash/wm/caption_buttons/frame_maximize_button.cc @@ -5,7 +5,7 @@ #include "ash/wm/caption_buttons/frame_maximize_button.h" #include "ash/metrics/user_metrics_recorder.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" #include "ash/touch/touch_uma.h" @@ -426,7 +426,7 @@ void FrameMaximizeButton::UpdateSnap(const gfx::Point& location, if (type == snap_type_) { if (snap_sizer_) { snap_sizer_->Update(LocationForSnapSizer(location)); - phantom_window_->Show(ScreenAsh::ConvertRectToScreen( + phantom_window_->Show(ScreenUtil::ConvertRectToScreen( frame_->GetNativeView()->parent(), snap_sizer_->target_bounds())); } @@ -490,12 +490,12 @@ gfx::Rect FrameMaximizeButton::ScreenBoundsForType( switch (type) { case SNAP_LEFT: case SNAP_RIGHT: - return ScreenAsh::ConvertRectToScreen(window->parent(), + return ScreenUtil::ConvertRectToScreen(window->parent(), snap_sizer.target_bounds()); case SNAP_MAXIMIZE: - return ScreenAsh::ConvertRectToScreen( + return ScreenUtil::ConvertRectToScreen( window->parent(), - ScreenAsh::GetMaximizedWindowBoundsInParent(window)); + ScreenUtil::GetMaximizedWindowBoundsInParent(window)); case SNAP_MINIMIZE: { gfx::Rect rect = GetMinimizeAnimationTargetBoundsInScreen(window); if (!rect.IsEmpty()) { diff --git a/ash/wm/dock/docked_window_layout_manager.cc b/ash/wm/dock/docked_window_layout_manager.cc index d5a3734..36dfa94 100644 --- a/ash/wm/dock/docked_window_layout_manager.cc +++ b/ash/wm/dock/docked_window_layout_manager.cc @@ -5,7 +5,7 @@ #include "ash/wm/dock/docked_window_layout_manager.h" #include "ash/ash_switches.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_constants.h" #include "ash/shelf/shelf_layout_manager.h" @@ -311,9 +311,9 @@ struct CompareWindowPos { // reordered. aura::Window* win1(window_with_height1.window()); aura::Window* win2(window_with_height2.window()); - gfx::Rect win1_bounds = ScreenAsh::ConvertRectToScreen( + gfx::Rect win1_bounds = ScreenUtil::ConvertRectToScreen( win1->parent(), win1->GetTargetBounds()); - gfx::Rect win2_bounds = ScreenAsh::ConvertRectToScreen( + gfx::Rect win2_bounds = ScreenUtil::ConvertRectToScreen( win2->parent(), win2->GetTargetBounds()); win1_bounds.set_height(window_with_height1.height_); win2_bounds.set_height(window_with_height2.height_); @@ -382,7 +382,7 @@ class DockedWindowLayoutManager::ShelfWindowObserver : public WindowObserver { virtual void OnWindowBoundsChanged(aura::Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) OVERRIDE { - shelf_bounds_in_screen_ = ScreenAsh::ConvertRectToScreen( + shelf_bounds_in_screen_ = ScreenUtil::ConvertRectToScreen( window->parent(), new_bounds); docked_layout_manager_->OnShelfBoundsChanged(); } @@ -1153,7 +1153,7 @@ void DockedWindowLayoutManager::FanOutChildren( for (std::vector<WindowWithHeight>::iterator iter = visible_windows->begin(); iter != visible_windows->end(); ++iter) { aura::Window* window = iter->window(); - gfx::Rect bounds = ScreenAsh::ConvertRectToScreen( + gfx::Rect bounds = ScreenUtil::ConvertRectToScreen( window->parent(), window->GetTargetBounds()); // A window is extended or shrunk to be as close as possible to the ideal // docked area width. Windows that were resized by a user are kept at their @@ -1200,7 +1200,7 @@ void DockedWindowLayoutManager::FanOutChildren( // If the following asserts it is probably because not all the children // have been removed when dock was closed. DCHECK_NE(alignment_, DOCKED_ALIGNMENT_NONE); - bounds = ScreenAsh::ConvertRectFromScreen(dock_container_, bounds); + bounds = ScreenUtil::ConvertRectFromScreen(dock_container_, bounds); if (bounds != window->GetTargetBounds()) { ui::Layer* layer = window->layer(); ui::ScopedLayerAnimationSettings slide_settings(layer->GetAnimator()); diff --git a/ash/wm/dock/docked_window_layout_manager_unittest.cc b/ash/wm/dock/docked_window_layout_manager_unittest.cc index 853cd25..32f0a02 100644 --- a/ash/wm/dock/docked_window_layout_manager_unittest.cc +++ b/ash/wm/dock/docked_window_layout_manager_unittest.cc @@ -6,7 +6,6 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_model.h" diff --git a/ash/wm/dock/docked_window_resizer.cc b/ash/wm/dock/docked_window_resizer.cc index f3e4561..f4d1e00 100644 --- a/ash/wm/dock/docked_window_resizer.cc +++ b/ash/wm/dock/docked_window_resizer.cc @@ -6,7 +6,7 @@ #include "ash/display/display_controller.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_types.h" #include "ash/shelf/shelf_widget.h" @@ -38,7 +38,7 @@ namespace { DockedWindowLayoutManager* GetDockedLayoutManagerAtPoint( const gfx::Point& point) { - gfx::Display display = ScreenAsh::FindDisplayContainingPoint(point); + gfx::Display display = ScreenUtil::FindDisplayContainingPoint(point); if (!display.is_valid()) return NULL; aura::Window* root = Shell::GetInstance()->display_controller()-> @@ -157,7 +157,7 @@ void DockedWindowResizer::MaybeSnapToEdge(const gfx::Rect& bounds, if (!was_docked_) return; DockedAlignment dock_alignment = dock_layout_->CalculateAlignment(); - gfx::Rect dock_bounds = ScreenAsh::ConvertRectFromScreen( + gfx::Rect dock_bounds = ScreenUtil::ConvertRectFromScreen( GetTarget()->parent(), dock_layout_->dock_container()->GetBoundsInScreen()); @@ -227,7 +227,7 @@ void DockedWindowResizer::FinishedDragging( // When drag is completed the dragged docked window is resized to the bounds // calculated by the layout manager that conform to other docked windows. if (!is_attached_panel && is_docked_ && !is_resized) { - gfx::Rect bounds = ScreenAsh::ConvertRectFromScreen( + gfx::Rect bounds = ScreenUtil::ConvertRectFromScreen( window->parent(), dock_layout_->dragged_bounds()); if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { window->SetBounds(bounds); diff --git a/ash/wm/dock/docked_window_resizer_unittest.cc b/ash/wm/dock/docked_window_resizer_unittest.cc index 1aac42b..61d57fe 100644 --- a/ash/wm/dock/docked_window_resizer_unittest.cc +++ b/ash/wm/dock/docked_window_resizer_unittest.cc @@ -6,7 +6,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_model.h" @@ -738,8 +738,8 @@ TEST_P(DockedWindowResizerTest, AttachTwoWindowsDetachOne) { scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); // Work area should cover the whole screen. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); // A window should be docked at the right edge. @@ -810,8 +810,8 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); // Work area should cover the whole screen. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); // A window should be docked at the right edge. @@ -845,15 +845,15 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { EXPECT_EQ(DOCKED_ALIGNMENT_RIGHT, docked_alignment(manager)); EXPECT_EQ(w1->bounds().width(), docked_width(manager)); // Desktop work area should now shrink. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - docked_width(manager) - min_dock_gap(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); // Maximize the second window - Maximized area should be shrunk. const gfx::Rect restored_bounds = w2->bounds(); wm::WindowState* w2_state = wm::GetWindowState(w2.get()); w2_state->Maximize(); - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - docked_width(manager) - min_dock_gap(), w2->bounds().width()); @@ -872,7 +872,7 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { EXPECT_EQ(DOCKED_ALIGNMENT_NONE, docked_alignment(manager)); EXPECT_EQ(0, docked_width(manager)); // The second window should now get resized and take up the whole screen. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), w2->bounds().width()); // Dock the first window to the left edge. @@ -891,7 +891,7 @@ TEST_P(DockedWindowResizerTest, AttachWindowMaximizeOther) { // Second window should still be in the desktop. EXPECT_EQ(internal::kShellWindowId_DefaultContainer, w2->parent()->id()); // Maximized window should be shrunk. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - docked_width(manager) - min_dock_gap(), w2->bounds().width()); @@ -909,8 +909,8 @@ TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); // Work area should cover the whole screen. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); DragToVerticalPositionAndToEdge(DOCKED_EDGE_LEFT, w1.get(), 20); // A window should be docked at the left edge. @@ -992,9 +992,9 @@ TEST_P(DockedWindowResizerTest, AttachOneTestSticky) { EXPECT_EQ(std::max(w1->bounds().width(), w2->bounds().width()), docked_width(manager)); // Desktop work area should now shrink by dock width. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - docked_width(manager) - min_dock_gap(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); } // Dock two windows, resize one. @@ -1008,8 +1008,8 @@ TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); scoped_ptr<aura::Window> w2(CreateTestWindow(gfx::Rect(0, 0, 210, 201))); // Work area should cover the whole screen. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width(), + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); // A window should be docked at the right edge. @@ -1052,9 +1052,9 @@ TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); EXPECT_EQ(w1->bounds().width(), docked_width(manager)); // Desktop work area should shrink. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - docked_width(manager) - min_dock_gap(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); // Resize the first window left by more than the dock maximum width. // This should cause the window width to be restricted by maximum dock width. @@ -1079,9 +1079,9 @@ TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { EXPECT_EQ(w1->bounds().width(), w2->bounds().width()); EXPECT_EQ(w1->bounds().width(), docked_width(manager)); // Desktop work area should shrink. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - docked_width(manager) - min_dock_gap(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); // Resize the first window right to get it completely inside the docked area. previous_width = w1->bounds().width(); @@ -1105,9 +1105,9 @@ TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { // The dock should be as wide as w1 or w2. EXPECT_EQ(w1->bounds().width(), docked_width(manager)); // Desktop work area should shrink. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w2.get()).width() - + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w2.get()).width() - docked_width(manager) - min_dock_gap(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w2.get()).width()); // Resize the first window left to be overhang again. previous_width = w1->bounds().width(); @@ -1138,9 +1138,9 @@ TEST_P(DockedWindowResizerTest, ResizeOneOfTwoWindows) { // The second window should be still docked. EXPECT_EQ(internal::kShellWindowId_DockedContainer, w2->parent()->id()); // Desktop work area should be inset. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w1.get()).width() - + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width() - docked_width(manager) - min_dock_gap(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); } // Dock a window, resize it and test that undocking it preserves the width. @@ -1336,8 +1336,8 @@ TEST_P(DockedWindowResizerTest, DragToShelf) { scoped_ptr<aura::Window> w1(CreateTestWindow(gfx::Rect(0, 0, 201, 201))); // Work area should cover the whole screen. - EXPECT_EQ(ScreenAsh::GetDisplayBoundsInParent(w1.get()).width(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); + EXPECT_EQ(ScreenUtil::GetDisplayBoundsInParent(w1.get()).width(), + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).width()); DragToVerticalPositionAndToEdge(DOCKED_EDGE_RIGHT, w1.get(), 20); // A window should be docked at the right edge. @@ -1482,7 +1482,7 @@ TEST_P(DockedWindowResizerTest, SideSnapDocked) { internal::SnapSizer::SnapWindow(window_state, internal::SnapSizer::RIGHT_EDGE); // The window should be snapped at the right edge and the dock should close. - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get())); + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get())); EXPECT_EQ(0, docked_width(manager)); EXPECT_EQ(work_area.height(), w1->bounds().height()); EXPECT_EQ(work_area.right(), w1->bounds().right()); @@ -1506,7 +1506,7 @@ TEST_P(DockedWindowResizerTest, SideSnapDocked) { internal::SnapSizer::LEFT_EDGE); // The window should be snapped at the right edge and the dock should close. EXPECT_EQ(work_area.ToString(), - ScreenAsh::GetDisplayWorkAreaBoundsInParent(w1.get()).ToString()); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(w1.get()).ToString()); EXPECT_EQ(0, docked_width(manager)); EXPECT_EQ(work_area.height(), w1->bounds().height()); EXPECT_EQ(work_area.x(), w1->bounds().x()); diff --git a/ash/wm/drag_window_resizer.cc b/ash/wm/drag_window_resizer.cc index c678d16..263f399 100644 --- a/ash/wm/drag_window_resizer.cc +++ b/ash/wm/drag_window_resizer.cc @@ -6,7 +6,7 @@ #include "ash/display/mouse_cursor_event_filter.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/system/tray/system_tray.h" #include "ash/system/user/tray_user.h" @@ -135,7 +135,7 @@ void DragWindowResizer::CompleteDrag() { bounds.set_height(size.height()); gfx::Rect dst_bounds = - ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds); + ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), bounds); // Adjust the position so that the cursor is on the window. if (!dst_bounds.Contains(last_mouse_location_in_screen)) { @@ -189,7 +189,7 @@ void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds, GetAnotherRootWindow(GetTarget()->GetRootWindow()); const gfx::Rect root_bounds_in_screen(another_root->GetBoundsInScreen()); const gfx::Rect bounds_in_screen = - ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds); + ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), bounds); gfx::Rect bounds_in_another_root = gfx::IntersectRects(root_bounds_in_screen, bounds_in_screen); const float fraction_in_another_window = diff --git a/ash/wm/gestures/system_pinch_handler.cc b/ash/wm/gestures/system_pinch_handler.cc index 981dc24..f1e0ffd 100644 --- a/ash/wm/gestures/system_pinch_handler.cc +++ b/ash/wm/gestures/system_pinch_handler.cc @@ -4,7 +4,7 @@ #include "ash/wm/gestures/system_pinch_handler.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" @@ -114,9 +114,9 @@ gfx::Rect SystemPinchHandler::GetPhantomWindowScreenBounds( const gfx::Point& point) { if (pinch_factor_ > kPinchThresholdForMaximize) { phantom_state_ = PHANTOM_WINDOW_MAXIMIZED; - return ScreenAsh::ConvertRectToScreen( + return ScreenUtil::ConvertRectToScreen( target_->parent(), - ScreenAsh::GetMaximizedWindowBoundsInParent(target_)); + ScreenUtil::GetMaximizedWindowBoundsInParent(target_)); } if (pinch_factor_ < kPinchThresholdForMinimize) { diff --git a/ash/wm/immersive_fullscreen_controller_unittest.cc b/ash/wm/immersive_fullscreen_controller_unittest.cc index c51217c..3172034 100644 --- a/ash/wm/immersive_fullscreen_controller_unittest.cc +++ b/ash/wm/immersive_fullscreen_controller_unittest.cc @@ -6,7 +6,6 @@ #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_types.h" #include "ash/shell.h" diff --git a/ash/wm/overview/scoped_transform_overview_window.cc b/ash/wm/overview/scoped_transform_overview_window.cc index 12b7c0c6..9beb49f 100644 --- a/ash/wm/overview/scoped_transform_overview_window.cc +++ b/ash/wm/overview/scoped_transform_overview_window.cc @@ -4,7 +4,7 @@ #include "ash/wm/overview/scoped_transform_overview_window.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/wm/overview/scoped_window_copy.h" #include "ash/wm/window_state.h" @@ -139,7 +139,7 @@ gfx::Rect ScopedTransformOverviewWindow::GetBoundsInScreen() const { gfx::Rect bounds; aura::Window* window = window_; while (window) { - bounds.Union(ScreenAsh::ConvertRectToScreen(window->parent(), + bounds.Union(ScreenUtil::ConvertRectToScreen(window->parent(), window->GetTargetBounds())); window = GetModalTransientParent(window); } @@ -245,7 +245,7 @@ void ScopedTransformOverviewWindow::SetTransformOnWindowAndTransientChildren( window_copies_.begin(); iter != window_copies_.end(); ++iter) { SetTransformOnWindow( (*iter)->GetWindow(), - TranslateTransformOrigin(ScreenAsh::ConvertRectToScreen( + TranslateTransformOrigin(ScreenUtil::ConvertRectToScreen( (*iter)->GetWindow()->parent(), (*iter)->GetWindow()->GetTargetBounds()).origin() - origin, transform), @@ -253,7 +253,7 @@ void ScopedTransformOverviewWindow::SetTransformOnWindowAndTransientChildren( } SetTransformOnWindowAndAllTransientChildren( window, - TranslateTransformOrigin(ScreenAsh::ConvertRectToScreen( + TranslateTransformOrigin(ScreenUtil::ConvertRectToScreen( window->parent(), window->GetTargetBounds()).origin() - origin, transform), animate); diff --git a/ash/wm/overview/scoped_window_copy.cc b/ash/wm/overview/scoped_window_copy.cc index 660b284..59acf73 100644 --- a/ash/wm/overview/scoped_window_copy.cc +++ b/ash/wm/overview/scoped_window_copy.cc @@ -4,7 +4,7 @@ #include "ash/wm/overview/scoped_window_copy.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/screen_position_client.h" diff --git a/ash/wm/overview/window_overview.cc b/ash/wm/overview/window_overview.cc index a7df1f7..4e7051b 100644 --- a/ash/wm/overview/window_overview.cc +++ b/ash/wm/overview/window_overview.cc @@ -7,7 +7,7 @@ #include <algorithm> #include "ash/metrics/user_metrics_recorder.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/mru_window_tracker.h" @@ -373,8 +373,8 @@ void WindowOverview::PositionWindowsOnRoot( return; gfx::Size window_size; - gfx::Rect total_bounds = ScreenAsh::ConvertRectToScreen(root_window, - ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect total_bounds = ScreenUtil::ConvertRectToScreen(root_window, + ScreenUtil::GetDisplayWorkAreaBoundsInParent( Shell::GetContainer(root_window, internal::kShellWindowId_DefaultContainer))); diff --git a/ash/wm/overview/window_selector_panels.cc b/ash/wm/overview/window_selector_panels.cc index 38ae9f6..37d6687 100644 --- a/ash/wm/overview/window_selector_panels.cc +++ b/ash/wm/overview/window_selector_panels.cc @@ -4,7 +4,6 @@ #include "ash/wm/overview/window_selector_panels.h" -#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/overview/scoped_transform_overview_window.h" diff --git a/ash/wm/overview/window_selector_unittest.cc b/ash/wm/overview/window_selector_unittest.cc index 52bca15..ae3d380 100644 --- a/ash/wm/overview/window_selector_unittest.cc +++ b/ash/wm/overview/window_selector_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" @@ -172,7 +172,7 @@ class WindowSelectorTest : public test::AshTestBase { } gfx::RectF GetTransformedBounds(aura::Window* window) { - gfx::RectF bounds(ash::ScreenAsh::ConvertRectToScreen( + gfx::RectF bounds(ScreenUtil::ConvertRectToScreen( window->parent(), window->layer()->bounds())); gfx::Transform transform(GetTransformRelativeTo(bounds.origin(), window->layer()->transform())); @@ -181,7 +181,7 @@ class WindowSelectorTest : public test::AshTestBase { } gfx::RectF GetTransformedTargetBounds(aura::Window* window) { - gfx::RectF bounds(ash::ScreenAsh::ConvertRectToScreen( + gfx::RectF bounds(ScreenUtil::ConvertRectToScreen( window->parent(), window->layer()->GetTargetBounds())); gfx::Transform transform(GetTransformRelativeTo(bounds.origin(), window->layer()->GetTargetTransform())); diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc index 1338133..7bfe4ad 100644 --- a/ash/wm/panels/panel_layout_manager.cc +++ b/ash/wm/panels/panel_layout_manager.cc @@ -7,7 +7,7 @@ #include <algorithm> #include <map> -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_types.h" @@ -232,7 +232,7 @@ class PanelCalloutWidget : public views::Widget { params.keep_on_top = true; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.parent = parent; - params.bounds = ScreenAsh::ConvertRectToScreen(parent, gfx::Rect()); + params.bounds = ScreenUtil::ConvertRectToScreen(parent, gfx::Rect()); params.bounds.set_width(kArrowWidth); params.bounds.set_height(kArrowHeight); // Why do we need this and can_activate = false? @@ -586,7 +586,7 @@ void PanelLayoutManager::Relayout() { ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment(); bool horizontal = alignment == SHELF_ALIGNMENT_TOP || alignment == SHELF_ALIGNMENT_BOTTOM; - gfx::Rect shelf_bounds = ash::ScreenAsh::ConvertRectFromScreen( + gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen( panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen()); int panel_start_bounds = kPanelIdealSpacing; int panel_end_bounds = horizontal ? @@ -630,8 +630,8 @@ void PanelLayoutManager::Relayout() { DCHECK(!active_panel); active_panel = panel; } - icon_bounds = ScreenAsh::ConvertRectFromScreen(panel_container_, - icon_bounds); + icon_bounds = ScreenUtil::ConvertRectFromScreen(panel_container_, + icon_bounds); gfx::Point icon_origin = icon_bounds.origin(); VisiblePanelPositionInfo position_info; int icon_start = horizontal ? icon_origin.x() : icon_origin.y(); @@ -796,8 +796,9 @@ void PanelLayoutManager::UpdateCallouts() { views::Widget* callout_widget = iter->callout_widget; gfx::Rect current_bounds = panel->GetBoundsInScreen(); - gfx::Rect bounds = ScreenAsh::ConvertRectToScreen(panel->parent(), - panel->GetTargetBounds()); + gfx::Rect bounds = ScreenUtil::ConvertRectToScreen( + panel->parent(), + panel->GetTargetBounds()); gfx::Rect icon_bounds = shelf_->GetScreenBoundsOfItemIconForWindow(panel); if (icon_bounds.IsEmpty() || !panel->layer()->GetTargetVisibility() || panel == dragged_panel_) { @@ -838,7 +839,7 @@ void PanelLayoutManager::UpdateCallouts() { callout_bounds.set_y(bounds.y() - callout_bounds.height()); break; } - callout_bounds = ScreenAsh::ConvertRectFromScreen( + callout_bounds = ScreenUtil::ConvertRectFromScreen( callout_widget->GetNativeWindow()->parent(), callout_bounds); diff --git a/ash/wm/panels/panel_layout_manager_unittest.cc b/ash/wm/panels/panel_layout_manager_unittest.cc index e573f0c..9608ba4 100644 --- a/ash/wm/panels/panel_layout_manager_unittest.cc +++ b/ash/wm/panels/panel_layout_manager_unittest.cc @@ -6,7 +6,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_button.h" #include "ash/shelf/shelf_layout_manager.h" @@ -95,7 +95,7 @@ class PanelLayoutManagerTest : public test::AshTestBase { void PanelInScreen(aura::Window* panel) { gfx::Rect panel_bounds = panel->GetBoundsInRootWindow(); gfx::Point root_point = gfx::Point(panel_bounds.x(), panel_bounds.y()); - gfx::Display display = ScreenAsh::FindDisplayContainingPoint(root_point); + gfx::Display display = ScreenUtil::FindDisplayContainingPoint(root_point); gfx::Rect panel_bounds_in_screen = panel->GetBoundsInScreen(); gfx::Point screen_bottom_right = gfx::Point( diff --git a/ash/wm/panels/panel_window_resizer.cc b/ash/wm/panels/panel_window_resizer.cc index 8e4311a..b1db4a5 100644 --- a/ash/wm/panels/panel_window_resizer.cc +++ b/ash/wm/panels/panel_window_resizer.cc @@ -5,7 +5,7 @@ #include "ash/wm/panels/panel_window_resizer.h" #include "ash/display/display_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_types.h" #include "ash/shelf/shelf_widget.h" @@ -136,7 +136,7 @@ bool PanelWindowResizer::AttachToLauncher(const gfx::Rect& bounds, if (panel_container_) { internal::PanelLayoutManager* panel_layout_manager = GetPanelLayoutManager(panel_container_); - gfx::Rect launcher_bounds = ScreenAsh::ConvertRectFromScreen( + gfx::Rect launcher_bounds = ScreenUtil::ConvertRectFromScreen( GetTarget()->parent(), panel_layout_manager->shelf()-> shelf_widget()->GetWindowBoundsInScreen()); diff --git a/ash/wm/solo_window_tracker_unittest.cc b/ash/wm/solo_window_tracker_unittest.cc index d134c40..25a8d21 100644 --- a/ash/wm/solo_window_tracker_unittest.cc +++ b/ash/wm/solo_window_tracker_unittest.cc @@ -103,7 +103,7 @@ class SoloWindowTrackerTest : public test::AshTestBase { // Because the tests use windows without delegates, // aura::test::EventGenerator cannot be used. gfx::Point drag_to = - ash::ScreenAsh::GetDisplayBoundsInParent(window).top_right(); + ash::ScreenUtil::GetDisplayBoundsInParent(window).top_right(); scoped_ptr<WindowResizer> resizer(CreateWindowResizer( window, window->bounds().origin(), @@ -118,7 +118,7 @@ class SoloWindowTrackerTest : public test::AshTestBase { // Drag |window| out of the dock. void UndockWindow(aura::Window* window) { gfx::Point drag_to = - ash::ScreenAsh::GetDisplayWorkAreaBoundsInParent(window).top_right() - + ash::ScreenUtil::GetDisplayWorkAreaBoundsInParent(window).top_right() - gfx::Vector2d(10, 0); scoped_ptr<WindowResizer> resizer(CreateWindowResizer( window, @@ -138,7 +138,7 @@ class SoloWindowTrackerTest : public test::AshTestBase { // Returns the secondary display. gfx::Display GetSecondaryDisplay() { - return ScreenAsh::GetSecondaryDisplay(); + return ScreenUtil::GetSecondaryDisplay(); } // Returns the window which uses the solo header, if any, on the primary @@ -329,7 +329,7 @@ TEST_F(SoloWindowTrackerTest, MultiDisplay) { // Moves the second window to the secondary display. Both w1/w2 should be // solo. w2->SetBoundsInScreen(gfx::Rect(1200, 0, 100, 100), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); EXPECT_EQ(w1.get(), GetWindowWithSoloHeaderInPrimary()); EXPECT_EQ(w2.get(), GetWindowWithSoloHeader(w2->GetRootWindow())); EXPECT_TRUE(checker1.IsPaintScheduledAndReset()); diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc index dc010c4..5aecb06 100644 --- a/ash/wm/window_animations.cc +++ b/ash/wm/window_animations.cc @@ -9,7 +9,7 @@ #include <algorithm> #include <vector> -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_widget.h" @@ -79,7 +79,7 @@ void AddLayerAnimationsForMinimize(aura::Window* window, gfx::Rect bounds = window->bounds(); gfx::Rect target_bounds = GetMinimizeAnimationTargetBoundsInScreen(window); target_bounds = - ScreenAsh::ConvertRectFromScreen(window->parent(), target_bounds); + ScreenUtil::ConvertRectFromScreen(window->parent(), target_bounds); float scale_x = static_cast<float>(target_bounds.width()) / bounds.width(); float scale_y = static_cast<float>(target_bounds.height()) / bounds.height(); diff --git a/ash/wm/window_positioner.cc b/ash/wm/window_positioner.cc index d0129f8..51f92a4 100644 --- a/ash/wm/window_positioner.cc +++ b/ash/wm/window_positioner.cc @@ -5,7 +5,7 @@ #include "ash/wm/window_positioner.h" #include "ash/ash_switches.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/mru_window_tracker.h" @@ -85,7 +85,7 @@ gfx::Rect GetWorkAreaForWindowInParent(aura::Window* window) { window->parent()->GetBoundsInScreen()).GetWorkAreaInsets()); return work_area; #else - return ScreenAsh::GetDisplayWorkAreaBoundsInParent(window); + return ScreenUtil::GetDisplayWorkAreaBoundsInParent(window); #endif } diff --git a/ash/wm/window_resizer.cc b/ash/wm/window_resizer.cc index 2631cc6..5569646 100644 --- a/ash/wm/window_resizer.cc +++ b/ash/wm/window_resizer.cc @@ -4,7 +4,7 @@ #include "ash/wm/window_resizer.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/coordinate_conversion.h" @@ -149,7 +149,7 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( dock_container->layout_manager()); work_area.Union(dock_layout->docked_bounds()); - work_area = ScreenAsh::ConvertRectFromScreen(GetTarget()->parent(), + work_area = ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), work_area); if (details().size_change_direction & kBoundsChangeDirection_Horizontal) { if (IsRightEdge(details().window_component) && @@ -222,7 +222,7 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( screen_work_area.Union(dock_layout->docked_bounds()); screen_work_area.Inset(kMinimumOnScreenArea, 0); gfx::Rect new_bounds_in_screen = - ScreenAsh::ConvertRectToScreen(parent, new_bounds); + ScreenUtil::ConvertRectToScreen(parent, new_bounds); if (!screen_work_area.Intersects(new_bounds_in_screen)) { // Make sure that the x origin does not leave the current display. new_bounds_in_screen.set_x( @@ -230,7 +230,7 @@ gfx::Rect WindowResizer::CalculateBoundsForDrag( std::min(screen_work_area.right(), new_bounds_in_screen.x()))); new_bounds = - ScreenAsh::ConvertRectFromScreen(parent, new_bounds_in_screen); + ScreenUtil::ConvertRectFromScreen(parent, new_bounds_in_screen); } } diff --git a/ash/wm/window_state.cc b/ash/wm/window_state.cc index 7a5dacc..8553b9c 100644 --- a/ash/wm/window_state.cc +++ b/ash/wm/window_state.cc @@ -6,7 +6,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell_window_ids.h" #include "ash/wm/window_properties.h" #include "ash/wm/window_state_delegate.h" @@ -203,14 +203,14 @@ void WindowState::ToggleFullscreen() { void WindowState::SetBoundsInScreen( const gfx::Rect& bounds_in_screen) { gfx::Rect bounds_in_parent = - ScreenAsh::ConvertRectFromScreen(window_->parent(), + ScreenUtil::ConvertRectFromScreen(window_->parent(), bounds_in_screen); window_->SetBounds(bounds_in_parent); } void WindowState::SaveCurrentBoundsForRestore() { gfx::Rect bounds_in_screen = - ScreenAsh::ConvertRectToScreen(window_->parent(), + ScreenUtil::ConvertRectToScreen(window_->parent(), window_->bounds()); SetRestoreBoundsInScreen(bounds_in_screen); } @@ -220,7 +220,7 @@ gfx::Rect WindowState::GetRestoreBoundsInScreen() const { } gfx::Rect WindowState::GetRestoreBoundsInParent() const { - return ScreenAsh::ConvertRectFromScreen(window_->parent(), + return ScreenUtil::ConvertRectFromScreen(window_->parent(), GetRestoreBoundsInScreen()); } @@ -230,7 +230,7 @@ void WindowState::SetRestoreBoundsInScreen(const gfx::Rect& bounds) { void WindowState::SetRestoreBoundsInParent(const gfx::Rect& bounds) { SetRestoreBoundsInScreen( - ScreenAsh::ConvertRectToScreen(window_->parent(), bounds)); + ScreenUtil::ConvertRectToScreen(window_->parent(), bounds)); } void WindowState::ClearRestoreBounds() { diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc index cc131d1..e690738 100644 --- a/ash/wm/window_util.cc +++ b/ash/wm/window_util.cc @@ -7,7 +7,7 @@ #include <vector> #include "ash/ash_constants.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/wm/window_properties.h" #include "ash/wm/window_state.h" @@ -71,7 +71,7 @@ void CenterWindow(aura::Window* window) { window_state->SetRestoreBoundsInScreen(center); window_state->Restore(); } else { - center = ScreenAsh::ConvertRectFromScreen(window->parent(), + center = ScreenUtil::ConvertRectFromScreen(window->parent(), center); center.ClampToCenteredSize(size); window->SetBounds(center); diff --git a/ash/wm/window_util_unittest.cc b/ash/wm/window_util_unittest.cc index 66618df..5445793 100644 --- a/ash/wm/window_util_unittest.cc +++ b/ash/wm/window_util_unittest.cc @@ -4,7 +4,7 @@ #include "ash/wm/window_util.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/test/ash_test_base.h" #include "ui/aura/window.h" @@ -33,7 +33,7 @@ TEST_F(WindowUtilTest, CenterWindow) { EXPECT_EQ("200,126 100x100", window->bounds().ToString()); EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString()); window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); wm::CenterWindow(window.get()); EXPECT_EQ("250,126 100x100", window->bounds().ToString()); EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString()); diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc index 6b5a006..177950e 100644 --- a/ash/wm/workspace/multi_window_resize_controller.cc +++ b/ash/wm/workspace/multi_window_resize_controller.cc @@ -4,7 +4,7 @@ #include "ash/wm/workspace/multi_window_resize_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/coordinate_conversion.h" @@ -398,7 +398,7 @@ void MultiWindowResizeController::ShowNow() { views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); resize_widget_->GetNativeWindow()->SetName("MultiWindowResizeController"); resize_widget_->SetContentsView(view); - show_bounds_in_screen_ = ScreenAsh::ConvertRectToScreen( + show_bounds_in_screen_ = ScreenUtil::ConvertRectToScreen( windows_.window1->parent(), CalculateResizeWidgetBounds(show_location_in_parent_)); resize_widget_->SetBounds(show_bounds_in_screen_); @@ -447,7 +447,7 @@ void MultiWindowResizeController::Resize(const gfx::Point& location_in_screen, aura::client::GetScreenPositionClient(windows_.window1->GetRootWindow())-> ConvertPointFromScreen(windows_.window1->parent(), &location_in_parent); window_resizer_->Drag(location_in_parent, event_flags); - gfx::Rect bounds = ScreenAsh::ConvertRectToScreen( + gfx::Rect bounds = ScreenUtil::ConvertRectToScreen( windows_.window1->parent(), CalculateResizeWidgetBounds(location_in_parent)); diff --git a/ash/wm/workspace/snap_sizer.cc b/ash/wm/workspace/snap_sizer.cc index ba35f6a..6f17339 100644 --- a/ash/wm/workspace/snap_sizer.cc +++ b/ash/wm/workspace/snap_sizer.cc @@ -7,7 +7,7 @@ #include <cmath> #include "ash/ash_switches.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/wm/window_resizer.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" @@ -55,7 +55,7 @@ int GetMinWidth(aura::Window* window) { // The aura::WindowDelegate's max size is ignored because // ash::wm::CanSnapWindow() returns false when a max size is specified. int GetMaxWidth(aura::Window* window) { - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(window)); return std::max(work_area.width() * kMaximumScreenPercent / 100, GetMinWidth(window)); } @@ -63,7 +63,7 @@ int GetMaxWidth(aura::Window* window) { // Returns the width that |window| should be snapped to if resizing is disabled // in the SnapSizer. int GetDefaultWidth(aura::Window* window) { - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(window)); int width = 0; if (!CommandLine::ForCurrentProcess()->HasSwitch( @@ -91,7 +91,7 @@ std::vector<int> BuildIdealWidthList(aura::Window* window) { int minimum_width = GetMinWidth(window); int maximum_width = GetMaxWidth(window); - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(window)); + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(window)); int half_width = work_area.width() / 2; if (half_width < minimum_width || half_width > maximum_width) half_width = 0; @@ -227,7 +227,7 @@ void SnapSizer::SelectDefaultSizeAndDisableResize() { } gfx::Rect SnapSizer::GetTargetBoundsForSize(size_t size_index) const { - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_state_->window())); int y = work_area.y(); int max_y = work_area.bottom(); @@ -283,7 +283,7 @@ gfx::Rect SnapSizer::GetTargetBounds() const { } bool SnapSizer::AlongEdge(int x) const { - gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_state_->window())); return (x <= area.x()) || (x >= area.right() - 1); } diff --git a/ash/wm/workspace/snap_sizer_unittest.cc b/ash/wm/workspace/snap_sizer_unittest.cc index 81a09f9..a86c4de 100644 --- a/ash/wm/workspace/snap_sizer_unittest.cc +++ b/ash/wm/workspace/snap_sizer_unittest.cc @@ -5,7 +5,7 @@ #include "ash/wm/workspace/snap_sizer.h" #include "ash/ash_switches.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/wm/window_state.h" @@ -32,7 +32,7 @@ TEST_F(SnapSizerTest, MultipleDisplays) { const gfx::Rect kPrimaryDisplayWorkAreaBounds = ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); const gfx::Rect kSecondaryDisplayWorkAreaBounds = - ScreenAsh::GetSecondaryDisplay().work_area(); + ScreenUtil::GetSecondaryDisplay().work_area(); scoped_ptr<aura::Window> window( CreateTestWindowInShellWithBounds(gfx::Rect(100, 100, 100, 100))); @@ -53,7 +53,7 @@ TEST_F(SnapSizerTest, MultipleDisplays) { // Move the window to the secondary display. window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); SnapSizer::SnapWindow(window_state, SnapSizer::RIGHT_EDGE); expected = gfx::Rect( @@ -254,8 +254,8 @@ TEST_F(SnapSizerTest, Default) { gfx::Rect expected(work_area); expected.set_width(work_area.width() * 0.9); EXPECT_EQ(expected.ToString(), - ScreenAsh::ConvertRectToScreen(window->parent(), - sizer.target_bounds()).ToString()); + ScreenUtil::ConvertRectToScreen(window->parent(), + sizer.target_bounds()).ToString()); // If the largest width the window can snap to is between 1024 and 1280, we // should snap to 1024. diff --git a/ash/wm/workspace/workspace_event_handler.cc b/ash/wm/workspace/workspace_event_handler.cc index 9cf2c6b..b4bce0b 100644 --- a/ash/wm/workspace/workspace_event_handler.cc +++ b/ash/wm/workspace/workspace_event_handler.cc @@ -5,7 +5,6 @@ #include "ash/wm/workspace/workspace_event_handler.h" #include "ash/metrics/user_metrics_recorder.h" -#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/touch/touch_uma.h" #include "ash/wm/coordinate_conversion.h" diff --git a/ash/wm/workspace/workspace_event_handler_unittest.cc b/ash/wm/workspace/workspace_event_handler_unittest.cc index 605d755..fd8da55 100644 --- a/ash/wm/workspace/workspace_event_handler_unittest.cc +++ b/ash/wm/workspace/workspace_event_handler_unittest.cc @@ -4,7 +4,7 @@ #include "ash/wm/workspace/workspace_event_handler.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/wm/window_state.h" @@ -156,9 +156,9 @@ TEST_F(WorkspaceEventHandlerTest, DoubleClickSingleAxisResizeEdge) { // Verify the double clicking the resize edge works on 2nd display too. UpdateDisplay("200x200,400x300"); - gfx::Rect work_area2 = ScreenAsh::GetSecondaryDisplay().work_area(); + gfx::Rect work_area2 = ScreenUtil::GetSecondaryDisplay().work_area(); restored_bounds.SetRect(220,20, 50, 50); - window->SetBoundsInScreen(restored_bounds, ScreenAsh::GetSecondaryDisplay()); + window->SetBoundsInScreen(restored_bounds, ScreenUtil::GetSecondaryDisplay()); aura::Window* second_root = Shell::GetAllRootWindows()[1]; EXPECT_EQ(second_root, window->GetRootWindow()); aura::test::EventGenerator generator2(second_root, window.get()); diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc index 2e893ae..a9981e7 100644 --- a/ash/wm/workspace/workspace_layout_manager.cc +++ b/ash/wm/workspace/workspace_layout_manager.cc @@ -6,7 +6,7 @@ #include "ash/display/display_controller.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" #include "ash/wm/always_on_top_controller.h" @@ -51,10 +51,10 @@ void MoveToDisplayForRestore(wm::WindowState* window_state) { window_state->window()).bounds(); if (!display_area.Intersects(restore_bounds)) { + const gfx::Display& display = + Shell::GetScreen()->GetDisplayMatching(restore_bounds); DisplayController* display_controller = Shell::GetInstance()->display_controller(); - const gfx::Display& display = - display_controller->GetDisplayMatching(restore_bounds); aura::Window* new_root = display_controller->GetRootWindowForDisplayId(display.id()); if (new_root != window_state->window()->GetRootWindow()) { @@ -71,7 +71,7 @@ WorkspaceLayoutManager::WorkspaceLayoutManager(aura::Window* window) : BaseLayoutManager(window->GetRootWindow()), shelf_(NULL), window_(window), - work_area_in_parent_(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + work_area_in_parent_(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window->parent())), is_fullscreen_(GetRootWindowController( window->GetRootWindow())->GetWindowForFullscreenMode() != NULL) { @@ -139,7 +139,7 @@ void WorkspaceLayoutManager::SetChildBounds( } void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { - const gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + const gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_->parent())); if (work_area != work_area_in_parent_) { AdjustAllWindowsBoundsForWorkAreaChange( @@ -205,7 +205,7 @@ void WorkspaceLayoutManager::OnWindowShowTypeChanged( void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( AdjustWindowReason reason) { work_area_in_parent_ = - ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_->parent()); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_->parent()); BaseLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange(reason); } @@ -222,7 +222,7 @@ void WorkspaceLayoutManager::AdjustWindowBoundsForWorkAreaChange( if (window_state->IsMaximized() && reason == ADJUST_WINDOW_WORK_AREA_INSETS_CHANGED) { SetChildBoundsDirect(window_state->window(), - ScreenAsh::GetMaximizedWindowBoundsInParent( + ScreenUtil::GetMaximizedWindowBoundsInParent( window_state->window()->parent()->parent())); return; } @@ -267,7 +267,7 @@ void WorkspaceLayoutManager::AdjustWindowBoundsWhenAdded( // be further shrunk by the docked area. The logic ensures 30% // visibility which should be enough to see where the window gets // moved. - gfx::Rect display_area = ScreenAsh::GetDisplayBoundsInParent(window); + gfx::Rect display_area = ScreenUtil::GetDisplayBoundsInParent(window); int min_width = bounds.width() * kMinimumPercentOnScreenArea; int min_height = bounds.height() * kMinimumPercentOnScreenArea; @@ -328,12 +328,12 @@ void WorkspaceLayoutManager::UpdateBoundsFromShowType( break; case wm::SHOW_TYPE_MAXIMIZED: - bounds_in_parent = ScreenAsh::GetMaximizedWindowBoundsInParent( + bounds_in_parent = ScreenUtil::GetMaximizedWindowBoundsInParent( window->parent()->parent()); break; case wm::SHOW_TYPE_FULLSCREEN: - bounds_in_parent = ScreenAsh::GetDisplayBoundsInParent( + bounds_in_parent = ScreenUtil::GetDisplayBoundsInParent( window->parent()->parent()); break; @@ -366,14 +366,14 @@ bool WorkspaceLayoutManager::SetMaximizedOrFullscreenBounds( // ignored. if (window_state->IsMaximized()) { SetChildBoundsDirect( - window_state->window(), ScreenAsh::GetMaximizedWindowBoundsInParent( + window_state->window(), ScreenUtil::GetMaximizedWindowBoundsInParent( window_state->window()->parent()->parent())); return true; } if (window_state->IsFullscreen()) { SetChildBoundsDirect( window_state->window(), - ScreenAsh::GetDisplayBoundsInParent( + ScreenUtil::GetDisplayBoundsInParent( window_state->window()->parent()->parent())); return true; } @@ -384,7 +384,7 @@ void WorkspaceLayoutManager::AdjustSnappedBounds(wm::WindowState* window_state, gfx::Rect* bounds) { if (window_state->is_dragged() || !window_state->IsSnapped()) return; - gfx::Rect maximized_bounds = ScreenAsh::GetMaximizedWindowBoundsInParent( + gfx::Rect maximized_bounds = ScreenUtil::GetMaximizedWindowBoundsInParent( window_state->window()->parent()->parent()); if (window_state->window_show_type() == wm::SHOW_TYPE_LEFT_SNAPPED) bounds->set_x(maximized_bounds.x()); diff --git a/ash/wm/workspace/workspace_layout_manager_unittest.cc b/ash/wm/workspace/workspace_layout_manager_unittest.cc index 8f2569f..41e067f 100644 --- a/ash/wm/workspace/workspace_layout_manager_unittest.cc +++ b/ash/wm/workspace/workspace_layout_manager_unittest.cc @@ -7,7 +7,7 @@ #include "ash/display/display_layout.h" #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" @@ -108,7 +108,7 @@ TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { UpdateDisplay("400x300,500x400"); window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); EXPECT_EQ(Shell::GetAllRootWindows()[1], window->GetRootWindow()); window_state->Minimize(); // This will not be used for un-minimizing window. diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc index 6278a0d..c6dc2a5 100644 --- a/ash/wm/workspace/workspace_window_resizer.cc +++ b/ash/wm/workspace/workspace_window_resizer.cc @@ -12,7 +12,7 @@ #include "ash/ash_switches.h" #include "ash/display/display_controller.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/coordinate_conversion.h" @@ -400,7 +400,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent, aura::Window* root = NULL; gfx::Display display = - ScreenAsh::FindDisplayContainingPoint(location_in_screen); + ScreenUtil::FindDisplayContainingPoint(location_in_screen); // Track the last screen that the pointer was on to keep the snap phantom // window there. if (display.is_valid()) { @@ -449,7 +449,7 @@ void WorkspaceWindowResizer::CompleteDrag() { dock_layout_->is_dragged_window_docked()) && (snap_type_ == SNAP_LEFT || snap_type_ == SNAP_RIGHT)) { if (!window_state()->HasRestoreBounds()) { - gfx::Rect initial_bounds = ScreenAsh::ConvertRectToScreen( + gfx::Rect initial_bounds = ScreenUtil::ConvertRectToScreen( GetTarget()->parent(), details().initial_bounds_in_parent); window_state()->SetRestoreBoundsInScreen( details().restore_bounds.IsEmpty() ? @@ -555,7 +555,8 @@ WorkspaceWindowResizer::WorkspaceWindowResizer( void WorkspaceWindowResizer::LayoutAttachedWindows( gfx::Rect* bounds) { - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(GetTarget())); + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( + GetTarget())); int initial_size = PrimaryAxisSize(details().initial_bounds_in_parent.size()); int current_size = PrimaryAxisSize(bounds->size()); int start = PrimaryAxisCoordinate(bounds->right(), bounds->bottom()); @@ -695,7 +696,7 @@ void WorkspaceWindowResizer::CreateBucketsForAttached( void WorkspaceWindowResizer::MagneticallySnapToOtherWindows(gfx::Rect* bounds) { if (UpdateMagnetismWindow(*bounds, kAllMagnetismEdges)) { gfx::Point point = OriginForMagneticAttach( - ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), *bounds), + ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), *bounds), magnetism_window_->GetBoundsInScreen(), magnetism_edge_); aura::client::GetScreenPositionClient(GetTarget()->GetRootWindow())-> @@ -709,10 +710,10 @@ void WorkspaceWindowResizer::MagneticallySnapResizeToOtherWindows( const uint32 edges = WindowComponentToMagneticEdge( details().window_component); if (UpdateMagnetismWindow(*bounds, edges)) { - *bounds = ScreenAsh::ConvertRectFromScreen( + *bounds = ScreenUtil::ConvertRectFromScreen( GetTarget()->parent(), BoundsForMagneticResizeAttach( - ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), *bounds), + ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), *bounds), magnetism_window_->GetBoundsInScreen(), magnetism_edge_)); } @@ -722,7 +723,7 @@ bool WorkspaceWindowResizer::UpdateMagnetismWindow(const gfx::Rect& bounds, uint32 edges) { // |bounds| are in coordinates of original window's parent. gfx::Rect bounds_in_screen = - ScreenAsh::ConvertRectToScreen(GetTarget()->parent(), bounds); + ScreenUtil::ConvertRectToScreen(GetTarget()->parent(), bounds); MagnetismMatcher matcher(bounds_in_screen, edges); // If we snapped to a window then check it first. That way we don't bounce @@ -778,7 +779,7 @@ void WorkspaceWindowResizer::AdjustBoundsForMainWindow( gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint( last_mouse_location_in_screen); gfx::Rect work_area = - ScreenAsh::ConvertRectFromScreen(GetTarget()->parent(), + ScreenUtil::ConvertRectFromScreen(GetTarget()->parent(), display.work_area()); if (details().window_component == HTCAPTION) { // Adjust the bounds to the work area where the mouse cursor is located. @@ -947,7 +948,7 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, SetDraggedWindowDocked(should_dock); snap_type_ = GetSnapType(location); if (dock_layout_->is_dragged_window_docked()) { - phantom_bounds = ScreenAsh::ConvertRectFromScreen( + phantom_bounds = ScreenUtil::ConvertRectFromScreen( GetTarget()->parent(), dock_layout_->dragged_bounds()); } @@ -960,7 +961,7 @@ void WorkspaceWindowResizer::UpdateSnapPhantomWindow(const gfx::Point& location, snap_phantom_window_controller_.reset( new PhantomWindowController(GetTarget())); } - snap_phantom_window_controller_->Show(ScreenAsh::ConvertRectToScreen( + snap_phantom_window_controller_->Show(ScreenUtil::ConvertRectToScreen( GetTarget()->parent(), phantom_bounds)); } @@ -999,11 +1000,11 @@ SnapType WorkspaceWindowResizer::GetSnapType( const gfx::Point& location) const { // TODO: this likely only wants total display area, not the area of a single // display. - gfx::Rect area(ScreenAsh::GetDisplayWorkAreaBoundsInParent(GetTarget())); + gfx::Rect area(ScreenUtil::GetDisplayWorkAreaBoundsInParent(GetTarget())); if (details().source == aura::client::WINDOW_MOVE_SOURCE_TOUCH) { // Increase tolerance for touch-snapping near the screen edges. This is only // necessary when the work area left or right edge is same as screen edge. - gfx::Rect display_bounds(ScreenAsh::GetDisplayBoundsInParent(GetTarget())); + gfx::Rect display_bounds(ScreenUtil::GetDisplayBoundsInParent(GetTarget())); int inset_left = 0; if (area.x() == display_bounds.x()) inset_left = kScreenEdgeInsetForTouchResize; diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc index ed2a53f..42eea1d 100644 --- a/ash/wm/workspace/workspace_window_resizer_unittest.cc +++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc @@ -8,7 +8,7 @@ #include "ash/ash_switches.h" #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" @@ -626,7 +626,7 @@ TEST_F(WorkspaceWindowResizerTest, Edge) { EXPECT_EQ(root_windows[0], window_->GetRootWindow()); // Window is wide enough not to get docked right away. window_->SetBoundsInScreen(gfx::Rect(800, 10, 400, 60), - ScreenAsh::GetSecondaryDisplay()); + ScreenUtil::GetSecondaryDisplay()); EXPECT_EQ(root_windows[1], window_->GetRootWindow()); { EXPECT_EQ("800,10 400x60", window_->GetBoundsInScreen().ToString()); @@ -636,7 +636,7 @@ TEST_F(WorkspaceWindowResizerTest, Edge) { ASSERT_TRUE(resizer.get()); resizer->Drag(CalculateDragPoint(*resizer, 499, 0), 0); int bottom = - ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); + ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).bottom(); resizer->CompleteDrag(); // With the resolution of 500x600 we will hit in this case the 50% screen // size setting. @@ -838,7 +838,7 @@ TEST_F(WorkspaceWindowResizerTest, ResizeBottomOutsideWorkArea) { TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { Shell::GetInstance()->SetDisplayWorkAreaInsets( Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); - int left = ScreenAsh::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); + int left = ScreenUtil::GetDisplayWorkAreaBoundsInParent(window_.get()).x(); int pixels_to_left_border = 50; int window_width = 300; int window_x = left - window_width + pixels_to_left_border; @@ -855,7 +855,7 @@ TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideLeftWorkArea) { TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { Shell::GetInstance()->SetDisplayWorkAreaInsets( Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); - int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( + int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get()).right(); int pixels_to_right_border = 50; int window_width = 300; @@ -875,7 +875,7 @@ TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideRightWorkArea) { TEST_F(WorkspaceWindowResizerTest, ResizeWindowOutsideBottomWorkArea) { Shell::GetInstance()->SetDisplayWorkAreaInsets( Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); - int bottom = ScreenAsh::GetDisplayWorkAreaBoundsInParent( + int bottom = ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get()).bottom(); int delta_to_bottom = 50; int height = 380; @@ -899,7 +899,7 @@ TEST_F(WorkspaceWindowResizerTest, DragWindowOutsideRightToSecondaryDisplay) { // display. Shell::GetInstance()->SetDisplayWorkAreaInsets( Shell::GetPrimaryRootWindow(), gfx::Insets(0, 0, 50, 0)); - int right = ScreenAsh::GetDisplayWorkAreaBoundsInParent( + int right = ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get()).right(); int pixels_to_right_border = 50; int window_width = 300; @@ -1015,7 +1015,7 @@ TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPLEFT) { // Verifies a resize snap when dragging TOPRIGHT. TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { window_->SetBounds(gfx::Rect(100, 200, 20, 30)); - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get())); scoped_ptr<WindowResizer> resizer(CreateResizerForTest( window_.get(), gfx::Point(), HTTOPRIGHT)); @@ -1031,7 +1031,7 @@ TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_TOPRIGHT) { // Verifies a resize snap when dragging BOTTOMRIGHT. TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { window_->SetBounds(gfx::Rect(100, 200, 20, 30)); - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get())); scoped_ptr<WindowResizer> resizer(CreateResizerForTest( window_.get(), gfx::Point(), HTBOTTOMRIGHT)); @@ -1048,7 +1048,7 @@ TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMRIGHT) { // Verifies a resize snap when dragging BOTTOMLEFT. TEST_F(WorkspaceWindowResizerTest, SnapToWorkArea_BOTTOMLEFT) { window_->SetBounds(gfx::Rect(100, 200, 20, 30)); - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get())); scoped_ptr<WindowResizer> resizer(CreateResizerForTest( window_.get(), gfx::Point(), HTBOTTOMLEFT)); @@ -1133,7 +1133,7 @@ TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPLEFT) { // Verifies a resize sticks when dragging TOPRIGHT. TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPRIGHT) { window_->SetBounds(gfx::Rect(100, 200, 20, 30)); - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get())); scoped_ptr<WindowResizer> resizer(CreateResizerForTest( window_.get(), gfx::Point(), HTTOPRIGHT)); @@ -1149,7 +1149,7 @@ TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_TOPRIGHT) { // Verifies a resize snap when dragging BOTTOMRIGHT. TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMRIGHT) { window_->SetBounds(gfx::Rect(100, 200, 20, 30)); - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get())); scoped_ptr<WindowResizer> resizer(CreateResizerForTest( window_.get(), gfx::Point(), HTBOTTOMRIGHT)); @@ -1165,7 +1165,7 @@ TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMRIGHT) { // Verifies a resize snap when dragging BOTTOMLEFT. TEST_F(WorkspaceWindowResizerTestSticky, StickToWorkArea_BOTTOMLEFT) { window_->SetBounds(gfx::Rect(100, 200, 20, 30)); - gfx::Rect work_area(ScreenAsh::GetDisplayWorkAreaBoundsInParent( + gfx::Rect work_area(ScreenUtil::GetDisplayWorkAreaBoundsInParent( window_.get())); scoped_ptr<WindowResizer> resizer(CreateResizerForTest( window_.get(), gfx::Point(), HTBOTTOMLEFT)); diff --git a/ash/wm/workspace_controller_unittest.cc b/ash/wm/workspace_controller_unittest.cc index d4e572f..8ec67d7 100644 --- a/ash/wm/workspace_controller_unittest.cc +++ b/ash/wm/workspace_controller_unittest.cc @@ -8,7 +8,7 @@ #include "ash/ash_switches.h" #include "ash/root_window_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shelf/shelf_layout_manager.h" #include "ash/shelf/shelf_widget.h" #include "ash/shell.h" @@ -183,9 +183,9 @@ TEST_F(WorkspaceControllerTest, SingleMaximizeWindow) { EXPECT_TRUE(wm::IsActiveWindow(w1.get())); EXPECT_EQ(w1.get(), GetDesktop()->children()[0]); - EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).width(), + EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get()).width(), w1->bounds().width()); - EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get()).height(), + EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get()).height(), w1->bounds().height()); // Restore the window. @@ -215,7 +215,7 @@ TEST_F(WorkspaceControllerTest, FullscreenWithNormalWindow) { EXPECT_EQ(w2.get(), GetDesktop()->children()[1]); gfx::Rect work_area( - ScreenAsh::GetMaximizedWindowBoundsInParent(w1.get())); + ScreenUtil::GetMaximizedWindowBoundsInParent(w1.get())); EXPECT_EQ(work_area.width(), w2->bounds().width()); EXPECT_EQ(work_area.height(), w2->bounds().height()); @@ -443,7 +443,7 @@ TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { wm::ActivateWindow(w1.get()); EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); - EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent( + EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent( w2->parent()).ToString(), w2->bounds().ToString()); @@ -452,7 +452,7 @@ TEST_F(WorkspaceControllerTest, ShelfStateUpdated) { EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); EXPECT_EQ("0,1 101x102", w1->bounds().ToString()); - EXPECT_EQ(ScreenAsh::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), + EXPECT_EQ(ScreenUtil::GetMaximizedWindowBoundsInParent(w2.get()).ToString(), w2->bounds().ToString()); // Turn off auto-hide, switch back to w2 (maximized) and verify overlap. diff --git a/chrome/browser/chromeos/display/display_preferences_unittest.cc b/chrome/browser/chromeos/display/display_preferences_unittest.cc index 1fd4b5c..03d604e 100644 --- a/chrome/browser/chromeos/display/display_preferences_unittest.cc +++ b/chrome/browser/chromeos/display/display_preferences_unittest.cc @@ -8,7 +8,7 @@ #include "ash/display/display_layout_store.h" #include "ash/display/display_manager.h" #include "ash/display/resolution_notification_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "base/prefs/scoped_user_pref_update.h" @@ -150,7 +150,7 @@ class DisplayPreferencesTest : public ash::test::AshTestBase { TEST_F(DisplayPreferencesTest, PairedLayoutOverrides) { UpdateDisplay("100x100,200x200"); int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); int64 dummy_id = id2 + 1; ASSERT_NE(id1, dummy_id); @@ -186,7 +186,7 @@ TEST_F(DisplayPreferencesTest, BasicStores) { UpdateDisplay("200x200*2, 400x300#400x400|300x200"); int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); gfx::Display::SetInternalDisplayId(id1); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); int64 dummy_id = id2 + 1; ASSERT_NE(id1, dummy_id); @@ -197,7 +197,7 @@ TEST_F(DisplayPreferencesTest, BasicStores) { id1, dummy_id, ash::DisplayLayout(ash::DisplayLayout::LEFT, 20)); // Can't switch to a display that does not exist. display_controller->SetPrimaryDisplayId(dummy_id); - EXPECT_NE(dummy_id, display_controller->GetPrimaryDisplay().id()); + EXPECT_NE(dummy_id, ash::Shell::GetScreen()->GetPrimaryDisplay().id()); display_controller->SetOverscanInsets(id1, gfx::Insets(10, 11, 12, 13)); display_manager->SetDisplayRotation(id1, gfx::Display::ROTATE_90); @@ -338,7 +338,7 @@ TEST_F(DisplayPreferencesTest, BasicStores) { UpdateDisplay("200x200*2, 600x500#600x500|500x400"); // Update key as the 2nd display gets new id. - id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); @@ -366,7 +366,7 @@ TEST_F(DisplayPreferencesTest, BasicStores) { UpdateDisplay("200x200*2"); UpdateDisplay("200x200*2, 500x400#600x500|500x400"); // Update key as the 2nd display gets new id. - id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); key = base::Int64ToString(id1) + "," + base::Int64ToString(id2); EXPECT_TRUE(displays->GetDictionary(key, &layout_value)); EXPECT_TRUE(layout_value->GetString(kPositionKey, &position)); @@ -431,12 +431,12 @@ TEST_F(DisplayPreferencesTest, PreventStore) { TEST_F(DisplayPreferencesTest, StoreForSwappedDisplay) { UpdateDisplay("100x100,200x200"); int64 id1 = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::DisplayController* display_controller = ash::Shell::GetInstance()->display_controller(); display_controller->SwapPrimaryDisplay(); - ASSERT_EQ(id1, ash::ScreenAsh::GetSecondaryDisplay().id()); + ASSERT_EQ(id1, ash::ScreenUtil::GetSecondaryDisplay().id()); LoggedInAsUser(); ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); @@ -472,15 +472,14 @@ TEST_F(DisplayPreferencesTest, DontStoreInGuestMode) { UpdateDisplay("200x200*2,200x200"); LoggedInAsGuest(); - int64 id1 = ash::ScreenAsh::GetNativeScreen()->GetPrimaryDisplay().id(); + int64 id1 = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); gfx::Display::SetInternalDisplayId(id1); - int64 id2 = ash::ScreenAsh::GetSecondaryDisplay().id(); + int64 id2 = ash::ScreenUtil::GetSecondaryDisplay().id(); ash::DisplayLayout layout(ash::DisplayLayout::TOP, 10); SetCurrentDisplayLayout(layout); display_manager->SetDisplayUIScale(id1, 1.25f); display_controller->SetPrimaryDisplayId(id2); - int64 new_primary = - ash::ScreenAsh::GetNativeScreen()->GetPrimaryDisplay().id(); + int64 new_primary = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); display_controller->SetOverscanInsets( new_primary, gfx::Insets(10, 11, 12, 13)); diff --git a/chrome/browser/extensions/api/system_display/display_info_provider_chromeos_unittest.cc b/chrome/browser/extensions/api/system_display/display_info_provider_chromeos_unittest.cc index c91e725..4dd2fe9 100644 --- a/chrome/browser/extensions/api/system_display/display_info_provider_chromeos_unittest.cc +++ b/chrome/browser/extensions/api/system_display/display_info_provider_chromeos_unittest.cc @@ -6,7 +6,7 @@ #include "ash/display/display_controller.h" #include "ash/display/display_manager.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/display_manager_test_api.h" @@ -312,7 +312,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { UpdateDisplay("1200x600,520x400"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(-520)); info.bounds_origin_y.reset(new int(50)); @@ -331,7 +331,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { UpdateDisplay("1200x600,520x400"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(1200)); info.bounds_origin_y.reset(new int(100)); @@ -350,7 +350,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { UpdateDisplay("1200x600,520x400"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(1100)); info.bounds_origin_y.reset(new int(-400)); @@ -369,7 +369,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { UpdateDisplay("1200x600,520x400"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(-350)); info.bounds_origin_y.reset(new int(600)); @@ -388,7 +388,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { UpdateDisplay("1200x600,520x400"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(340)); info.bounds_origin_y.reset(new int(100)); @@ -407,7 +407,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { UpdateDisplay("1200x600,520x400"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(-1040)); info.bounds_origin_y.reset(new int(100)); @@ -426,7 +426,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { UpdateDisplay("1200x600,520x400"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(-360)); info.bounds_origin_y.reset(new int(-301)); @@ -446,7 +446,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftButSharesBottomSide) { UpdateDisplay("1200x600,1000x100"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(-650)); info.bounds_origin_y.reset(new int(700)); @@ -466,7 +466,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { UpdateDisplay("1200x600,1000x100"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(850)); info.bounds_origin_y.reset(new int(-150)); @@ -486,7 +486,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { UpdateDisplay("1200x600,1000x100/l"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(-150)); info.bounds_origin_y.reset(new int(-650)); @@ -506,7 +506,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomButSharesRightSide) { UpdateDisplay("1200x600,1000x100/l"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(1350)); info.bounds_origin_y.reset(new int(450)); @@ -525,7 +525,7 @@ TEST_F(DisplayInfoProviderChromeosTest, TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { UpdateDisplay("1200x600*2,500x500"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(250)); info.bounds_origin_y.reset(new int(-100)); @@ -544,7 +544,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(450)); info.bounds_origin_y.reset(new int(-100)); @@ -563,7 +563,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(0x200001)); info.bounds_origin_y.reset(new int(-100)); @@ -582,7 +582,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(300)); info.bounds_origin_y.reset(new int(-0x200001)); @@ -601,7 +601,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { UpdateDisplay("1200x4600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(200000)); info.bounds_origin_y.reset(new int(10)); @@ -620,7 +620,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(300)); info.is_primary.reset(new bool(true)); @@ -636,14 +636,14 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); // The operation failed because the primary property would be set before // setting bounds. The primary display shouldn't have been changed, though. - EXPECT_NE(ash::DisplayController::GetPrimaryDisplay().id(), secondary.id()); + EXPECT_NE(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); } TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); - const gfx::Display& primary = GetDisplayController()->GetPrimaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); + const gfx::Display& primary = ash::Shell::GetScreen()->GetPrimaryDisplay(); api::system_display::DisplayProperties info; info.bounds_origin_x.reset(new int(300)); @@ -663,7 +663,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.rotation.reset(new int(90)); @@ -699,7 +699,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); EXPECT_EQ(gfx::Display::ROTATE_180, secondary.rotation()); - EXPECT_EQ(ash::DisplayController::GetPrimaryDisplay().id(), secondary.id()); + EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); info.rotation.reset(new int(0)); CallSetDisplayUnitInfo(base::Int64ToString(secondary.id()), info, @@ -710,13 +710,13 @@ TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation()); - EXPECT_EQ(ash::DisplayController::GetPrimaryDisplay().id(), secondary.id()); + EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); } TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.rotation.reset(new int(91)); @@ -732,7 +732,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.overscan.reset(new api::system_display::Insets); info.overscan->left= -10; @@ -795,7 +795,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.overscan.reset(new api::system_display::Insets); // Horizontal overscan is 151, which would make the bounds width 149. @@ -817,7 +817,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { UpdateDisplay("1200x600,600x1000"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.overscan.reset(new api::system_display::Insets); // Vertical overscan is 501, which would make the bounds height 499. @@ -839,7 +839,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { UpdateDisplay("1200x600,600x1000*2"); - const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); + const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); api::system_display::DisplayProperties info; info.overscan.reset(new api::system_display::Insets); info.overscan->left= 20; diff --git a/chrome/browser/extensions/api/system_display/system_display_api.cc b/chrome/browser/extensions/api/system_display/system_display_api.cc index 6cd480c..95074fa 100644 --- a/chrome/browser/extensions/api/system_display/system_display_api.cc +++ b/chrome/browser/extensions/api/system_display/system_display_api.cc @@ -6,13 +6,14 @@ #include <string> -#include "base/memory/scoped_ptr.h" -#include "base/strings/string_number_conversions.h" #include "chrome/browser/extensions/api/system_display/display_info_provider.h" #include "chrome/common/extensions/api/system_display.h" + +#if defined(OS_CHROMEOS) +#include "base/memory/scoped_ptr.h" #include "extensions/common/manifest_handlers/kiosk_mode_info.h" -#include "ui/gfx/display.h" #include "ui/gfx/screen.h" +#endif namespace extensions { diff --git a/chrome/browser/extensions/api/system_display/system_display_apitest.cc b/chrome/browser/extensions/api/system_display/system_display_apitest.cc index 57c741d..17a0dcf 100644 --- a/chrome/browser/extensions/api/system_display/system_display_apitest.cc +++ b/chrome/browser/extensions/api/system_display/system_display_apitest.cc @@ -14,7 +14,7 @@ #include "ui/gfx/screen.h" #if defined(OS_CHROMEOS) -#include "ash/screen_ash.h" +#include "ash/display/screen_ash.h" #include "ash/shell.h" #endif @@ -185,7 +185,7 @@ class SystemDisplayApiTest: public ExtensionApiTest { virtual void CleanUpOnMainThread() OVERRIDE { #if defined(OS_CHROMEOS) gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, - ash::Shell::GetInstance()->screen()); + ash::Shell::GetScreen()); #endif ExtensionApiTest::CleanUpOnMainThread(); } diff --git a/chrome/browser/extensions/api/system_info/system_info_api.cc b/chrome/browser/extensions/api/system_info/system_info_api.cc index b97c1b7..0b7ffee 100644 --- a/chrome/browser/extensions/api/system_info/system_info_api.cc +++ b/chrome/browser/extensions/api/system_info/system_info_api.cc @@ -23,8 +23,8 @@ #include "ui/gfx/display_observer.h" #if defined(USE_ASH) -#include "ash/screen_ash.h" #include "ash/shell.h" +#include "ui/gfx/screen.h" #endif namespace extensions { diff --git a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc index 8aed9c3..b0253b9 100644 --- a/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc +++ b/chrome/browser/ui/ash/ash_keyboard_controller_proxy.cc @@ -188,7 +188,7 @@ void AshKeyboardControllerProxy::ShowKeyboardContainer( // is set. if (GetInputMethod()->GetTextInputClient()) { gfx::Rect showing_area = - ash::DisplayController::GetPrimaryDisplay().work_area(); + ash::Shell::GetScreen()->GetPrimaryDisplay().work_area(); GetInputMethod()->GetTextInputClient()->EnsureCaretInRect(showing_area); } } diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc index 7073fa1..3b66ed6 100644 --- a/chrome/browser/ui/views/apps/native_app_window_views.cc +++ b/chrome/browser/ui/views/apps/native_app_window_views.cc @@ -48,7 +48,7 @@ #if defined(USE_ASH) #include "ash/ash_constants.h" #include "ash/ash_switches.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/wm/custom_frame_view_ash.h" #include "ash/wm/immersive_fullscreen_controller.h" @@ -361,7 +361,7 @@ void NativeAppWindowViews::InitializePanelWindow( if (ash::Shell::HasInstance()) { // Open a new panel on the target root. aura::Window* target = ash::Shell::GetTargetRootWindow(); - params.bounds = ash::ScreenAsh::ConvertRectToScreen( + params.bounds = ash::ScreenUtil::ConvertRectToScreen( target, gfx::Rect(preferred_size_)); } else { params.bounds = gfx::Rect(preferred_size_); diff --git a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc index 2cb5bd3..0200843 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/display_options_handler.cc @@ -10,7 +10,6 @@ #include "ash/display/display_manager.h" #include "ash/display/output_configurator_animation.h" #include "ash/display/resolution_notification_controller.h" -#include "ash/screen_ash.h" #include "ash/shell.h" #include "base/bind.h" #include "base/logging.h" diff --git a/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc b/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc index a6f0948..c176b0b 100644 --- a/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/display_overscan_handler.cc @@ -7,7 +7,7 @@ #include <string> #include "ash/display/display_controller.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "base/bind.h" #include "base/logging.h" @@ -18,6 +18,7 @@ #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/display.h" +#include "ui/gfx/screen.h" namespace chromeos { namespace options { @@ -108,7 +109,7 @@ void DisplayOverscanHandler::HandleStart(const base::ListValue* args) { return; } - const gfx::Display& display = ash::ScreenAsh::GetDisplayForId(display_id); + const gfx::Display& display = ash::ScreenUtil::GetDisplayForId(display_id); DCHECK(display.is_valid()); if (!display.is_valid()) return; diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc index 83407c3..7858259 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc +++ b/chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "ash/scoped_target_root_window.h" -#include "ash/screen_ash.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #include "ash/test/test_shell_delegate.h" @@ -23,6 +23,7 @@ #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/aura/test/test_windows.h" +#include "ui/gfx/screen.h" typedef ash::test::AshTestBase WindowSizerAshTest; @@ -607,7 +608,7 @@ TEST_F(WindowSizerAshTest, MAYBE_PlaceNewWindowsOnMultipleDisplays) { UpdateDisplay("1600x1200,1600x1200"); gfx::Rect primary_bounds = ash::Shell::GetInstance()->GetScreen()-> GetPrimaryDisplay().bounds(); - gfx::Rect secondary_bounds = ash::ScreenAsh::GetSecondaryDisplay().bounds(); + gfx::Rect secondary_bounds = ash::ScreenUtil::GetSecondaryDisplay().bounds(); ash::Shell::GetInstance()->set_target_root_window( ash::Shell::GetPrimaryRootWindow()); |