diff options
author | oshima <oshima@chromium.org> | 2015-07-27 18:18:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-28 01:19:26 +0000 |
commit | e28189248660c42b8e0cb9ad973638d7260b47b7 (patch) | |
tree | 90109ef81a619744a85b920d246f6d290c5c7a22 /ash | |
parent | 4bf2ca554347fc20e1649e5ff4cf700d9fbd713a (diff) | |
download | chromium_src-e28189248660c42b8e0cb9ad973638d7260b47b7.zip chromium_src-e28189248660c42b8e0cb9ad973638d7260b47b7.tar.gz chromium_src-e28189248660c42b8e0cb9ad973638d7260b47b7.tar.bz2 |
Rename DisplayController to WindowTreeHostManager
This class manages WTH <-> display mapping, and WTHManager is more appropriate than DisplayController.
BUG=None
Review URL: https://codereview.chromium.org/1262483003
Cr-Commit-Position: refs/heads/master@{#340624}
Diffstat (limited to 'ash')
59 files changed, 556 insertions, 503 deletions
diff --git a/ash/accelerators/accelerator_controller.cc b/ash/accelerators/accelerator_controller.cc index 2884ec1..7f01b369 100644 --- a/ash/accelerators/accelerator_controller.cc +++ b/ash/accelerators/accelerator_controller.cc @@ -12,9 +12,9 @@ #include "ash/accelerators/debug_commands.h" #include "ash/ash_switches.h" #include "ash/debug.h" -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" #include "ash/display/display_util.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/focus_cycler.h" #include "ash/gpu_support.h" #include "ash/ime_control_delegate.h" @@ -550,7 +550,7 @@ void HandleSilenceSpokenFeedback() { void HandleSwapPrimaryDisplay() { base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display")); - Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); + Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplay(); } bool CanHandleCycleUser() { @@ -599,7 +599,7 @@ void HandleToggleCapsLock() { void HandleToggleMirrorMode() { base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode")); - Shell::GetInstance()->display_controller()->ToggleMirrorMode(); + Shell::GetInstance()->window_tree_host_manager()->ToggleMirrorMode(); } void HandleToggleSpokenFeedback() { diff --git a/ash/ash.gyp b/ash/ash.gyp index 13d84ce..884b73b 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -69,8 +69,8 @@ 'display/display_change_observer_chromeos.h', 'display/display_configurator_animation.cc', 'display/display_configurator_animation.h', - 'display/display_controller.cc', - 'display/display_controller.h', + 'display/window_tree_host_manager.cc', + 'display/window_tree_host_manager.h', 'display/display_error_observer_chromeos.cc', 'display/display_error_observer_chromeos.h', 'display/display_info.cc', @@ -796,7 +796,7 @@ 'dip_unittest.cc', 'display/cursor_window_controller_unittest.cc', 'display/display_change_observer_chromeos_unittest.cc', - 'display/display_controller_unittest.cc', + 'display/window_tree_host_manager_unittest.cc', 'display/display_error_observer_chromeos_unittest.cc', 'display/display_info_unittest.cc', 'display/display_manager_unittest.cc', diff --git a/ash/content/display/screen_orientation_controller_chromeos.cc b/ash/content/display/screen_orientation_controller_chromeos.cc index 0e63f65..8901032 100644 --- a/ash/content/display/screen_orientation_controller_chromeos.cc +++ b/ash/content/display/screen_orientation_controller_chromeos.cc @@ -79,7 +79,7 @@ ScreenOrientationController::~ScreenOrientationController() { content::ScreenOrientationProvider::SetDelegate(NULL); Shell::GetInstance()->RemoveShellObserver(this); chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); Shell::GetInstance()->activation_client()->RemoveObserver(this); for (auto& windows : locking_windows_) windows.first->RemoveObserver(this); @@ -232,12 +232,12 @@ void ScreenOrientationController::OnMaximizeModeStarted() { if (!rotation_locked_) LoadDisplayRotationProperties(); chromeos::AccelerometerReader::GetInstance()->AddObserver(this); - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); } void ScreenOrientationController::OnMaximizeModeEnded() { chromeos::AccelerometerReader::GetInstance()->RemoveObserver(this); - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); if (current_rotation_ != user_rotation_) SetDisplayRotation(user_rotation_, gfx::Display::ROTATION_SOURCE_USER); } diff --git a/ash/content/display/screen_orientation_controller_chromeos.h b/ash/content/display/screen_orientation_controller_chromeos.h index 32d78fb..b387198 100644 --- a/ash/content/display/screen_orientation_controller_chromeos.h +++ b/ash/content/display/screen_orientation_controller_chromeos.h @@ -8,7 +8,7 @@ #include <map> #include "ash/ash_export.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shell_observer.h" #include "base/macros.h" #include "base/observer_list.h" @@ -36,7 +36,7 @@ class ASH_EXPORT ScreenOrientationController public aura::WindowObserver, public chromeos::AccelerometerReader::Observer, public content::ScreenOrientationDelegate, - public DisplayController::Observer, + public WindowTreeHostManager::Observer, public ShellObserver { public: // Observer that reports changes to the state of ScreenOrientationProvider's @@ -96,7 +96,7 @@ class ASH_EXPORT ScreenOrientationController bool ScreenOrientationProviderSupported() override; void Unlock(content::WebContents* web_contents) override; - // DisplayController::Observer: + // WindowTreeHostManager::Observer: void OnDisplayConfigurationChanged() override; // ShellObserver: diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc index ed7414e..f1bdc03 100644 --- a/ash/desktop_background/desktop_background_controller.cc +++ b/ash/desktop_background/desktop_background_controller.cc @@ -53,12 +53,12 @@ DesktopBackgroundController::DesktopBackgroundController() : locked_(false), desktop_background_mode_(BACKGROUND_NONE), wallpaper_reload_delay_(kWallpaperReloadDelayMs) { - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); Shell::GetInstance()->AddShellObserver(this); } DesktopBackgroundController::~DesktopBackgroundController() { - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); Shell::GetInstance()->RemoveShellObserver(this); } diff --git a/ash/desktop_background/desktop_background_controller.h b/ash/desktop_background/desktop_background_controller.h index ebebeaa..a06a3fd 100644 --- a/ash/desktop_background/desktop_background_controller.h +++ b/ash/desktop_background/desktop_background_controller.h @@ -6,7 +6,7 @@ #define ASH_DESKTOP_BACKGROUND_DESKTOP_BACKGROUND_CONTROLLER_H_ #include "ash/ash_export.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shell_observer.h" #include "base/basictypes.h" #include "base/files/file_path.h" @@ -37,7 +37,7 @@ class DesktopBackgroundControllerObserver; // Updates background layer if necessary. class ASH_EXPORT DesktopBackgroundController - : public DisplayController::Observer, + : public WindowTreeHostManager::Observer, public ShellObserver { public: class TestAPI; @@ -87,7 +87,7 @@ class ASH_EXPORT DesktopBackgroundController // Returns true if the desktop moved. bool MoveDesktopToUnlockedContainer(); - // DisplayController::Observer: + // WindowTreeHostManager::Observer: void OnDisplayConfigurationChanged() override; // ShellObserver: diff --git a/ash/display/cursor_window_controller.cc b/ash/display/cursor_window_controller.cc index dbab9b4..633652c 100644 --- a/ash/display/cursor_window_controller.cc +++ b/ash/display/cursor_window_controller.cc @@ -4,8 +4,8 @@ #include "ash/display/cursor_window_controller.h" -#include "ash/display/display_controller.h" #include "ash/display/mirror_window_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" @@ -122,10 +122,10 @@ void CursorWindowController::UpdateContainer() { if (display.is_valid()) SetDisplay(display); } else { - aura::Window* mirror_window = Shell::GetInstance()-> - display_controller()-> - mirror_window_controller()-> - GetWindow(); + aura::Window* mirror_window = Shell::GetInstance() + ->window_tree_host_manager() + ->mirror_window_controller() + ->GetWindow(); if (mirror_window) display_ = Shell::GetScreen()->GetPrimaryDisplay(); SetContainer(mirror_window); @@ -139,8 +139,9 @@ void CursorWindowController::SetDisplay(const gfx::Display& display) { return; display_ = display; - aura::Window* root_window = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + aura::Window* root_window = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); if (!root_window) return; diff --git a/ash/display/cursor_window_controller_unittest.cc b/ash/display/cursor_window_controller_unittest.cc index 7cea0f4..d822bce 100644 --- a/ash/display/cursor_window_controller_unittest.cc +++ b/ash/display/cursor_window_controller_unittest.cc @@ -4,7 +4,7 @@ #include "ash/display/cursor_window_controller.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" @@ -43,8 +43,9 @@ class CursorWindowControllerTest : public test::AshTestBase { } void SetCursorCompositionEnabled(bool enabled) { - cursor_window_controller_ = - Shell::GetInstance()->display_controller()->cursor_window_controller(); + cursor_window_controller_ = Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller(); cursor_window_controller_->SetCursorCompositingEnabled(enabled); } @@ -63,14 +64,14 @@ TEST_F(CursorWindowControllerTest, MoveToDifferentDisplay) { UpdateDisplay("200x200,200x200*2/r"); - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); - int64 primary_display_id = display_controller->GetPrimaryDisplayId(); + WindowTreeHostManager* window_tree_host_manager = + Shell::GetInstance()->window_tree_host_manager(); + int64 primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); int64 secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); aura::Window* primary_root = - display_controller->GetRootWindowForDisplayId(primary_display_id); + window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id); aura::Window* secondary_root = - display_controller->GetRootWindowForDisplayId(secondary_display_id); + window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); ui::test::EventGenerator primary_generator(primary_root); primary_generator.MoveMouseToInHost(20, 50); diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h index 4983f58..bb26bb3 100644 --- a/ash/display/display_manager.h +++ b/ash/display/display_manager.h @@ -38,7 +38,6 @@ class Screen; namespace ash { class AcceleratorControllerTest; -class DisplayController; class DisplayLayoutStore; class MouseWarpController; class ScreenAsh; diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index a7ec228..59dcef0 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc @@ -5,11 +5,11 @@ #include "ash/display/display_manager.h" #include "ash/ash_switches.h" -#include "ash/display/display_controller.h" #include "ash/display/display_info.h" #include "ash/display/display_layout_store.h" #include "ash/display/display_util.h" #include "ash/display/mirror_window_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" @@ -395,7 +395,7 @@ TEST_F(DisplayManagerTest, OverscanInsetsTest) { updated_display_info2.GetOverscanInsetsInPixel().ToString()); // Make sure switching primary display applies the overscan offset only once. - ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay( + ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplay( ScreenUtil::GetSecondaryDisplay()); EXPECT_EQ("-500,0 500x500", ScreenUtil::GetSecondaryDisplay().bounds().ToString()); @@ -650,7 +650,7 @@ TEST_F(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { UpdateDisplay("100+0-500x500,0+501-400x400"); - const int64 primary_id = DisplayController::GetPrimaryDisplayId(); + const int64 primary_id = WindowTreeHostManager::GetPrimaryDisplayId(); const int64 secondary_id = ScreenUtil::GetSecondaryDisplay().id(); DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id); @@ -667,7 +667,7 @@ TEST_F(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) { display_info_list.push_back(secondary_info); display_manager()->OnNativeDisplaysChanged(display_info_list); - EXPECT_EQ(third_id, DisplayController::GetPrimaryDisplayId()); + EXPECT_EQ(third_id, WindowTreeHostManager::GetPrimaryDisplayId()); EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString()); EXPECT_EQ(secondary_id, ScreenUtil::GetSecondaryDisplay().id()); } @@ -722,7 +722,7 @@ TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) { GetDisplayForId(internal_display_id).bounds().ToString()); EXPECT_EQ("500,0 100x100", GetDisplayForId(10).bounds().ToString()); - ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay( + ash::Shell::GetInstance()->window_tree_host_manager()->SetPrimaryDisplay( GetDisplayForId(secondary_display_info.id())); EXPECT_EQ("-500,0 500x500", GetDisplayForId(internal_display_id).bounds().ToString()); @@ -1317,14 +1317,16 @@ TEST_F(DisplayManagerTest, SingleDisplayToSoftwareMirroring) { EXPECT_TRUE(display_manager->IsInMirrorMode()); EXPECT_EQ(1U, display_manager->GetNumDisplays()); - DisplayController* display_controller = - ash::Shell::GetInstance()->display_controller(); - EXPECT_TRUE(display_controller->mirror_window_controller()->GetWindow()); + WindowTreeHostManager* window_tree_host_manager = + ash::Shell::GetInstance()->window_tree_host_manager(); + EXPECT_TRUE( + window_tree_host_manager->mirror_window_controller()->GetWindow()); UpdateDisplay("600x400"); EXPECT_FALSE(display_manager->IsInMirrorMode()); EXPECT_EQ(1U, display_manager->GetNumDisplays()); - EXPECT_FALSE(display_controller->mirror_window_controller()->GetWindow()); + EXPECT_FALSE( + window_tree_host_manager->mirror_window_controller()->GetWindow()); } #if defined(OS_CHROMEOS) @@ -1422,7 +1424,7 @@ TEST_F(DisplayManagerTest, NotifyPrimaryChange) { if (!SupportsMultipleDisplays()) return; UpdateDisplay("500x500,500x500"); - ash::Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); + ash::Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplay(); reset(); UpdateDisplay("500x500"); EXPECT_FALSE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); @@ -1432,7 +1434,7 @@ TEST_F(DisplayManagerTest, NotifyPrimaryChange) { gfx::DisplayObserver::DISPLAY_METRIC_PRIMARY); UpdateDisplay("500x500,500x500"); - ash::Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); + ash::Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplay(); reset(); UpdateDisplay("500x400"); EXPECT_TRUE(changed_metrics() & gfx::DisplayObserver::DISPLAY_METRIC_BOUNDS); diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc index e971259..06ada9f 100644 --- a/ash/display/mirror_window_controller.cc +++ b/ash/display/mirror_window_controller.cc @@ -13,11 +13,11 @@ #endif #include "ash/display/cursor_window_controller.h" -#include "ash/display/display_controller.h" #include "ash/display/display_info.h" #include "ash/display/display_manager.h" #include "ash/display/root_window_transformers.h" #include "ash/display/screen_position_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/host/ash_window_tree_host.h" #include "ash/host/ash_window_tree_host_init_params.h" #include "ash/host/root_window_transformer.h" @@ -187,14 +187,15 @@ void MirrorWindowController::UpdateWindow( aura::WindowTreeHost* host = host_info->ash_host->AsWindowTreeHost(); host->SetSharedInputMethod( - Shell::GetInstance()->display_controller()->input_method()); + Shell::GetInstance()->window_tree_host_manager()->input_method()); host->window()->SetName( base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); host->compositor()->SetBackgroundColor(SK_ColorBLACK); - // No need to remove the observer because the DisplayController outlives + // No need to remove the observer because the WindowTreeHostManager + // outlives // the // host. - host->AddObserver(Shell::GetInstance()->display_controller()); + host->AddObserver(Shell::GetInstance()->window_tree_host_manager()); host->AddObserver(this); // TODO(oshima): TouchHUD is using idkey. InitRootWindowSettings(host->window())->display_id = display_info.id(); @@ -209,7 +210,7 @@ void MirrorWindowController::UpdateWindow( host_info->ash_host->ConfineCursorToRootWindow(); AshWindowTreeHost* unified_ash_host = Shell::GetInstance() - ->display_controller() + ->window_tree_host_manager() ->GetAshWindowTreeHostForDisplayId( Shell::GetScreen()->GetPrimaryDisplay().id()); unified_ash_host->RegisterMirroringHost(host_info->ash_host.get()); @@ -303,7 +304,7 @@ void MirrorWindowController::OnHostResized(const aura::WindowTreeHost* host) { // No need to update the transformer as new transformer is already set // in UpdateWindow. Shell::GetInstance() - ->display_controller() + ->window_tree_host_manager() ->cursor_window_controller() ->UpdateLocation(); return; @@ -366,7 +367,7 @@ void MirrorWindowController::CloseAndDeleteHost(MirroringHostInfo* host_info, aura::client::SetCaptureClient(host->window(), nullptr); delete capture_client; - host->RemoveObserver(Shell::GetInstance()->display_controller()); + host->RemoveObserver(Shell::GetInstance()->window_tree_host_manager()); host->RemoveObserver(this); host_info->ash_host->PrepareForShutdown(); reflector_->RemoveMirroringLayer(host_info->mirror_window->layer()); diff --git a/ash/display/mirror_window_controller_unittest.cc b/ash/display/mirror_window_controller_unittest.cc index 644d2ed..5c2fb01 100644 --- a/ash/display/mirror_window_controller_unittest.cc +++ b/ash/display/mirror_window_controller_unittest.cc @@ -5,8 +5,8 @@ #include "ash/display/mirror_window_controller.h" #include "ash/ash_switches.h" -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/screen_util.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" @@ -217,17 +217,18 @@ TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorLocations) { TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorMoveOnEnter) { aura::Env* env = aura::Env::GetInstance(); Shell* shell = Shell::GetInstance(); - DisplayController* display_controller = shell->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + shell->window_tree_host_manager(); UpdateDisplay("400x400*2/r,400x400"); - int64 primary_display_id = display_controller->GetPrimaryDisplayId(); + int64 primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); int64 secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); test::ScopedSetInternalDisplayId set_internal(primary_display_id); // Chrome uses the internal display as the source display for software mirror // mode. Move the cursor to the external display. aura::Window* secondary_root_window = - display_controller->GetRootWindowForDisplayId(secondary_display_id); + window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); secondary_root_window->MoveCursorTo(gfx::Point(100, 200)); EXPECT_EQ("300,200", env->last_mouse_location().ToString()); test::CursorManagerTestApi cursor_test_api(shell->cursor_manager()); diff --git a/ash/display/mouse_cursor_event_filter.cc b/ash/display/mouse_cursor_event_filter.cc index fb24f2c..570058f 100644 --- a/ash/display/mouse_cursor_event_filter.cc +++ b/ash/display/mouse_cursor_event_filter.cc @@ -15,11 +15,11 @@ namespace ash { MouseCursorEventFilter::MouseCursorEventFilter() : mouse_warp_enabled_(true) { - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); } MouseCursorEventFilter::~MouseCursorEventFilter() { - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); } void MouseCursorEventFilter::ShowSharedEdgeIndicator(aura::Window* from) { @@ -57,8 +57,10 @@ void MouseCursorEventFilter::OnMouseEvent(ui::MouseEvent* event) { return; } - Shell::GetInstance()->display_controller()-> - cursor_window_controller()->UpdateLocation(); + Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller() + ->UpdateLocation(); mouse_warp_controller_->SetEnabled(mouse_warp_enabled_); if (mouse_warp_controller_->WarpMouseCursor(event)) diff --git a/ash/display/mouse_cursor_event_filter.h b/ash/display/mouse_cursor_event_filter.h index 46c1e5a..a6652a5 100644 --- a/ash/display/mouse_cursor_event_filter.h +++ b/ash/display/mouse_cursor_event_filter.h @@ -6,7 +6,7 @@ #define ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H #include "ash/ash_export.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "base/compiler_specific.h" #include "base/gtest_prod_util.h" #include "base/memory/scoped_ptr.h" @@ -23,8 +23,9 @@ class DisplayEdgeController; // An event filter that controls mouse location in extended desktop // environment. -class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler, - public DisplayController::Observer { +class ASH_EXPORT MouseCursorEventFilter + : public ui::EventHandler, + public WindowTreeHostManager::Observer { public: MouseCursorEventFilter(); ~MouseCursorEventFilter() override; @@ -36,7 +37,7 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler, void ShowSharedEdgeIndicator(aura::Window* from); void HideSharedEdgeIndicator(); - // DisplayController::Observer: + // WindowTreeHostManager::Observer: void OnDisplaysInitialized() override; void OnDisplayConfigurationChanged() override; diff --git a/ash/display/resolution_notification_controller.cc b/ash/display/resolution_notification_controller.cc index a0e98ea..b2238c8 100644 --- a/ash/display/resolution_notification_controller.cc +++ b/ash/display/resolution_notification_controller.cc @@ -4,7 +4,6 @@ #include "ash/display/resolution_notification_controller.h" -#include "ash/display/display_controller.h" #include "ash/display/display_info.h" #include "ash/display/display_manager.h" #include "ash/shell.h" @@ -150,12 +149,12 @@ ResolutionNotificationController::ResolutionChangeInfo:: } ResolutionNotificationController::ResolutionNotificationController() { - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); Shell::GetScreen()->AddObserver(this); } ResolutionNotificationController::~ResolutionNotificationController() { - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); Shell::GetScreen()->RemoveObserver(this); } diff --git a/ash/display/resolution_notification_controller.h b/ash/display/resolution_notification_controller.h index 23a1f69..8a74ae8 100644 --- a/ash/display/resolution_notification_controller.h +++ b/ash/display/resolution_notification_controller.h @@ -6,7 +6,7 @@ #define ASH_DISPLAY_RESOLUTION_NOTIFICATION_CONTROLLER_H_ #include "ash/ash_export.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "base/callback.h" #include "base/gtest_prod_util.h" #include "base/timer/timer.h" @@ -30,7 +30,7 @@ struct DisplayMode; // also manages the timeout in case the new resolution is unusable. class ASH_EXPORT ResolutionNotificationController : public gfx::DisplayObserver, - public DisplayController::Observer { + public WindowTreeHostManager::Observer { public: ResolutionNotificationController(); ~ResolutionNotificationController() override; @@ -91,7 +91,7 @@ class ASH_EXPORT ResolutionNotificationController void OnDisplayMetricsChanged(const gfx::Display& display, uint32_t metrics) override; - // DisplayController::Observer overrides: + // WindowTreeHostManager::Observer overrides: void OnDisplayConfigurationChanged() override; static void SuppressTimerForTest(); diff --git a/ash/display/screen_ash.cc b/ash/display/screen_ash.cc index 5941bcc..3928e46 100644 --- a/ash/display/screen_ash.cc +++ b/ash/display/screen_ash.cc @@ -4,8 +4,8 @@ #include "ash/display/screen_ash.h" -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/root_window_controller.h" #include "ash/root_window_settings.h" #include "ash/shelf/shelf_layout_manager.h" @@ -194,7 +194,7 @@ gfx::Display ScreenAsh::GetDisplayMatching(const gfx::Rect& match_rect) const { gfx::Display ScreenAsh::GetPrimaryDisplay() const { return GetDisplayManager()->GetDisplayForId( - DisplayController::GetPrimaryDisplayId()); + WindowTreeHostManager::GetPrimaryDisplayId()); } void ScreenAsh::AddObserver(gfx::DisplayObserver* observer) { diff --git a/ash/display/screen_position_controller.cc b/ash/display/screen_position_controller.cc index a64fb4b..f3401d7 100644 --- a/ash/display/screen_position_controller.cc +++ b/ash/display/screen_position_controller.cc @@ -4,7 +4,7 @@ #include "ash/display/screen_position_controller.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" @@ -38,8 +38,9 @@ bool ShouldStayInSameRootWindow(const aura::Window* window) { // the child windows and transient children of the transient children. void MoveAllTransientChildrenToNewRoot(const gfx::Display& display, aura::Window* window) { - aura::Window* dst_root = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + aura::Window* dst_root = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); aura::Window::Windows transient_children = ::wm::GetTransientChildren(window); for (aura::Window::Windows::iterator iter = transient_children.begin(); @@ -166,9 +167,9 @@ void ScreenPositionController::SetBounds(aura::Window* window, // outside of the display. if (!::wm::GetTransientParent(window) && !ShouldStayInSameRootWindow(window)) { - aura::Window* dst_root = - Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( - display.id()); + aura::Window* dst_root = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); DCHECK(dst_root); aura::Window* dst_container = NULL; if (dst_root != window->GetRootWindow()) { diff --git a/ash/display/unified_mouse_warp_controller.cc b/ash/display/unified_mouse_warp_controller.cc index 468d4f0..9334d90 100644 --- a/ash/display/unified_mouse_warp_controller.cc +++ b/ash/display/unified_mouse_warp_controller.cc @@ -6,10 +6,10 @@ #include <cmath> -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" #include "ash/display/display_util.h" #include "ash/display/mirror_window_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/host/ash_window_tree_host.h" #include "ash/shell.h" #include "ui/aura/window.h" @@ -25,7 +25,7 @@ namespace { AshWindowTreeHost* GetMirroringAshWindowTreeHostForDisplayId(int64 display_id) { return Shell::GetInstance() - ->display_controller() + ->window_tree_host_manager() ->mirror_window_controller() ->GetAshWindowTreeHostForDisplayId(display_id); } diff --git a/ash/display/display_controller.cc b/ash/display/window_tree_host_manager.cc index fcb0dcb..f1e6aaf 100644 --- a/ash/display/display_controller.cc +++ b/ash/display/window_tree_host_manager.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include <algorithm> #include <cmath> @@ -133,9 +133,7 @@ void SetDisplayPropertiesOnHost(AshWindowTreeHost* ash_host, gfx::AcceleratedWidget xwindow = host->GetAcceleratedWidget(); ui::SetIntProperty(xwindow, kInternalProp, kCARDINAL, internal); ui::SetIntProperty(xwindow, kRotationProp, kCARDINAL, xrandr_rotation); - ui::SetIntProperty(xwindow, - kScaleFactorProp, - kCARDINAL, + ui::SetIntProperty(xwindow, kScaleFactorProp, kCARDINAL, 100 * display.device_scale_factor()); #elif defined(USE_OZONE) // Scale all motion on High-DPI displays. @@ -248,24 +246,23 @@ class FocusActivationStore { //////////////////////////////////////////////////////////////////////////////// // DisplayChangeLimiter -DisplayController::DisplayChangeLimiter::DisplayChangeLimiter() - : throttle_timeout_(base::Time::Now()) { -} +WindowTreeHostManager::DisplayChangeLimiter::DisplayChangeLimiter() + : throttle_timeout_(base::Time::Now()) {} -void DisplayController::DisplayChangeLimiter::SetThrottleTimeout( +void WindowTreeHostManager::DisplayChangeLimiter::SetThrottleTimeout( int64 throttle_ms) { throttle_timeout_ = base::Time::Now() + base::TimeDelta::FromMilliseconds(throttle_ms); } -bool DisplayController::DisplayChangeLimiter::IsThrottled() const { +bool WindowTreeHostManager::DisplayChangeLimiter::IsThrottled() const { return base::Time::Now() < throttle_timeout_; } //////////////////////////////////////////////////////////////////////////////// -// DisplayController +// WindowTreeHostManager -DisplayController::DisplayController() +WindowTreeHostManager::WindowTreeHostManager() : primary_tree_host_for_replace_(nullptr), focus_activation_store_(new FocusActivationStore()), cursor_window_controller_(new CursorWindowController()), @@ -281,17 +278,16 @@ DisplayController::DisplayController() primary_display_id = gfx::Display::kInvalidDisplayID; } -DisplayController::~DisplayController() { -} +WindowTreeHostManager::~WindowTreeHostManager() {} -void DisplayController::Start() { +void WindowTreeHostManager::Start() { Shell::GetScreen()->AddObserver(this); Shell::GetInstance()->display_manager()->set_delegate(this); } -void DisplayController::Shutdown() { +void WindowTreeHostManager::Shutdown() { // Unset the display manager's delegate here because - // DisplayManager outlives DisplayController. + // DisplayManager outlives WindowTreeHostManager. Shell::GetInstance()->display_manager()->set_delegate(nullptr); cursor_window_controller_.reset(); @@ -303,12 +299,12 @@ void DisplayController::Shutdown() { // Delete non primary root window controllers first, then // delete the primary root window controller. - aura::Window::Windows root_windows = DisplayController::GetAllRootWindows(); + aura::Window::Windows root_windows = + WindowTreeHostManager::GetAllRootWindows(); std::vector<RootWindowController*> to_delete; RootWindowController* primary_rwc = nullptr; for (aura::Window::Windows::iterator iter = root_windows.begin(); - iter != root_windows.end(); - ++iter) { + iter != root_windows.end(); ++iter) { RootWindowController* rwc = GetRootWindowController(*iter); if (GetRootWindowSettings(*iter)->display_id == primary_id) primary_rwc = rwc; @@ -321,7 +317,7 @@ void DisplayController::Shutdown() { delete primary_rwc; } -void DisplayController::CreatePrimaryHost( +void WindowTreeHostManager::CreatePrimaryHost( const AshWindowTreeHostInitParams& init_params) { const gfx::Display& primary_candidate = GetDisplayManager()->GetPrimaryDisplayCandidate(); @@ -330,15 +326,15 @@ void DisplayController::CreatePrimaryHost( AddWindowTreeHostForDisplay(primary_candidate, init_params); } -void DisplayController::InitDisplays() { +void WindowTreeHostManager::InitHosts() { RootWindowController::CreateForPrimaryDisplay( window_tree_hosts_[primary_display_id]); DisplayManager* display_manager = GetDisplayManager(); for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { const gfx::Display& display = display_manager->GetDisplayAt(i); if (primary_display_id != display.id()) { - AshWindowTreeHost* ash_host = AddWindowTreeHostForDisplay( - display, AshWindowTreeHostInitParams()); + AshWindowTreeHost* ash_host = + AddWindowTreeHostForDisplay(display, AshWindowTreeHostInitParams()); RootWindowController::CreateForSecondaryDisplay(ash_host); } } @@ -346,41 +342,40 @@ void DisplayController::InitDisplays() { FOR_EACH_OBSERVER(Observer, observers_, OnDisplaysInitialized()); } -void DisplayController::AddObserver(Observer* observer) { +void WindowTreeHostManager::AddObserver(Observer* observer) { observers_.AddObserver(observer); } -void DisplayController::RemoveObserver(Observer* observer) { +void WindowTreeHostManager::RemoveObserver(Observer* observer) { observers_.RemoveObserver(observer); } // static -int64 DisplayController::GetPrimaryDisplayId() { +int64 WindowTreeHostManager::GetPrimaryDisplayId() { CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id); return primary_display_id; } -aura::Window* DisplayController::GetPrimaryRootWindow() { +aura::Window* WindowTreeHostManager::GetPrimaryRootWindow() { return GetRootWindowForDisplayId(primary_display_id); } -aura::Window* DisplayController::GetRootWindowForDisplayId(int64 id) { +aura::Window* WindowTreeHostManager::GetRootWindowForDisplayId(int64 id) { AshWindowTreeHost* host = GetAshWindowTreeHostForDisplayId(id); CHECK(host); return GetWindow(host); } -AshWindowTreeHost* DisplayController::GetAshWindowTreeHostForDisplayId( +AshWindowTreeHost* WindowTreeHostManager::GetAshWindowTreeHostForDisplayId( int64 display_id) { - CHECK_EQ(1u, window_tree_hosts_.count(display_id)) - << "display id = " << display_id; + CHECK_EQ(1u, window_tree_hosts_.count(display_id)) << "display id = " + << display_id; return window_tree_hosts_[display_id]; } -void DisplayController::CloseChildWindows() { +void WindowTreeHostManager::CloseChildWindows() { for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); - it != window_tree_hosts_.end(); - ++it) { + it != window_tree_hosts_.end(); ++it) { aura::Window* root_window = GetWindow(it->second); RootWindowController* controller = GetRootWindowController(root_window); if (controller) { @@ -394,11 +389,10 @@ void DisplayController::CloseChildWindows() { } } -aura::Window::Windows DisplayController::GetAllRootWindows() { +aura::Window::Windows WindowTreeHostManager::GetAllRootWindows() { aura::Window::Windows windows; for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); - it != window_tree_hosts_.end(); - ++it) { + it != window_tree_hosts_.end(); ++it) { DCHECK(it->second); if (GetRootWindowController(GetWindow(it->second))) windows.push_back(GetWindow(it->second)); @@ -406,21 +400,21 @@ aura::Window::Windows DisplayController::GetAllRootWindows() { return windows; } -gfx::Insets DisplayController::GetOverscanInsets(int64 display_id) const { +gfx::Insets WindowTreeHostManager::GetOverscanInsets(int64 display_id) const { return GetDisplayManager()->GetOverscanInsets(display_id); } -void DisplayController::SetOverscanInsets(int64 display_id, - const gfx::Insets& insets_in_dip) { +void WindowTreeHostManager::SetOverscanInsets( + int64 display_id, + const gfx::Insets& insets_in_dip) { GetDisplayManager()->SetOverscanInsets(display_id, insets_in_dip); } std::vector<RootWindowController*> -DisplayController::GetAllRootWindowControllers() { +WindowTreeHostManager::GetAllRootWindowControllers() { std::vector<RootWindowController*> controllers; for (WindowTreeHostMap::const_iterator it = window_tree_hosts_.begin(); - it != window_tree_hosts_.end(); - ++it) { + it != window_tree_hosts_.end(); ++it) { RootWindowController* controller = GetRootWindowController(GetWindow(it->second)); if (controller) @@ -429,13 +423,13 @@ DisplayController::GetAllRootWindowControllers() { return controllers; } -void DisplayController::ToggleMirrorMode() { +void WindowTreeHostManager::ToggleMirrorMode() { DisplayManager* display_manager = GetDisplayManager(); if (display_manager->num_connected_displays() <= 1) return; if (limiter_) { - if (limiter_->IsThrottled()) + if (limiter_->IsThrottled()) return; limiter_->SetThrottleTimeout(kCycleDisplayThrottleTimeoutMs); } @@ -444,14 +438,14 @@ void DisplayController::ToggleMirrorMode() { DisplayConfiguratorAnimation* animation = shell->display_configurator_animation(); animation->StartFadeOutAnimation(base::Bind( - &DisplayController::SetMirrorModeAfterAnimation, + &WindowTreeHostManager::SetMirrorModeAfterAnimation, weak_ptr_factory_.GetWeakPtr(), !display_manager->IsInMirrorMode())); #endif } -void DisplayController::SwapPrimaryDisplay() { +void WindowTreeHostManager::SwapPrimaryDisplay() { if (limiter_) { - if (limiter_->IsThrottled()) + if (limiter_->IsThrottled()) return; limiter_->SetThrottleTimeout(kSwapDisplayThrottleTimeoutMs); } @@ -461,9 +455,9 @@ void DisplayController::SwapPrimaryDisplay() { DisplayConfiguratorAnimation* animation = Shell::GetInstance()->display_configurator_animation(); if (animation) { - animation->StartFadeOutAnimation(base::Bind( - &DisplayController::OnFadeOutForSwapDisplayFinished, - weak_ptr_factory_.GetWeakPtr())); + animation->StartFadeOutAnimation( + base::Bind(&WindowTreeHostManager::OnFadeOutForSwapDisplayFinished, + weak_ptr_factory_.GetWeakPtr())); } else { SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); } @@ -473,7 +467,7 @@ void DisplayController::SwapPrimaryDisplay() { } } -void DisplayController::SetPrimaryDisplayId(int64 id) { +void WindowTreeHostManager::SetPrimaryDisplayId(int64 id) { DCHECK_NE(gfx::Display::kInvalidDisplayID, id); if (id == gfx::Display::kInvalidDisplayID || primary_display_id == id) return; @@ -483,7 +477,7 @@ void DisplayController::SetPrimaryDisplayId(int64 id) { SetPrimaryDisplay(display); } -void DisplayController::SetPrimaryDisplay( +void WindowTreeHostManager::SetPrimaryDisplay( const gfx::Display& new_primary_display) { DisplayManager* display_manager = GetDisplayManager(); DCHECK(new_primary_display.is_valid()); @@ -535,16 +529,16 @@ void DisplayController::SetPrimaryDisplay( // Update the dispay manager with new display info. std::vector<DisplayInfo> display_info_list; - display_info_list.push_back(display_manager->GetDisplayInfo( - primary_display_id)); - display_info_list.push_back(display_manager->GetDisplayInfo( - ScreenUtil::GetSecondaryDisplay().id())); + display_info_list.push_back( + display_manager->GetDisplayInfo(primary_display_id)); + display_info_list.push_back( + display_manager->GetDisplayInfo(ScreenUtil::GetSecondaryDisplay().id())); GetDisplayManager()->set_force_bounds_changed(true); GetDisplayManager()->UpdateDisplays(display_info_list); GetDisplayManager()->set_force_bounds_changed(false); } -void DisplayController::UpdateMouseLocationAfterDisplayChange() { +void WindowTreeHostManager::UpdateMouseLocationAfterDisplayChange() { // If the mouse is currently on a display in native location, // use the same native location. Otherwise find the display closest // to the current cursor location in screen coordinates. @@ -630,7 +624,7 @@ void DisplayController::UpdateMouseLocationAfterDisplayChange() { #endif } -bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( +bool WindowTreeHostManager::UpdateWorkAreaOfDisplayNearestWindow( const aura::Window* window, const gfx::Insets& insets) { const aura::Window* root_window = window->GetRootWindow(); @@ -640,7 +634,7 @@ bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow( return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets); } -void DisplayController::OnDisplayAdded(const gfx::Display& display) { +void WindowTreeHostManager::OnDisplayAdded(const gfx::Display& display) { #if defined(OS_CHROMEOS) // If we're switching from/to offscreen WTH, we need to // create new WTH for primary display instead of reusing. @@ -715,7 +709,7 @@ void DisplayController::OnDisplayAdded(const gfx::Display& display) { } } -void DisplayController::DeleteHost(AshWindowTreeHost* host_to_delete) { +void WindowTreeHostManager::DeleteHost(AshWindowTreeHost* host_to_delete) { ClearDisplayPropertiesOnHost(host_to_delete); RootWindowController* controller = GetRootWindowController(GetWindow(host_to_delete)); @@ -727,7 +721,7 @@ void DisplayController::DeleteHost(AshWindowTreeHost* host_to_delete) { base::MessageLoop::current()->DeleteSoon(FROM_HERE, controller); } -void DisplayController::OnDisplayRemoved(const gfx::Display& display) { +void WindowTreeHostManager::OnDisplayRemoved(const gfx::Display& display) { AshWindowTreeHost* host_to_delete = window_tree_hosts_[display.id()]; CHECK(host_to_delete) << display.ToString(); @@ -775,8 +769,8 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) { window_tree_hosts_.erase(display.id()); } -void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display, - uint32_t metrics) { +void WindowTreeHostManager::OnDisplayMetricsChanged(const gfx::Display& display, + uint32_t metrics) { if (!(metrics & (DISPLAY_METRIC_BOUNDS | DISPLAY_METRIC_ROTATION | DISPLAY_METRIC_DEVICE_SCALE_FACTOR))) return; @@ -788,7 +782,7 @@ void DisplayController::OnDisplayMetricsChanged(const gfx::Display& display, SetDisplayPropertiesOnHost(ash_host, display); } -void DisplayController::OnHostResized(const aura::WindowTreeHost* host) { +void WindowTreeHostManager::OnHostResized(const aura::WindowTreeHost* host) { gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( const_cast<aura::Window*>(host->window())); @@ -799,7 +793,7 @@ void DisplayController::OnHostResized(const aura::WindowTreeHost* host) { } } -void DisplayController::CreateOrUpdateMirroringDisplay( +void WindowTreeHostManager::CreateOrUpdateMirroringDisplay( const DisplayInfoList& info_list) { if (GetDisplayManager()->IsInMirrorMode() || GetDisplayManager()->IsInUnifiedMode()) { @@ -810,7 +804,7 @@ void DisplayController::CreateOrUpdateMirroringDisplay( } } -void DisplayController::CloseMirroringDisplayIfNotNecessary() { +void WindowTreeHostManager::CloseMirroringDisplayIfNotNecessary() { mirror_window_controller_->CloseIfNotNecessary(); // If cursor_compositing is enabled for large cursor, the cursor window is // always on the desktop display (the visible cursor on the non-desktop @@ -820,7 +814,7 @@ void DisplayController::CloseMirroringDisplayIfNotNecessary() { cursor_window_controller_->UpdateContainer(); } -void DisplayController::PreDisplayConfigurationChange(bool clear_focus) { +void WindowTreeHostManager::PreDisplayConfigurationChange(bool clear_focus) { FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); focus_activation_store_->Store(clear_focus); gfx::Screen* screen = Shell::GetScreen(); @@ -837,7 +831,7 @@ void DisplayController::PreDisplayConfigurationChange(bool clear_focus) { cursor_location_in_native_coords_for_restore_ = point_in_native; } -void DisplayController::PostDisplayConfigurationChange() { +void WindowTreeHostManager::PostDisplayConfigurationChange() { if (limiter_) limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); @@ -852,12 +846,12 @@ void DisplayController::PostDisplayConfigurationChange() { display_manager->default_multi_display_mode() == DisplayManager::UNIFIED); - if (Shell::GetScreen()->GetNumDisplays() > 1 ) { + if (Shell::GetScreen()->GetNumDisplays() > 1) { DisplayLayout layout = layout_store->GetRegisteredDisplayLayout(pair); int64 primary_id = layout.primary_id; - SetPrimaryDisplayId( - primary_id == gfx::Display::kInvalidDisplayID ? - pair.first : primary_id); + SetPrimaryDisplayId(primary_id == gfx::Display::kInvalidDisplayID + ? pair.first + : primary_id); // Update the primary_id in case the above call is // ignored. Happens when a) default layout's primary id // doesn't exist, or b) the primary_id has already been @@ -870,7 +864,7 @@ void DisplayController::PostDisplayConfigurationChange() { UpdateMouseLocationAfterDisplayChange(); } -bool DisplayController::DispatchKeyEventPostIME(const ui::KeyEvent& event) { +bool WindowTreeHostManager::DispatchKeyEventPostIME(const ui::KeyEvent& event) { // Getting the active root window to dispatch the event. This isn't // significant as the event will be sent to the window resolved by // aura::client::FocusClient which is FocusController in ash. @@ -880,7 +874,7 @@ bool DisplayController::DispatchKeyEventPostIME(const ui::KeyEvent& event) { return root_window->GetHost()->DispatchKeyEventPostIME(event); } -AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( +AshWindowTreeHost* WindowTreeHostManager::AddWindowTreeHostForDisplay( const gfx::Display& display, const AshWindowTreeHostInitParams& init_params) { static int host_count = 0; @@ -909,7 +903,7 @@ AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( host_count++)); host->window()->SetTitle(base::UTF8ToUTF16(display_info.name())); host->compositor()->SetBackgroundColor(SK_ColorBLACK); - // No need to remove our observer observer because the DisplayController + // No need to remove our observer observer because the WindowTreeHostManager // outlives the host. host->AddObserver(this); InitRootWindowSettings(host->window())->display_id = display.id(); @@ -925,15 +919,16 @@ AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( return ash_host; } -void DisplayController::OnFadeOutForSwapDisplayFinished() { +void WindowTreeHostManager::OnFadeOutForSwapDisplayFinished() { #if defined(OS_CHROMEOS) SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); - Shell::GetInstance()->display_configurator_animation() + Shell::GetInstance() + ->display_configurator_animation() ->StartFadeInAnimation(); #endif } -void DisplayController::SetMirrorModeAfterAnimation(bool mirror) { +void WindowTreeHostManager::SetMirrorModeAfterAnimation(bool mirror) { GetDisplayManager()->SetMirrorMode(mirror); } diff --git a/ash/display/display_controller.h b/ash/display/window_tree_host_manager.h index 9ae9944..9829b28 100644 --- a/ash/display/display_controller.h +++ b/ash/display/window_tree_host_manager.h @@ -31,7 +31,8 @@ class WindowTreeHost; namespace base { class Value; -template <typename T> class JSONValueConverter; +template <typename T> +class JSONValueConverter; } namespace gfx { @@ -50,13 +51,15 @@ class InputMethodEventHandler; class MirrorWindowController; class RootWindowController; -// DisplayController owns and maintains RootWindows for each attached +// WindowTreeHostManager owns and maintains RootWindows for each attached // display, keeping them in sync with display configuration changes. -class ASH_EXPORT DisplayController : public gfx::DisplayObserver, - public aura::WindowTreeHostObserver, - public DisplayManager::Delegate, - public ui::internal::InputMethodDelegate { +class ASH_EXPORT WindowTreeHostManager + : public gfx::DisplayObserver, + public aura::WindowTreeHostObserver, + public DisplayManager::Delegate, + public ui::internal::InputMethodDelegate { public: + // TODO(oshima): Consider moving this to gfx::DisplayObserver. class ASH_EXPORT Observer { public: // Invoked only once after all displays are initialized @@ -69,20 +72,20 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, // Invoked when the all display configuration changes // have been applied. - virtual void OnDisplayConfigurationChanged() {}; + virtual void OnDisplayConfigurationChanged(){}; protected: virtual ~Observer() {} }; - DisplayController(); - ~DisplayController() override; + WindowTreeHostManager(); + ~WindowTreeHostManager() override; void Start(); void Shutdown(); // Returns primary display's ID. - // TODO(oshima): Move this out from DisplayController; + // TODO(oshima): Move this out from WindowTreeHostManager; static int64 GetPrimaryDisplayId(); CursorWindowController* cursor_window_controller() { @@ -97,8 +100,8 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, // |initial_bounds| in |init_params|. void CreatePrimaryHost(const AshWindowTreeHostInitParams& init_params); - // Initializes all displays. - void InitDisplays(); + // Initializes all WindowTreeHosts. + void InitHosts(); // Add/Remove observers. void AddObserver(Observer* observer); @@ -178,8 +181,8 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, } private: - FRIEND_TEST_ALL_PREFIXES(DisplayControllerTest, BoundsUpdated); - FRIEND_TEST_ALL_PREFIXES(DisplayControllerTest, SecondaryDisplayLayout); + FRIEND_TEST_ALL_PREFIXES(WindowTreeHostManagerTest, BoundsUpdated); + FRIEND_TEST_ALL_PREFIXES(WindowTreeHostManagerTest, SecondaryDisplayLayout); friend class DisplayManager; friend class MirrorWindowController; @@ -246,9 +249,9 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver, // should be moved after a display configuration change. int64 cursor_display_id_for_restore_; - base::WeakPtrFactory<DisplayController> weak_ptr_factory_; + base::WeakPtrFactory<WindowTreeHostManager> weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(DisplayController); + DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManager); }; } // namespace ash diff --git a/ash/display/display_controller_unittest.cc b/ash/display/window_tree_host_manager_unittest.cc index 9e72799..b04d72e 100644 --- a/ash/display/display_controller_unittest.cc +++ b/ash/display/window_tree_host_manager_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/ash_switches.h" #include "ash/display/display_info.h" @@ -42,13 +42,11 @@ namespace { const char kDesktopBackgroundView[] = "DesktopBackgroundView"; -template<typename T> +template <typename T> class Resetter { public: - explicit Resetter(T* value) : value_(*value) { - *value = 0; - } - ~Resetter() { } + explicit Resetter(T* value) : value_(*value) { *value = 0; } + ~Resetter() {} T value() { return value_; } private: @@ -56,7 +54,7 @@ class Resetter { DISALLOW_COPY_AND_ASSIGN(Resetter); }; -class TestObserver : public DisplayController::Observer, +class TestObserver : public WindowTreeHostManager::Observer, public gfx::DisplayObserver, public aura::client::FocusChangeObserver, public aura::client::ActivationChangeObserver { @@ -71,24 +69,24 @@ class TestObserver : public DisplayController::Observer, changed_display_id_(0), focus_changed_count_(0), activation_changed_count_(0) { - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); Shell::GetScreen()->AddObserver(this); - aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> - AddObserver(this); - aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> - AddObserver(this); + aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) + ->AddObserver(this); + aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) + ->AddObserver(this); } ~TestObserver() override { - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); Shell::GetScreen()->RemoveObserver(this); - aura::client::GetFocusClient(Shell::GetPrimaryRootWindow())-> - RemoveObserver(this); - aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> - RemoveObserver(this); + aura::client::GetFocusClient(Shell::GetPrimaryRootWindow()) + ->RemoveObserver(this); + aura::client::GetActivationClient(Shell::GetPrimaryRootWindow()) + ->RemoveObserver(this); } - // Overridden from DisplayController::Observer + // Overridden from WindowTreeHostManager::Observer void OnDisplayConfigurationChanging() override { ++changing_count_; } void OnDisplayConfigurationChanged() override { ++changed_count_; } @@ -188,8 +186,7 @@ void SetSecondaryDisplayLayoutAndOffset(DisplayLayout::Position position, int offset) { DisplayLayout layout(position, offset); ASSERT_GT(Shell::GetScreen()->GetNumDisplays(), 1); - Shell::GetInstance()->display_manager()-> - SetLayoutForCurrentDisplays(layout); + Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(layout); } void SetSecondaryDisplayLayout(DisplayLayout::Position position) { @@ -197,14 +194,16 @@ void SetSecondaryDisplayLayout(DisplayLayout::Position position) { } void SetDefaultDisplayLayout(DisplayLayout::Position position) { - Shell::GetInstance()->display_manager()->layout_store()-> - SetDefaultDisplayLayout(DisplayLayout(position, 0)); + Shell::GetInstance() + ->display_manager() + ->layout_store() + ->SetDefaultDisplayLayout(DisplayLayout(position, 0)); } -class DisplayControllerShutdownTest : public test::AshTestBase { +class WindowTreeHostManagerShutdownTest : public test::AshTestBase { public: - DisplayControllerShutdownTest() {} - ~DisplayControllerShutdownTest() override {} + WindowTreeHostManagerShutdownTest() {} + ~WindowTreeHostManagerShutdownTest() override {} void TearDown() override { test::AshTestBase::TearDown(); @@ -218,29 +217,27 @@ class DisplayControllerShutdownTest : public test::AshTestBase { } private: - DISALLOW_COPY_AND_ASSIGN(DisplayControllerShutdownTest); + DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerShutdownTest); }; class StartupHelper : public test::TestShellDelegate, - public DisplayController::Observer { + public WindowTreeHostManager::Observer { public: StartupHelper() : displays_initialized_(false) {} ~StartupHelper() override {} // ash::ShellSelegate: void PreInit() override { - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); } - // ash::DisplayController::Observer: + // ash::WindowTreeHostManager::Observer: void OnDisplaysInitialized() override { DCHECK(!displays_initialized_); displays_initialized_ = true; } - bool displays_initialized() const { - return displays_initialized_; - } + bool displays_initialized() const { return displays_initialized_; } private: bool displays_initialized_; @@ -248,10 +245,10 @@ class StartupHelper : public test::TestShellDelegate, DISALLOW_COPY_AND_ASSIGN(StartupHelper); }; -class DisplayControllerStartupTest : public test::AshTestBase { +class WindowTreeHostManagerStartupTest : public test::AshTestBase { public: - DisplayControllerStartupTest() : startup_helper_(new StartupHelper) {} - ~DisplayControllerStartupTest() override {} + WindowTreeHostManagerStartupTest() : startup_helper_(new StartupHelper) {} + ~WindowTreeHostManagerStartupTest() override {} // ash::test::AshTestBase: void SetUp() override { @@ -259,7 +256,8 @@ class DisplayControllerStartupTest : public test::AshTestBase { test::AshTestBase::SetUp(); } void TearDown() override { - Shell::GetInstance()->display_controller()->RemoveObserver(startup_helper_); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver( + startup_helper_); test::AshTestBase::TearDown(); } @@ -268,18 +266,19 @@ class DisplayControllerStartupTest : public test::AshTestBase { private: StartupHelper* startup_helper_; // Owned by ash::Shell. - DISALLOW_COPY_AND_ASSIGN(DisplayControllerStartupTest); + DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManagerStartupTest); }; class TestEventHandler : public ui::EventHandler { public: - TestEventHandler() : target_root_(NULL), - touch_radius_x_(0.0), - touch_radius_y_(0.0), - scroll_x_offset_(0.0), - scroll_y_offset_(0.0), - scroll_x_offset_ordinal_(0.0), - scroll_y_offset_ordinal_(0.0) {} + TestEventHandler() + : target_root_(NULL), + touch_radius_x_(0.0), + touch_radius_y_(0.0), + scroll_x_offset_(0.0), + scroll_y_offset_(0.0), + scroll_x_offset_ordinal_(0.0), + scroll_y_offset_ordinal_(0.0) {} ~TestEventHandler() override {} void OnMouseEvent(ui::MouseEvent* event) override { @@ -350,8 +349,10 @@ class TestEventHandler : public ui::EventHandler { }; float GetStoredUIScale(int64 id) { - return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). - GetEffectiveUIScale(); + return Shell::GetInstance() + ->display_manager() + ->GetDisplayInfo(id) + .GetEffectiveUIScale(); } class TestMouseWatcherListener : public views::MouseWatcherListener { @@ -367,23 +368,23 @@ class TestMouseWatcherListener : public views::MouseWatcherListener { } // namespace -typedef test::AshTestBase DisplayControllerTest; +typedef test::AshTestBase WindowTreeHostManagerTest; -TEST_F(DisplayControllerShutdownTest, Shutdown) { +TEST_F(WindowTreeHostManagerShutdownTest, Shutdown) { if (!SupportsMultipleDisplays()) return; UpdateDisplay("444x333, 200x200"); } -TEST_F(DisplayControllerStartupTest, Startup) { +TEST_F(WindowTreeHostManagerStartupTest, Startup) { if (!SupportsMultipleDisplays()) return; EXPECT_TRUE(startup_helper()->displays_initialized()); } -TEST_F(DisplayControllerTest, SecondaryDisplayLayout) { +TEST_F(WindowTreeHostManagerTest, SecondaryDisplayLayout) { if (!SupportsMultipleDisplays()) return; @@ -537,8 +538,7 @@ DisplayInfo CreateDisplayInfo(int64 id, return info; } -DisplayInfo CreateMirroredDisplayInfo(int64 id, - float device_scale_factor) { +DisplayInfo CreateMirroredDisplayInfo(int64 id, float device_scale_factor) { DisplayInfo info = CreateDisplayInfo(id, 0, gfx::Display::ROTATE_0); info.set_device_scale_factor(device_scale_factor); return info; @@ -546,7 +546,7 @@ DisplayInfo CreateMirroredDisplayInfo(int64 id, } // namespace -TEST_F(DisplayControllerTest, MirrorToDockedWithFullscreen) { +TEST_F(WindowTreeHostManagerTest, MirrorToDockedWithFullscreen) { if (!SupportsMultipleDisplays()) return; @@ -557,10 +557,8 @@ TEST_F(DisplayControllerTest, MirrorToDockedWithFullscreen) { // Docked mode. DisplayManager* display_manager = Shell::GetInstance()->display_manager(); - const DisplayInfo internal_display_info = - CreateMirroredDisplayInfo(1, 2.0f); - const DisplayInfo external_display_info = - CreateMirroredDisplayInfo(2, 1.0f); + const DisplayInfo internal_display_info = CreateMirroredDisplayInfo(1, 2.0f); + const DisplayInfo external_display_info = CreateMirroredDisplayInfo(2, 1.0f); std::vector<DisplayInfo> display_info_list; // Mirror. @@ -598,7 +596,7 @@ TEST_F(DisplayControllerTest, MirrorToDockedWithFullscreen) { EXPECT_EQ("0,0 500x500", w1->bounds().ToString()); } -TEST_F(DisplayControllerTest, BoundsUpdated) { +TEST_F(WindowTreeHostManagerTest, BoundsUpdated) { if (!SupportsMultipleDisplays()) return; @@ -696,12 +694,12 @@ TEST_F(DisplayControllerTest, BoundsUpdated) { EXPECT_EQ(0, observer.GetActivationChangedCountAndReset()); } -TEST_F(DisplayControllerTest, SwapPrimary) { +TEST_F(WindowTreeHostManagerTest, SwapPrimary) { if (!SupportsMultipleDisplays()) return; - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + Shell::GetInstance()->window_tree_host_manager(); DisplayManager* display_manager = Shell::GetInstance()->display_manager(); UpdateDisplay("200x200,300x300"); @@ -713,17 +711,18 @@ TEST_F(DisplayControllerTest, SwapPrimary) { EXPECT_NE(primary_display.id(), secondary_display.id()); aura::Window* primary_root = - display_controller->GetRootWindowForDisplayId(primary_display.id()); + window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); aura::Window* secondary_root = - display_controller->GetRootWindowForDisplayId(secondary_display.id()); + window_tree_host_manager->GetRootWindowForDisplayId( + secondary_display.id()); EXPECT_NE(primary_root, secondary_root); aura::Window* shelf_window = 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()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); @@ -731,11 +730,10 @@ TEST_F(DisplayControllerTest, SwapPrimary) { EXPECT_EQ("0,0 200x153", primary_display.work_area().ToString()); EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString()); EXPECT_EQ("200,0 300x253", secondary_display.work_area().ToString()); - EXPECT_EQ("right, 50", - display_manager->GetCurrentDisplayLayout().ToString()); + EXPECT_EQ("right, 50", display_manager->GetCurrentDisplayLayout().ToString()); // Switch primary and secondary - display_controller->SetPrimaryDisplay(secondary_display); + window_tree_host_manager->SetPrimaryDisplay(secondary_display); const DisplayLayout& inverted_layout = display_manager->GetCurrentDisplayLayout(); EXPECT_EQ("left, -50", inverted_layout.ToString()); @@ -743,18 +741,16 @@ TEST_F(DisplayControllerTest, SwapPrimary) { EXPECT_EQ(secondary_display.id(), Shell::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(), + Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); - EXPECT_EQ( - primary_root, - display_controller->GetRootWindowForDisplayId(secondary_display.id())); - EXPECT_EQ( - secondary_root, - display_controller->GetRootWindowForDisplayId(primary_display.id())); + EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( + secondary_display.id())); + EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( + primary_display.id())); EXPECT_TRUE(primary_root->Contains(shelf_window)); EXPECT_FALSE(secondary_root->Contains(shelf_window)); @@ -776,9 +772,9 @@ TEST_F(DisplayControllerTest, SwapPrimary) { 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( + primary_display.id(), + Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); EXPECT_TRUE(tracker.Contains(primary_root)); @@ -786,12 +782,12 @@ TEST_F(DisplayControllerTest, SwapPrimary) { EXPECT_TRUE(primary_root->Contains(shelf_window)); } -TEST_F(DisplayControllerTest, FindNearestDisplay) { +TEST_F(WindowTreeHostManagerTest, FindNearestDisplay) { if (!SupportsMultipleDisplays()) return; - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + Shell::GetInstance()->window_tree_host_manager(); DisplayManager* display_manager = Shell::GetInstance()->display_manager(); UpdateDisplay("200x200,300x300"); @@ -802,38 +798,48 @@ TEST_F(DisplayControllerTest, FindNearestDisplay) { gfx::Display secondary_display = ScreenUtil::GetSecondaryDisplay(); EXPECT_NE(primary_display.id(), secondary_display.id()); aura::Window* primary_root = - display_controller->GetRootWindowForDisplayId(primary_display.id()); + window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); aura::Window* secondary_root = - display_controller->GetRootWindowForDisplayId(secondary_display.id()); + window_tree_host_manager->GetRootWindowForDisplayId( + secondary_display.id()); 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(), + 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()); } -TEST_F(DisplayControllerTest, SwapPrimaryById) { +TEST_F(WindowTreeHostManagerTest, SwapPrimaryById) { if (!SupportsMultipleDisplays()) return; - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + Shell::GetInstance()->window_tree_host_manager(); DisplayManager* display_manager = Shell::GetInstance()->display_manager(); UpdateDisplay("200x200,300x300"); @@ -845,34 +851,33 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { EXPECT_NE(primary_display.id(), secondary_display.id()); aura::Window* primary_root = - display_controller->GetRootWindowForDisplayId(primary_display.id()); + window_tree_host_manager->GetRootWindowForDisplayId(primary_display.id()); aura::Window* secondary_root = - display_controller->GetRootWindowForDisplayId(secondary_display.id()); + window_tree_host_manager->GetRootWindowForDisplayId( + secondary_display.id()); aura::Window* shelf_window = Shelf::ForPrimaryDisplay()->shelf_widget()->GetNativeView(); 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()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); // Switch primary and secondary by display ID. TestObserver observer; - display_controller->SetPrimaryDisplayId(secondary_display.id()); + window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); EXPECT_LT(0, observer.CountAndReset()); - EXPECT_EQ( - primary_root, - display_controller->GetRootWindowForDisplayId(secondary_display.id())); - EXPECT_EQ( - secondary_root, - display_controller->GetRootWindowForDisplayId(primary_display.id())); + EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( + secondary_display.id())); + EXPECT_EQ(secondary_root, window_tree_host_manager->GetRootWindowForDisplayId( + primary_display.id())); EXPECT_TRUE(primary_root->Contains(shelf_window)); EXPECT_FALSE(secondary_root->Contains(shelf_window)); @@ -882,7 +887,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { EXPECT_EQ("left, -50", inverted_layout.ToString()); // Calling the same ID don't do anything. - display_controller->SetPrimaryDisplayId(secondary_display.id()); + window_tree_host_manager->SetPrimaryDisplayId(secondary_display.id()); EXPECT_EQ(0, observer.CountAndReset()); aura::WindowTracker tracker; @@ -894,9 +899,9 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { 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( + primary_display.id(), + Shell::GetScreen()->GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestWindow(NULL).id()); EXPECT_TRUE(tracker.Contains(primary_root)); @@ -916,19 +921,17 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(primary_display.id(), ScreenUtil::GetSecondaryDisplay().id()); - EXPECT_EQ( - primary_root, - display_controller->GetRootWindowForDisplayId(secondary_display.id())); - EXPECT_NE( - primary_root, - display_controller->GetRootWindowForDisplayId(primary_display.id())); + EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( + secondary_display.id())); + EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( + primary_display.id())); EXPECT_TRUE(primary_root->Contains(shelf_window)); // Deleting 2nd display and adding 2nd display with a different ID. The 2nd // display shouldn't become primary. UpdateDisplay("200x200"); - DisplayInfo third_display_info( - secondary_display.id() + 1, std::string(), false); + DisplayInfo third_display_info(secondary_display.id() + 1, std::string(), + false); third_display_info.SetBounds(secondary_display.bounds()); ASSERT_NE(primary_display.id(), third_display_info.id()); @@ -939,24 +942,21 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) { 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(primary_display.id(), Shell::GetScreen()->GetPrimaryDisplay().id()); EXPECT_EQ(third_display_info.id(), ScreenUtil::GetSecondaryDisplay().id()); - EXPECT_EQ( - primary_root, - display_controller->GetRootWindowForDisplayId(primary_display.id())); - EXPECT_NE( - primary_root, - display_controller->GetRootWindowForDisplayId(third_display_info.id())); + EXPECT_EQ(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( + primary_display.id())); + EXPECT_NE(primary_root, window_tree_host_manager->GetRootWindowForDisplayId( + third_display_info.id())); EXPECT_TRUE(primary_root->Contains(shelf_window)); } -TEST_F(DisplayControllerTest, OverscanInsets) { +TEST_F(WindowTreeHostManagerTest, OverscanInsets) { if (!SupportsMultipleDisplays()) return; - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + Shell::GetInstance()->window_tree_host_manager(); TestEventHandler event_handler; Shell::GetInstance()->AddPreTargetHandler(&event_handler); @@ -964,8 +964,8 @@ TEST_F(DisplayControllerTest, OverscanInsets) { gfx::Display display1 = Shell::GetScreen()->GetPrimaryDisplay(); aura::Window::Windows root_windows = Shell::GetAllRootWindows(); - display_controller->SetOverscanInsets(display1.id(), - gfx::Insets(10, 15, 20, 25)); + window_tree_host_manager->SetOverscanInsets(display1.id(), + gfx::Insets(10, 15, 20, 25)); EXPECT_EQ("0,0 80x170", root_windows[0]->bounds().ToString()); EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); EXPECT_EQ("80,0 150x200", @@ -975,7 +975,7 @@ TEST_F(DisplayControllerTest, OverscanInsets) { generator.MoveMouseToInHost(20, 25); EXPECT_EQ("5,15", event_handler.GetLocationAndReset()); - display_controller->SetOverscanInsets(display1.id(), gfx::Insets()); + window_tree_host_manager->SetOverscanInsets(display1.id(), gfx::Insets()); EXPECT_EQ("0,0 120x200", root_windows[0]->bounds().ToString()); EXPECT_EQ("120,0 150x200", ScreenUtil::GetSecondaryDisplay().bounds().ToString()); @@ -988,20 +988,20 @@ TEST_F(DisplayControllerTest, OverscanInsets) { UpdateDisplay("400x300*2,600x400/o"); root_windows = Shell::GetAllRootWindows(); gfx::Point point; - Shell::GetAllRootWindows()[1]->GetHost()-> - GetRootTransform().TransformPoint(&point); + Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( + &point); EXPECT_EQ("15,10", point.ToString()); - display_controller->SwapPrimaryDisplay(); + window_tree_host_manager->SwapPrimaryDisplay(); point.SetPoint(0, 0); - Shell::GetAllRootWindows()[1]->GetHost()-> - GetRootTransform().TransformPoint(&point); + Shell::GetAllRootWindows()[1]->GetHost()->GetRootTransform().TransformPoint( + &point); EXPECT_EQ("15,10", point.ToString()); Shell::GetInstance()->RemovePreTargetHandler(&event_handler); } -TEST_F(DisplayControllerTest, Rotate) { +TEST_F(WindowTreeHostManagerTest, Rotate) { if (!SupportsMultipleDisplays()) return; @@ -1076,7 +1076,7 @@ TEST_F(DisplayControllerTest, Rotate) { Shell::GetInstance()->RemovePreTargetHandler(&event_handler); } -TEST_F(DisplayControllerTest, ScaleRootWindow) { +TEST_F(WindowTreeHostManagerTest, ScaleRootWindow) { if (!SupportsMultipleDisplays()) return; @@ -1112,7 +1112,7 @@ TEST_F(DisplayControllerTest, ScaleRootWindow) { Shell::GetInstance()->RemovePreTargetHandler(&event_handler); } -TEST_F(DisplayControllerTest, TouchScale) { +TEST_F(WindowTreeHostManagerTest, TouchScale) { if (!SupportsMultipleDisplays()) return; @@ -1131,9 +1131,9 @@ TEST_F(DisplayControllerTest, TouchScale) { EXPECT_EQ(0.5, event_handler.touch_radius_x()); EXPECT_EQ(0.5, event_handler.touch_radius_y()); - generator.ScrollSequence(gfx::Point(0,0), - base::TimeDelta::FromMilliseconds(100), - 10.0, 1.0, 5, 1); + generator.ScrollSequence(gfx::Point(0, 0), + base::TimeDelta::FromMilliseconds(100), 10.0, 1.0, 5, + 1); // ordinal_offset is invariant to the device scale factor. EXPECT_EQ(event_handler.scroll_x_offset(), @@ -1144,7 +1144,7 @@ TEST_F(DisplayControllerTest, TouchScale) { Shell::GetInstance()->RemovePreTargetHandler(&event_handler); } -TEST_F(DisplayControllerTest, ConvertHostToRootCoords) { +TEST_F(WindowTreeHostManagerTest, ConvertHostToRootCoords) { if (!SupportsMultipleDisplays()) return; @@ -1206,7 +1206,7 @@ TEST_F(DisplayControllerTest, ConvertHostToRootCoords) { // Make sure that the compositor based mirroring can switch // from/to dock mode. -TEST_F(DisplayControllerTest, DockToSingle) { +TEST_F(WindowTreeHostManagerTest, DockToSingle) { if (!SupportsMultipleDisplays()) return; @@ -1234,21 +1234,25 @@ TEST_F(DisplayControllerTest, DockToSingle) { display_info_list.push_back(external_display_info); display_manager->OnNativeDisplaysChanged(display_info_list); EXPECT_EQ(1U, display_manager->GetNumDisplays()); - EXPECT_FALSE(Shell::GetPrimaryRootWindow()->GetHost()-> - GetRootTransform().IsIdentityOrIntegerTranslation()); + EXPECT_FALSE(Shell::GetPrimaryRootWindow() + ->GetHost() + ->GetRootTransform() + .IsIdentityOrIntegerTranslation()); // Switch to single mode and make sure the transform is the one // for the internal display. display_info_list.clear(); display_info_list.push_back(internal_display_info); display_manager->OnNativeDisplaysChanged(display_info_list); - EXPECT_TRUE(Shell::GetPrimaryRootWindow()->GetHost()-> - GetRootTransform().IsIdentityOrIntegerTranslation()); + EXPECT_TRUE(Shell::GetPrimaryRootWindow() + ->GetHost() + ->GetRootTransform() + .IsIdentityOrIntegerTranslation()); } // Tests if switching two displays at the same time while the primary display // is swapped should not cause a crash. (crbug.com/426292) -TEST_F(DisplayControllerTest, ReplaceSwappedPrimary) { +TEST_F(WindowTreeHostManagerTest, ReplaceSwappedPrimary) { if (!SupportsMultipleDisplays()) return; DisplayManager* display_manager = Shell::GetInstance()->display_manager(); @@ -1264,7 +1268,7 @@ TEST_F(DisplayControllerTest, ReplaceSwappedPrimary) { display_info_list.push_back(second_display_info); display_manager->OnNativeDisplaysChanged(display_info_list); - Shell::GetInstance()->display_controller()->SwapPrimaryDisplay(); + Shell::GetInstance()->window_tree_host_manager()->SwapPrimaryDisplay(); EXPECT_EQ(11, Shell::GetScreen()->GetPrimaryDisplay().id()); @@ -1280,7 +1284,7 @@ TEST_F(DisplayControllerTest, ReplaceSwappedPrimary) { EXPECT_EQ(20, Shell::GetScreen()->GetPrimaryDisplay().id()); } -TEST_F(DisplayControllerTest, UpdateMouseLocationAfterDisplayChange) { +TEST_F(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange) { if (!SupportsMultipleDisplays()) return; @@ -1323,7 +1327,8 @@ TEST_F(DisplayControllerTest, UpdateMouseLocationAfterDisplayChange) { EXPECT_EQ("450,10", env->last_mouse_location().ToString()); } -TEST_F(DisplayControllerTest, UpdateMouseLocationAfterDisplayChange_2ndOnLeft) { +TEST_F(WindowTreeHostManagerTest, + UpdateMouseLocationAfterDisplayChange_2ndOnLeft) { if (!SupportsMultipleDisplays()) return; @@ -1363,7 +1368,7 @@ TEST_F(DisplayControllerTest, UpdateMouseLocationAfterDisplayChange_2ndOnLeft) { // Test that the cursor swaps displays and that its scale factor and rotation // are updated when the primary display is swapped. -TEST_F(DisplayControllerTest, +TEST_F(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange_SwapPrimary) { if (!SupportsMultipleDisplays()) return; @@ -1372,16 +1377,18 @@ TEST_F(DisplayControllerTest, aura::Env* env = aura::Env::GetInstance(); Shell* shell = Shell::GetInstance(); - DisplayController* display_controller = shell->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + shell->window_tree_host_manager(); test::CursorManagerTestApi test_api(shell->cursor_manager()); - display_controller->GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(20, 50)); + window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( + gfx::Point(20, 50)); EXPECT_EQ("20,50", env->last_mouse_location().ToString()); EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); - display_controller->SwapPrimaryDisplay(); + window_tree_host_manager->SwapPrimaryDisplay(); EXPECT_EQ("20,50", env->last_mouse_location().ToString()); EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); @@ -1390,30 +1397,33 @@ TEST_F(DisplayControllerTest, // Test that the cursor moves to the other display and that its scale factor // and rotation are updated when the primary display is disconnected. -TEST_F(DisplayControllerTest, +TEST_F(WindowTreeHostManagerTest, UpdateMouseLocationAfterDisplayChange_PrimaryDisconnected) { if (!SupportsMultipleDisplays()) return; aura::Env* env = aura::Env::GetInstance(); Shell* shell = Shell::GetInstance(); - DisplayController* display_controller = shell->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + shell->window_tree_host_manager(); test::CursorManagerTestApi test_api(shell->cursor_manager()); UpdateDisplay("300x300*2/r,200x200"); // Swap the primary display to make it possible to remove the primary display // via UpdateDisplay(). - display_controller->SwapPrimaryDisplay(); - int primary_display_id = display_controller->GetPrimaryDisplayId(); + window_tree_host_manager->SwapPrimaryDisplay(); + int primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); - display_controller->GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(20, 50)); + window_tree_host_manager->GetPrimaryRootWindow()->MoveCursorTo( + gfx::Point(20, 50)); EXPECT_EQ("20,50", env->last_mouse_location().ToString()); EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor()); EXPECT_EQ(gfx::Display::ROTATE_0, test_api.GetCurrentCursorRotation()); UpdateDisplay("300x300*2/r"); - ASSERT_NE(primary_display_id, display_controller->GetPrimaryDisplayId()); + ASSERT_NE(primary_display_id, + window_tree_host_manager->GetPrimaryDisplayId()); // Cursor should be centered on the remaining display. EXPECT_EQ("75,75", env->last_mouse_location().ToString()); @@ -1423,15 +1433,16 @@ TEST_F(DisplayControllerTest, // GetRootWindowForDisplayId() for removed gfx::Display during // OnDisplayRemoved() should not cause crash. See http://crbug.com/415222 -TEST_F(DisplayControllerTest, +TEST_F(WindowTreeHostManagerTest, GetRootWindowForDisplayIdDuringDisplayDisconnection) { if (!SupportsMultipleDisplays()) return; UpdateDisplay("300x300,200x200"); aura::Window* root2 = - Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( - ScreenUtil::GetSecondaryDisplay().id()); + Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(ScreenUtil::GetSecondaryDisplay().id()); views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( nullptr, root2, gfx::Rect(350, 0, 100, 100)); views::View* view = new views::View(); diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index e27bf8b..64eee29 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h index 44d1b40..ffa19e1 100644 --- a/ash/root_window_controller.h +++ b/ash/root_window_controller.h @@ -74,7 +74,7 @@ class AshTouchExplorationManager; // This class maintains the per root window state for ash. This class // owns the root window and other dependent objects that should be // deleted upon the deletion of the root window. This object is -// indirectly owned and deleted by |DisplayController|. +// indirectly owned and deleted by |WindowTreeHostManager|. // The RootWindowController for particular root window is stored in // its property (RootWindowSettings) and can be obtained using // |GetRootWindowController(aura::WindowEventDispatcher*)| function. diff --git a/ash/rotator/screen_rotation_animator.cc b/ash/rotator/screen_rotation_animator.cc index 9b746b6..1df099b 100644 --- a/ash/rotator/screen_rotation_animator.cc +++ b/ash/rotator/screen_rotation_animator.cc @@ -8,9 +8,9 @@ #include <vector> #include "ash/ash_switches.h" -#include "ash/display/display_controller.h" #include "ash/display/display_info.h" #include "ash/display/display_manager.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/rotator/screen_rotation_animation.h" #include "ash/shell.h" #include "base/command_line.h" @@ -171,9 +171,9 @@ void RotateScreen(int64 display_id, int rotation_degree_offset, gfx::Tween::Type tween_type, bool should_scale) { - aura::Window* root_window = - Shell::GetInstance()->display_controller()->GetRootWindowForDisplayId( - display_id); + aura::Window* root_window = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display_id); const gfx::Display::Rotation initial_orientation = GetCurrentRotation(display_id); diff --git a/ash/screen_util.cc b/ash/screen_util.cc index bd4f22d..d0e4121 100644 --- a/ash/screen_util.cc +++ b/ash/screen_util.cc @@ -4,7 +4,6 @@ #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" diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc index b737e80..d447b06 100644 --- a/ash/shelf/shelf_layout_manager_unittest.cc +++ b/ash/shelf/shelf_layout_manager_unittest.cc @@ -7,8 +7,8 @@ #include "ash/accelerators/accelerator_controller.h" #include "ash/accelerators/accelerator_table.h" #include "ash/ash_switches.h" -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/focus_cycler.h" #include "ash/root_window_controller.h" #include "ash/session/session_state_delegate.h" @@ -1221,8 +1221,10 @@ TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { UpdateDisplay("0+0-200x200,+200+0-100x100"); EXPECT_EQ(2U, shell->display_manager()->GetNumDisplays()); - DisplayController* display_controller = shell->display_controller(); - aura::Window::Windows root_windows = display_controller->GetAllRootWindows(); + WindowTreeHostManager* window_tree_host_manager = + shell->window_tree_host_manager(); + aura::Window::Windows root_windows = + window_tree_host_manager->GetAllRootWindows(); EXPECT_EQ(root_windows.size(), 2U); std::vector<ShelfWidget*> shelf_widgets; @@ -1449,8 +1451,10 @@ TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { UpdateDisplay("0+0-200x200,+200+0-100x100"); EXPECT_EQ(2U, display_manager->GetNumDisplays()); - DisplayController* display_controller = shell->display_controller(); - aura::Window::Windows root_windows = display_controller->GetAllRootWindows(); + WindowTreeHostManager* window_tree_host_manager = + shell->window_tree_host_manager(); + aura::Window::Windows root_windows = + window_tree_host_manager->GetAllRootWindows(); EXPECT_EQ(root_windows.size(), 2U); // Get the shelves in both displays and set them to be 'AutoHide'. @@ -1582,8 +1586,10 @@ TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { UpdateDisplay("200x200,100x100"); EXPECT_EQ(2U, display_manager->GetNumDisplays()); - DisplayController* display_controller = shell->display_controller(); - aura::Window::Windows root_windows = display_controller->GetAllRootWindows(); + WindowTreeHostManager* window_tree_host_manager = + shell->window_tree_host_manager(); + aura::Window::Windows root_windows = + window_tree_host_manager->GetAllRootWindows(); EXPECT_EQ(2U, root_windows.size()); // Get the shelves in both displays and set them to be 'AutoHide'. diff --git a/ash/shelf/shelf_window_watcher.cc b/ash/shelf/shelf_window_watcher.cc index 546d212..4bdb024 100644 --- a/ash/shelf/shelf_window_watcher.cc +++ b/ash/shelf/shelf_window_watcher.cc @@ -4,7 +4,7 @@ #include "ash/shelf/shelf_window_watcher.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shelf/shelf_constants.h" #include "ash/shelf/shelf_item_delegate_manager.h" #include "ash/shelf/shelf_model.h" @@ -268,8 +268,9 @@ void ShelfWindowWatcher::OnWindowPropertyChanged(aura::Window* window, void ShelfWindowWatcher::OnDisplayAdded(const gfx::Display& new_display) { // Add a new RootWindow and its ActivationClient to observed list. - aura::Window* root_window = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(new_display.id()); + aura::Window* root_window = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(new_display.id()); // When the primary root window's display get removed, the existing root // window is taken over by the new display and the observer is already set. diff --git a/ash/shell.cc b/ash/shell.cc index c67beb3..4cbc6d4 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -17,11 +17,11 @@ #include "ash/desktop_background/desktop_background_view.h" #include "ash/desktop_background/user_wallpaper_delegate.h" #include "ash/display/cursor_window_controller.h" -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" #include "ash/display/event_transformation_handler.h" #include "ash/display/mouse_cursor_event_filter.h" #include "ash/display/screen_position_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/drag_drop/drag_drop_controller.h" #include "ash/first_run/first_run_helper_impl.h" #include "ash/focus_cycler.h" @@ -222,14 +222,15 @@ RootWindowController* Shell::GetPrimaryRootWindowController() { // static Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { CHECK(HasInstance()); - return Shell::GetInstance()->display_controller()-> - GetAllRootWindowControllers(); + return Shell::GetInstance() + ->window_tree_host_manager() + ->GetAllRootWindowControllers(); } // static aura::Window* Shell::GetPrimaryRootWindow() { CHECK(HasInstance()); - return GetInstance()->display_controller()->GetPrimaryRootWindow(); + return GetInstance()->window_tree_host_manager()->GetPrimaryRootWindow(); } // static @@ -249,8 +250,7 @@ gfx::Screen* Shell::GetScreen() { // static aura::Window::Windows Shell::GetAllRootWindows() { CHECK(HasInstance()); - return Shell::GetInstance()->display_controller()-> - GetAllRootWindows(); + return Shell::GetInstance()->window_tree_host_manager()->GetAllRootWindows(); } // static @@ -367,7 +367,7 @@ void Shell::RotateFocus(Direction direction) { void Shell::SetDisplayWorkAreaInsets(Window* contains, const gfx::Insets& insets) { - if (!display_controller_->UpdateWorkAreaOfDisplayNearestWindow( + if (!window_tree_host_manager_->UpdateWorkAreaOfDisplayNearestWindow( contains, insets)) { return; } @@ -618,8 +618,8 @@ ash::FirstRunHelper* Shell::CreateFirstRunHelper() { } void Shell::SetCursorCompositingEnabled(bool enabled) { - display_controller_->cursor_window_controller()->SetCursorCompositingEnabled( - enabled); + window_tree_host_manager_->cursor_window_controller() + ->SetCursorCompositingEnabled(enabled); native_cursor_manager_->SetNativeCursorEnabled(!enabled); } #endif // defined(OS_CHROMEOS) @@ -649,7 +649,7 @@ Shell::Shell(ShellDelegate* delegate) DCHECK(delegate_.get()); gpu_support_.reset(delegate_->CreateGPUSupport()); display_manager_.reset(new DisplayManager); - display_controller_.reset(new DisplayController); + window_tree_host_manager_.reset(new WindowTreeHostManager); user_metrics_recorder_.reset(new UserMetricsRecorder); #if defined(OS_CHROMEOS) @@ -674,7 +674,8 @@ Shell::~Shell() { // Please keep in same order as in Init() because it's easy to miss one. if (window_modality_controller_) window_modality_controller_.reset(); - RemovePreTargetHandler(display_controller_->input_method_event_handler()); + RemovePreTargetHandler( + window_tree_host_manager_->input_method_event_handler()); #if defined(OS_CHROMEOS) RemovePreTargetHandler(magnifier_key_scroll_handler_.get()); magnifier_key_scroll_handler_.reset(); @@ -734,7 +735,7 @@ Shell::~Shell() { drag_drop_controller_.reset(); // Controllers who have WindowObserver added must be deleted - // before |display_controller_| is deleted. + // before |window_tree_host_manager_| is deleted. #if defined(OS_CHROMEOS) // VideoActivityNotifier must be deleted before |video_detector_| is @@ -756,7 +757,7 @@ Shell::~Shell() { shelf_window_watcher_.reset(); // Destroy all child windows including widgets. - display_controller_->CloseChildWindows(); + window_tree_host_manager_->CloseChildWindows(); // MruWindowTracker must be destroyed after all windows have been deleted to // avoid a possible crash when Shell is destroyed from a non-normal shutdown // path. (crbug.com/485438). @@ -801,11 +802,12 @@ Shell::~Shell() { #endif // defined(OS_CHROMEOS) // This also deletes all RootWindows. Note that we invoke Shutdown() on - // DisplayController before resetting |display_controller_|, since destruction + // WindowTreeHostManager before resetting |window_tree_host_manager_|, since + // destruction // of its owned RootWindowControllers relies on the value. display_manager_->CreateScreenForShutdown(); - display_controller_->Shutdown(); - display_controller_.reset(); + window_tree_host_manager_->Shutdown(); + window_tree_host_manager_.reset(); screen_position_controller_.reset(); accessibility_delegate_.reset(); new_window_delegate_.reset(); @@ -902,10 +904,10 @@ void Shell::Init(const ShellInitParams& init_params) { screen_position_controller_.reset(new ScreenPositionController); - display_controller_->Start(); - display_controller_->CreatePrimaryHost( + window_tree_host_manager_->Start(); + window_tree_host_manager_->CreatePrimaryHost( ShellInitParamsToAshWindowTreeHostInitParams(init_params)); - aura::Window* root_window = display_controller_->GetPrimaryRootWindow(); + aura::Window* root_window = window_tree_host_manager_->GetPrimaryRootWindow(); target_root_window_ = root_window; #if defined(OS_CHROMEOS) @@ -920,7 +922,7 @@ void Shell::Init(const ShellInitParams& init_params) { accelerator_controller_.reset(new AcceleratorController); maximize_mode_controller_.reset(new MaximizeModeController()); - AddPreTargetHandler(display_controller_->input_method_event_handler()); + AddPreTargetHandler(window_tree_host_manager_->input_method_event_handler()); #if defined(OS_CHROMEOS) magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler(); @@ -1041,13 +1043,14 @@ void Shell::Init(const ShellInitParams& init_params) { base::Bind(&SystemTrayDelegate::SignOut, base::Unretained(system_tray_delegate_.get())))); - // Create TouchTransformerController before DisplayController::InitDisplays() + // Create TouchTransformerController before + // WindowTreeHostManager::InitDisplays() // since TouchTransformerController listens on - // DisplayController::Observer::OnDisplaysInitialized(). + // WindowTreeHostManager::Observer::OnDisplaysInitialized(). touch_transformer_controller_.reset(new TouchTransformerController()); #endif // defined(OS_CHROMEOS) - display_controller_->InitDisplays(); + window_tree_host_manager_->InitHosts(); #if defined(OS_CHROMEOS) // Needs to be created after InitDisplays() since it may cause the virtual diff --git a/ash/shell.h b/ash/shell.h index db196e6..d2480a8 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -84,7 +84,7 @@ class DesktopBackgroundController; class DisplayChangeObserver; class DisplayColorManager; class DisplayConfiguratorAnimation; -class DisplayController; +class WindowTreeHostManager; class DisplayErrorObserver; class DisplayManager; class DragDropController; @@ -374,8 +374,8 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, return window_selector_controller_.get(); } FocusCycler* focus_cycler() { return focus_cycler_.get(); } - DisplayController* display_controller() { - return display_controller_.get(); + WindowTreeHostManager* window_tree_host_manager() { + return window_tree_host_manager_.get(); } #if defined(OS_CHROMEOS) PowerEventObserver* power_event_observer() { @@ -514,7 +514,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, } #if defined(OS_CHROMEOS) - // TODO(oshima): Move these objects to DisplayController. + // TODO(oshima): Move these objects to WindowTreeHostManager. ui::DisplayConfigurator* display_configurator() { return display_configurator_.get(); } @@ -671,7 +671,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, scoped_ptr<WindowCycleController> window_cycle_controller_; scoped_ptr<WindowSelectorController> window_selector_controller_; scoped_ptr<FocusCycler> focus_cycler_; - scoped_ptr<DisplayController> display_controller_; + scoped_ptr<WindowTreeHostManager> window_tree_host_manager_; scoped_ptr<HighContrastController> high_contrast_controller_; scoped_ptr<MagnificationController> magnification_controller_; scoped_ptr<PartialMagnificationController> partial_magnification_controller_; diff --git a/ash/shell/toplevel_window.cc b/ash/shell/toplevel_window.cc index 27c96d6..ab9cdc4 100644 --- a/ash/shell/toplevel_window.cc +++ b/ash/shell/toplevel_window.cc @@ -4,7 +4,6 @@ #include "ash/shell/toplevel_window.h" -#include "ash/display/display_controller.h" #include "ash/shell.h" #include "ash/wm/window_positioner.h" #include "ash/wm/window_state.h" diff --git a/ash/shell/window_watcher.cc b/ash/shell/window_watcher.cc index f5b194c..bd5d148 100644 --- a/ash/shell/window_watcher.cc +++ b/ash/shell/window_watcher.cc @@ -4,7 +4,7 @@ #include "ash/shell/window_watcher.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_item_delegate_manager.h" #include "ash/shelf/shelf_model.h" @@ -137,8 +137,9 @@ void WindowWatcher::OnWillRemoveWindow(aura::Window* window) { } void WindowWatcher::OnDisplayAdded(const gfx::Display& new_display) { - aura::Window* root = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(new_display.id()); + aura::Window* root = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(new_display.id()); workspace_window_watcher_->RootWindowAdded(root); } diff --git a/ash/sticky_keys/sticky_keys_overlay_unittest.cc b/ash/sticky_keys/sticky_keys_overlay_unittest.cc index 2566a8b..d28c536 100644 --- a/ash/sticky_keys/sticky_keys_overlay_unittest.cc +++ b/ash/sticky_keys/sticky_keys_overlay_unittest.cc @@ -4,8 +4,8 @@ #include "ash/sticky_keys/sticky_keys_overlay.h" -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shell.h" #include "ash/sticky_keys/sticky_keys_controller.h" #include "ash/test/ash_test_base.h" @@ -55,16 +55,18 @@ TEST_F(StickyKeysOverlayTest, OverlayNotDestroyedAfterDisplayRemoved) { // The overlay should belong to the secondary root window. StickyKeysOverlay overlay; views::Widget* overlay_widget = overlay.GetWidgetForTesting(); - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); - EXPECT_EQ(display_controller->GetRootWindowForDisplayId(secondary_display_id), - overlay_widget->GetNativeWindow()->GetRootWindow()); + WindowTreeHostManager* window_tree_host_manager = + Shell::GetInstance()->window_tree_host_manager(); + EXPECT_EQ( + window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id), + overlay_widget->GetNativeWindow()->GetRootWindow()); // Removing the second display should move the overlay to the primary root // window. UpdateDisplay("1280x1024"); - EXPECT_EQ(display_controller->GetRootWindowForDisplayId(primary_display_id), - overlay_widget->GetNativeWindow()->GetRootWindow()); + EXPECT_EQ( + window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id), + overlay_widget->GetNativeWindow()->GetRootWindow()); overlay.SetModifierKeyState(ui::EF_SHIFT_DOWN, STICKY_KEY_STATE_ENABLED); EXPECT_EQ(STICKY_KEY_STATE_ENABLED, diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc index be9adec..6f4142b 100644 --- a/ash/system/chromeos/tray_display.cc +++ b/ash/system/chromeos/tray_display.cc @@ -7,8 +7,8 @@ #include <vector> #include "ash/content/display/screen_orientation_controller_chromeos.h" -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shell.h" #include "ash/system/chromeos/devicetype_utils.h" #include "ash/system/system_notifier.h" @@ -293,12 +293,12 @@ class DisplayView : public ActionableView { TrayDisplay::TrayDisplay(SystemTray* system_tray) : SystemTrayItem(system_tray), default_(NULL) { - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); UpdateDisplayInfo(NULL); } TrayDisplay::~TrayDisplay() { - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); } void TrayDisplay::UpdateDisplayInfo(TrayDisplay::DisplayInfoMap* old_info) { diff --git a/ash/system/chromeos/tray_display.h b/ash/system/chromeos/tray_display.h index 72b0980..08309ce 100644 --- a/ash/system/chromeos/tray_display.h +++ b/ash/system/chromeos/tray_display.h @@ -8,8 +8,8 @@ #include <map> #include "ash/ash_export.h" -#include "ash/display/display_controller.h" #include "ash/display/display_info.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/system/tray/system_tray_item.h" #include "base/strings/string16.h" #include "ui/views/view.h" @@ -22,12 +22,12 @@ class AshTestBase; } class ASH_EXPORT TrayDisplay : public SystemTrayItem, - public DisplayController::Observer { + public WindowTreeHostManager::Observer { public: explicit TrayDisplay(SystemTray* system_tray); ~TrayDisplay() override; - // Overridden from DisplayControllerObserver: + // Overridden from WindowTreeHostManagerObserver: void OnDisplayConfigurationChanged() override; private: diff --git a/ash/system/web_notification/ash_popup_alignment_delegate.cc b/ash/system/web_notification/ash_popup_alignment_delegate.cc index 0c77877..a452f18 100644 --- a/ash/system/web_notification/ash_popup_alignment_delegate.cc +++ b/ash/system/web_notification/ash_popup_alignment_delegate.cc @@ -4,7 +4,7 @@ #include "ash/system/web_notification/ash_popup_alignment_delegate.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/screen_util.h" #include "ash/shelf/shelf_constants.h" #include "ash/shelf/shelf_layout_manager.h" @@ -49,7 +49,7 @@ void AshPopupAlignmentDelegate::StartObserving(gfx::Screen* screen, screen_ = screen; work_area_ = display.work_area(); root_window_ = ash::Shell::GetInstance() - ->display_controller() + ->window_tree_host_manager() ->GetRootWindowForDisplayId(display.id()); UpdateShelf(); screen->AddObserver(this); diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc index f483044..dc0e36e 100644 --- a/ash/test/ash_test_base.cc +++ b/ash/test/ash_test_base.cc @@ -8,7 +8,7 @@ #include <vector> #include "ash/ash_switches.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/ime/input_method_event_handler.h" #include "ash/shell.h" #include "ash/shell/toplevel_window.h" @@ -68,8 +68,10 @@ class AshEventGeneratorDelegate const gfx::Point& point_in_screen) const override { gfx::Screen* screen = Shell::GetScreen(); gfx::Display display = screen->GetDisplayNearestPoint(point_in_screen); - return Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id())->GetHost(); + return Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()) + ->GetHost(); } aura::client::ScreenPositionClient* GetScreenPositionClient( @@ -271,8 +273,9 @@ aura::Window* AshTestBase::CreateTestWindowInShellWithDelegateAndType( } else { gfx::Display display = Shell::GetScreen()->GetDisplayMatching(bounds); - aura::Window* root = ash::Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + aura::Window* root = ash::Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); gfx::Point origin = bounds.origin(); ::wm::ConvertPointFromScreen(root, &origin); window->SetBounds(gfx::Rect(origin, bounds.size())); @@ -361,7 +364,9 @@ void AshTestBase::UnblockUserSession() { void AshTestBase::DisableIME() { Shell::GetInstance()->RemovePreTargetHandler( - Shell::GetInstance()->display_controller()->input_method_event_handler()); + Shell::GetInstance() + ->window_tree_host_manager() + ->input_method_event_handler()); } } // namespace test diff --git a/ash/test/mirror_window_test_api.cc b/ash/test/mirror_window_test_api.cc index a66417a..5f687f8 100644 --- a/ash/test/mirror_window_test_api.cc +++ b/ash/test/mirror_window_test_api.cc @@ -5,9 +5,9 @@ #include "ash/test/mirror_window_test_api.h" #include "ash/display/cursor_window_controller.h" -#include "ash/display/display_controller.h" #include "ash/display/mirror_window_controller.h" #include "ash/display/root_window_transformers.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/host/root_window_transformer.h" #include "ash/shell.h" #include "ui/gfx/geometry/point.h" @@ -17,20 +17,24 @@ namespace test { const aura::WindowTreeHost* MirrorWindowTestApi::GetHost() const { aura::Window* window = Shell::GetInstance() - ->display_controller() + ->window_tree_host_manager() ->mirror_window_controller() ->GetWindow(); return window ? window->GetHost() : NULL; } int MirrorWindowTestApi::GetCurrentCursorType() const { - return Shell::GetInstance()->display_controller()-> - cursor_window_controller()->cursor_type_; + return Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller() + ->cursor_type_; } const gfx::Point& MirrorWindowTestApi::GetCursorHotPoint() const { - return Shell::GetInstance()->display_controller()-> - cursor_window_controller()->hot_point_; + return Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller() + ->hot_point_; } gfx::Point MirrorWindowTestApi::GetCursorHotPointLocationInRootWindow() const { @@ -39,8 +43,10 @@ gfx::Point MirrorWindowTestApi::GetCursorHotPointLocationInRootWindow() const { } const aura::Window* MirrorWindowTestApi::GetCursorWindow() const { - return Shell::GetInstance()->display_controller()-> - cursor_window_controller()->cursor_window_.get(); + return Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller() + ->cursor_window_.get(); } gfx::Point MirrorWindowTestApi::GetCursorLocation() const { diff --git a/ash/touch/touch_observer_hud.cc b/ash/touch/touch_observer_hud.cc index 02f85ad..1ace7fd 100644 --- a/ash/touch/touch_observer_hud.cc +++ b/ash/touch/touch_observer_hud.cc @@ -51,12 +51,12 @@ TouchObserverHUD::TouchObserverHUD(aura::Window* initial_root) Shell::GetInstance()->display_configurator()->AddObserver(this); #endif // defined(OS_CHROMEOS) - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); root_window_->AddPreTargetHandler(this); } TouchObserverHUD::~TouchObserverHUD() { - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); #if defined(OS_CHROMEOS) Shell::GetInstance()->display_configurator()->RemoveObserver(this); @@ -136,8 +136,9 @@ void TouchObserverHUD::OnDisplayConfigurationChanged() { if (root_window_) return; - root_window_ = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display_id_); + root_window_ = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display_id_); views::Widget::ReparentNativeView( widget_->GetNativeView(), diff --git a/ash/touch/touch_observer_hud.h b/ash/touch/touch_observer_hud.h index e678372..1a558ee 100644 --- a/ash/touch/touch_observer_hud.h +++ b/ash/touch/touch_observer_hud.h @@ -6,7 +6,7 @@ #define ASH_TOUCH_TOUCH_OBSERVER_HUD_H_ #include "ash/ash_export.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ui/events/event_handler.h" #include "ui/gfx/display_observer.h" #include "ui/views/widget/widget_observer.h" @@ -29,7 +29,7 @@ class ASH_EXPORT TouchObserverHUD : public ui::EventHandler, #if defined(OS_CHROMEOS) public ui::DisplayConfigurator::Observer, #endif // defined(OS_CHROMEOS) - public DisplayController::Observer { + public WindowTreeHostManager::Observer { public: // Called to clear touch points and traces from the screen. Default // implementation does nothing. Sub-classes should implement appropriately. @@ -70,7 +70,7 @@ class ASH_EXPORT TouchObserverHUD : public ui::EventHandler, const ui::DisplayConfigurator::DisplayStateList& outputs) override; #endif // defined(OS_CHROMEOS) - // Overriden form DisplayController::Observer. + // Overriden form WindowTreeHostManager::Observer. void OnDisplaysInitialized() override; void OnDisplayConfigurationChanging() override; void OnDisplayConfigurationChanged() override; diff --git a/ash/touch/touch_observer_hud_unittest.cc b/ash/touch/touch_observer_hud_unittest.cc index 7a3cf22..f7293a5 100644 --- a/ash/touch/touch_observer_hud_unittest.cc +++ b/ash/touch/touch_observer_hud_unittest.cc @@ -68,13 +68,13 @@ class TouchHudTestBase : public test::AshTestBase { void SetInternalAsPrimary() { const gfx::Display& internal_display = GetDisplayManager()->GetDisplayForId(internal_display_id_); - GetDisplayController()->SetPrimaryDisplay(internal_display); + GetWindowTreeHostManager()->SetPrimaryDisplay(internal_display); } void SetExternalAsPrimary() { const gfx::Display& external_display = GetDisplayManager()->GetDisplayForId(external_display_id_); - GetDisplayController()->SetPrimaryDisplay(external_display); + GetWindowTreeHostManager()->SetPrimaryDisplay(external_display); } void MirrorDisplays() { @@ -131,8 +131,8 @@ class TouchHudTestBase : public test::AshTestBase { return Shell::GetInstance()->display_manager(); } - DisplayController* GetDisplayController() { - return Shell::GetInstance()->display_controller(); + WindowTreeHostManager* GetWindowTreeHostManager() { + return Shell::GetInstance()->window_tree_host_manager(); } const gfx::Display& GetInternalDisplay() { @@ -144,23 +144,23 @@ class TouchHudTestBase : public test::AshTestBase { } aura::Window* GetInternalRootWindow() { - return GetDisplayController()->GetRootWindowForDisplayId( + return GetWindowTreeHostManager()->GetRootWindowForDisplayId( internal_display_id_); } aura::Window* GetExternalRootWindow() { - return GetDisplayController()->GetRootWindowForDisplayId( + return GetWindowTreeHostManager()->GetRootWindowForDisplayId( external_display_id_); } aura::Window* GetPrimaryRootWindow() { const gfx::Display& display = GetPrimaryDisplay(); - return GetDisplayController()->GetRootWindowForDisplayId(display.id()); + return GetWindowTreeHostManager()->GetRootWindowForDisplayId(display.id()); } aura::Window* GetSecondaryRootWindow() { const gfx::Display& display = GetSecondaryDisplay(); - return GetDisplayController()->GetRootWindowForDisplayId(display.id()); + return GetWindowTreeHostManager()->GetRootWindowForDisplayId(display.id()); } RootWindowController* GetInternalRootController() { diff --git a/ash/touch/touch_transformer_controller.cc b/ash/touch/touch_transformer_controller.cc index bc4cd64..a419b67 100644 --- a/ash/touch/touch_transformer_controller.cc +++ b/ash/touch/touch_transformer_controller.cc @@ -4,8 +4,8 @@ #include "ash/touch/touch_transformer_controller.h" -#include "ash/display/display_controller.h" #include "ash/display/display_manager.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/host/ash_window_tree_host.h" #include "ash/root_window_controller.h" #include "ash/shell.h" @@ -117,11 +117,11 @@ gfx::Transform TouchTransformerController::GetTouchTransform( } TouchTransformerController::TouchTransformerController() { - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); } TouchTransformerController::~TouchTransformerController() { - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); } void TouchTransformerController::UpdateTouchRadius( @@ -162,8 +162,8 @@ void TouchTransformerController::UpdateTouchTransformer() const { int64 single_display_id = gfx::Display::kInvalidDisplayID; DisplayInfo single_display; - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + Shell::GetInstance()->window_tree_host_manager(); DisplayManager* display_manager = GetDisplayManager(); if (display_manager->num_connected_displays() == 0) { return; @@ -189,7 +189,8 @@ void TouchTransformerController::UpdateTouchTransformer() const { Shell::GetInstance()->display_configurator()->framebuffer_size(); if (display_manager->IsInMirrorMode()) { - int64_t primary_display_id = display_controller->GetPrimaryDisplayId(); + int64_t primary_display_id = + window_tree_host_manager->GetPrimaryDisplayId(); if (GetDisplayManager()->SoftwareMirroringEnabled()) { // In extended but software mirroring mode, there is a WindowTreeHost for // each display, but all touches are forwarded to the primary root diff --git a/ash/touch/touch_transformer_controller.h b/ash/touch/touch_transformer_controller.h index bf06f8c..2464b72 100644 --- a/ash/touch/touch_transformer_controller.h +++ b/ash/touch/touch_transformer_controller.h @@ -6,7 +6,7 @@ #define ASH_TOUCH_TOUCH_TRANSFORMER_CONTROLLER_H_ #include "ash/ash_export.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ui/gfx/transform.h" namespace ui { @@ -18,7 +18,7 @@ namespace ash { // TouchTransformerController listens to display configuration change // and updates the touch transformation for touch displays. class ASH_EXPORT TouchTransformerController - : public DisplayController::Observer { + : public WindowTreeHostManager::Observer { public: TouchTransformerController(); ~TouchTransformerController() override; @@ -27,7 +27,7 @@ class ASH_EXPORT TouchTransformerController // TouchTransformer into device manager. void UpdateTouchTransformer() const; - // DisplayController::Observer: + // WindowTreeHostManager::Observer: void OnDisplaysInitialized() override; void OnDisplayConfigurationChanged() override; diff --git a/ash/utility/partial_screenshot_controller_unittest.cc b/ash/utility/partial_screenshot_controller_unittest.cc index 423eaf9..71d6619 100644 --- a/ash/utility/partial_screenshot_controller_unittest.cc +++ b/ash/utility/partial_screenshot_controller_unittest.cc @@ -5,8 +5,8 @@ #include "ash/utility/partial_screenshot_controller.h" #include "ash/display/cursor_window_controller.h" -#include "ash/display/display_controller.h" #include "ash/display/mouse_cursor_event_filter.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/screenshot_delegate.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" @@ -195,7 +195,7 @@ TEST_F(PartialScreenshotControllerTest, VisibilityTest) { TEST_F(PartialScreenshotControllerTest, LargeCursor) { Shell::GetInstance()->cursor_manager()->SetCursorSet(ui::CURSOR_SET_LARGE); Shell::GetInstance() - ->display_controller() + ->window_tree_host_manager() ->cursor_window_controller() ->SetCursorCompositingEnabled(true); diff --git a/ash/wm/ash_native_cursor_manager.cc b/ash/wm/ash_native_cursor_manager.cc index 7f48cad..ef1576b 100644 --- a/ash/wm/ash_native_cursor_manager.cc +++ b/ash/wm/ash_native_cursor_manager.cc @@ -5,7 +5,7 @@ #include "ash/wm/ash_native_cursor_manager.h" #include "ash/display/cursor_window_controller.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shell.h" #include "base/logging.h" #include "ui/aura/env.h" @@ -25,8 +25,10 @@ void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) { iter != root_windows.end(); ++iter) (*iter)->GetHost()->SetCursor(cursor); #if defined(OS_CHROMEOS) - Shell::GetInstance()->display_controller()-> - cursor_window_controller()->SetCursor(cursor); + Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller() + ->SetCursor(cursor); #endif } @@ -37,8 +39,10 @@ void NotifyCursorVisibilityChange(bool visible) { iter != root_windows.end(); ++iter) (*iter)->GetHost()->OnCursorVisibilityChanged(visible); #if defined(OS_CHROMEOS) - Shell::GetInstance()->display_controller()->cursor_window_controller()-> - SetVisibility(visible); + Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller() + ->SetVisibility(visible); #endif } @@ -89,8 +93,10 @@ void AshNativeCursorManager::SetDisplay( if (image_cursors_->SetDisplay(display, cursor_scale)) SetCursor(delegate->GetCursor(), delegate); #if defined(OS_CHROMEOS) - Shell::GetInstance()->display_controller()->cursor_window_controller()-> - SetDisplay(display); + Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller() + ->SetDisplay(display); #endif } @@ -129,8 +135,10 @@ void AshNativeCursorManager::SetCursorSet( SetCursor(delegate->GetCursor(), delegate); #if defined(OS_CHROMEOS) - Shell::GetInstance()->display_controller()->cursor_window_controller()-> - SetCursorSet(cursor_set); + Shell::GetInstance() + ->window_tree_host_manager() + ->cursor_window_controller() + ->SetCursorSet(cursor_set); #endif } diff --git a/ash/wm/coordinate_conversion.cc b/ash/wm/coordinate_conversion.cc index c13ccdc9..c09448c 100644 --- a/ash/wm/coordinate_conversion.cc +++ b/ash/wm/coordinate_conversion.cc @@ -4,7 +4,7 @@ #include "ash/wm/coordinate_conversion.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shell.h" #include "ui/aura/client/screen_position_client.h" #include "ui/gfx/display.h" @@ -21,14 +21,16 @@ aura::Window* GetRootWindowAt(const gfx::Point& point) { DCHECK(display.is_valid()); // TODO(yusukes): Move coordinate_conversion.cc and .h to ui/aura/ once // GetRootWindowForDisplayId() is moved to aura::Env. - return Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + return Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); } aura::Window* GetRootWindowMatching(const gfx::Rect& rect) { const gfx::Display& display = Shell::GetScreen()->GetDisplayMatching(rect); - return Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + return Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); } } // namespace wm diff --git a/ash/wm/default_state.cc b/ash/wm/default_state.cc index 953789e..b5e5f5b 100644 --- a/ash/wm/default_state.cc +++ b/ash/wm/default_state.cc @@ -4,7 +4,7 @@ #include "ash/wm/default_state.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" @@ -58,10 +58,10 @@ void MoveToDisplayForRestore(WindowState* window_state) { if (!display_area.Intersects(restore_bounds)) { const gfx::Display& display = Shell::GetScreen()->GetDisplayMatching(restore_bounds); - DisplayController* display_controller = - Shell::GetInstance()->display_controller(); + WindowTreeHostManager* window_tree_host_manager = + Shell::GetInstance()->window_tree_host_manager(); aura::Window* new_root = - display_controller->GetRootWindowForDisplayId(display.id()); + window_tree_host_manager->GetRootWindowForDisplayId(display.id()); if (new_root != window_state->window()->GetRootWindow()) { aura::Window* new_container = Shell::GetContainer(new_root, window_state->window()->parent()->id()); diff --git a/ash/wm/dock/docked_window_resizer.cc b/ash/wm/dock/docked_window_resizer.cc index 4f92f23..9e4eb2d 100644 --- a/ash/wm/dock/docked_window_resizer.cc +++ b/ash/wm/dock/docked_window_resizer.cc @@ -4,7 +4,7 @@ #include "ash/wm/dock/docked_window_resizer.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" #include "ash/shelf/shelf.h" @@ -40,8 +40,9 @@ DockedWindowLayoutManager* GetDockedLayoutManagerAtPoint( gfx::Display display = ScreenUtil::FindDisplayContainingPoint(point); if (!display.is_valid()) return NULL; - aura::Window* root = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + aura::Window* root = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); aura::Window* dock_container = Shell::GetContainer( root, kShellWindowId_DockedContainer); return static_cast<DockedWindowLayoutManager*>( diff --git a/ash/wm/dock/docked_window_resizer_unittest.cc b/ash/wm/dock/docked_window_resizer_unittest.cc index 6ace192b..a96c262 100644 --- a/ash/wm/dock/docked_window_resizer_unittest.cc +++ b/ash/wm/dock/docked_window_resizer_unittest.cc @@ -5,6 +5,7 @@ #include "ash/wm/dock/docked_window_resizer.h" #include "ash/ash_switches.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" #include "ash/shelf/shelf.h" @@ -100,8 +101,9 @@ class DockedWindowResizerTest } else { gfx::Display display = Shell::GetScreen()->GetDisplayMatching(bounds); - aura::Window* root = ash::Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + aura::Window* root = ash::Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); gfx::Point origin = bounds.origin(); ::wm::ConvertPointFromScreen(root, &origin); window->SetBounds(gfx::Rect(origin, bounds.size())); diff --git a/ash/wm/gestures/long_press_affordance_handler.cc b/ash/wm/gestures/long_press_affordance_handler.cc index 11be224..692510f 100644 --- a/ash/wm/gestures/long_press_affordance_handler.cc +++ b/ash/wm/gestures/long_press_affordance_handler.cc @@ -4,7 +4,6 @@ #include "ash/wm/gestures/long_press_affordance_handler.h" -#include "ash/display/display_controller.h" #include "ash/root_window_controller.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" diff --git a/ash/wm/maximize_mode/maximize_mode_window_state.cc b/ash/wm/maximize_mode/maximize_mode_window_state.cc index 0590077..e8da85a 100644 --- a/ash/wm/maximize_mode/maximize_mode_window_state.cc +++ b/ash/wm/maximize_mode/maximize_mode_window_state.cc @@ -4,7 +4,6 @@ #include "ash/wm/maximize_mode/maximize_mode_window_state.h" -#include "ash/display/display_controller.h" #include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" diff --git a/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc index 22419c9..7704394 100644 --- a/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc +++ b/ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc @@ -8,7 +8,7 @@ #include <X11/extensions/XInput2.h> #include <X11/Xlib.h> -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/screen_util.h" #include "ash/shell.h" #include "base/memory/scoped_ptr.h" @@ -52,8 +52,9 @@ void SetMouseLocationInScreen(const gfx::Point& screen_location) { screen_location); if (!display.is_valid()) return; - aura::Window* root_window = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + aura::Window* root_window = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); gfx::Point host_location(screen_location); aura::client::ScreenPositionClient* client = aura::client::GetScreenPositionClient(root_window); diff --git a/ash/wm/panels/panel_layout_manager.cc b/ash/wm/panels/panel_layout_manager.cc index 11f2c1d..8e59a7f 100644 --- a/ash/wm/panels/panel_layout_manager.cc +++ b/ash/wm/panels/panel_layout_manager.cc @@ -268,7 +268,7 @@ PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) DCHECK(panel_container); aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> AddObserver(this); - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); Shell::GetInstance()->AddShellObserver(this); } @@ -290,7 +290,7 @@ void PanelLayoutManager::Shutdown() { shelf_ = NULL; aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> RemoveObserver(this); - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); Shell::GetInstance()->RemoveShellObserver(this); } @@ -526,7 +526,7 @@ void PanelLayoutManager::OnWindowActivated( } //////////////////////////////////////////////////////////////////////////////// -// PanelLayoutManager, DisplayController::Observer implementation: +// PanelLayoutManager, WindowTreeHostManager::Observer implementation: void PanelLayoutManager::OnDisplayConfigurationChanged() { Relayout(); diff --git a/ash/wm/panels/panel_layout_manager.h b/ash/wm/panels/panel_layout_manager.h index 427e5f1..434506a 100644 --- a/ash/wm/panels/panel_layout_manager.h +++ b/ash/wm/panels/panel_layout_manager.h @@ -8,7 +8,7 @@ #include <list> #include "ash/ash_export.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/shelf/shelf_icon_observer.h" #include "ash/shelf/shelf_layout_manager_observer.h" #include "ash/shell_observer.h" @@ -58,7 +58,7 @@ class ASH_EXPORT PanelLayoutManager public wm::WindowStateObserver, public aura::client::ActivationChangeObserver, public keyboard::KeyboardControllerObserver, - public DisplayController::Observer, + public WindowTreeHostManager::Observer, public ShelfLayoutManagerObserver { public: explicit PanelLayoutManager(aura::Window* panel_container); @@ -113,7 +113,7 @@ class ASH_EXPORT PanelLayoutManager aura::Window* gained_active, aura::Window* lost_active) override; - // Overridden from DisplayController::Observer + // Overridden from WindowTreeHostManager::Observer void OnDisplayConfigurationChanged() override; // Overridden from ShelfLayoutManagerObserver diff --git a/ash/wm/panels/panel_window_resizer.cc b/ash/wm/panels/panel_window_resizer.cc index a57ac59..57a8de5 100644 --- a/ash/wm/panels/panel_window_resizer.cc +++ b/ash/wm/panels/panel_window_resizer.cc @@ -4,7 +4,7 @@ #include "ash/wm/panels/panel_window_resizer.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/screen_util.h" #include "ash/shelf/shelf.h" #include "ash/shelf/shelf_types.h" @@ -70,8 +70,9 @@ void PanelWindowResizer::Drag(const gfx::Point& location, int event_flags) { // complete it would begin positioning the panel. if (GetTarget()->parent() != panel_container_) GetPanelLayoutManager(panel_container_)->FinishDragging(); - aura::Window* dst_root = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(dst_display.id()); + aura::Window* dst_root = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(dst_display.id()); panel_container_ = Shell::GetContainer(dst_root, kShellWindowId_PanelContainer); diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/toplevel_window_event_handler.cc index 667fc52..884efd4 100644 --- a/ash/wm/toplevel_window_event_handler.cc +++ b/ash/wm/toplevel_window_event_handler.cc @@ -166,11 +166,11 @@ ToplevelWindowEventHandler::ToplevelWindowEventHandler() in_gesture_drag_(false), drag_reverted_(false), destroyed_(NULL) { - Shell::GetInstance()->display_controller()->AddObserver(this); + Shell::GetInstance()->window_tree_host_manager()->AddObserver(this); } ToplevelWindowEventHandler::~ToplevelWindowEventHandler() { - Shell::GetInstance()->display_controller()->RemoveObserver(this); + Shell::GetInstance()->window_tree_host_manager()->RemoveObserver(this); if (destroyed_) *destroyed_ = true; } diff --git a/ash/wm/toplevel_window_event_handler.h b/ash/wm/toplevel_window_event_handler.h index bcaaa91..80ce0f8 100644 --- a/ash/wm/toplevel_window_event_handler.h +++ b/ash/wm/toplevel_window_event_handler.h @@ -8,7 +8,7 @@ #include <set> #include "ash/ash_export.h" -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/wm/wm_types.h" #include "base/callback.h" #include "base/compiler_specific.h" @@ -33,7 +33,7 @@ class WindowResizer; class ASH_EXPORT ToplevelWindowEventHandler : public ui::EventHandler, public aura::client::WindowMoveClient, - public DisplayController::Observer { + public WindowTreeHostManager::Observer { public: ToplevelWindowEventHandler(); ~ToplevelWindowEventHandler() override; @@ -50,7 +50,7 @@ class ASH_EXPORT ToplevelWindowEventHandler aura::client::WindowMoveSource move_source) override; void EndMoveLoop() override; - // Overridden form ash::DisplayController::Observer: + // Overridden form ash::WindowTreeHostManager::Observer: void OnDisplayConfigurationChanging() override; private: diff --git a/ash/wm/workspace/workspace_layout_manager.cc b/ash/wm/workspace/workspace_layout_manager.cc index b8b2f1f..6c8a8ee 100644 --- a/ash/wm/workspace/workspace_layout_manager.cc +++ b/ash/wm/workspace/workspace_layout_manager.cc @@ -6,7 +6,6 @@ #include <algorithm> -#include "ash/display/display_controller.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" #include "ash/session/session_state_delegate.h" diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc index 73ba6fb..2b30dd1 100644 --- a/ash/wm/workspace/workspace_window_resizer.cc +++ b/ash/wm/workspace/workspace_window_resizer.cc @@ -9,7 +9,7 @@ #include <utility> #include <vector> -#include "ash/display/display_controller.h" +#include "ash/display/window_tree_host_manager.h" #include "ash/metrics/user_metrics_recorder.h" #include "ash/root_window_controller.h" #include "ash/screen_util.h" @@ -383,8 +383,9 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_parent, // Track the last screen that the pointer was on to keep the snap phantom // window there. if (display.is_valid()) { - root = Shell::GetInstance()->display_controller()-> - GetRootWindowForDisplayId(display.id()); + root = Shell::GetInstance() + ->window_tree_host_manager() + ->GetRootWindowForDisplayId(display.id()); } if (!attached_windows_.empty()) LayoutAttachedWindows(&bounds); |