diff options
author | scottmg <scottmg@chromium.org> | 2016-01-26 21:07:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-27 05:08:46 +0000 |
commit | e8b0429751298d4bff935658ad0501597bedfb54 (patch) | |
tree | 2fc8223b144eb8183f9b248b40cb13fa07f808f6 /ash/display | |
parent | fc512ffcf066bf2c50b565bd54019ee0074a542d (diff) | |
download | chromium_src-e8b0429751298d4bff935658ad0501597bedfb54.zip chromium_src-e8b0429751298d4bff935658ad0501597bedfb54.tar.gz chromium_src-e8b0429751298d4bff935658ad0501597bedfb54.tar.bz2 |
Remove now-unnecessary wrappers around gfx::Screen::GetScreen()
- ash::Shell::GetScreen()
- DisplayInfoProvider::GetActiveScreen()
Followup to https://codereview.chromium.org/1608733002/.
R=oshima@chromium.org, sky@chromium.org
BUG=558054
Review URL: https://codereview.chromium.org/1608053002
Cr-Commit-Position: refs/heads/master@{#371733}
Diffstat (limited to 'ash/display')
-rw-r--r-- | ash/display/cursor_window_controller.cc | 5 | ||||
-rw-r--r-- | ash/display/cursor_window_controller_unittest.cc | 12 | ||||
-rw-r--r-- | ash/display/display_manager_unittest.cc | 93 | ||||
-rw-r--r-- | ash/display/event_transformation_handler.cc | 3 | ||||
-rw-r--r-- | ash/display/extended_mouse_warp_controller.cc | 6 | ||||
-rw-r--r-- | ash/display/mirror_window_controller.cc | 5 | ||||
-rw-r--r-- | ash/display/resolution_notification_controller.cc | 4 | ||||
-rw-r--r-- | ash/display/resolution_notification_controller_unittest.cc | 4 | ||||
-rw-r--r-- | ash/display/root_window_transformers.cc | 3 | ||||
-rw-r--r-- | ash/display/root_window_transformers_unittest.cc | 16 | ||||
-rw-r--r-- | ash/display/screen_ash.cc | 3 | ||||
-rw-r--r-- | ash/display/screen_ash_unittest.cc | 8 | ||||
-rw-r--r-- | ash/display/screen_position_controller.cc | 20 | ||||
-rw-r--r-- | ash/display/screen_position_controller_unittest.cc | 10 | ||||
-rw-r--r-- | ash/display/shared_display_edge_indicator.cc | 2 | ||||
-rw-r--r-- | ash/display/window_tree_host_manager.cc | 21 | ||||
-rw-r--r-- | ash/display/window_tree_host_manager_unittest.cc | 177 |
17 files changed, 217 insertions, 175 deletions
diff --git a/ash/display/cursor_window_controller.cc b/ash/display/cursor_window_controller.cc index eb334b8..fb0bff9 100644 --- a/ash/display/cursor_window_controller.cc +++ b/ash/display/cursor_window_controller.cc @@ -23,6 +23,7 @@ #include "ui/gfx/geometry/dip_util.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia_operations.h" +#include "ui/gfx/screen.h" namespace ash { @@ -101,7 +102,7 @@ void CursorWindowController::SetCursorCompositingEnabled(bool enabled) { void CursorWindowController::UpdateContainer() { if (is_cursor_compositing_enabled_) { - gfx::Screen* screen = Shell::GetScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Display display = screen->GetDisplayNearestPoint( screen->GetCursorScreenPoint()); DCHECK(display.is_valid()); @@ -113,7 +114,7 @@ void CursorWindowController::UpdateContainer() { ->mirror_window_controller() ->GetWindow(); if (mirror_window) - display_ = Shell::GetScreen()->GetPrimaryDisplay(); + display_ = gfx::Screen::GetScreen()->GetPrimaryDisplay(); SetContainer(mirror_window); } // Updates the hot point based on the current display. diff --git a/ash/display/cursor_window_controller_unittest.cc b/ash/display/cursor_window_controller_unittest.cc index 5640bb1..3311095 100644 --- a/ash/display/cursor_window_controller_unittest.cc +++ b/ash/display/cursor_window_controller_unittest.cc @@ -154,17 +154,19 @@ TEST_F(CursorWindowControllerTest, VisibilityTest) { // the DSF becomes 1x as a result of zooming out. TEST_F(CursorWindowControllerTest, DSF) { UpdateDisplay("1000x500*2"); - int64_t primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); + int64_t primary_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); test::ScopedSetInternalDisplayId set_internal(primary_id); SetCursorCompositionEnabled(true); - ASSERT_EQ(2.0f, - Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + ASSERT_EQ( + 2.0f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); ASSERT_TRUE(SetDisplayUIScale(primary_id, 2.0f)); - ASSERT_EQ(1.0f, - Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + ASSERT_EQ( + 1.0f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); } #endif diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index d773c08..4bad4eb 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc @@ -59,12 +59,12 @@ class DisplayManagerTest : public test::AshTestBase, void SetUp() override { AshTestBase::SetUp(); - Shell::GetScreen()->AddObserver(this); + gfx::Screen::GetScreen()->AddObserver(this); Shell::GetPrimaryRootWindow()->AddObserver(this); } void TearDown() override { Shell::GetPrimaryRootWindow()->RemoveObserver(this); - Shell::GetScreen()->RemoveObserver(this); + gfx::Screen::GetScreen()->RemoveObserver(this); AshTestBase::TearDown(); } @@ -415,31 +415,32 @@ TEST_F(DisplayManagerTest, OverscanInsetsTest) { GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()). bounds_in_native().ToString()); EXPECT_EQ("0,501 400x400", - GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). - bounds_in_native().ToString()); + GetDisplayInfo(gfx::Screen::GetScreen()->GetPrimaryDisplay()) + .bounds_in_native() + .ToString()); EXPECT_EQ("0,0 188x190", - Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); // Make sure just moving the overscan area should property notify observers. UpdateDisplay("0+0-500x500"); - int64_t primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); + int64_t primary_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 20, 20)); EXPECT_EQ("0,0 480x480", - Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); reset(); display_manager()->SetOverscanInsets(primary_id, gfx::Insets(10, 10, 10, 10)); EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); EXPECT_TRUE( changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); EXPECT_EQ("0,0 480x480", - Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); reset(); display_manager()->SetOverscanInsets(primary_id, gfx::Insets(0, 0, 0, 0)); EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); EXPECT_TRUE( changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_WORK_AREA); EXPECT_EQ("0,0 500x500", - Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); } TEST_F(DisplayManagerTest, ZeroOverscanInsets) { @@ -530,7 +531,7 @@ TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) { GetDisplayInfoForId(external_id).bounds_in_native().ToString()); EXPECT_EQ(1U, display_manager()->num_connected_displays()); EXPECT_FALSE(display_manager()->IsInMirrorMode()); - EXPECT_EQ(external_id, Shell::GetScreen()->GetPrimaryDisplay().id()); + EXPECT_EQ(external_id, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(internal_display_id, gfx::Display::InternalDisplayId()); @@ -540,7 +541,8 @@ TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) { display_info_list.push_back(external_display_info); display_manager()->OnNativeDisplaysChanged(display_info_list); EXPECT_EQ(2U, display_manager()->GetNumDisplays()); - EXPECT_EQ(internal_display_id, Shell::GetScreen()->GetPrimaryDisplay().id()); + EXPECT_EQ(internal_display_id, + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); // This combinatino is new, so internal display becomes primary. EXPECT_EQ("0,0 500x500", @@ -955,7 +957,7 @@ TEST_F(DisplayManagerTest, UIScale) { test::ScopedDisable125DSFForUIScaling disable; UpdateDisplay("1280x800"); - int64_t display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); + int64_t display_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); SetDisplayUIScale(display_id, 1.125f); EXPECT_EQ(1.0, GetDisplayInfoAt(0).configured_ui_scale()); SetDisplayUIScale(display_id, 0.8f); @@ -1012,7 +1014,7 @@ TEST_F(DisplayManagerTest, UIScale) { EXPECT_EQ(1.125f, GetDisplayInfoAt(0).configured_ui_scale()); SetDisplayUIScale(display_id, 1.0f); EXPECT_EQ(1.0f, GetDisplayInfoAt(0).configured_ui_scale()); - gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); EXPECT_EQ(2.0f, display.device_scale_factor()); EXPECT_EQ("640x425", display.bounds().size().ToString()); @@ -1030,7 +1032,7 @@ TEST_F(DisplayManagerTest, UIScale) { SetDisplayUIScale(display_id, 2.0f); EXPECT_EQ(2.0f, GetDisplayInfoAt(0).configured_ui_scale()); EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); - display = Shell::GetScreen()->GetPrimaryDisplay(); + display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); EXPECT_EQ(1.0f, display.device_scale_factor()); EXPECT_EQ("1280x850", display.bounds().size().ToString()); @@ -1040,7 +1042,7 @@ TEST_F(DisplayManagerTest, UIScale) { SetDisplayUIScale(display_id, 1.25f); EXPECT_EQ(1.25f, GetDisplayInfoAt(0).configured_ui_scale()); EXPECT_EQ(1.0f, GetDisplayInfoAt(0).GetEffectiveUIScale()); - display = Shell::GetScreen()->GetPrimaryDisplay(); + display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); EXPECT_EQ(1.0f, display.device_scale_factor()); EXPECT_EQ("1280x850", display.bounds().size().ToString()); } @@ -1105,7 +1107,7 @@ TEST_F(DisplayManagerTest, UIScaleWithDisplayMode) { } TEST_F(DisplayManagerTest, Use125DSFForUIScaling) { - int64_t display_id = Shell::GetScreen()->GetPrimaryDisplay().id(); + int64_t display_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); test::ScopedSetInternalDisplayId set_internal(display_id); UpdateDisplay("1920x1080*1.25"); @@ -1139,7 +1141,7 @@ TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) { UpdateDisplay("200x200, 400x400"); - int64_t unified_id = Shell::GetScreen()->GetPrimaryDisplay().id(); + int64_t unified_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); DisplayInfo info = display_manager->GetDisplayInfo(unified_id); ASSERT_EQ(2u, info.display_modes().size()); EXPECT_EQ("400x200", info.display_modes()[0].size.ToString()); @@ -1147,7 +1149,7 @@ TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) { EXPECT_EQ("800x400", info.display_modes()[1].size.ToString()); EXPECT_FALSE(info.display_modes()[1].native); EXPECT_EQ("400x200", - Shell::GetScreen()->GetPrimaryDisplay().size().ToString()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); DisplayMode active_mode = display_manager->GetActiveModeForDisplayId(unified_id); EXPECT_EQ(1.0f, active_mode.ui_scale); @@ -1155,7 +1157,7 @@ TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) { EXPECT_TRUE(test::SetDisplayResolution(unified_id, gfx::Size(800, 400))); EXPECT_EQ("800x400", - Shell::GetScreen()->GetPrimaryDisplay().size().ToString()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); active_mode = display_manager->GetActiveModeForDisplayId(unified_id); EXPECT_EQ(1.0f, active_mode.ui_scale); @@ -1164,7 +1166,7 @@ TEST_F(DisplayManagerTest, ResolutionChangeInUnifiedMode) { // resolution change will not persist in unified desktop mode. UpdateDisplay("600x600, 200x200"); EXPECT_EQ("1200x600", - Shell::GetScreen()->GetPrimaryDisplay().size().ToString()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().size().ToString()); active_mode = display_manager->GetActiveModeForDisplayId(unified_id); EXPECT_EQ(1.0f, active_mode.ui_scale); EXPECT_TRUE(active_mode.native); @@ -1270,7 +1272,7 @@ TEST_F(DisplayManagerTest, SoftwareMirroring) { EXPECT_EQ(NULL, test_api.GetHost()); TestDisplayObserver display_observer; - Shell::GetScreen()->AddObserver(&display_observer); + gfx::Screen::GetScreen()->AddObserver(&display_observer); DisplayManager* display_manager = Shell::GetInstance()->display_manager(); display_manager->SetMultiDisplayMode(DisplayManager::MIRRORING); @@ -1279,7 +1281,7 @@ TEST_F(DisplayManagerTest, SoftwareMirroring) { EXPECT_TRUE(display_observer.changed_and_reset()); EXPECT_EQ(1U, display_manager->GetNumDisplays()); EXPECT_EQ("0,0 300x400", - Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("400x500", test_api.GetHost()->GetBounds().size().ToString()); EXPECT_EQ("300x400", test_api.GetHost()->window()->bounds().size().ToString()); @@ -1322,7 +1324,7 @@ TEST_F(DisplayManagerTest, SoftwareMirroring) { EXPECT_EQ("400x600", test_api.GetHost()->window()->bounds().size().ToString()); - Shell::GetScreen()->RemoveObserver(&display_observer); + gfx::Screen::GetScreen()->RemoveObserver(&display_observer); } TEST_F(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { @@ -1395,17 +1397,17 @@ TEST_F(DisplayManagerTest, MirroredLayout) { DisplayManager* display_manager = Shell::GetInstance()->display_manager(); UpdateDisplay("500x500,400x400"); EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); - EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_EQ(2U, display_manager->num_connected_displays()); UpdateDisplay("1+0-500x500,1+0-500x500"); EXPECT_TRUE(display_manager->GetCurrentDisplayLayout().mirrored); - EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); + EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_EQ(2U, display_manager->num_connected_displays()); UpdateDisplay("500x500,500x500"); EXPECT_FALSE(display_manager->GetCurrentDisplayLayout().mirrored); - EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_EQ(2U, display_manager->num_connected_displays()); } @@ -1491,7 +1493,7 @@ TEST_F(DisplayManagerTest, NotifyPrimaryChangeUndock) { TEST_F(DisplayManagerTest, MAYBE_UpdateDisplayWithHostOrigin) { UpdateDisplay("100x200,300x400"); - ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); aura::Window::Windows root_windows = Shell::GetInstance()->GetAllRootWindows(); ASSERT_EQ(2U, root_windows.size()); @@ -1505,21 +1507,21 @@ TEST_F(DisplayManagerTest, MAYBE_UpdateDisplayWithHostOrigin) { EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); UpdateDisplay("100x200,200+300-300x400"); - ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_EQ("0,0", host0->GetBounds().origin().ToString()); EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); EXPECT_EQ("200,300", host1->GetBounds().origin().ToString()); EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); UpdateDisplay("400+500-200x300,300x400"); - ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_EQ("400,500", host0->GetBounds().origin().ToString()); EXPECT_EQ("200x300", host0->GetBounds().size().ToString()); EXPECT_EQ("0,0", host1->GetBounds().origin().ToString()); EXPECT_EQ("300x400", host1->GetBounds().size().ToString()); UpdateDisplay("100+200-100x200,300+500-200x300"); - ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_EQ("100,200", host0->GetBounds().origin().ToString()); EXPECT_EQ("100x200", host0->GetBounds().size().ToString()); EXPECT_EQ("300,500", host1->GetBounds().origin().ToString()); @@ -1924,7 +1926,8 @@ typedef testing::Test DisplayManagerFontTest; TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); ASSERT_DOUBLE_EQ( - 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 1.0f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); } @@ -1933,7 +1936,8 @@ TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { test::ScopedDisable125DSFForUIScaling disable; FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); ASSERT_DOUBLE_EQ( - 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 1.25f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); } @@ -1941,14 +1945,16 @@ TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); ASSERT_DOUBLE_EQ( - 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 2.0f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); - SetDisplayUIScale(Shell::GetScreen()->GetPrimaryDisplay().id(), 2.0f); + SetDisplayUIScale(gfx::Screen::GetScreen()->GetPrimaryDisplay().id(), 2.0f); ASSERT_DOUBLE_EQ( - 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 1.0f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); } @@ -1956,7 +1962,8 @@ TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { FontTestHelper helper(1.0f, FontTestHelper::EXTERNAL); ASSERT_DOUBLE_EQ( - 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 1.0f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); } @@ -1964,7 +1971,8 @@ TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) { FontTestHelper helper(1.25f, FontTestHelper::EXTERNAL); ASSERT_DOUBLE_EQ( - 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 1.25f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); } @@ -1972,7 +1980,8 @@ TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) { TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL); ASSERT_DOUBLE_EQ( - 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 2.0f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); } @@ -1981,14 +1990,16 @@ TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125InternalWithScaling) { FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); ASSERT_DOUBLE_EQ( - 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 1.0f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); EXPECT_NE(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); - SetDisplayUIScale(Shell::GetScreen()->GetPrimaryDisplay().id(), 0.8f); + SetDisplayUIScale(gfx::Screen::GetScreen()->GetPrimaryDisplay().id(), 0.8f); ASSERT_DOUBLE_EQ( - 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); + 1.25f, + gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); EXPECT_EQ(gfx::FontRenderParams::HINTING_NONE, GetFontHintingParams()); } diff --git a/ash/display/event_transformation_handler.cc b/ash/display/event_transformation_handler.cc index e1af21f..484a20a 100644 --- a/ash/display/event_transformation_handler.cc +++ b/ash/display/event_transformation_handler.cc @@ -8,7 +8,6 @@ #include "ash/display/display_info.h" #include "ash/display/display_manager.h" -#include "ash/shell.h" #include "ash/wm/window_util.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" @@ -43,7 +42,7 @@ void EventTransformationHandler::OnScrollEvent(ui::ScrollEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); ::wm::ConvertPointToScreen(target, &point_in_screen); const gfx::Display& display = - Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen); + gfx::Screen::GetScreen()->GetDisplayNearestPoint(point_in_screen); // Apply some additional scaling if the display is non-integrated. if (!display.IsInternal()) diff --git a/ash/display/extended_mouse_warp_controller.cc b/ash/display/extended_mouse_warp_controller.cc index f17444b..3d28c5f 100644 --- a/ash/display/extended_mouse_warp_controller.cc +++ b/ash/display/extended_mouse_warp_controller.cc @@ -42,7 +42,7 @@ aura::Window* GetRootWindowForDisplayId(int64_t display_id) { // Helper method that maps an aura::Window to a gfx::Display. gfx::Display GetDisplayFromWindow(aura::Window* window) { - return Shell::GetScreen()->GetDisplayNearestWindow(window); + return gfx::Screen::GetScreen()->GetDisplayNearestWindow(window); } } // namespace @@ -94,7 +94,7 @@ ExtendedMouseWarpController::ExtendedMouseWarpController( // display. DisplayLayout::Position is defined in terms of primary. DisplayLayout::Position position = display_manager->GetCurrentDisplayLayout().position; - const gfx::Display& a = Shell::GetScreen()->GetPrimaryDisplay(); + const gfx::Display& a = gfx::Screen::GetScreen()->GetPrimaryDisplay(); const gfx::Display& b = ScreenUtil::GetSecondaryDisplay(); // TODO(oshima): Use ComputeBondary instead. @@ -112,7 +112,7 @@ ExtendedMouseWarpController::~ExtendedMouseWarpController() { } bool ExtendedMouseWarpController::WarpMouseCursor(ui::MouseEvent* event) { - if (Shell::GetScreen()->GetNumDisplays() <= 1 || !enabled_) + if (gfx::Screen::GetScreen()->GetNumDisplays() <= 1 || !enabled_) return false; aura::Window* target = static_cast<aura::Window*>(event->target()); diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc index df57174..c93bba0 100644 --- a/ash/display/mirror_window_controller.cc +++ b/ash/display/mirror_window_controller.cc @@ -35,6 +35,7 @@ #include "ui/compositor/reflector.h" #include "ui/gfx/canvas.h" #include "ui/gfx/native_widget_types.h" +#include "ui/gfx/screen.h" #if defined(USE_X11) #include "ui/gfx/x/x11_types.h" @@ -159,7 +160,7 @@ void MirrorWindowController::UpdateWindow( const std::vector<DisplayInfo>& display_info_list) { static int mirror_host_count = 0; DisplayManager* display_manager = Shell::GetInstance()->display_manager(); - const gfx::Display& primary = Shell::GetScreen()->GetPrimaryDisplay(); + const gfx::Display& primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); const DisplayInfo& source_display_info = display_manager->GetDisplayInfo(primary.id()); @@ -214,7 +215,7 @@ void MirrorWindowController::UpdateWindow( Shell::GetInstance() ->window_tree_host_manager() ->GetAshWindowTreeHostForDisplayId( - Shell::GetScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); unified_ash_host->RegisterMirroringHost(host_info->ash_host.get()); aura::client::SetScreenPositionClient(host->window(), screen_position_client_.get()); diff --git a/ash/display/resolution_notification_controller.cc b/ash/display/resolution_notification_controller.cc index 609b4ea0..9f50d1c 100644 --- a/ash/display/resolution_notification_controller.cc +++ b/ash/display/resolution_notification_controller.cc @@ -152,12 +152,12 @@ ResolutionNotificationController::ResolutionChangeInfo:: ResolutionNotificationController::ResolutionNotificationController() { Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); - Shell::GetScreen()->AddObserver(this); + gfx::Screen::GetScreen()->AddObserver(this); } ResolutionNotificationController::~ResolutionNotificationController() { Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); - Shell::GetScreen()->RemoveObserver(this); + gfx::Screen::GetScreen()->RemoveObserver(this); } void ResolutionNotificationController::PrepareNotification( diff --git a/ash/display/resolution_notification_controller_unittest.cc b/ash/display/resolution_notification_controller_unittest.cc index a6a7f1e..79922fe 100644 --- a/ash/display/resolution_notification_controller_unittest.cc +++ b/ash/display/resolution_notification_controller_unittest.cc @@ -233,7 +233,7 @@ TEST_F(ResolutionNotificationControllerTest, AcceptButton) { ash::Shell::GetInstance()->display_manager(); UpdateDisplay("300x300#300x300%59|200x200%60"); - const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay(); + const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); EXPECT_TRUE(IsNotificationVisible()); @@ -298,7 +298,7 @@ TEST_F(ResolutionNotificationControllerTest, Timeout) { return; UpdateDisplay("300x300#300x300%59|200x200%60"); - const gfx::Display& display = ash::Shell::GetScreen()->GetPrimaryDisplay(); + const gfx::Display& display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); SetDisplayResolutionAndNotify(display, gfx::Size(200, 200)); for (int i = 0; i < ResolutionNotificationController::kTimeoutInSec; ++i) { diff --git a/ash/display/root_window_transformers.cc b/ash/display/root_window_transformers.cc index 830cdba..4e3d139 100644 --- a/ash/display/root_window_transformers.cc +++ b/ash/display/root_window_transformers.cc @@ -21,6 +21,7 @@ #include "ui/gfx/display.h" #include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/size_conversions.h" +#include "ui/gfx/screen.h" #include "ui/gfx/transform.h" #include "ui/gfx/transform.h" @@ -279,7 +280,7 @@ class PartialBoundsRootWindowTransformer : public RootWindowTransformer { PartialBoundsRootWindowTransformer(const gfx::Rect& screen_bounds, const gfx::Display& display) { gfx::Display unified_display = - Shell::GetInstance()->GetScreen()->GetPrimaryDisplay(); + gfx::Screen::GetScreen()->GetPrimaryDisplay(); DisplayInfo display_info = Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id()); root_bounds_ = gfx::Rect(display_info.bounds_in_native().size()); diff --git a/ash/display/root_window_transformers_unittest.cc b/ash/display/root_window_transformers_unittest.cc index cf16d70..1da6c92 100644 --- a/ash/display/root_window_transformers_unittest.cc +++ b/ash/display/root_window_transformers_unittest.cc @@ -120,7 +120,7 @@ CreateCurrentRootWindowTransformerForMirroring() { const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo(display_manager->mirroring_display_id()); const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( - Shell::GetScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); return scoped_ptr<RootWindowTransformer>( CreateRootWindowTransformerForMirroredDisplay(source_display_info, mirror_display_info)); @@ -151,7 +151,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_RotateAndMagnify) { Shell::GetInstance()->AddPreTargetHandler(&event_handler); UpdateDisplay("120x200,300x400*2"); - gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); @@ -243,7 +243,7 @@ TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { UpdateDisplay("600x400*2@1.5,500x300"); - gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); test::ScopedSetInternalDisplayId set_internal(display1.id()); gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); @@ -264,7 +264,7 @@ TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { magnifier->SetEnabled(false); SetDisplayUIScale(display1.id(), 1.25f); - display1 = Shell::GetScreen()->GetPrimaryDisplay(); + display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); display2 = ScreenUtil::GetSecondaryDisplay(); magnifier->SetEnabled(true); EXPECT_EQ(2.0f, magnifier->GetScale()); @@ -283,7 +283,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_TouchScaleAndMagnify) { Shell::GetInstance()->AddPreTargetHandler(&event_handler); UpdateDisplay("200x200*2"); - gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); aura::Window* root_window = root_windows[0]; ui::test::EventGenerator generator(root_window); @@ -323,7 +323,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_ConvertHostToRootCoords) { // Test 1 UpdateDisplay("600x400*2/r@1.5"); - gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); @@ -349,7 +349,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_ConvertHostToRootCoords) { // Test 2 UpdateDisplay("600x400*2/u@1.5"); - display1 = Shell::GetScreen()->GetPrimaryDisplay(); + display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); root_windows = Shell::GetAllRootWindows(); EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); @@ -374,7 +374,7 @@ TEST_F(RootWindowTransformersTest, MAYBE_ConvertHostToRootCoords) { // Test 3 UpdateDisplay("600x400*2/l@1.5"); - display1 = Shell::GetScreen()->GetPrimaryDisplay(); + display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); root_windows = Shell::GetAllRootWindows(); EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc index 477c710..d5c33a4 100644 --- a/ash/display/screen_ash.cc +++ b/ash/display/screen_ash.cc @@ -99,7 +99,8 @@ gfx::Point ScreenAsh::GetCursorScreenPoint() { } gfx::NativeWindow ScreenAsh::GetWindowUnderCursor() { - return GetWindowAtScreenPoint(Shell::GetScreen()->GetCursorScreenPoint()); + return GetWindowAtScreenPoint( + gfx::Screen::GetScreen()->GetCursorScreenPoint()); } gfx::NativeWindow ScreenAsh::GetWindowAtScreenPoint(const gfx::Point& point) { diff --git a/ash/display/screen_ash_unittest.cc b/ash/display/screen_ash_unittest.cc index 798b5e6..a60d54f 100644 --- a/ash/display/screen_ash_unittest.cc +++ b/ash/display/screen_ash_unittest.cc @@ -15,8 +15,6 @@ class ScreenAshTest : public test::AshTestBase { ScreenAshTest() {} ~ScreenAshTest() override {} - static gfx::Screen* Screen() { return Shell::GetScreen(); } - private: DISALLOW_COPY_AND_ASSIGN(ScreenAshTest); }; @@ -38,8 +36,10 @@ TEST_F(ScreenAshTest, TestGetWindowAtScreenPoint) { ASSERT_NE(win1->GetRootWindow(), win2->GetRootWindow()); - EXPECT_EQ(win1.get(), Screen()->GetWindowAtScreenPoint(gfx::Point(50, 60))); - EXPECT_EQ(win2.get(), Screen()->GetWindowAtScreenPoint(gfx::Point(250, 260))); + EXPECT_EQ(win1.get(), gfx::Screen::GetScreen()->GetWindowAtScreenPoint( + gfx::Point(50, 60))); + EXPECT_EQ(win2.get(), gfx::Screen::GetScreen()->GetWindowAtScreenPoint( + gfx::Point(250, 260))); } } // namespace ash diff --git a/ash/display/screen_position_controller.cc b/ash/display/screen_position_controller.cc index 9503fd4..2c146a8 100644 --- a/ash/display/screen_position_controller.cc +++ b/ash/display/screen_position_controller.cc @@ -123,8 +123,11 @@ void ScreenPositionController::ConvertPointToScreen( gfx::Point* point) { const aura::Window* root = window->GetRootWindow(); aura::Window::ConvertPointToTarget(window, root, point); - const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( - const_cast<aura::Window*>(root)).bounds().origin(); + const gfx::Point display_origin = + gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(const_cast<aura::Window*>(root)) + .bounds() + .origin(); point->Offset(display_origin.x(), display_origin.y()); } @@ -132,8 +135,11 @@ void ScreenPositionController::ConvertPointFromScreen( const aura::Window* window, gfx::Point* point) { const aura::Window* root = window->GetRootWindow(); - const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( - const_cast<aura::Window*>(root)).bounds().origin(); + const gfx::Point display_origin = + gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(const_cast<aura::Window*>(root)) + .bounds() + .origin(); point->Offset(-display_origin.x(), -display_origin.y()); aura::Window::ConvertPointToTarget(root, window, point); } @@ -222,8 +228,10 @@ void ScreenPositionController::SetBounds(aura::Window* window, } } gfx::Point origin(bounds.origin()); - const gfx::Point display_origin = Shell::GetScreen()->GetDisplayNearestWindow( - window).bounds().origin(); + const gfx::Point display_origin = gfx::Screen::GetScreen() + ->GetDisplayNearestWindow(window) + .bounds() + .origin(); origin.Offset(-display_origin.x(), -display_origin.y()); window->SetBounds(gfx::Rect(origin, bounds.size())); } diff --git a/ash/display/screen_position_controller_unittest.cc b/ash/display/screen_position_controller_unittest.cc index a35b565..35a4727 100644 --- a/ash/display/screen_position_controller_unittest.cc +++ b/ash/display/screen_position_controller_unittest.cc @@ -114,7 +114,7 @@ TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) { const gfx::Point window_pos(100, 100); window_->SetBoundsInScreen( gfx::Rect(window_pos, gfx::Size(100, 100)), - Shell::GetScreen()->GetDisplayNearestPoint(window_pos)); + gfx::Screen::GetScreen()->GetDisplayNearestPoint(window_pos)); SetSecondaryDisplayLayout(DisplayLayout::RIGHT); // The point is on the primary root window. EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); @@ -152,7 +152,7 @@ TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreen) { const gfx::Point window_pos2(300, 100); window_->SetBoundsInScreen( gfx::Rect(window_pos2, gfx::Size(100, 100)), - Shell::GetScreen()->GetDisplayNearestPoint(window_pos2)); + gfx::Screen::GetScreen()->GetDisplayNearestPoint(window_pos2)); // The point is on the secondary display. EXPECT_EQ("250,50", ConvertHostPointToScreen(50, 50)); // The point is out of the all root windows. @@ -197,7 +197,7 @@ TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { // Put |window_| to the primary 2x display. window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), - Shell::GetScreen()->GetPrimaryDisplay()); + gfx::Screen::GetScreen()->GetPrimaryDisplay()); // (30, 30) means the host coordinate, so the point is still on the primary // root window. Since it's 2x, the specified native point was halved. EXPECT_EQ("15,15", ConvertHostPointToScreen(30, 30)); @@ -223,7 +223,7 @@ TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenRotate) { UpdateDisplay("100+100-200x200/r,100+500-200x200/l"); // Put |window_| to the 1st. window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), - Shell::GetScreen()->GetPrimaryDisplay()); + gfx::Screen::GetScreen()->GetPrimaryDisplay()); // The point is on the 1st host. EXPECT_EQ("70,149", ConvertHostPointToScreen(50, 70)); @@ -255,7 +255,7 @@ TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenUIScale) { UpdateDisplay("100+100-200x200*2@1.5,100+500-200x200"); // Put |window_| to the 1st. window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), - Shell::GetScreen()->GetPrimaryDisplay()); + gfx::Screen::GetScreen()->GetPrimaryDisplay()); // The point is on the 1st host. EXPECT_EQ("45,45", ConvertHostPointToScreen(60, 60)); diff --git a/ash/display/shared_display_edge_indicator.cc b/ash/display/shared_display_edge_indicator.cc index 09d666a..0618622 100644 --- a/ash/display/shared_display_edge_indicator.cc +++ b/ash/display/shared_display_edge_indicator.cc @@ -57,7 +57,7 @@ views::Widget* CreateWidget(const gfx::Rect& bounds, widget->SetVisibilityChangedAnimationsEnabled(false); widget->GetNativeWindow()->SetName("SharedEdgeIndicator"); widget->SetContentsView(contents_view); - gfx::Display display = Shell::GetScreen()->GetDisplayMatching(bounds); + gfx::Display display = gfx::Screen::GetScreen()->GetDisplayMatching(bounds); aura::Window* window = widget->GetNativeWindow(); aura::client::ScreenPositionClient* screen_position_client = aura::client::GetScreenPositionClient(window->GetRootWindow()); diff --git a/ash/display/window_tree_host_manager.cc b/ash/display/window_tree_host_manager.cc index f99f7a4..f298e9c 100644 --- a/ash/display/window_tree_host_manager.cc +++ b/ash/display/window_tree_host_manager.cc @@ -246,7 +246,7 @@ WindowTreeHostManager::WindowTreeHostManager() WindowTreeHostManager::~WindowTreeHostManager() {} void WindowTreeHostManager::Start() { - Shell::GetScreen()->AddObserver(this); + gfx::Screen::GetScreen()->AddObserver(this); Shell::GetInstance()->display_manager()->set_delegate(this); } @@ -260,9 +260,9 @@ void WindowTreeHostManager::Shutdown() { cursor_window_controller_.reset(); mirror_window_controller_.reset(); - Shell::GetScreen()->RemoveObserver(this); + gfx::Screen::GetScreen()->RemoveObserver(this); - int64_t primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); + int64_t primary_id = gfx::Screen::GetScreen()->GetPrimaryDisplay().id(); // Delete non primary root window controllers first, then // delete the primary root window controller. @@ -391,7 +391,7 @@ WindowTreeHostManager::GetAllRootWindowControllers() { } void WindowTreeHostManager::SwapPrimaryDisplayForTest() { - if (Shell::GetScreen()->GetNumDisplays() <= 1) + if (gfx::Screen::GetScreen()->GetNumDisplays() <= 1) return; SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); } @@ -432,7 +432,8 @@ void WindowTreeHostManager::SetPrimaryDisplay( if (!non_primary_host) return; - gfx::Display old_primary_display = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display old_primary_display = + gfx::Screen::GetScreen()->GetPrimaryDisplay(); // Swap root windows between current and new primary display. AshWindowTreeHost* primary_host = window_tree_hosts_[primary_display_id]; @@ -467,7 +468,7 @@ void WindowTreeHostManager::UpdateMouseLocationAfterDisplayChange() { // use the same native location. Otherwise find the display closest // to the current cursor location in screen coordinates. - gfx::Point point_in_screen = Shell::GetScreen()->GetCursorScreenPoint(); + gfx::Point point_in_screen = gfx::Screen::GetScreen()->GetCursorScreenPoint(); gfx::Point target_location_in_native; int64_t closest_distance_squared = -1; DisplayManager* display_manager = GetDisplayManager(); @@ -707,7 +708,7 @@ void WindowTreeHostManager::OnDisplayMetricsChanged(const gfx::Display& display, } void WindowTreeHostManager::OnHostResized(const aura::WindowTreeHost* host) { - gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( + gfx::Display display = gfx::Screen::GetScreen()->GetDisplayNearestWindow( const_cast<aura::Window*>(host->window())); DisplayManager* display_manager = GetDisplayManager(); @@ -741,7 +742,7 @@ void WindowTreeHostManager::CloseMirroringDisplayIfNotNecessary() { void WindowTreeHostManager::PreDisplayConfigurationChange(bool clear_focus) { FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); focus_activation_store_->Store(clear_focus); - gfx::Screen* screen = Shell::GetScreen(); + gfx::Screen* screen = gfx::Screen::GetScreen(); gfx::Point point_in_screen = screen->GetCursorScreenPoint(); cursor_location_in_screen_coords_for_restore_ = point_in_screen; @@ -766,7 +767,7 @@ void WindowTreeHostManager::PostDisplayConfigurationChange() { layout_store->UpdateMultiDisplayState( pair, display_manager->IsInMirrorMode(), layout.default_unified); - if (Shell::GetScreen()->GetNumDisplays() > 1) { + if (gfx::Screen::GetScreen()->GetNumDisplays() > 1) { int64_t primary_id = layout.primary_id; SetPrimaryDisplayId(primary_id == gfx::Display::kInvalidDisplayID ? pair.first @@ -776,7 +777,7 @@ void WindowTreeHostManager::PostDisplayConfigurationChange() { // doesn't exist, or b) the primary_id has already been // set to the same and didn't update it. layout_store->UpdatePrimaryDisplayId( - pair, Shell::GetScreen()->GetPrimaryDisplay().id()); + pair, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); } } FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); diff --git a/ash/display/window_tree_host_manager_unittest.cc b/ash/display/window_tree_host_manager_unittest.cc index 391e53b..8481b19 100644 --- a/ash/display/window_tree_host_manager_unittest.cc +++ b/ash/display/window_tree_host_manager_unittest.cc @@ -71,7 +71,7 @@ class TestObserver : public WindowTreeHostManager::Observer, focus_changed_count_(0), activation_changed_count_(0) { Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); - Shell::GetScreen()->AddObserver(this); + gfx::Screen::GetScreen()->AddObserver(this); aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) ->AddObserver(this); aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) @@ -80,7 +80,7 @@ class TestObserver : public WindowTreeHostManager::Observer, ~TestObserver() override { Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); - Shell::GetScreen()->RemoveObserver(this); + gfx::Screen::GetScreen()->RemoveObserver(this); aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) ->RemoveObserver(this); aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) @@ -174,19 +174,19 @@ class TestObserver : public WindowTreeHostManager::Observer, }; gfx::Display GetPrimaryDisplay() { - return Shell::GetScreen()->GetDisplayNearestWindow( + return gfx::Screen::GetScreen()->GetDisplayNearestWindow( Shell::GetAllRootWindows()[0]); } gfx::Display GetSecondaryDisplay() { - return Shell::GetScreen()->GetDisplayNearestWindow( + return gfx::Screen::GetScreen()->GetDisplayNearestWindow( Shell::GetAllRootWindows()[1]); } void SetSecondaryDisplayLayoutAndOffset(DisplayLayout::Position position, int offset) { DisplayLayout layout(position, offset); - ASSERT_GT(Shell::GetScreen()->GetNumDisplays(), 1); + ASSERT_GT(gfx::Screen::GetScreen()->GetNumDisplays(), 1); Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(layout); } @@ -212,9 +212,9 @@ class WindowTreeHostManagerShutdownTest : public test::AshTestBase { return; // Make sure that primary display is accessible after shutdown. - gfx::Display primary = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); EXPECT_EQ("0,0 444x333", primary.bounds().ToString()); - EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); } private: @@ -640,13 +640,13 @@ TEST_F(WindowTreeHostManagerTest, BoundsUpdated) { EXPECT_LE(1, observer.GetFocusChangedCountAndReset()); EXPECT_LE(1, observer.GetActivationChangedCountAndReset()); EXPECT_EQ("0,0 400x400", GetPrimaryDisplay().bounds().ToString()); - EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); + EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); UpdateDisplay("400x500*2,300x300"); EXPECT_EQ(1, observer.CountAndReset()); EXPECT_EQ(0, observer.GetFocusChangedCountAndReset()); EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); - ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + ASSERT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_EQ("0,0 200x250", GetPrimaryDisplay().bounds().ToString()); EXPECT_EQ("0,250 300x300", GetSecondaryDisplay().bounds().ToString()); @@ -713,7 +713,7 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimary) { DisplayManager* display_manager = Shell::GetInstance()->display_manager(); UpdateDisplay("200x200,300x300"); - gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); DisplayLayout display_layout(DisplayLayout::RIGHT, 50); @@ -730,11 +730,12 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimary) { Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); EXPECT_TRUE(primary_root->Contains(shelf_window)); EXPECT_FALSE(secondary_root->Contains(shelf_window)); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(-100, -100)) + .id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString()); EXPECT_EQ("0,0 200x153", primary_display.work_area().ToString()); @@ -749,13 +750,14 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimary) { EXPECT_EQ("left, -50", inverted_layout.ToString()); EXPECT_EQ(secondary_display.id(), - Shell::GetScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(-100, -100)) + .id()); EXPECT_EQ(secondary_display.id(), - Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); + gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( secondary_display.id())); @@ -765,7 +767,7 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimary) { EXPECT_FALSE(secondary_root->Contains(shelf_window)); // Test if the bounds are correctly swapped. - gfx::Display swapped_primary = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display swapped_primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); 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()); @@ -780,13 +782,15 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimary) { // Deleting 2nd display should move the primary to original primary display. UpdateDisplay("200x200"); RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. - EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); - EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); + EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(-100, -100)) + .id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); EXPECT_TRUE(tracker.Contains(primary_root)); EXPECT_FALSE(tracker.Contains(secondary_root)); EXPECT_TRUE(primary_root->Contains(shelf_window)); @@ -804,7 +808,7 @@ TEST_F(WindowTreeHostManagerTest, FindNearestDisplay) { DisplayLayout display_layout(DisplayLayout::RIGHT, 50); display_manager->SetLayoutForCurrentDisplays(display_layout); - gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); EXPECT_NE(primary_display.id(), secondary_display.id()); aura::Window* primary_root = @@ -815,33 +819,42 @@ TEST_F(WindowTreeHostManagerTest, FindNearestDisplay) { EXPECT_NE(primary_root, secondary_root); // Test that points outside of any display return the nearest display. - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, 0)).id()); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(0, -100)).id()); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(100, 100)).id()); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(224, 25)).id()); - EXPECT_EQ( - secondary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(226, 25)).id()); - EXPECT_EQ( - secondary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(600, 100)).id()); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(174, 225)).id()); - EXPECT_EQ( - secondary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(176, 225)).id()); - EXPECT_EQ( - secondary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(300, 400)).id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(-100, 0)) + .id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(0, -100)) + .id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(100, 100)) + .id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(224, 25)) + .id()); + EXPECT_EQ(secondary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(226, 25)) + .id()); + EXPECT_EQ(secondary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(600, 100)) + .id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(174, 225)) + .id()); + EXPECT_EQ(secondary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(176, 225)) + .id()); + EXPECT_EQ(secondary_display.id(), + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(300, 400)) + .id()); } TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { @@ -853,7 +866,7 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { DisplayManager* display_manager = Shell::GetInstance()->display_manager(); UpdateDisplay("200x200,300x300"); - gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display primary_display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); DisplayLayout display_layout(DisplayLayout::RIGHT, 50); @@ -870,17 +883,18 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { EXPECT_TRUE(primary_root->Contains(shelf_window)); EXPECT_FALSE(secondary_root->Contains(shelf_window)); EXPECT_NE(primary_root, secondary_root); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(-100, -100)) + .id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); // Switch primary and secondary by display ID. TestObserver observer; window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); EXPECT_EQ(secondary_display.id(), - Shell::GetScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_LT(0, observer.CountAndReset()); @@ -907,13 +921,15 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { // Deleting 2nd display should move the primary to original primary display. UpdateDisplay("200x200"); RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. - EXPECT_EQ(1, Shell::GetScreen()->GetNumDisplays()); - EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); - EXPECT_EQ( - primary_display.id(), - Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); + EXPECT_EQ(1, gfx::Screen::GetScreen()->GetNumDisplays()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(primary_display.id(), - Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); + gfx::Screen::GetScreen() + ->GetDisplayNearestPoint(gfx::Point(-100, -100)) + .id()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen()->GetDisplayNearestWindow(NULL).id()); EXPECT_TRUE(tracker.Contains(primary_root)); EXPECT_FALSE(tracker.Contains(secondary_root)); EXPECT_TRUE(primary_root->Contains(shelf_window)); @@ -927,9 +943,9 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { display_manager->GetDisplayInfo(secondary_display.id())); display_manager->OnNativeDisplaysChanged(display_info_list); - EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); + EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); EXPECT_EQ(secondary_display.id(), - Shell::GetScreen()->GetPrimaryDisplay().id()); + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( secondary_display.id())); @@ -951,8 +967,9 @@ TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { display_info_list2.push_back(primary_display_info); display_info_list2.push_back(third_display_info); display_manager->OnNativeDisplaysChanged(display_info_list2); - EXPECT_EQ(2, Shell::GetScreen()->GetNumDisplays()); - EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); + EXPECT_EQ(2, gfx::Screen::GetScreen()->GetNumDisplays()); + EXPECT_EQ(primary_display.id(), + gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( primary_display.id())); @@ -971,7 +988,7 @@ TEST_F(WindowTreeHostManagerTest, OverscanInsets) { Shell::GetInstance()->AddPreTargetHandler(&event_handler); UpdateDisplay("120x200,300x400*2"); - gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); window_tree_host_manager->SetOverscanInsets(display1.id(), @@ -1020,7 +1037,7 @@ TEST_F(WindowTreeHostManagerTest, Rotate) { Shell::GetInstance()->AddPreTargetHandler(&event_handler); UpdateDisplay("120x200,300x400*2"); - gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); int64_t display2_id = ScreenUtil::GetSecondaryDisplay().id(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); ui::test::EventGenerator generator1(root_windows[0]); @@ -1095,7 +1112,7 @@ TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) { UpdateDisplay("600x400*2@1.5,500x300"); - gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); test::ScopedSetInternalDisplayId set_internal(display1.id()); gfx::Display display2 = ScreenUtil::GetSecondaryDisplay(); @@ -1111,7 +1128,7 @@ TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) { EXPECT_EQ("449,150", event_handler.GetLocationAndReset()); SetDisplayUIScale(display1.id(), 1.25f); - display1 = Shell::GetScreen()->GetPrimaryDisplay(); + display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); display2 = ScreenUtil::GetSecondaryDisplay(); EXPECT_EQ("0,0 375x250", display1.bounds().ToString()); EXPECT_EQ("0,0 375x250", root_windows[0]->bounds().ToString()); @@ -1130,7 +1147,7 @@ TEST_F(WindowTreeHostManagerTest, TouchScale) { Shell::GetInstance()->AddPreTargetHandler(&event_handler); UpdateDisplay("200x200*2"); - gfx::Display display = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display = gfx::Screen::GetScreen()->GetPrimaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); aura::Window* root_window = root_windows[0]; ui::test::EventGenerator generator(root_window); @@ -1163,7 +1180,7 @@ TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) { UpdateDisplay("600x400*2/r@1.5"); - gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); + gfx::Display display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); @@ -1180,7 +1197,7 @@ TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) { EXPECT_EQ("299,449", event_handler.GetLocationAndReset()); UpdateDisplay("600x400*2/u@1.5"); - display1 = Shell::GetScreen()->GetPrimaryDisplay(); + display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); root_windows = Shell::GetAllRootWindows(); EXPECT_EQ("0,0 450x300", display1.bounds().ToString()); EXPECT_EQ("0,0 450x300", root_windows[0]->bounds().ToString()); @@ -1196,7 +1213,7 @@ TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) { EXPECT_EQ("449,0", event_handler.GetLocationAndReset()); UpdateDisplay("600x400*2/l@1.5"); - display1 = Shell::GetScreen()->GetPrimaryDisplay(); + display1 = gfx::Screen::GetScreen()->GetPrimaryDisplay(); root_windows = Shell::GetAllRootWindows(); EXPECT_EQ("0,0 300x450", display1.bounds().ToString()); EXPECT_EQ("0,0 300x450", root_windows[0]->bounds().ToString()); @@ -1280,7 +1297,7 @@ TEST_F(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplayForTest(); - EXPECT_EQ(11, Shell::GetScreen()->GetPrimaryDisplay().id()); + EXPECT_EQ(11, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); display_info_list.clear(); const DisplayInfo new_first_display_info = @@ -1291,7 +1308,7 @@ TEST_F(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { display_info_list.push_back(new_second_display_info); display_manager->OnNativeDisplaysChanged(display_info_list); - EXPECT_EQ(20, Shell::GetScreen()->GetPrimaryDisplay().id()); + EXPECT_EQ(20, gfx::Screen::GetScreen()->GetPrimaryDisplay().id()); } namespace { |