diff options
author | sky <sky@chromium.org> | 2016-03-15 16:49:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-15 23:51:27 +0000 |
commit | a120428fc3730dac6df8042c7e324cd797619c72 (patch) | |
tree | e1c445705be48d31c9dfd27583f5ff02b9cb5bda | |
parent | a2b4112f23abd2a0d70a5607f753f8b507e9be7e (diff) | |
download | chromium_src-a120428fc3730dac6df8042c7e324cd797619c72.zip chromium_src-a120428fc3730dac6df8042c7e324cd797619c72.tar.gz chromium_src-a120428fc3730dac6df8042c7e324cd797619c72.tar.bz2 |
Renames ConnectionManager to WindowServer
WindowServer makes a lot more sense in this context.
BUG=none
TEST=none
R=ben@chromium.org
TBR=ben@chromium.org
Review URL: https://codereview.chromium.org/1806773002
Cr-Commit-Position: refs/heads/master@{#381352}
32 files changed, 366 insertions, 387 deletions
diff --git a/components/mus/mus_app.cc b/components/mus/mus_app.cc index 07a0c68..9f226a9 100644 --- a/components/mus/mus_app.cc +++ b/components/mus/mus_app.cc @@ -12,11 +12,11 @@ #include "build/build_config.h" #include "components/mus/common/args.h" #include "components/mus/gles2/gpu_impl.h" -#include "components/mus/ws/connection_manager.h" #include "components/mus/ws/display.h" #include "components/mus/ws/display_binding.h" #include "components/mus/ws/display_manager.h" #include "components/mus/ws/user_display_manager.h" +#include "components/mus/ws/window_server.h" #include "components/mus/ws/window_tree.h" #include "components/mus/ws/window_tree_binding.h" #include "components/mus/ws/window_tree_factory.h" @@ -71,8 +71,8 @@ MandolineUIServicesApp::MandolineUIServicesApp() {} MandolineUIServicesApp::~MandolineUIServicesApp() { if (platform_display_init_params_.gpu_state) platform_display_init_params_.gpu_state->StopThreads(); - // Destroy |connection_manager_| first, since it depends on |event_source_|. - connection_manager_.reset(); + // Destroy |window_server_| first, since it depends on |event_source_|. + window_server_.reset(); } void MandolineUIServicesApp::InitializeResources(mojo::Connector* connector) { @@ -111,7 +111,7 @@ MandolineUIServicesApp::UserState* MandolineUIServicesApp::GetUserState( } void MandolineUIServicesApp::AddUserIfNecessary(mojo::Connection* connection) { - connection_manager_->user_id_tracker()->AddUserId( + window_server_->user_id_tracker()->AddUserId( connection->GetRemoteIdentity().user_id()); } @@ -152,8 +152,8 @@ void MandolineUIServicesApp::Initialize(mojo::Connector* connector, // TODO(rjkroege): It is possible that we might want to generalize the // GpuState object. platform_display_init_params_.gpu_state = new GpuState(); - connection_manager_.reset(new ws::ConnectionManager( - this, platform_display_init_params_.surfaces_state)); + window_server_.reset( + new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); tracing_.Initialize(connector, identity.name()); } @@ -186,45 +186,45 @@ void MandolineUIServicesApp::OnNoMoreDisplays() { scoped_ptr<ws::WindowTreeBinding> MandolineUIServicesApp::CreateWindowTreeBindingForEmbedAtWindow( - ws::ConnectionManager* connection_manager, + ws::WindowServer* window_server, ws::WindowTree* tree, mojom::WindowTreeRequest tree_request, mojom::WindowTreeClientPtr client) { return make_scoped_ptr(new ws::DefaultWindowTreeBinding( - tree, connection_manager, std::move(tree_request), std::move(client))); + tree, window_server, std::move(tree_request), std::move(client))); } void MandolineUIServicesApp::CreateDefaultDisplays() { // Display manages its own lifetime. ws::Display* host_impl = - new ws::Display(connection_manager_.get(), platform_display_init_params_); + new ws::Display(window_server_.get(), platform_display_init_params_); host_impl->Init(nullptr); } void MandolineUIServicesApp::Create(mojo::Connection* connection, mojom::DisplayManagerRequest request) { - connection_manager_->display_manager() + window_server_->display_manager() ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id()) ->AddDisplayManagerBinding(std::move(request)); } void MandolineUIServicesApp::Create(mojo::Connection* connection, mojom::UserAccessManagerRequest request) { - connection_manager_->user_id_tracker()->Bind(std::move(request)); + window_server_->user_id_tracker()->Bind(std::move(request)); } void MandolineUIServicesApp::Create( mojo::Connection* connection, mojom::WindowManagerFactoryServiceRequest request) { AddUserIfNecessary(connection); - connection_manager_->window_manager_factory_registry()->Register( + window_server_->window_manager_factory_registry()->Register( connection->GetRemoteIdentity().user_id(), std::move(request)); } void MandolineUIServicesApp::Create(Connection* connection, mojom::WindowTreeFactoryRequest request) { AddUserIfNecessary(connection); - if (!connection_manager_->display_manager()->has_displays()) { + if (!window_server_->display_manager()->has_displays()) { scoped_ptr<PendingRequest> pending_request(new PendingRequest); pending_request->connection = connection; pending_request->wtf_request.reset( @@ -237,7 +237,7 @@ void MandolineUIServicesApp::Create(Connection* connection, UserState* user_state = GetUserState(connection); if (!user_state->window_tree_factory) { user_state->window_tree_factory.reset(new ws::WindowTreeFactory( - connection_manager_.get(), connection->GetRemoteIdentity().user_id())); + window_server_.get(), connection->GetRemoteIdentity().user_id())); } user_state->window_tree_factory->AddBinding(std::move(request)); } @@ -248,7 +248,7 @@ void MandolineUIServicesApp::Create( UserState* user_state = GetUserState(connection); if (!user_state->window_tree_host_factory) { user_state->window_tree_host_factory.reset(new ws::WindowTreeHostFactory( - connection_manager_.get(), connection->GetRemoteIdentity().user_id(), + window_server_.get(), connection->GetRemoteIdentity().user_id(), platform_display_init_params_)); } user_state->window_tree_host_factory->AddBinding(std::move(request)); diff --git a/components/mus/mus_app.h b/components/mus/mus_app.h index fca8db1..e217fba 100644 --- a/components/mus/mus_app.h +++ b/components/mus/mus_app.h @@ -18,9 +18,9 @@ #include "components/mus/public/interfaces/window_manager_factory.mojom.h" #include "components/mus/public/interfaces/window_tree.mojom.h" #include "components/mus/public/interfaces/window_tree_host.mojom.h" -#include "components/mus/ws/connection_manager_delegate.h" #include "components/mus/ws/platform_display_init_params.h" #include "components/mus/ws/user_id.h" +#include "components/mus/ws/window_server_delegate.h" #include "mojo/services/tracing/public/cpp/tracing_impl.h" #include "mojo/shell/public/cpp/application_runner.h" #include "mojo/shell/public/cpp/interface_factory.h" @@ -36,13 +36,13 @@ class PlatformEventSource; namespace mus { namespace ws { -class ConnectionManager; class ForwardingWindowManager; +class WindowServer; } class MandolineUIServicesApp : public mojo::ShellClient, - public ws::ConnectionManagerDelegate, + public ws::WindowServerDelegate, public mojo::InterfaceFactory<mojom::DisplayManager>, public mojo::InterfaceFactory<mojom::UserAccessManager>, public mojo::InterfaceFactory<mojom::WindowManagerFactoryService>, @@ -77,11 +77,11 @@ class MandolineUIServicesApp bool AcceptConnection(mojo::Connection* connection) override; void ShellConnectionLost() override; - // ConnectionManagerDelegate: + // WindowServerDelegate: void OnFirstDisplayReady() override; void OnNoMoreDisplays() override; scoped_ptr<ws::WindowTreeBinding> CreateWindowTreeBindingForEmbedAtWindow( - ws::ConnectionManager* connection_manager, + ws::WindowServer* window_server, ws::WindowTree* tree, mojom::WindowTreeRequest tree_request, mojom::WindowTreeClientPtr client) override; @@ -111,7 +111,7 @@ class MandolineUIServicesApp void Create(mojo::Connection* connection, mojom::GpuRequest request) override; ws::PlatformDisplayInitParams platform_display_init_params_; - scoped_ptr<ws::ConnectionManager> connection_manager_; + scoped_ptr<ws::WindowServer> window_server_; scoped_ptr<ui::PlatformEventSource> event_source_; mojo::TracingImpl tracing_; using PendingRequests = std::vector<scoped_ptr<PendingRequest>>; diff --git a/components/mus/ws/BUILD.gn b/components/mus/ws/BUILD.gn index c5439551..da53872 100644 --- a/components/mus/ws/BUILD.gn +++ b/components/mus/ws/BUILD.gn @@ -11,10 +11,6 @@ source_set("lib") { sources = [ "access_policy.h", "access_policy_delegate.h", - "connection_manager.cc", - "connection_manager.h", - "connection_manager_delegate.cc", - "connection_manager_delegate.h", "default_access_policy.cc", "default_access_policy.h", "display.cc", @@ -70,6 +66,10 @@ source_set("lib") { "window_manager_factory_service.h", "window_manager_state.cc", "window_manager_state.h", + "window_server.cc", + "window_server.h", + "window_server_delegate.cc", + "window_server_delegate.h", "window_tree.cc", "window_tree.h", "window_tree_binding.cc", diff --git a/components/mus/ws/display.cc b/components/mus/ws/display.cc index c295c74..a8c9229 100644 --- a/components/mus/ws/display.cc +++ b/components/mus/ws/display.cc @@ -7,8 +7,6 @@ #include "base/debug/debugger.h" #include "base/strings/utf_string_conversions.h" #include "components/mus/common/types.h" -#include "components/mus/ws/connection_manager.h" -#include "components/mus/ws/connection_manager_delegate.h" #include "components/mus/ws/display_binding.h" #include "components/mus/ws/display_manager.h" #include "components/mus/ws/focus_controller.h" @@ -16,6 +14,8 @@ #include "components/mus/ws/platform_display_init_params.h" #include "components/mus/ws/window_manager_factory_service.h" #include "components/mus/ws/window_manager_state.h" +#include "components/mus/ws/window_server.h" +#include "components/mus/ws/window_server_delegate.h" #include "components/mus/ws/window_tree.h" #include "components/mus/ws/window_tree_binding.h" #include "mojo/common/common_type_converters.h" @@ -25,22 +25,22 @@ namespace mus { namespace ws { -Display::Display(ConnectionManager* connection_manager, +Display::Display(WindowServer* window_server, const PlatformDisplayInitParams& platform_display_init_params) - : id_(connection_manager->display_manager()->GetAndAdvanceNextDisplayId()), - connection_manager_(connection_manager), + : id_(window_server->display_manager()->GetAndAdvanceNextDisplayId()), + window_server_(window_server), platform_display_(PlatformDisplay::Create(platform_display_init_params)), last_cursor_(0) { platform_display_->Init(this); - connection_manager_->window_manager_factory_registry()->AddObserver(this); - connection_manager_->user_id_tracker()->AddObserver(this); + window_server_->window_manager_factory_registry()->AddObserver(this); + window_server_->user_id_tracker()->AddObserver(this); } Display::~Display() { - connection_manager_->user_id_tracker()->RemoveObserver(this); + window_server_->user_id_tracker()->RemoveObserver(this); - connection_manager_->window_manager_factory_registry()->RemoveObserver(this); + window_server_->window_manager_factory_registry()->RemoveObserver(this); DestroyFocusController(); for (ServerWindow* window : windows_needing_frame_destruction_) @@ -53,7 +53,7 @@ Display::~Display() { for (auto& pair : window_manager_state_map_) states.insert(pair.second.get()); for (WindowManagerState* state : states) - connection_manager_->DestroyTree(state->tree()); + window_server_->DestroyTree(state->tree()); } void Display::Init(scoped_ptr<DisplayBinding> binding) { @@ -64,11 +64,11 @@ void Display::Init(scoped_ptr<DisplayBinding> binding) { } DisplayManager* Display::display_manager() { - return connection_manager_->display_manager(); + return window_server_->display_manager(); } const DisplayManager* Display::display_manager() const { - return connection_manager_->display_manager(); + return window_server_->display_manager(); } mojom::DisplayPtr Display::ToMojomDisplay() const { @@ -150,7 +150,7 @@ mojom::Rotation Display::GetRotation() const { const WindowManagerState* Display::GetActiveWindowManagerState() const { return GetWindowManagerStateForUser( - connection_manager_->user_id_tracker()->active_id()); + window_server_->user_id_tracker()->active_id()); } void Display::SetFocusedWindow(ServerWindow* new_focused_window) { @@ -263,7 +263,7 @@ void Display::InitWindowManagersIfNecessary() { void Display::CreateWindowManagerStatesFromRegistry() { std::vector<WindowManagerFactoryService*> services = - connection_manager_->window_manager_factory_registry()->GetServices(); + window_server_->window_manager_factory_registry()->GetServices(); for (WindowManagerFactoryService* service : services) { if (service->window_manager_factory()) CreateWindowManagerStateFromService(service); @@ -277,11 +277,11 @@ void Display::CreateWindowManagerStateFromService( top_level_surface_id_, service->user_id())); WindowManagerState* wms = wms_ptr.get(); window_manager_state_map_[service->user_id()] = std::move(wms_ptr); - wms->tree_ = connection_manager_->CreateTreeForWindowManager( + wms->tree_ = window_server_->CreateTreeForWindowManager( this, service->window_manager_factory(), wms->root(), service->user_id()); if (!binding_) { - const bool is_active = service->user_id() == - connection_manager_->user_id_tracker()->active_id(); + const bool is_active = + service->user_id() == window_server_->user_id_tracker()->active_id(); wms->root()->SetVisible(is_active); } } @@ -310,7 +310,7 @@ void Display::OnViewportMetricsChanged( const mojom::ViewportMetrics& old_metrics, const mojom::ViewportMetrics& new_metrics) { if (!root_) { - root_.reset(connection_manager_->CreateServerWindow( + root_.reset(window_server_->CreateServerWindow( display_manager()->GetAndAdvanceNextRootId(), ServerWindow::Properties())); root_->SetBounds(gfx::Rect(new_metrics.size_in_pixels.To<gfx::Size>())); @@ -326,8 +326,7 @@ void Display::OnViewportMetricsChanged( } // TODO(sky): if bounds changed, then need to update // Display/WindowManagerState appropriately (e.g. notify observers). - connection_manager_->ProcessViewportMetricsChanged(this, old_metrics, - new_metrics); + window_server_->ProcessViewportMetricsChanged(this, old_metrics, new_metrics); } void Display::OnTopLevelSurfaceChanged(cc::SurfaceId surface_id) { @@ -375,14 +374,13 @@ void Display::OnFocusChanged(FocusControllerChangeSource change_source, WindowTree* embedded_tree_old = nullptr; if (old_focused_window) { - owning_tree_old = connection_manager_->GetTreeWithId( - old_focused_window->id().connection_id); + owning_tree_old = + window_server_->GetTreeWithId(old_focused_window->id().connection_id); if (owning_tree_old) { owning_tree_old->ProcessFocusChanged(old_focused_window, new_focused_window); } - embedded_tree_old = - connection_manager_->GetTreeWithRoot(old_focused_window); + embedded_tree_old = window_server_->GetTreeWithRoot(old_focused_window); if (embedded_tree_old) { DCHECK_NE(owning_tree_old, embedded_tree_old); embedded_tree_old->ProcessFocusChanged(old_focused_window, @@ -392,15 +390,14 @@ void Display::OnFocusChanged(FocusControllerChangeSource change_source, WindowTree* owning_tree_new = nullptr; WindowTree* embedded_tree_new = nullptr; if (new_focused_window) { - owning_tree_new = connection_manager_->GetTreeWithId( - new_focused_window->id().connection_id); + owning_tree_new = + window_server_->GetTreeWithId(new_focused_window->id().connection_id); if (owning_tree_new && owning_tree_new != owning_tree_old && owning_tree_new != embedded_tree_old) { owning_tree_new->ProcessFocusChanged(old_focused_window, new_focused_window); } - embedded_tree_new = - connection_manager_->GetTreeWithRoot(new_focused_window); + embedded_tree_new = window_server_->GetTreeWithRoot(new_focused_window); if (embedded_tree_new && embedded_tree_new != owning_tree_old && embedded_tree_new != embedded_tree_old) { DCHECK_NE(owning_tree_new, embedded_tree_new); @@ -479,7 +476,7 @@ void Display::OnUserIdRemoved(const UserId& id) { // DestroyTree() calls back to OnWillDestroyTree() and the WindowManagerState // is destroyed (and removed). - connection_manager_->DestroyTree(state->tree()); + window_server_->DestroyTree(state->tree()); DCHECK_EQ(0u, window_manager_state_map_.count(id)); } diff --git a/components/mus/ws/display.h b/components/mus/ws/display.h index 8554b99..ad1e8e1 100644 --- a/components/mus/ws/display.h +++ b/components/mus/ws/display.h @@ -28,12 +28,12 @@ namespace mus { namespace ws { -class ConnectionManager; class DisplayBinding; class DisplayManager; class FocusController; struct PlatformDisplayInitParams; class WindowManagerState; +class WindowServer; class WindowTree; namespace test { @@ -57,7 +57,7 @@ class Display : public PlatformDisplayDelegate, public UserIdTrackerObserver, public WindowManagerFactoryRegistryObserver { public: - Display(ConnectionManager* connection_manager, + Display(WindowServer* window_server, const PlatformDisplayInitParams& platform_display_init_params); ~Display() override; @@ -87,7 +87,7 @@ class Display : public PlatformDisplayDelegate, mojom::Rotation GetRotation() const; - ConnectionManager* connection_manager() { return connection_manager_; } + WindowServer* window_server() { return window_server_; } // Returns the root of the Display. The root's children are the roots // of the corresponding WindowManagers. @@ -196,7 +196,7 @@ class Display : public PlatformDisplayDelegate, scoped_ptr<DisplayBinding> binding_; // Set once Init() has been called. bool init_called_ = false; - ConnectionManager* const connection_manager_; + WindowServer* const window_server_; scoped_ptr<ServerWindow> root_; scoped_ptr<PlatformDisplay> platform_display_; scoped_ptr<FocusController> focus_controller_; diff --git a/components/mus/ws/display_binding.cc b/components/mus/ws/display_binding.cc index 20e788c..3673adf 100644 --- a/components/mus/ws/display_binding.cc +++ b/components/mus/ws/display_binding.cc @@ -4,9 +4,9 @@ #include "components/mus/ws/display_binding.h" -#include "components/mus/ws/connection_manager.h" #include "components/mus/ws/display.h" #include "components/mus/ws/window_manager_access_policy.h" +#include "components/mus/ws/window_server.h" #include "components/mus/ws/window_tree.h" #include "mojo/shell/public/interfaces/connector.mojom.h" @@ -17,8 +17,8 @@ DisplayBindingImpl::DisplayBindingImpl(mojom::WindowTreeHostRequest request, Display* display, const UserId& user_id, mojom::WindowTreeClientPtr client, - ConnectionManager* manager) - : connection_manager_(manager), + WindowServer* window_server) + : window_server_(window_server), user_id_(user_id), binding_(display, std::move(request)), client_(std::move(client)) {} @@ -26,7 +26,7 @@ DisplayBindingImpl::DisplayBindingImpl(mojom::WindowTreeHostRequest request, DisplayBindingImpl::~DisplayBindingImpl() {} WindowTree* DisplayBindingImpl::CreateWindowTree(ServerWindow* root) { - WindowTree* tree = connection_manager_->EmbedAtWindow( + WindowTree* tree = window_server_->EmbedAtWindow( root, user_id_, std::move(client_), make_scoped_ptr(new WindowManagerAccessPolicy)); tree->ConfigureWindowManager(); diff --git a/components/mus/ws/display_binding.h b/components/mus/ws/display_binding.h index 6bfc3c9..54cacf0 100644 --- a/components/mus/ws/display_binding.h +++ b/components/mus/ws/display_binding.h @@ -15,8 +15,8 @@ namespace mus { namespace ws { -class ConnectionManager; class ServerWindow; +class WindowServer; class WindowTree; // DisplayBinding manages the binding between a Display and it's mojo clients. @@ -38,14 +38,14 @@ class DisplayBindingImpl : public DisplayBinding { Display* display, const UserId& user_id, mojom::WindowTreeClientPtr client, - ConnectionManager* connection_manager); + WindowServer* window_server); ~DisplayBindingImpl() override; private: // DisplayBinding: WindowTree* CreateWindowTree(ServerWindow* root) override; - ConnectionManager* connection_manager_; + WindowServer* window_server_; const UserId user_id_; mojo::Binding<mojom::WindowTreeHost> binding_; mojom::WindowTreeClientPtr client_; diff --git a/components/mus/ws/display_manager.h b/components/mus/ws/display_manager.h index 0a9ccd5..402569e 100644 --- a/components/mus/ws/display_manager.h +++ b/components/mus/ws/display_manager.h @@ -81,8 +81,7 @@ class DisplayManager { DisplayManagerDelegate* delegate_; // Displays are initially added to |pending_displays_|. When the display is - // initialized it is moved to |displays_|. ConnectionManager owns the - // Displays. + // initialized it is moved to |displays_|. WindowServer owns the Displays. std::set<Display*> pending_displays_; std::set<Display*> displays_; diff --git a/components/mus/ws/display_unittest.cc b/components/mus/ws/display_unittest.cc index c9f06a1..7b62e5f 100644 --- a/components/mus/ws/display_unittest.cc +++ b/components/mus/ws/display_unittest.cc @@ -12,8 +12,6 @@ #include "components/mus/common/util.h" #include "components/mus/public/interfaces/window_tree.mojom.h" #include "components/mus/surfaces/surfaces_state.h" -#include "components/mus/ws/connection_manager.h" -#include "components/mus/ws/connection_manager_delegate.h" #include "components/mus/ws/display_manager.h" #include "components/mus/ws/ids.h" #include "components/mus/ws/platform_display.h" @@ -21,6 +19,8 @@ #include "components/mus/ws/server_window.h" #include "components/mus/ws/test_utils.h" #include "components/mus/ws/window_manager_state.h" +#include "components/mus/ws/window_server.h" +#include "components/mus/ws/window_server_delegate.h" #include "components/mus/ws/window_tree.h" #include "components/mus/ws/window_tree_binding.h" #include "testing/gtest/include/gtest/gtest.h" @@ -59,17 +59,16 @@ class DisplayTest : public testing::Test { // testing::Test: void SetUp() override { PlatformDisplay::set_factory_for_testing(&platform_display_factory_); - connection_manager_.reset(new ConnectionManager( - &connection_manager_delegate_, scoped_refptr<SurfacesState>())); - connection_manager_delegate_.set_connection_manager( - connection_manager_.get()); + window_server_.reset(new WindowServer(&window_server_delegate_, + scoped_refptr<SurfacesState>())); + window_server_delegate_.set_window_server(window_server_.get()); } protected: int32_t cursor_id_; TestPlatformDisplayFactory platform_display_factory_; - TestConnectionManagerDelegate connection_manager_delegate_; - scoped_ptr<ConnectionManager> connection_manager_; + TestWindowServerDelegate window_server_delegate_; + scoped_ptr<WindowServer> window_server_; base::MessageLoop message_loop_; TestWindowManagerFactory test_window_manager_factory_; @@ -78,13 +77,13 @@ class DisplayTest : public testing::Test { TEST_F(DisplayTest, CallsCreateDefaultDisplays) { const int kNumHostsToCreate = 2; - connection_manager_delegate_.set_num_displays_to_create(kNumHostsToCreate); + window_server_delegate_.set_num_displays_to_create(kNumHostsToCreate); const UserId kTestId1 = "2"; const UserId kTestId2 = "21"; - DisplayManager* display_manager = connection_manager_->display_manager(); + DisplayManager* display_manager = window_server_->display_manager(); WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kTestId1, &test_window_manager_factory_); // The first register should trigger creation of the default // Displays. There should be kNumHostsToCreate Displays. @@ -100,7 +99,7 @@ TEST_F(DisplayTest, CallsCreateDefaultDisplays) { // Add another registry, should trigger creation of another wm. WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kTestId2, &test_window_manager_factory_); for (Display* display : display_manager->displays()) { ASSERT_EQ(2u, display->num_window_manger_states()); @@ -117,58 +116,58 @@ TEST_F(DisplayTest, CallsCreateDefaultDisplays) { } TEST_F(DisplayTest, Destruction) { - connection_manager_delegate_.set_num_displays_to_create(1); + window_server_delegate_.set_num_displays_to_create(1); const UserId kTestId1 = "2"; const UserId kTestId2 = "21"; WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kTestId1, &test_window_manager_factory_); // Add another registry, should trigger creation of another wm. - DisplayManager* display_manager = connection_manager_->display_manager(); + DisplayManager* display_manager = window_server_->display_manager(); WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kTestId2, &test_window_manager_factory_); ASSERT_EQ(1u, display_manager->displays().size()); Display* display = *display_manager->displays().begin(); ASSERT_EQ(2u, display->num_window_manger_states()); // There should be two trees, one for each windowmanager. - EXPECT_EQ(2u, connection_manager_->num_trees()); + EXPECT_EQ(2u, window_server_->num_trees()); { WindowManagerState* state = display->GetWindowManagerStateForUser(kTestId1); // Destroy the tree associated with |state|. Should result in deleting // |state|. - connection_manager_->DestroyTree(state->tree()); + window_server_->DestroyTree(state->tree()); ASSERT_EQ(1u, display->num_window_manger_states()); EXPECT_FALSE(display->GetWindowManagerStateForUser(kTestId1)); EXPECT_EQ(1u, display_manager->displays().size()); - EXPECT_EQ(1u, connection_manager_->num_trees()); + EXPECT_EQ(1u, window_server_->num_trees()); } - EXPECT_FALSE(connection_manager_delegate_.got_on_no_more_displays()); + EXPECT_FALSE(window_server_delegate_.got_on_no_more_displays()); // Destroy the Display, which should shutdown the trees. - connection_manager_->display_manager()->DestroyDisplay(display); - EXPECT_EQ(0u, connection_manager_->num_trees()); - EXPECT_TRUE(connection_manager_delegate_.got_on_no_more_displays()); + window_server_->display_manager()->DestroyDisplay(display); + EXPECT_EQ(0u, window_server_->num_trees()); + EXPECT_TRUE(window_server_delegate_.got_on_no_more_displays()); } TEST_F(DisplayTest, EventStateResetOnUserSwitch) { - connection_manager_delegate_.set_num_displays_to_create(1); + window_server_delegate_.set_num_displays_to_create(1); const UserId kTestId1 = "20"; const UserId kTestId2 = "201"; WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kTestId1, &test_window_manager_factory_); WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kTestId2, &test_window_manager_factory_); - connection_manager_->user_id_tracker()->SetActiveUserId(kTestId1); + window_server_->user_id_tracker()->SetActiveUserId(kTestId1); - DisplayManager* display_manager = connection_manager_->display_manager(); + DisplayManager* display_manager = window_server_->display_manager(); ASSERT_EQ(1u, display_manager->displays().size()); Display* display = *display_manager->displays().begin(); WindowManagerState* active_wms = display->GetActiveWindowManagerState(); @@ -187,7 +186,7 @@ TEST_F(DisplayTest, EventStateResetOnUserSwitch) { // Switch the user. Should trigger resetting state in old event dispatcher // and update state in new event dispatcher. - connection_manager_->user_id_tracker()->SetActiveUserId(kTestId2); + window_server_->user_id_tracker()->SetActiveUserId(kTestId2); EXPECT_NE(active_wms, display->GetActiveWindowManagerState()); EXPECT_FALSE(EventDispatcherTestApi(active_wms->event_dispatcher()) .AreAnyPointersDown()); @@ -201,17 +200,17 @@ TEST_F(DisplayTest, EventStateResetOnUserSwitch) { // Verifies capture fails when wm is inactive and succeeds when wm is active. TEST_F(DisplayTest, SetCaptureFromWindowManager) { - connection_manager_delegate_.set_num_displays_to_create(1); + window_server_delegate_.set_num_displays_to_create(1); const UserId kTestId1 = "20"; const UserId kTestId2 = "201"; WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kTestId1, &test_window_manager_factory_); WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kTestId2, &test_window_manager_factory_); - connection_manager_->user_id_tracker()->SetActiveUserId(kTestId1); - DisplayManager* display_manager = connection_manager_->display_manager(); + window_server_->user_id_tracker()->SetActiveUserId(kTestId1); + DisplayManager* display_manager = window_server_->display_manager(); ASSERT_EQ(1u, display_manager->displays().size()); Display* display = *display_manager->displays().begin(); WindowManagerState* wms_for_id2 = @@ -236,7 +235,7 @@ TEST_F(DisplayTest, SetCaptureFromWindowManager) { EXPECT_FALSE(tree->SetCapture(child_window_id)); // Make the second user active and verify capture works. - connection_manager_->user_id_tracker()->SetActiveUserId(kTestId2); + window_server_->user_id_tracker()->SetActiveUserId(kTestId2); EXPECT_TRUE(wms_for_id2->IsActive()); EXPECT_TRUE(tree->SetCapture(child_window_id)); } diff --git a/components/mus/ws/operation.cc b/components/mus/ws/operation.cc index 47a17eec..33b37df 100644 --- a/components/mus/ws/operation.cc +++ b/components/mus/ws/operation.cc @@ -4,27 +4,27 @@ #include "components/mus/ws/operation.h" -#include "components/mus/ws/connection_manager.h" +#include "components/mus/ws/window_server.h" #include "components/mus/ws/window_tree.h" namespace mus { namespace ws { Operation::Operation(WindowTree* tree, - ConnectionManager* connection_manager, + WindowServer* window_server, OperationType operation_type) - : connection_manager_(connection_manager), + : window_server_(window_server), source_tree_id_(tree->id()), operation_type_(operation_type) { DCHECK(operation_type != OperationType::NONE); // Tell the connection manager about the operation currently in flight. // The connection manager uses this information to suppress certain calls // out to clients. - connection_manager_->PrepareForOperation(this); + window_server_->PrepareForOperation(this); } Operation::~Operation() { - connection_manager_->FinishOperation(); + window_server_->FinishOperation(); } } // namespace ws diff --git a/components/mus/ws/operation.h b/components/mus/ws/operation.h index 363d35b..6c25fcd 100644 --- a/components/mus/ws/operation.h +++ b/components/mus/ws/operation.h @@ -13,7 +13,7 @@ namespace mus { namespace ws { -class ConnectionManager; +class WindowServer; class WindowTree; enum class OperationType { @@ -40,7 +40,7 @@ enum class OperationType { class Operation { public: Operation(WindowTree* tree, - ConnectionManager* connection_manager, + WindowServer* window_server, OperationType operation_type); ~Operation(); @@ -60,7 +60,7 @@ class Operation { } private: - ConnectionManager* const connection_manager_; + WindowServer* const window_server_; const ConnectionSpecificId source_tree_id_; const OperationType operation_type_; diff --git a/components/mus/ws/test_utils.cc b/components/mus/ws/test_utils.cc index 1418c27..87b517c 100644 --- a/components/mus/ws/test_utils.cc +++ b/components/mus/ws/test_utils.cc @@ -249,18 +249,18 @@ void TestWindowTreeBinding::SetIncomingMethodCallProcessingPaused(bool paused) { is_paused_ = paused; } -// TestConnectionManagerDelegate ---------------------------------------------- +// TestWindowServerDelegate ---------------------------------------------- -TestConnectionManagerDelegate::TestConnectionManagerDelegate() {} -TestConnectionManagerDelegate::~TestConnectionManagerDelegate() {} +TestWindowServerDelegate::TestWindowServerDelegate() {} +TestWindowServerDelegate::~TestWindowServerDelegate() {} -void TestConnectionManagerDelegate::OnNoMoreDisplays() { +void TestWindowServerDelegate::OnNoMoreDisplays() { got_on_no_more_displays_ = true; } scoped_ptr<WindowTreeBinding> -TestConnectionManagerDelegate::CreateWindowTreeBindingForEmbedAtWindow( - ws::ConnectionManager* connection_manager, +TestWindowServerDelegate::CreateWindowTreeBindingForEmbedAtWindow( + ws::WindowServer* window_server, ws::WindowTree* tree, mojom::WindowTreeRequest tree_request, mojom::WindowTreeClientPtr client) { @@ -269,14 +269,13 @@ TestConnectionManagerDelegate::CreateWindowTreeBindingForEmbedAtWindow( return std::move(binding); } -void TestConnectionManagerDelegate::CreateDefaultDisplays() { +void TestWindowServerDelegate::CreateDefaultDisplays() { DCHECK(num_displays_to_create_); - DCHECK(connection_manager_); + DCHECK(window_server_); for (int i = 0; i < num_displays_to_create_; ++i) { // Display manages its own lifetime. - Display* display = - new Display(connection_manager_, PlatformDisplayInitParams()); + Display* display = new Display(window_server_, PlatformDisplayInitParams()); display->Init(nullptr); } } diff --git a/components/mus/ws/test_utils.h b/components/mus/ws/test_utils.h index 31826d9..096caaf 100644 --- a/components/mus/ws/test_utils.h +++ b/components/mus/ws/test_utils.h @@ -9,7 +9,6 @@ #include "components/mus/public/interfaces/display.mojom.h" #include "components/mus/public/interfaces/window_tree.mojom.h" -#include "components/mus/ws/connection_manager_delegate.h" #include "components/mus/ws/display.h" #include "components/mus/ws/event_dispatcher.h" #include "components/mus/ws/platform_display.h" @@ -18,6 +17,7 @@ #include "components/mus/ws/user_display_manager.h" #include "components/mus/ws/window_manager_factory_registry.h" #include "components/mus/ws/window_manager_state.h" +#include "components/mus/ws/window_server_delegate.h" #include "components/mus/ws/window_tree.h" #include "components/mus/ws/window_tree_binding.h" @@ -246,14 +246,14 @@ class TestWindowTreeBinding : public WindowTreeBinding { // ----------------------------------------------------------------------------- -// ConnectionManagerDelegate that creates TestWindowTreeClients. -class TestConnectionManagerDelegate : public ConnectionManagerDelegate { +// WindowServerDelegate that creates TestWindowTreeClients. +class TestWindowServerDelegate : public WindowServerDelegate { public: - TestConnectionManagerDelegate(); - ~TestConnectionManagerDelegate() override; + TestWindowServerDelegate(); + ~TestWindowServerDelegate() override; - void set_connection_manager(ConnectionManager* connection_manager) { - connection_manager_ = connection_manager; + void set_window_server(WindowServer* window_server) { + window_server_ = window_server; } void set_num_displays_to_create(int count) { @@ -267,10 +267,10 @@ class TestConnectionManagerDelegate : public ConnectionManagerDelegate { bool got_on_no_more_displays() const { return got_on_no_more_displays_; } - // ConnectionManagerDelegate: + // WindowServerDelegate: void OnNoMoreDisplays() override; scoped_ptr<WindowTreeBinding> CreateWindowTreeBindingForEmbedAtWindow( - ws::ConnectionManager* connection_manager, + ws::WindowServer* window_server, ws::WindowTree* tree, mojom::WindowTreeRequest tree_request, mojom::WindowTreeClientPtr client) override; @@ -282,10 +282,10 @@ class TestConnectionManagerDelegate : public ConnectionManagerDelegate { int num_displays_to_create_ = 0; TestWindowTreeBinding* last_binding_ = nullptr; Display* display_ = nullptr; - ConnectionManager* connection_manager_ = nullptr; + WindowServer* window_server_ = nullptr; bool got_on_no_more_displays_ = false; - DISALLOW_COPY_AND_ASSIGN(TestConnectionManagerDelegate); + DISALLOW_COPY_AND_ASSIGN(TestWindowServerDelegate); }; } // namespace test diff --git a/components/mus/ws/user_display_manager_unittest.cc b/components/mus/ws/user_display_manager_unittest.cc index d2ff1c2..dcaf764 100644 --- a/components/mus/ws/user_display_manager_unittest.cc +++ b/components/mus/ws/user_display_manager_unittest.cc @@ -13,8 +13,6 @@ #include "components/mus/common/util.h" #include "components/mus/public/interfaces/window_tree.mojom.h" #include "components/mus/surfaces/surfaces_state.h" -#include "components/mus/ws/connection_manager.h" -#include "components/mus/ws/connection_manager_delegate.h" #include "components/mus/ws/display_binding.h" #include "components/mus/ws/display_manager.h" #include "components/mus/ws/ids.h" @@ -24,6 +22,8 @@ #include "components/mus/ws/server_window.h" #include "components/mus/ws/test_utils.h" #include "components/mus/ws/window_manager_state.h" +#include "components/mus/ws/window_server.h" +#include "components/mus/ws/window_server_delegate.h" #include "components/mus/ws/window_tree.h" #include "components/mus/ws/window_tree_binding.h" #include "testing/gtest/include/gtest/gtest.h" @@ -115,17 +115,16 @@ class UserDisplayManagerTest : public testing::Test { // testing::Test: void SetUp() override { PlatformDisplay::set_factory_for_testing(&platform_display_factory_); - connection_manager_.reset(new ConnectionManager( - &connection_manager_delegate_, scoped_refptr<SurfacesState>())); - connection_manager_delegate_.set_connection_manager( - connection_manager_.get()); + window_server_.reset(new WindowServer(&window_server_delegate_, + scoped_refptr<SurfacesState>())); + window_server_delegate_.set_window_server(window_server_.get()); } protected: int32_t cursor_id_; TestPlatformDisplayFactory platform_display_factory_; - TestConnectionManagerDelegate connection_manager_delegate_; - scoped_ptr<ConnectionManager> connection_manager_; + TestWindowServerDelegate window_server_delegate_; + scoped_ptr<WindowServer> window_server_; base::MessageLoop message_loop_; TestWindowManagerFactory test_window_manager_factory_; @@ -133,13 +132,13 @@ class UserDisplayManagerTest : public testing::Test { }; TEST_F(UserDisplayManagerTest, OnlyNotifyWhenFrameDecorationsSet) { - connection_manager_delegate_.set_num_displays_to_create(1); + window_server_delegate_.set_num_displays_to_create(1); const UserId kUserId1 = "2"; TestDisplayManagerObserver display_manager_observer1; - DisplayManager* display_manager = connection_manager_->display_manager(); + DisplayManager* display_manager = window_server_->display_manager(); WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kUserId1, &test_window_manager_factory_); UserDisplayManager* user_display_manager1 = display_manager->GetUserDisplayManager(kUserId1); @@ -162,13 +161,13 @@ TEST_F(UserDisplayManagerTest, OnlyNotifyWhenFrameDecorationsSet) { } TEST_F(UserDisplayManagerTest, AddObserverAfterFrameDecorationsSet) { - connection_manager_delegate_.set_num_displays_to_create(1); + window_server_delegate_.set_num_displays_to_create(1); const UserId kUserId1 = "2"; TestDisplayManagerObserver display_manager_observer1; - DisplayManager* display_manager = connection_manager_->display_manager(); + DisplayManager* display_manager = window_server_->display_manager(); WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kUserId1, &test_window_manager_factory_); UserDisplayManager* user_display_manager1 = display_manager->GetUserDisplayManager(kUserId1); @@ -187,13 +186,13 @@ TEST_F(UserDisplayManagerTest, AddObserverAfterFrameDecorationsSet) { } TEST_F(UserDisplayManagerTest, AddRemoveDisplay) { - connection_manager_delegate_.set_num_displays_to_create(1); + window_server_delegate_.set_num_displays_to_create(1); const UserId kUserId1 = "2"; TestDisplayManagerObserver display_manager_observer1; - DisplayManager* display_manager = connection_manager_->display_manager(); + DisplayManager* display_manager = window_server_->display_manager(); WindowManagerFactoryRegistryTestApi( - connection_manager_->window_manager_factory_registry()) + window_server_->window_manager_factory_registry()) .AddService(kUserId1, &test_window_manager_factory_); UserDisplayManager* user_display_manager1 = display_manager->GetUserDisplayManager(kUserId1); @@ -209,7 +208,7 @@ TEST_F(UserDisplayManagerTest, AddRemoveDisplay) { // Add another display. Display* display2 = - new Display(connection_manager_.get(), PlatformDisplayInitParams()); + new Display(window_server_.get(), PlatformDisplayInitParams()); display2->Init(nullptr); // Observer should not have been notified yet as frame decorations not set. diff --git a/components/mus/ws/window_manager_factory_registry.cc b/components/mus/ws/window_manager_factory_registry.cc index 8c76131..b5c7df5 100644 --- a/components/mus/ws/window_manager_factory_registry.cc +++ b/components/mus/ws/window_manager_factory_registry.cc @@ -4,18 +4,18 @@ #include "components/mus/ws/window_manager_factory_registry.h" -#include "components/mus/ws/connection_manager.h" #include "components/mus/ws/user_id_tracker_observer.h" #include "components/mus/ws/window_manager_factory_registry_observer.h" #include "components/mus/ws/window_manager_factory_service.h" +#include "components/mus/ws/window_server.h" namespace mus { namespace ws { WindowManagerFactoryRegistry::WindowManagerFactoryRegistry( - ConnectionManager* connection_manager, + WindowServer* window_server, UserIdTracker* id_tracker) - : id_tracker_(id_tracker), connection_manager_(connection_manager) { + : id_tracker_(id_tracker), window_server_(window_server) { id_tracker_->AddObserver(this); } @@ -87,10 +87,10 @@ void WindowManagerFactoryRegistry::OnWindowManagerFactorySet( FOR_EACH_OBSERVER(WindowManagerFactoryRegistryObserver, observers_, OnWindowManagerFactorySet(service)); - // Notify after other observers as ConnectionManager triggers other + // Notify after other observers as WindowServer triggers other // observers being added, which will have already processed the add. if (is_first_valid_factory) - connection_manager_->OnFirstWindowManagerFactorySet(); + window_server_->OnFirstWindowManagerFactorySet(); } void WindowManagerFactoryRegistry::OnActiveUserIdChanged( diff --git a/components/mus/ws/window_manager_factory_registry.h b/components/mus/ws/window_manager_factory_registry.h index ece6d39..fe41e72 100644 --- a/components/mus/ws/window_manager_factory_registry.h +++ b/components/mus/ws/window_manager_factory_registry.h @@ -18,10 +18,10 @@ namespace mus { namespace ws { -class ConnectionManager; class UserIdTracker; class WindowManagerFactoryRegistryObserver; class WindowManagerFactoryService; +class WindowServer; namespace test { class WindowManagerFactoryRegistryTestApi; @@ -31,8 +31,8 @@ class WindowManagerFactoryRegistryTestApi; // WindowManagerFactoryServices. class WindowManagerFactoryRegistry : public UserIdTrackerObserver { public: - explicit WindowManagerFactoryRegistry(ConnectionManager* connection_manager, - UserIdTracker* tracker); + WindowManagerFactoryRegistry(WindowServer* connection_manager, + UserIdTracker* tracker); ~WindowManagerFactoryRegistry() override; void Register( @@ -64,7 +64,7 @@ class WindowManagerFactoryRegistry : public UserIdTrackerObserver { // Set to true the first time a valid factory has been found. bool got_valid_factory_ = false; UserIdTracker* id_tracker_; - ConnectionManager* connection_manager_; + WindowServer* window_server_; std::vector<scoped_ptr<WindowManagerFactoryService>> services_; diff --git a/components/mus/ws/window_manager_factory_service.cc b/components/mus/ws/window_manager_factory_service.cc index f1d2460..847df79 100644 --- a/components/mus/ws/window_manager_factory_service.cc +++ b/components/mus/ws/window_manager_factory_service.cc @@ -4,7 +4,7 @@ #include "components/mus/ws/window_manager_factory_service.h" -#include "components/mus/ws/connection_manager.h" +#include "components/mus/ws/window_manager_factory_registry.h" #include "components/mus/ws/window_tree.h" namespace mus { diff --git a/components/mus/ws/window_manager_state.cc b/components/mus/ws/window_manager_state.cc index 709aa56..4b9454e 100644 --- a/components/mus/ws/window_manager_state.cc +++ b/components/mus/ws/window_manager_state.cc @@ -4,12 +4,12 @@ #include "components/mus/ws/window_manager_state.h" -#include "components/mus/ws/connection_manager.h" #include "components/mus/ws/display_manager.h" #include "components/mus/ws/platform_display.h" #include "components/mus/ws/server_window.h" #include "components/mus/ws/user_display_manager.h" #include "components/mus/ws/user_id_tracker.h" +#include "components/mus/ws/window_server.h" #include "components/mus/ws/window_tree.h" #include "mojo/shell/public/interfaces/connector.mojom.h" #include "ui/events/event.h" @@ -107,8 +107,8 @@ void WindowManagerState::SetFrameDecorationValues( bool WindowManagerState::SetCapture(ServerWindow* window, bool in_nonclient_area) { - // TODO(sky): capture should be a singleton. Need to route to - // ConnectionManager so that all other EventDispatchers are updated. + // TODO(sky): capture should be a singleton. Need to route to WindowServer + // so that all other EventDispatchers are updated. DCHECK(IsActive()); if (capture_window() == window) return true; @@ -167,9 +167,8 @@ WindowManagerState::WindowManagerState(Display* display, frame_decoration_values_->maximized_client_area_insets = mojo::Insets::New(); frame_decoration_values_->max_title_bar_button_width = 0u; - ConnectionManager* connection_manager = display_->connection_manager(); - root_.reset(connection_manager->CreateServerWindow( - connection_manager->display_manager()->GetAndAdvanceNextRootId(), + root_.reset(window_server()->CreateServerWindow( + window_server()->display_manager()->GetAndAdvanceNextRootId(), ServerWindow::Properties())); // Our root is always a child of the Display's root. Do this // before the WindowTree has been created so that the client doesn't get @@ -228,8 +227,8 @@ void WindowManagerState::OnEventAck(mojom::WindowTree* tree) { ProcessNextEventFromQueue(); } -ConnectionManager* WindowManagerState::connection_manager() { - return display_->connection_manager(); +WindowServer* WindowManagerState::window_server() { + return display_->window_server(); } void WindowManagerState::OnEventAckTimeout() { @@ -285,8 +284,8 @@ void WindowManagerState::DispatchInputEventToWindowImpl( // embedded window. WindowTree* tree = in_nonclient_area - ? connection_manager()->GetTreeWithId(target->id().connection_id) - : connection_manager()->GetTreeWithRoot(target); + ? window_server()->GetTreeWithId(target->id().connection_id) + : window_server()->GetTreeWithRoot(target); if (!tree) { if (in_nonclient_area) { // Being the root of the tree means we may get events outside the bounds @@ -295,7 +294,7 @@ void WindowManagerState::DispatchInputEventToWindowImpl( DCHECK_EQ(target, root_.get()); tree = tree_; } else { - tree = connection_manager()->GetTreeWithId(target->id().connection_id); + tree = window_server()->GetTreeWithId(target->id().connection_id); } } @@ -337,7 +336,7 @@ void WindowManagerState::ReleaseNativeCapture() { void WindowManagerState::OnServerWindowCaptureLost(ServerWindow* window) { DCHECK(window); - display_->connection_manager()->ProcessLostCapture(window); + window_server()->ProcessLostCapture(window); } void WindowManagerState::DispatchInputEventToWindow(ServerWindow* target, diff --git a/components/mus/ws/window_manager_state.h b/components/mus/ws/window_manager_state.h index 4b3cf62..18195d2 100644 --- a/components/mus/ws/window_manager_state.h +++ b/components/mus/ws/window_manager_state.h @@ -10,10 +10,10 @@ #include "base/memory/scoped_ptr.h" #include "base/timer/timer.h" #include "components/mus/public/interfaces/display.mojom.h" -#include "components/mus/ws/connection_manager.h" #include "components/mus/ws/event_dispatcher.h" #include "components/mus/ws/event_dispatcher_delegate.h" #include "components/mus/ws/user_id.h" +#include "components/mus/ws/window_server.h" namespace cc { struct SurfaceId; @@ -130,7 +130,7 @@ class WindowManagerState : public EventDispatcherDelegate { bool is_user_id_valid, const UserId& user_id); - ConnectionManager* connection_manager(); + WindowServer* window_server(); void OnEventAckTimeout(); diff --git a/components/mus/ws/connection_manager.cc b/components/mus/ws/window_server.cc index 9d63c61..3bfadc2 100644 --- a/components/mus/ws/connection_manager.cc +++ b/components/mus/ws/window_server.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/mus/ws/connection_manager.h" +#include "components/mus/ws/window_server.h" #include "base/logging.h" #include "base/stl_util.h" -#include "components/mus/ws/connection_manager_delegate.h" #include "components/mus/ws/display.h" #include "components/mus/ws/display_binding.h" #include "components/mus/ws/display_manager.h" @@ -16,6 +15,7 @@ #include "components/mus/ws/window_manager_access_policy.h" #include "components/mus/ws/window_manager_factory_service.h" #include "components/mus/ws/window_manager_state.h" +#include "components/mus/ws/window_server_delegate.h" #include "components/mus/ws/window_tree.h" #include "components/mus/ws/window_tree_binding.h" #include "mojo/converters/geometry/geometry_type_converters.h" @@ -27,8 +27,8 @@ namespace mus { namespace ws { -ConnectionManager::ConnectionManager( - ConnectionManagerDelegate* delegate, +WindowServer::WindowServer( + WindowServerDelegate* delegate, const scoped_refptr<mus::SurfacesState>& surfaces_state) : delegate_(delegate), surfaces_state_(surfaces_state), @@ -39,7 +39,7 @@ ConnectionManager::ConnectionManager( next_wm_change_id_(0), window_manager_factory_registry_(this, &user_id_tracker_) {} -ConnectionManager::~ConnectionManager() { +WindowServer::~WindowServer() { in_destructor_ = true; // Destroys the window trees results in querying for the display. Tear down @@ -53,7 +53,7 @@ ConnectionManager::~ConnectionManager() { display_manager_.reset(); } -ServerWindow* ConnectionManager::CreateServerWindow( +ServerWindow* WindowServer::CreateServerWindow( const WindowId& id, const std::map<std::string, std::vector<uint8_t>>& properties) { ServerWindow* window = new ServerWindow(this, id, properties); @@ -61,13 +61,13 @@ ServerWindow* ConnectionManager::CreateServerWindow( return window; } -ConnectionSpecificId ConnectionManager::GetAndAdvanceNextConnectionId() { +ConnectionSpecificId WindowServer::GetAndAdvanceNextConnectionId() { const ConnectionSpecificId id = next_connection_id_++; DCHECK_LT(id, next_connection_id_); return id; } -WindowTree* ConnectionManager::EmbedAtWindow( +WindowTree* WindowServer::EmbedAtWindow( ServerWindow* root, const UserId& user_id, mojom::WindowTreeClientPtr client, @@ -86,9 +86,9 @@ WindowTree* ConnectionManager::EmbedAtWindow( return tree; } -WindowTree* ConnectionManager::AddTree(scoped_ptr<WindowTree> tree_impl_ptr, - scoped_ptr<WindowTreeBinding> binding, - mojom::WindowTreePtr tree_ptr) { +WindowTree* WindowServer::AddTree(scoped_ptr<WindowTree> tree_impl_ptr, + scoped_ptr<WindowTreeBinding> binding, + mojom::WindowTreePtr tree_ptr) { CHECK_EQ(0u, tree_map_.count(tree_impl_ptr->id())); WindowTree* tree = tree_impl_ptr.get(); tree_map_[tree->id()] = std::move(tree_impl_ptr); @@ -96,7 +96,7 @@ WindowTree* ConnectionManager::AddTree(scoped_ptr<WindowTree> tree_impl_ptr, return tree; } -WindowTree* ConnectionManager::CreateTreeForWindowManager( +WindowTree* WindowServer::CreateTreeForWindowManager( Display* display, mojom::WindowManagerFactory* factory, ServerWindow* root, @@ -115,7 +115,7 @@ WindowTree* ConnectionManager::CreateTreeForWindowManager( return tree; } -void ConnectionManager::DestroyTree(WindowTree* tree) { +void WindowServer::DestroyTree(WindowTree* tree) { scoped_ptr<WindowTree> tree_ptr; { auto iter = tree_map_.find(tree->id()); @@ -153,13 +153,12 @@ void ConnectionManager::DestroyTree(WindowTree* tree) { in_flight_wm_change_map_.erase(id); } -WindowTree* ConnectionManager::GetTreeWithId( - ConnectionSpecificId connection_id) { +WindowTree* WindowServer::GetTreeWithId(ConnectionSpecificId connection_id) { auto iter = tree_map_.find(connection_id); return iter == tree_map_.end() ? nullptr : iter->second.get(); } -ServerWindow* ConnectionManager::GetWindow(const WindowId& id) { +ServerWindow* WindowServer::GetWindow(const WindowId& id) { // kInvalidConnectionId is used for Display and WindowManager nodes. if (id.connection_id == kInvalidConnectionId) { for (Display* display : display_manager_->displays()) { @@ -172,23 +171,23 @@ ServerWindow* ConnectionManager::GetWindow(const WindowId& id) { return tree ? tree->GetWindow(id) : nullptr; } -void ConnectionManager::SchedulePaint(ServerWindow* window, - const gfx::Rect& bounds) { +void WindowServer::SchedulePaint(ServerWindow* window, + const gfx::Rect& bounds) { Display* display = display_manager_->GetDisplayContaining(window); if (display) display->SchedulePaint(window, bounds); } -void ConnectionManager::OnTreeMessagedClient(ConnectionSpecificId id) { +void WindowServer::OnTreeMessagedClient(ConnectionSpecificId id) { if (current_operation_) current_operation_->MarkTreeAsMessaged(id); } -bool ConnectionManager::DidTreeMessageClient(ConnectionSpecificId id) const { +bool WindowServer::DidTreeMessageClient(ConnectionSpecificId id) const { return current_operation_ && current_operation_->DidMessageTree(id); } -mojom::ViewportMetricsPtr ConnectionManager::GetViewportMetricsForWindow( +mojom::ViewportMetricsPtr WindowServer::GetViewportMetricsForWindow( const ServerWindow* window) { const Display* display = display_manager_->GetDisplayContaining(window); if (display) @@ -204,7 +203,7 @@ mojom::ViewportMetricsPtr ConnectionManager::GetViewportMetricsForWindow( return metrics; } -const WindowTree* ConnectionManager::GetTreeWithRoot( +const WindowTree* WindowServer::GetTreeWithRoot( const ServerWindow* window) const { if (!window) return nullptr; @@ -215,7 +214,7 @@ const WindowTree* ConnectionManager::GetTreeWithRoot( return nullptr; } -void ConnectionManager::OnFirstWindowManagerFactorySet() { +void WindowServer::OnFirstWindowManagerFactorySet() { if (display_manager_->has_active_or_pending_displays()) return; @@ -225,7 +224,7 @@ void ConnectionManager::OnFirstWindowManagerFactorySet() { delegate_->CreateDefaultDisplays(); } -uint32_t ConnectionManager::GenerateWindowManagerChangeId( +uint32_t WindowServer::GenerateWindowManagerChangeId( WindowTree* source, uint32_t client_change_id) { const uint32_t wm_change_id = next_wm_change_id_++; @@ -233,7 +232,7 @@ uint32_t ConnectionManager::GenerateWindowManagerChangeId( return wm_change_id; } -void ConnectionManager::WindowManagerChangeCompleted( +void WindowServer::WindowManagerChangeCompleted( uint32_t window_manager_change_id, bool success) { InFlightWindowManagerChange change; @@ -246,7 +245,7 @@ void ConnectionManager::WindowManagerChangeCompleted( tree->OnChangeCompleted(change.client_change_id, success); } -void ConnectionManager::WindowManagerCreatedTopLevelWindow( +void WindowServer::WindowManagerCreatedTopLevelWindow( WindowTree* wm_tree, uint32_t window_manager_change_id, const ServerWindow* window) { @@ -274,17 +273,16 @@ void ConnectionManager::WindowManagerCreatedTopLevelWindow( change.client_change_id, window); } -void ConnectionManager::ProcessWindowBoundsChanged( - const ServerWindow* window, - const gfx::Rect& old_bounds, - const gfx::Rect& new_bounds) { +void WindowServer::ProcessWindowBoundsChanged(const ServerWindow* window, + const gfx::Rect& old_bounds, + const gfx::Rect& new_bounds) { for (auto& pair : tree_map_) { pair.second->ProcessWindowBoundsChanged(window, old_bounds, new_bounds, IsOperationSource(pair.first)); } } -void ConnectionManager::ProcessClientAreaChanged( +void WindowServer::ProcessClientAreaChanged( const ServerWindow* window, const gfx::Insets& new_client_area, const std::vector<gfx::Rect>& new_additional_client_areas) { @@ -295,13 +293,13 @@ void ConnectionManager::ProcessClientAreaChanged( } } -void ConnectionManager::ProcessLostCapture(const ServerWindow* window) { +void WindowServer::ProcessLostCapture(const ServerWindow* window) { for (auto& pair : tree_map_) { pair.second->ProcessLostCapture(window, IsOperationSource(pair.first)); } } -void ConnectionManager::ProcessWillChangeWindowHierarchy( +void WindowServer::ProcessWillChangeWindowHierarchy( const ServerWindow* window, const ServerWindow* new_parent, const ServerWindow* old_parent) { @@ -311,7 +309,7 @@ void ConnectionManager::ProcessWillChangeWindowHierarchy( } } -void ConnectionManager::ProcessWindowHierarchyChanged( +void WindowServer::ProcessWindowHierarchyChanged( const ServerWindow* window, const ServerWindow* new_parent, const ServerWindow* old_parent) { @@ -321,10 +319,9 @@ void ConnectionManager::ProcessWindowHierarchyChanged( } } -void ConnectionManager::ProcessWindowReorder( - const ServerWindow* window, - const ServerWindow* relative_window, - const mojom::OrderDirection direction) { +void WindowServer::ProcessWindowReorder(const ServerWindow* window, + const ServerWindow* relative_window, + const mojom::OrderDirection direction) { // We'll probably do a bit of reshuffling when we add a transient window. if ((current_operation_type() == OperationType::ADD_TRANSIENT_WINDOW) || (current_operation_type() == @@ -337,14 +334,13 @@ void ConnectionManager::ProcessWindowReorder( } } -void ConnectionManager::ProcessWindowDeleted(const ServerWindow* window) { +void WindowServer::ProcessWindowDeleted(const ServerWindow* window) { for (auto& pair : tree_map_) pair.second->ProcessWindowDeleted(window, IsOperationSource(pair.first)); } -void ConnectionManager::ProcessWillChangeWindowPredefinedCursor( - ServerWindow* window, - int32_t cursor_id) { +void WindowServer::ProcessWillChangeWindowPredefinedCursor(ServerWindow* window, + int32_t cursor_id) { for (auto& pair : tree_map_) { pair.second->ProcessCursorChanged(window, cursor_id, IsOperationSource(pair.first)); @@ -356,7 +352,7 @@ void ConnectionManager::ProcessWillChangeWindowPredefinedCursor( display->OnCursorUpdated(window); } -void ConnectionManager::ProcessViewportMetricsChanged( +void WindowServer::ProcessViewportMetricsChanged( Display* display, const mojom::ViewportMetrics& old_metrics, const mojom::ViewportMetrics& new_metrics) { @@ -366,7 +362,7 @@ void ConnectionManager::ProcessViewportMetricsChanged( } } -bool ConnectionManager::GetAndClearInFlightWindowManagerChange( +bool WindowServer::GetAndClearInFlightWindowManagerChange( uint32_t window_manager_change_id, InFlightWindowManagerChange* change) { // There are valid reasons as to why we wouldn't know about the id. The @@ -381,47 +377,47 @@ bool ConnectionManager::GetAndClearInFlightWindowManagerChange( return true; } -void ConnectionManager::PrepareForOperation(Operation* op) { +void WindowServer::PrepareForOperation(Operation* op) { // Should only ever have one change in flight. CHECK(!current_operation_); current_operation_ = op; } -void ConnectionManager::FinishOperation() { +void WindowServer::FinishOperation() { // PrepareForOperation/FinishOperation should be balanced. CHECK(current_operation_); current_operation_ = nullptr; } -void ConnectionManager::MaybeUpdateNativeCursor(ServerWindow* window) { +void WindowServer::MaybeUpdateNativeCursor(ServerWindow* window) { // This can be null in unit tests. Display* display = display_manager_->GetDisplayContaining(window); if (display) display->MaybeChangeCursorOnWindowTreeChange(); } -mus::SurfacesState* ConnectionManager::GetSurfacesState() { +mus::SurfacesState* WindowServer::GetSurfacesState() { return surfaces_state_.get(); } -void ConnectionManager::OnScheduleWindowPaint(ServerWindow* window) { +void WindowServer::OnScheduleWindowPaint(ServerWindow* window) { if (!in_destructor_) SchedulePaint(window, gfx::Rect(window->bounds().size())); } -const ServerWindow* ConnectionManager::GetRootWindow( +const ServerWindow* WindowServer::GetRootWindow( const ServerWindow* window) const { const Display* display = display_manager_->GetDisplayContaining(window); return display ? display->root_window() : nullptr; } -void ConnectionManager::ScheduleSurfaceDestruction(ServerWindow* window) { +void WindowServer::ScheduleSurfaceDestruction(ServerWindow* window) { Display* display = display_manager_->GetDisplayContaining(window); if (display) display->ScheduleSurfaceDestruction(window); } -ServerWindow* ConnectionManager::FindWindowForSurface( +ServerWindow* WindowServer::FindWindowForSurface( const ServerWindow* ancestor, mojom::SurfaceType surface_type, const ClientWindowId& client_window_id) { @@ -446,22 +442,22 @@ ServerWindow* ConnectionManager::FindWindowForSurface( return window_tree->GetWindowByClientId(client_window_id); } -void ConnectionManager::OnWindowDestroyed(ServerWindow* window) { +void WindowServer::OnWindowDestroyed(ServerWindow* window) { ProcessWindowDeleted(window); } -void ConnectionManager::OnWillChangeWindowHierarchy(ServerWindow* window, - ServerWindow* new_parent, - ServerWindow* old_parent) { +void WindowServer::OnWillChangeWindowHierarchy(ServerWindow* window, + ServerWindow* new_parent, + ServerWindow* old_parent) { if (in_destructor_) return; ProcessWillChangeWindowHierarchy(window, new_parent, old_parent); } -void ConnectionManager::OnWindowHierarchyChanged(ServerWindow* window, - ServerWindow* new_parent, - ServerWindow* old_parent) { +void WindowServer::OnWindowHierarchyChanged(ServerWindow* window, + ServerWindow* new_parent, + ServerWindow* old_parent) { if (in_destructor_) return; @@ -481,9 +477,9 @@ void ConnectionManager::OnWindowHierarchyChanged(ServerWindow* window, MaybeUpdateNativeCursor(window); } -void ConnectionManager::OnWindowBoundsChanged(ServerWindow* window, - const gfx::Rect& old_bounds, - const gfx::Rect& new_bounds) { +void WindowServer::OnWindowBoundsChanged(ServerWindow* window, + const gfx::Rect& old_bounds, + const gfx::Rect& new_bounds) { if (in_destructor_) return; @@ -497,7 +493,7 @@ void ConnectionManager::OnWindowBoundsChanged(ServerWindow* window, MaybeUpdateNativeCursor(window); } -void ConnectionManager::OnWindowClientAreaChanged( +void WindowServer::OnWindowClientAreaChanged( ServerWindow* window, const gfx::Insets& new_client_area, const std::vector<gfx::Rect>& new_additional_client_areas) { @@ -508,16 +504,16 @@ void ConnectionManager::OnWindowClientAreaChanged( new_additional_client_areas); } -void ConnectionManager::OnWindowReordered(ServerWindow* window, - ServerWindow* relative, - mojom::OrderDirection direction) { +void WindowServer::OnWindowReordered(ServerWindow* window, + ServerWindow* relative, + mojom::OrderDirection direction) { ProcessWindowReorder(window, relative, direction); if (!in_destructor_) SchedulePaint(window, gfx::Rect(window->bounds().size())); MaybeUpdateNativeCursor(window); } -void ConnectionManager::OnWillChangeWindowVisibility(ServerWindow* window) { +void WindowServer::OnWillChangeWindowVisibility(ServerWindow* window) { if (in_destructor_) return; @@ -535,7 +531,7 @@ void ConnectionManager::OnWillChangeWindowVisibility(ServerWindow* window) { } } -void ConnectionManager::OnWindowVisibilityChanged(ServerWindow* window) { +void WindowServer::OnWindowVisibilityChanged(ServerWindow* window) { if (in_destructor_) return; @@ -545,15 +541,15 @@ void ConnectionManager::OnWindowVisibilityChanged(ServerWindow* window) { wms->ReleaseCaptureBlockedByModalWindow(window); } -void ConnectionManager::OnWindowPredefinedCursorChanged(ServerWindow* window, - int32_t cursor_id) { +void WindowServer::OnWindowPredefinedCursorChanged(ServerWindow* window, + int32_t cursor_id) { if (in_destructor_) return; ProcessWillChangeWindowPredefinedCursor(window, cursor_id); } -void ConnectionManager::OnWindowSharedPropertyChanged( +void WindowServer::OnWindowSharedPropertyChanged( ServerWindow* window, const std::string& name, const std::vector<uint8_t>* new_data) { @@ -563,24 +559,23 @@ void ConnectionManager::OnWindowSharedPropertyChanged( } } -void ConnectionManager::OnWindowTextInputStateChanged( +void WindowServer::OnWindowTextInputStateChanged( ServerWindow* window, const ui::TextInputState& state) { Display* display = display_manager_->GetDisplayContaining(window); display->UpdateTextInputState(window, state); } -void ConnectionManager::OnTransientWindowAdded(ServerWindow* window, - ServerWindow* transient_child) { +void WindowServer::OnTransientWindowAdded(ServerWindow* window, + ServerWindow* transient_child) { for (auto& pair : tree_map_) { pair.second->ProcessTransientWindowAdded(window, transient_child, IsOperationSource(pair.first)); } } -void ConnectionManager::OnTransientWindowRemoved( - ServerWindow* window, - ServerWindow* transient_child) { +void WindowServer::OnTransientWindowRemoved(ServerWindow* window, + ServerWindow* transient_child) { // If we're deleting a window, then this is a superfluous message. if (current_operation_type() == OperationType::DELETE_WINDOW) return; @@ -590,11 +585,11 @@ void ConnectionManager::OnTransientWindowRemoved( } } -void ConnectionManager::OnFirstDisplayReady() { +void WindowServer::OnFirstDisplayReady() { delegate_->OnFirstDisplayReady(); } -void ConnectionManager::OnNoMoreDisplays() { +void WindowServer::OnNoMoreDisplays() { delegate_->OnNoMoreDisplays(); } diff --git a/components/mus/ws/connection_manager.h b/components/mus/ws/window_server.h index b4a10b4..9d3abe2 100644 --- a/components/mus/ws/connection_manager.h +++ b/components/mus/ws/window_server.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ -#define COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ +#ifndef COMPONENTS_MUS_WS_WINDOW_SERVER_H_ +#define COMPONENTS_MUS_WS_WINDOW_SERVER_H_ #include <stdint.h> @@ -32,24 +32,24 @@ namespace mus { namespace ws { class AccessPolicy; -class ConnectionManagerDelegate; class DisplayManager; class ServerWindow; class WindowManagerState; +class WindowServerDelegate; class WindowTree; class WindowTreeBinding; -// ConnectionManager manages the set of connections to the window server (all -// the WindowTrees) as well as providing the root of the hierarchy. -class ConnectionManager : public ServerWindowDelegate, - public ServerWindowObserver, - public DisplayManagerDelegate { +// WindowServer manages the set of connections to the window server (all the +// WindowTrees) as well as providing the root of the hierarchy. +class WindowServer : public ServerWindowDelegate, + public ServerWindowObserver, + public DisplayManagerDelegate { public: - ConnectionManager(ConnectionManagerDelegate* delegate, - const scoped_refptr<mus::SurfacesState>& surfaces_state); - ~ConnectionManager() override; + WindowServer(WindowServerDelegate* delegate, + const scoped_refptr<mus::SurfacesState>& surfaces_state); + ~WindowServer() override; - ConnectionManagerDelegate* delegate() { return delegate_; } + WindowServerDelegate* delegate() { return delegate_; } UserIdTracker* user_id_tracker() { return &user_id_tracker_; } const UserIdTracker* user_id_tracker() const { return &user_id_tracker_; } @@ -60,7 +60,7 @@ class ConnectionManager : public ServerWindowDelegate, } // Creates a new ServerWindow. The return value is owned by the caller, but - // must be destroyed before ConnectionManager. + // must be destroyed before WindowServer. ServerWindow* CreateServerWindow( const WindowId& id, const std::map<std::string, std::vector<uint8_t>>& properties); @@ -118,7 +118,7 @@ class ConnectionManager : public ServerWindowDelegate, // Returns the WindowTree that has |id| as a root. WindowTree* GetTreeWithRoot(const ServerWindow* window) { return const_cast<WindowTree*>( - const_cast<const ConnectionManager*>(this)->GetTreeWithRoot(window)); + const_cast<const WindowServer*>(this)->GetTreeWithRoot(window)); } const WindowTree* GetTreeWithRoot(const ServerWindow* window) const; @@ -263,7 +263,7 @@ class ConnectionManager : public ServerWindowDelegate, UserIdTracker user_id_tracker_; - ConnectionManagerDelegate* delegate_; + WindowServerDelegate* delegate_; // State for rendering into a Surface. scoped_refptr<mus::SurfacesState> surfaces_state_; @@ -291,10 +291,10 @@ class ConnectionManager : public ServerWindowDelegate, WindowManagerFactoryRegistry window_manager_factory_registry_; - DISALLOW_COPY_AND_ASSIGN(ConnectionManager); + DISALLOW_COPY_AND_ASSIGN(WindowServer); }; } // namespace ws } // namespace mus -#endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_H_ +#endif // COMPONENTS_MUS_WS_WINDOW_SERVER_H_ diff --git a/components/mus/ws/connection_manager_delegate.cc b/components/mus/ws/window_server_delegate.cc index abafa6a..5886112 100644 --- a/components/mus/ws/connection_manager_delegate.cc +++ b/components/mus/ws/window_server_delegate.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/mus/ws/connection_manager_delegate.h" +#include "components/mus/ws/window_server_delegate.h" namespace mus { namespace ws { -void ConnectionManagerDelegate::OnFirstDisplayReady() {} +void WindowServerDelegate::OnFirstDisplayReady() {} } // namespace ws } // namespace mus diff --git a/components/mus/ws/connection_manager_delegate.h b/components/mus/ws/window_server_delegate.h index a777ecb..e7ca4a2 100644 --- a/components/mus/ws/connection_manager_delegate.h +++ b/components/mus/ws/window_server_delegate.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef COMPONENTS_MUS_WS_CONNECTION_MANAGER_DELEGATE_H_ -#define COMPONENTS_MUS_WS_CONNECTION_MANAGER_DELEGATE_H_ +#ifndef COMPONENTS_MUS_WS_WINDOW_SERVER_DELEGATE_H_ +#define COMPONENTS_MUS_WS_WINDOW_SERVER_DELEGATE_H_ #include <stdint.h> @@ -24,13 +24,13 @@ class WindowTree; namespace ws { -class ConnectionManager; class Display; class ServerWindow; +class WindowServer; class WindowTree; class WindowTreeBinding; -class ConnectionManagerDelegate { +class WindowServerDelegate { public: // Called once when the AcceleratedWidget of a Display is available. virtual void OnFirstDisplayReady(); @@ -38,9 +38,9 @@ class ConnectionManagerDelegate { virtual void OnNoMoreDisplays() = 0; // Creates a WindowTreeBinding in response to Embed() calls on the - // ConnectionManager. + // WindowServer. virtual scoped_ptr<WindowTreeBinding> CreateWindowTreeBindingForEmbedAtWindow( - ws::ConnectionManager* connection_manager, + ws::WindowServer* window_server, ws::WindowTree* tree, mojom::WindowTreeRequest tree_request, mojom::WindowTreeClientPtr client) = 0; @@ -50,10 +50,10 @@ class ConnectionManagerDelegate { virtual void CreateDefaultDisplays() = 0; protected: - virtual ~ConnectionManagerDelegate() {} + virtual ~WindowServerDelegate() {} }; } // namespace ws } // namespace mus -#endif // COMPONENTS_MUS_WS_CONNECTION_MANAGER_DELEGATE_H_ +#endif // COMPONENTS_MUS_WS_WINDOW_SERVER_DELEGATE_H_ diff --git a/components/mus/ws/window_tree.cc b/components/mus/ws/window_tree.cc index b729105..9923a2a 100644 --- a/components/mus/ws/window_tree.cc +++ b/components/mus/ws/window_tree.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/macros.h" #include "base/stl_util.h" -#include "components/mus/ws/connection_manager.h" #include "components/mus/ws/default_access_policy.h" #include "components/mus/ws/display.h" #include "components/mus/ws/display_manager.h" @@ -20,6 +19,7 @@ #include "components/mus/ws/server_window.h" #include "components/mus/ws/server_window_observer.h" #include "components/mus/ws/window_manager_state.h" +#include "components/mus/ws/window_server.h" #include "components/mus/ws/window_tree_binding.h" #include "mojo/converters/geometry/geometry_type_converters.h" #include "mojo/converters/ime/ime_type_converters.h" @@ -64,13 +64,13 @@ class TargetedEvent : public ServerWindowObserver { DISALLOW_COPY_AND_ASSIGN(TargetedEvent); }; -WindowTree::WindowTree(ConnectionManager* connection_manager, +WindowTree::WindowTree(WindowServer* window_server, const UserId& user_id, ServerWindow* root, scoped_ptr<AccessPolicy> access_policy) - : connection_manager_(connection_manager), + : window_server_(window_server), user_id_(user_id), - id_(connection_manager_->GetAndAdvanceNextConnectionId()), + id_(window_server_->GetAndAdvanceNextConnectionId()), next_window_id_(1), access_policy_(std::move(access_policy)), event_ack_id_(0), @@ -119,7 +119,7 @@ const ServerWindow* WindowTree::GetWindow(const WindowId& id) const { auto iter = created_window_map_.find(id); return iter == created_window_map_.end() ? nullptr : iter->second; } - return connection_manager_->GetWindow(id); + return window_server_->GetWindow(id); } bool WindowTree::IsWindowKnown(const ServerWindow* window, @@ -201,7 +201,7 @@ bool WindowTree::NewWindow( const WindowId window_id = GenerateNewWindowId(); DCHECK(!GetWindow(window_id)); ServerWindow* window = - connection_manager_->CreateServerWindow(window_id, properties); + window_server_->CreateServerWindow(window_id, properties); created_window_map_[window_id] = window; client_id_to_window_id_map_[client_window_id] = window_id; window_id_to_client_id_map_[window_id] = client_window_id; @@ -214,7 +214,7 @@ bool WindowTree::AddWindow(const ClientWindowId& parent_id, ServerWindow* child = GetWindowByClientId(child_id); if (parent && child && child->parent() != parent && !child->Contains(parent) && access_policy_->CanAddWindow(parent, child)) { - Operation op(this, connection_manager_, OperationType::ADD_WINDOW); + Operation op(this, window_server_, OperationType::ADD_WINDOW); parent->Add(child); return true; } @@ -227,8 +227,7 @@ bool WindowTree::AddTransientWindow(const ClientWindowId& window_id, ServerWindow* transient_window = GetWindowByClientId(transient_window_id); if (window && transient_window && !transient_window->Contains(window) && access_policy_->CanAddTransientWindow(window, transient_window)) { - Operation op(this, connection_manager_, - OperationType::ADD_TRANSIENT_WINDOW); + Operation op(this, window_server_, OperationType::ADD_TRANSIENT_WINDOW); window->AddTransientWindow(transient_window); return true; } @@ -263,7 +262,7 @@ bool WindowTree::SetWindowVisibility(const ClientWindowId& window_id, !access_policy_->CanChangeWindowVisibility(window)) { return false; } - Operation op(this, connection_manager_, OperationType::SET_WINDOW_VISIBILITY); + Operation op(this, window_server_, OperationType::SET_WINDOW_VISIBILITY); window->SetVisible(visible); return true; } @@ -276,8 +275,8 @@ bool WindowTree::Embed(const ClientWindowId& window_id, PrepareForEmbed(window); // When embedding we don't know the user id of where the TreeClient came // from. Use an invalid id, which limits what the client is able to do. - connection_manager_->EmbedAtWindow(window, InvalidUserId(), std::move(client), - make_scoped_ptr(new DefaultAccessPolicy)); + window_server_->EmbedAtWindow(window, InvalidUserId(), std::move(client), + make_scoped_ptr(new DefaultAccessPolicy)); return true; } @@ -428,10 +427,10 @@ void WindowTree::ProcessWindowHierarchyChanged(const ServerWindow* window, std::vector<const ServerWindow*> unused; GetUnknownWindowsFrom(window, &unused); } - if (originated_change || (connection_manager_->current_operation_type() == + if (originated_change || (window_server_->current_operation_type() == OperationType::DELETE_WINDOW) || - (connection_manager_->current_operation_type() == OperationType::EMBED) || - connection_manager_->DidTreeMessageClient(id_)) { + (window_server_->current_operation_type() == OperationType::EMBED) || + window_server_->DidTreeMessageClient(id_)) { return; } @@ -457,7 +456,7 @@ void WindowTree::ProcessWindowHierarchyChanged(const ServerWindow* window, client()->OnWindowHierarchyChanged( client_window_id.id, new_parent_client_window_id.id, old_parent_client_window_id.id, WindowsToWindowDatas(to_send)); - connection_manager_->OnTreeMessagedClient(id_); + window_server_->OnTreeMessagedClient(id_); } void WindowTree::ProcessWindowReorder(const ServerWindow* window, @@ -468,7 +467,7 @@ void WindowTree::ProcessWindowReorder(const ServerWindow* window, ClientWindowId client_window_id, relative_client_window_id; if (originated_change || !IsWindowKnown(window, &client_window_id) || !IsWindowKnown(relative_window, &relative_client_window_id) || - connection_manager_->DidTreeMessageClient(id_)) + window_server_->DidTreeMessageClient(id_)) return; // Do not notify ordering changes of the root windows, since the client @@ -479,7 +478,7 @@ void WindowTree::ProcessWindowReorder(const ServerWindow* window, client()->OnWindowReordered(client_window_id.id, relative_client_window_id.id, direction); - connection_manager_->OnTreeMessagedClient(id_); + window_server_->OnTreeMessagedClient(id_); } void WindowTree::ProcessWindowDeleted(const ServerWindow* window, @@ -500,7 +499,7 @@ void WindowTree::ProcessWindowDeleted(const ServerWindow* window, return; client()->OnWindowDeleted(client_window_id.id); - connection_manager_->OnTreeMessagedClient(id_); + window_server_->OnTreeMessagedClient(id_); } void WindowTree::ProcessWillChangeWindowVisibility(const ServerWindow* window, @@ -586,11 +585,11 @@ void WindowTree::ProcessTransientWindowRemoved( } DisplayManager* WindowTree::display_manager() { - return connection_manager_->display_manager(); + return window_server_->display_manager(); } const DisplayManager* WindowTree::display_manager() const { - return connection_manager_->display_manager(); + return window_server_->display_manager(); } Display* WindowTree::GetDisplayForWindowManager() { @@ -639,7 +638,7 @@ bool WindowTree::ShouldRouteToWindowManager(const ServerWindow* window) const { void WindowTree::ProcessLostCapture(const ServerWindow* old_capture_window, bool originated_change) { if ((originated_change && - connection_manager_->current_operation_type() == + window_server_->current_operation_type() == OperationType::RELEASE_CAPTURE) || !IsWindowKnown(old_capture_window)) { return; @@ -693,7 +692,7 @@ bool WindowTree::CanReorderWindow(const ServerWindow* window, bool WindowTree::DeleteWindowImpl(WindowTree* source, ServerWindow* window) { DCHECK(window); DCHECK_EQ(window->id().connection_id, id_); - Operation op(source, connection_manager_, OperationType::DELETE_WINDOW); + Operation op(source, window_server_, OperationType::DELETE_WINDOW); delete window; return true; } @@ -761,7 +760,7 @@ void WindowTree::RemoveRoot(const ServerWindow* window, if (reason == RemoveRootReason::EMBED) { client()->OnUnembed(client_window_id.id); client()->OnWindowDeleted(client_window_id.id); - connection_manager_->OnTreeMessagedClient(id_); + window_server_->OnTreeMessagedClient(id_); } // This connection no longer knows about the window. Unparent any windows that @@ -799,7 +798,7 @@ mojom::WindowDataPtr WindowTree::WindowToWindowData( window_data->visible = window->visible(); window_data->drawn = window->IsDrawn(); window_data->viewport_metrics = - connection_manager_->GetViewportMetricsForWindow(window); + window_server_->GetViewportMetricsForWindow(window); return window_data; } @@ -840,7 +839,7 @@ void WindowTree::DestroyWindows() { if (created_window_map_.empty()) return; - Operation op(this, connection_manager_, OperationType::DELETE_WINDOW); + Operation op(this, window_server_, OperationType::DELETE_WINDOW); // If we get here from the destructor we're not going to get // ProcessWindowDeleted(). Copy the map and delete from the copy so that we // don't have to worry about whether |created_window_map_| changes or not. @@ -865,13 +864,13 @@ void WindowTree::PrepareForEmbed(ServerWindow* window) { DCHECK(window); // Only allow a node to be the root for one connection. - WindowTree* existing_owner = connection_manager_->GetTreeWithRoot(window); + WindowTree* existing_owner = window_server_->GetTreeWithRoot(window); - Operation op(this, connection_manager_, OperationType::EMBED); + Operation op(this, window_server_, OperationType::EMBED); RemoveChildrenAsPartOfEmbed(window); if (existing_owner) { // Never message the originating connection. - connection_manager_->OnTreeMessagedClient(id_); + window_server_->OnTreeMessagedClient(id_); existing_owner->RemoveRoot(window, RemoveRootReason::EMBED); } } @@ -939,7 +938,7 @@ void WindowTree::NewTopLevelWindow( binding_->SetIncomingMethodCallProcessingPaused(true); const uint32_t wm_change_id = - connection_manager_->GenerateWindowManagerChangeId(this, change_id); + window_server_->GenerateWindowManagerChangeId(this, change_id); waiting_for_top_level_window_info_.reset( new WaitingForTopLevelWindowInfo(client_window_id, wm_change_id)); @@ -956,7 +955,7 @@ void WindowTree::DeleteWindow(uint32_t change_id, Id transport_window_id) { ShouldRouteToWindowManager(window)); if (should_close) { WindowTree* tree = - connection_manager_->GetTreeWithId(window->id().connection_id); + window_server_->GetTreeWithId(window->id().connection_id); success = tree && tree->DeleteWindowImpl(this, window); } client()->OnChangeCompleted(change_id, success); @@ -973,7 +972,7 @@ void WindowTree::RemoveWindowFromParent(uint32_t change_id, Id window_id) { if (window && window->parent() && access_policy_->CanRemoveWindowFromParent(window)) { success = true; - Operation op(this, connection_manager_, + Operation op(this, window_server_, OperationType::REMOVE_WINDOW_FROM_PARENT); window->parent()->Remove(window); } @@ -996,7 +995,7 @@ void WindowTree::RemoveTransientWindowFromParent(uint32_t change_id, if (transient_window && transient_window->transient_parent() && access_policy_->CanRemoveTransientWindowFromParent(transient_window)) { success = true; - Operation op(this, connection_manager_, + Operation op(this, window_server_, OperationType::REMOVE_TRANSIENT_WINDOW_FROM_PARENT); transient_window->transient_parent()->RemoveTransientWindow( transient_window); @@ -1018,10 +1017,9 @@ void WindowTree::ReorderWindow(uint32_t change_id, GetWindowByClientId(ClientWindowId(relative_window_id)); if (CanReorderWindow(window, relative_window, direction)) { success = true; - Operation op(this, connection_manager_, OperationType::REORDER_WINDOW); + Operation op(this, window_server_, OperationType::REORDER_WINDOW); window->Reorder(relative_window, direction); - connection_manager_->ProcessWindowReorder(window, relative_window, - direction); + window_server_->ProcessWindowReorder(window, relative_window, direction); } client()->OnChangeCompleted(change_id, success); } @@ -1047,7 +1045,7 @@ void WindowTree::ReleaseCapture(uint32_t change_id, Id window_id) { access_policy_->CanSetCapture(current_capture_window)) && window == current_capture_window; if (success) { - Operation op(this, connection_manager_, OperationType::RELEASE_CAPTURE); + Operation op(this, window_server_, OperationType::RELEASE_CAPTURE); success = wms->SetCapture(nullptr, false); } client()->OnChangeCompleted(change_id, success); @@ -1059,7 +1057,7 @@ void WindowTree::SetWindowBounds(uint32_t change_id, ServerWindow* window = GetWindowByClientId(ClientWindowId(window_id)); if (window && ShouldRouteToWindowManager(window)) { const uint32_t wm_change_id = - connection_manager_->GenerateWindowManagerChangeId(this, change_id); + window_server_->GenerateWindowManagerChangeId(this, change_id); // |window_id| may be a client id, use the id from the window to ensure // the windowmanager doesn't get an id it doesn't know about. WindowManagerState* wms = display_manager() @@ -1074,7 +1072,7 @@ void WindowTree::SetWindowBounds(uint32_t change_id, // Only the owner of the window can change the bounds. bool success = window && access_policy_->CanSetWindowBounds(window); if (success) { - Operation op(this, connection_manager_, OperationType::SET_WINDOW_BOUNDS); + Operation op(this, window_server_, OperationType::SET_WINDOW_BOUNDS); window->SetBounds(bounds.To<gfx::Rect>()); } client()->OnChangeCompleted(change_id, success); @@ -1096,7 +1094,7 @@ void WindowTree::SetWindowProperty(uint32_t change_id, GetWindowByClientId(ClientWindowId(transport_window_id)); if (window && ShouldRouteToWindowManager(window)) { const uint32_t wm_change_id = - connection_manager_->GenerateWindowManagerChangeId(this, change_id); + window_server_->GenerateWindowManagerChangeId(this, change_id); WindowManagerState* wms = display_manager() ->GetWindowManagerAndDisplay(window) .window_manager_state; @@ -1107,7 +1105,7 @@ void WindowTree::SetWindowProperty(uint32_t change_id, } const bool success = window && access_policy_->CanSetWindowProperties(window); if (success) { - Operation op(this, connection_manager_, OperationType::SET_WINDOW_PROPERTY); + Operation op(this, window_server_, OperationType::SET_WINDOW_PROPERTY); if (value.is_null()) { window->SetProperty(name, nullptr); } else { @@ -1215,7 +1213,7 @@ void WindowTree::SetFocus(uint32_t change_id, Id transport_window_id) { const bool success = window && window->IsDrawn() && window->can_focus() && access_policy_->CanSetFocus(window) && display; if (success) { - Operation op(this, connection_manager_, OperationType::SET_FOCUS); + Operation op(this, window_server_, OperationType::SET_FOCUS); display->SetFocusedWindow(window); } client()->OnChangeCompleted(change_id, success); @@ -1239,7 +1237,7 @@ void WindowTree::SetPredefinedCursor(uint32_t change_id, // Only the owner of the window can change the bounds. bool success = window && access_policy_->CanSetCursorProperties(window); if (success) { - Operation op(this, connection_manager_, + Operation op(this, window_server_, OperationType::SET_WINDOW_PREDEFINED_CURSOR); window->SetPredefinedCursor(cursor_id); } @@ -1314,7 +1312,7 @@ void WindowTree::SetUnderlaySurfaceOffsetAndExtendedHitArea( void WindowTree::WmResponse(uint32_t change_id, bool response) { // TODO(sky): think about what else case means. if (GetDisplayForWindowManager()) - connection_manager_->WindowManagerChangeCompleted(change_id, response); + window_server_->WindowManagerChangeCompleted(change_id, response); } void WindowTree::WmRequestClose(Id transport_window_id) { @@ -1325,7 +1323,7 @@ void WindowTree::WmRequestClose(Id transport_window_id) { ServerWindow* window = GetWindowByClientId(ClientWindowId(transport_window_id)); - WindowTree* tree = connection_manager_->GetTreeWithRoot(window); + WindowTree* tree = window_server_->GetTreeWithRoot(window); if (tree && tree != this) { tree->client()->RequestClose(tree->ClientWindowIdForWindow(window).id); } @@ -1345,11 +1343,10 @@ void WindowTree::OnWmCreatedTopLevelWindow(uint32_t change_id, ServerWindow* window = GetWindowByClientId(ClientWindowId(transport_window_id)); if (window && window->id().connection_id != id_) { - connection_manager_->WindowManagerSentBogusMessage(); + window_server_->WindowManagerSentBogusMessage(); window = nullptr; } - connection_manager_->WindowManagerCreatedTopLevelWindow(this, change_id, - window); + window_server_->WindowManagerCreatedTopLevelWindow(this, change_id, window); } // TODO(sky): think about what else case means. } @@ -1365,7 +1362,7 @@ bool WindowTree::IsWindowKnownForAccessPolicy( bool WindowTree::IsWindowRootOfAnotherTreeForAccessPolicy( const ServerWindow* window) const { - WindowTree* tree = connection_manager_->GetTreeWithRoot(window); + WindowTree* tree = window_server_->GetTreeWithRoot(window); return tree && tree != this; } diff --git a/components/mus/ws/window_tree.h b/components/mus/ws/window_tree.h index e21aa3b..95989a8 100644 --- a/components/mus/ws/window_tree.h +++ b/components/mus/ws/window_tree.h @@ -37,12 +37,12 @@ namespace mus { namespace ws { class AccessPolicy; -class ConnectionManager; class DisplayManager; class Display; class ServerWindow; class TargetedEvent; class WindowManagerState; +class WindowServer; class WindowTreeTest; namespace test { @@ -62,7 +62,7 @@ class WindowTree : public mojom::WindowTree, public AccessPolicyDelegate, public mojom::WindowManagerClient { public: - WindowTree(ConnectionManager* connection_manager, + WindowTree(WindowServer* window_server, const UserId& user_id, ServerWindow* root, scoped_ptr<AccessPolicy> access_policy); @@ -390,11 +390,11 @@ class WindowTree : public mojom::WindowTree, bool IsWindowRootOfAnotherTreeForAccessPolicy( const ServerWindow* window) const override; - ConnectionManager* connection_manager_; + WindowServer* window_server_; const UserId user_id_; - // Id of this tree as assigned by ConnectionManager. + // Id of this tree as assigned by WindowServer. const ConnectionSpecificId id_; ConnectionSpecificId next_window_id_; diff --git a/components/mus/ws/window_tree_binding.cc b/components/mus/ws/window_tree_binding.cc index 2eaae79..351758c 100644 --- a/components/mus/ws/window_tree_binding.cc +++ b/components/mus/ws/window_tree_binding.cc @@ -5,7 +5,7 @@ #include "components/mus/ws/window_tree_binding.h" #include "base/bind.h" -#include "components/mus/ws/connection_manager.h" +#include "components/mus/ws/window_server.h" #include "components/mus/ws/window_tree.h" namespace mus { @@ -18,25 +18,25 @@ WindowTreeBinding::~WindowTreeBinding() {} DefaultWindowTreeBinding::DefaultWindowTreeBinding( WindowTree* tree, - ConnectionManager* connection_manager, + WindowServer* window_server, mojom::WindowTreeRequest service_request, mojom::WindowTreeClientPtr client) : WindowTreeBinding(client.get()), - connection_manager_(connection_manager), + window_server_(window_server), binding_(tree, std::move(service_request)), client_(std::move(client)) { - // Both |connection_manager| and |tree| outlive us. + // Both |window_server| and |tree| outlive us. binding_.set_connection_error_handler( - base::Bind(&ConnectionManager::DestroyTree, - base::Unretained(connection_manager), base::Unretained(tree))); + base::Bind(&WindowServer::DestroyTree, base::Unretained(window_server), + base::Unretained(tree))); } DefaultWindowTreeBinding::DefaultWindowTreeBinding( WindowTree* tree, - ConnectionManager* connection_manager, + WindowServer* window_server, mojom::WindowTreeClientPtr client) : WindowTreeBinding(client.get()), - connection_manager_(connection_manager), + window_server_(window_server), binding_(tree), client_(std::move(client)) {} diff --git a/components/mus/ws/window_tree_binding.h b/components/mus/ws/window_tree_binding.h index cfe0f92..53cfbf7 100644 --- a/components/mus/ws/window_tree_binding.h +++ b/components/mus/ws/window_tree_binding.h @@ -13,7 +13,7 @@ namespace mus { namespace ws { -class ConnectionManager; +class WindowServer; class WindowTree; // WindowTreeBinding manages the binding between a WindowTree and its mojo @@ -41,11 +41,11 @@ class WindowTreeBinding { class DefaultWindowTreeBinding : public WindowTreeBinding { public: DefaultWindowTreeBinding(WindowTree* tree, - ConnectionManager* connection_manager, + WindowServer* window_server, mojom::WindowTreeRequest service_request, mojom::WindowTreeClientPtr client); DefaultWindowTreeBinding(WindowTree* tree, - ConnectionManager* connection_manager, + WindowServer* window_server, mojom::WindowTreeClientPtr client); ~DefaultWindowTreeBinding() override; @@ -58,7 +58,7 @@ class DefaultWindowTreeBinding : public WindowTreeBinding { void SetIncomingMethodCallProcessingPaused(bool paused) override; private: - ConnectionManager* connection_manager_; + WindowServer* window_server_; mojo::Binding<mojom::WindowTree> binding_; mojom::WindowTreeClientPtr client_; mojom::WindowManagerAssociatedPtr window_manager_internal_; diff --git a/components/mus/ws/window_tree_factory.cc b/components/mus/ws/window_tree_factory.cc index 53f1bba..4d2552c 100644 --- a/components/mus/ws/window_tree_factory.cc +++ b/components/mus/ws/window_tree_factory.cc @@ -4,17 +4,17 @@ #include "components/mus/ws/window_tree_factory.h" -#include "components/mus/ws/connection_manager.h" #include "components/mus/ws/default_access_policy.h" +#include "components/mus/ws/window_server.h" #include "components/mus/ws/window_tree.h" #include "components/mus/ws/window_tree_binding.h" namespace mus { namespace ws { -WindowTreeFactory::WindowTreeFactory(ConnectionManager* connection_manager, +WindowTreeFactory::WindowTreeFactory(WindowServer* window_server, const UserId& user_id) - : connection_manager_(connection_manager), user_id_(user_id) {} + : window_server_(window_server), user_id_(user_id) {} WindowTreeFactory::~WindowTreeFactory() {} @@ -27,13 +27,13 @@ void WindowTreeFactory::CreateWindowTree( mojo::InterfaceRequest<mojom::WindowTree> tree_request, mojom::WindowTreeClientPtr client) { scoped_ptr<ws::WindowTree> service( - new ws::WindowTree(connection_manager_, user_id_, nullptr, + new ws::WindowTree(window_server_, user_id_, nullptr, make_scoped_ptr(new DefaultAccessPolicy))); scoped_ptr<ws::DefaultWindowTreeBinding> binding( - new ws::DefaultWindowTreeBinding(service.get(), connection_manager_, + new ws::DefaultWindowTreeBinding(service.get(), window_server_, std::move(tree_request), std::move(client))); - connection_manager_->AddTree(std::move(service), std::move(binding), nullptr); + window_server_->AddTree(std::move(service), std::move(binding), nullptr); } } // namespace ws diff --git a/components/mus/ws/window_tree_factory.h b/components/mus/ws/window_tree_factory.h index fcc2862..5ace24f 100644 --- a/components/mus/ws/window_tree_factory.h +++ b/components/mus/ws/window_tree_factory.h @@ -13,12 +13,11 @@ namespace mus { namespace ws { -class ConnectionManager; +class WindowServer; class WindowTreeFactory : public mus::mojom::WindowTreeFactory { public: - WindowTreeFactory(ConnectionManager* connection_manager, - const UserId& user_id); + WindowTreeFactory(WindowServer* window_server, const UserId& user_id); ~WindowTreeFactory() override; void AddBinding( @@ -29,7 +28,7 @@ class WindowTreeFactory : public mus::mojom::WindowTreeFactory { mojom::WindowTreeClientPtr client) override; private: - ConnectionManager* connection_manager_; + WindowServer* window_server_; const UserId user_id_; mojo::BindingSet<mus::mojom::WindowTreeFactory> binding_; diff --git a/components/mus/ws/window_tree_host_factory.cc b/components/mus/ws/window_tree_host_factory.cc index c8886b7..9e629e2 100644 --- a/components/mus/ws/window_tree_host_factory.cc +++ b/components/mus/ws/window_tree_host_factory.cc @@ -6,18 +6,18 @@ #include "components/mus/gles2/gpu_state.h" #include "components/mus/surfaces/surfaces_state.h" -#include "components/mus/ws/connection_manager.h" #include "components/mus/ws/display.h" #include "components/mus/ws/display_binding.h" +#include "components/mus/ws/window_server.h" namespace mus { namespace ws { WindowTreeHostFactory::WindowTreeHostFactory( - ConnectionManager* connection_manager, + WindowServer* window_server, const UserId& user_id, const PlatformDisplayInitParams& platform_display_init_params) - : connection_manager_(connection_manager), + : window_server_(window_server), user_id_(user_id), platform_display_init_params_(platform_display_init_params) {} @@ -31,11 +31,10 @@ void WindowTreeHostFactory::AddBinding( void WindowTreeHostFactory::CreateWindowTreeHost( mojom::WindowTreeHostRequest host, mojom::WindowTreeClientPtr tree_client) { - Display* display = - new Display(connection_manager_, platform_display_init_params_); + Display* display = new Display(window_server_, platform_display_init_params_); scoped_ptr<DisplayBindingImpl> display_binding( new DisplayBindingImpl(std::move(host), display, user_id_, - std::move(tree_client), connection_manager_)); + std::move(tree_client), window_server_)); display->Init(std::move(display_binding)); } diff --git a/components/mus/ws/window_tree_host_factory.h b/components/mus/ws/window_tree_host_factory.h index 51090c8..3df36ee 100644 --- a/components/mus/ws/window_tree_host_factory.h +++ b/components/mus/ws/window_tree_host_factory.h @@ -15,12 +15,12 @@ namespace mus { namespace ws { -class ConnectionManager; +class WindowServer; class WindowTreeHostFactory : public mojom::WindowTreeHostFactory { public: WindowTreeHostFactory( - ConnectionManager* connection_manager, + WindowServer* window_server, const UserId& user_id, const PlatformDisplayInitParams& platform_display_init_params); ~WindowTreeHostFactory() override; @@ -32,7 +32,7 @@ class WindowTreeHostFactory : public mojom::WindowTreeHostFactory { void CreateWindowTreeHost(mojom::WindowTreeHostRequest host, mojom::WindowTreeClientPtr tree_client) override; - ConnectionManager* connection_manager_; + WindowServer* window_server_; const UserId user_id_; const PlatformDisplayInitParams platform_display_init_params_; mojo::BindingSet<mojom::WindowTreeHostFactory> bindings_; diff --git a/components/mus/ws/window_tree_unittest.cc b/components/mus/ws/window_tree_unittest.cc index 01c8e26..aaccfeb 100644 --- a/components/mus/ws/window_tree_unittest.cc +++ b/components/mus/ws/window_tree_unittest.cc @@ -14,8 +14,6 @@ #include "components/mus/common/util.h" #include "components/mus/public/interfaces/window_tree.mojom.h" #include "components/mus/surfaces/surfaces_state.h" -#include "components/mus/ws/connection_manager.h" -#include "components/mus/ws/connection_manager_delegate.h" #include "components/mus/ws/default_access_policy.h" #include "components/mus/ws/display_binding.h" #include "components/mus/ws/ids.h" @@ -27,6 +25,8 @@ #include "components/mus/ws/test_change_tracker.h" #include "components/mus/ws/test_utils.h" #include "components/mus/ws/window_manager_access_policy.h" +#include "components/mus/ws/window_server.h" +#include "components/mus/ws/window_server_delegate.h" #include "components/mus/ws/window_tree.h" #include "components/mus/ws/window_tree_binding.h" #include "mojo/converters/geometry/geometry_type_converters.h" @@ -100,21 +100,21 @@ class TestWindowManager : public mojom::WindowManager { class TestDisplayBinding : public DisplayBinding { public: - TestDisplayBinding(Display* display, ConnectionManager* manager) - : display_(display), connection_manager_(manager) {} + TestDisplayBinding(Display* display, WindowServer* window_server) + : display_(display), window_server_(window_server) {} ~TestDisplayBinding() override {} private: // DisplayBinding: WindowTree* CreateWindowTree(ServerWindow* root) override { - return connection_manager_->EmbedAtWindow( + return window_server_->EmbedAtWindow( root, mojo::shell::mojom::kRootUserID, mus::mojom::WindowTreeClientPtr(), make_scoped_ptr(new WindowManagerAccessPolicy)); } Display* display_; - ConnectionManager* connection_manager_; + WindowServer* window_server_; DISALLOW_COPY_AND_ASSIGN(TestDisplayBinding); }; @@ -177,7 +177,7 @@ class WindowTreeTest : public testing::Test { ~WindowTreeTest() override {} // WindowTree for the window manager. - WindowTree* wm_tree() { return connection_manager_->GetTreeWithId(1); } + WindowTree* wm_tree() { return window_server_->GetTreeWithId(1); } TestWindowTreeClient* last_window_tree_client() { return delegate_.last_client(); @@ -185,10 +185,10 @@ class WindowTreeTest : public testing::Test { TestWindowTreeBinding* last_binding() { return delegate_.last_binding(); } - ConnectionManager* connection_manager() { return connection_manager_.get(); } + WindowServer* window_server() { return window_server_.get(); } ServerWindow* GetWindowById(const WindowId& id) { - return connection_manager_->GetWindow(id); + return window_server_->GetWindow(id); } TestWindowTreeClient* wm_client() { return wm_client_; } @@ -226,12 +226,11 @@ class WindowTreeTest : public testing::Test { // a WindowTreeFactory does. WindowTree* CreateNewTree(const UserId& user_id, TestWindowTreeBinding** binding) { - WindowTree* tree = - new WindowTree(connection_manager_.get(), user_id, nullptr, - make_scoped_ptr(new DefaultAccessPolicy)); + WindowTree* tree = new WindowTree(window_server_.get(), user_id, nullptr, + make_scoped_ptr(new DefaultAccessPolicy)); *binding = new TestWindowTreeBinding; - connection_manager_->AddTree(make_scoped_ptr(tree), - make_scoped_ptr(*binding), nullptr); + window_server_->AddTree(make_scoped_ptr(tree), make_scoped_ptr(*binding), + nullptr); return tree; } @@ -239,13 +238,11 @@ class WindowTreeTest : public testing::Test { // testing::Test: void SetUp() override { PlatformDisplay::set_factory_for_testing(&platform_display_factory_); - connection_manager_.reset( - new ConnectionManager(&delegate_, surfaces_state_)); + window_server_.reset(new WindowServer(&delegate_, surfaces_state_)); PlatformDisplayInitParams display_init_params; display_init_params.surfaces_state = surfaces_state_; - display_ = new Display(connection_manager_.get(), display_init_params); - display_binding_ = - new TestDisplayBinding(display_, connection_manager_.get()); + display_ = new Display(window_server_.get(), display_init_params); + display_binding_ = new TestDisplayBinding(display_, window_server_.get()); display_->Init(make_scoped_ptr(display_binding_)); wm_client_ = delegate_.last_client(); } @@ -255,12 +252,12 @@ class WindowTreeTest : public testing::Test { TestWindowTreeClient* wm_client_; int32_t cursor_id_; TestPlatformDisplayFactory platform_display_factory_; - TestConnectionManagerDelegate delegate_; - // Owned by ConnectionManager. + TestWindowServerDelegate delegate_; + // Owned by WindowServer. TestDisplayBinding* display_binding_; Display* display_ = nullptr; scoped_refptr<SurfacesState> surfaces_state_; - scoped_ptr<ConnectionManager> connection_manager_; + scoped_ptr<WindowServer> window_server_; base::MessageLoop message_loop_; DISALLOW_COPY_AND_ASSIGN(WindowTreeTest); @@ -283,7 +280,7 @@ void WindowTreeTest::SetupEventTargeting(TestWindowTreeClient** out_client, wm_client()->Bind(std::move(client_request)); wm_tree()->Embed(embed_window_id, std::move(client)); ServerWindow* embed_window = wm_tree()->GetWindowByClientId(embed_window_id); - WindowTree* tree1 = connection_manager()->GetTreeWithRoot(embed_window); + WindowTree* tree1 = window_server()->GetTreeWithRoot(embed_window); ASSERT_TRUE(tree1 != nullptr); ASSERT_NE(tree1, wm_tree()); @@ -326,7 +323,7 @@ TEST_F(WindowTreeTest, FocusOnPointer) { mojom::WindowTreeClientRequest client_request = GetProxy(&client); wm_client()->Bind(std::move(client_request)); wm_tree()->Embed(embed_window_id, std::move(client)); - WindowTree* tree1 = connection_manager()->GetTreeWithRoot(embed_window); + WindowTree* tree1 = window_server()->GetTreeWithRoot(embed_window); ASSERT_TRUE(tree1 != nullptr); ASSERT_NE(tree1, wm_tree()); |