| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 void OnStart() override { | 55 void OnStart() override { |
| 56 CHECK(!started_); | 56 CHECK(!started_); |
| 57 started_ = true; | 57 started_ = true; |
| 58 test_screen_ = base::MakeUnique<display::test::TestScreen>(); | 58 test_screen_ = base::MakeUnique<display::test::TestScreen>(); |
| 59 display::Screen::SetScreenInstance(test_screen_.get()); | 59 display::Screen::SetScreenInstance(test_screen_.get()); |
| 60 aura_env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); | 60 aura_env_ = aura::Env::CreateInstance(aura::Env::Mode::MUS); |
| 61 gpu_service_ = ui::GpuService::Create(context()->connector(), nullptr); | 61 gpu_service_ = ui::GpuService::Create(context()->connector(), nullptr); |
| 62 compositor_context_factory_ = | 62 compositor_context_factory_ = |
| 63 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get()); | 63 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get()); |
| 64 aura_env_->set_context_factory(compositor_context_factory_.get()); | 64 aura_env_->set_context_factory(compositor_context_factory_.get()); |
| 65 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>(this, this); | 65 window_tree_client_ = base::MakeUnique<aura::WindowTreeClient>( |
| 66 context()->connector(), this, this); |
| 66 aura_env_->SetWindowTreeClient(window_tree_client_.get()); | 67 aura_env_->SetWindowTreeClient(window_tree_client_.get()); |
| 67 window_tree_client_->ConnectAsWindowManager(context()->connector()); | 68 window_tree_client_->ConnectAsWindowManager(); |
| 68 } | 69 } |
| 69 | 70 |
| 70 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 71 bool OnConnect(const service_manager::ServiceInfo& remote_info, |
| 71 service_manager::InterfaceRegistry* registry) override { | 72 service_manager::InterfaceRegistry* registry) override { |
| 72 return false; | 73 return false; |
| 73 } | 74 } |
| 74 | 75 |
| 75 // aura::WindowTreeClientDelegate: | 76 // aura::WindowTreeClientDelegate: |
| 76 void OnEmbed( | 77 void OnEmbed( |
| 77 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override { | 78 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 SetWindowType(window, window_type); | 120 SetWindowType(window, window_type); |
| 120 window->Init(LAYER_NOT_DRAWN); | 121 window->Init(LAYER_NOT_DRAWN); |
| 121 window->SetBounds(gfx::Rect(10, 10, 500, 500)); | 122 window->SetBounds(gfx::Rect(10, 10, 500, 500)); |
| 122 root_->AddChild(window); | 123 root_->AddChild(window); |
| 123 return window; | 124 return window; |
| 124 } | 125 } |
| 125 void OnWmClientJankinessChanged(const std::set<aura::Window*>& client_windows, | 126 void OnWmClientJankinessChanged(const std::set<aura::Window*>& client_windows, |
| 126 bool janky) override { | 127 bool janky) override { |
| 127 // Don't care. | 128 // Don't care. |
| 128 } | 129 } |
| 130 void OnWmWillCreateDisplay(const display::Display& display) override {} |
| 129 void OnWmNewDisplay(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, | 131 void OnWmNewDisplay(std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, |
| 130 const display::Display& display) override { | 132 const display::Display& display) override { |
| 131 // Only handles a single root. | 133 // Only handles a single root. |
| 132 DCHECK(!root_); | 134 DCHECK(!root_); |
| 133 window_tree_host_ = std::move(window_tree_host); | 135 window_tree_host_ = std::move(window_tree_host); |
| 134 root_ = window_tree_host_->window(); | 136 root_ = window_tree_host_->window(); |
| 135 DCHECK(window_manager_client_); | 137 DCHECK(window_manager_client_); |
| 136 window_manager_client_->AddActivationParent(root_); | 138 window_manager_client_->AddActivationParent(root_); |
| 137 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = | 139 ui::mojom::FrameDecorationValuesPtr frame_decoration_values = |
| 138 ui::mojom::FrameDecorationValues::New(); | 140 ui::mojom::FrameDecorationValues::New(); |
| 139 frame_decoration_values->max_title_bar_button_width = 0; | 141 frame_decoration_values->max_title_bar_button_width = 0; |
| 140 window_manager_client_->SetFrameDecorationValues( | 142 window_manager_client_->SetFrameDecorationValues( |
| 141 std::move(frame_decoration_values)); | 143 std::move(frame_decoration_values)); |
| 142 aura::client::SetFocusClient(root_, &focus_client_); | 144 aura::client::SetFocusClient(root_, &focus_client_); |
| 143 } | 145 } |
| 144 void OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) override { | 146 void OnWmDisplayRemoved(aura::WindowTreeHostMus* window_tree_host) override { |
| 145 DCHECK_EQ(window_tree_host, window_tree_host_.get()); | 147 DCHECK_EQ(window_tree_host, window_tree_host_.get()); |
| 146 root_ = nullptr; | 148 root_ = nullptr; |
| 147 window_tree_host_.reset(); | 149 window_tree_host_.reset(); |
| 148 } | 150 } |
| 149 void OnWmDisplayModified(const display::Display& display) override {} | 151 void OnWmDisplayModified(const display::Display& display) override {} |
| 150 void OnWmPerformMoveLoop(aura::Window* window, | 152 void OnWmPerformMoveLoop(aura::Window* window, |
| 151 mojom::MoveLoopSource source, | 153 mojom::MoveLoopSource source, |
| 152 const gfx::Point& cursor_location, | 154 const gfx::Point& cursor_location, |
| 153 const base::Callback<void(bool)>& on_done) override { | 155 const base::Callback<void(bool)>& on_done) override { |
| 154 // Don't care. | 156 // Don't care. |
| 155 } | 157 } |
| 156 void OnWmCancelMoveLoop(aura::Window* window) override {} | 158 void OnWmCancelMoveLoop(aura::Window* window) override {} |
| 159 void OnWmSetClientArea( |
| 160 aura::Window* window, |
| 161 const gfx::Insets& insets, |
| 162 const std::vector<gfx::Rect>& additional_client_areas) override {} |
| 157 | 163 |
| 158 // Dummy screen required to be the screen instance. | 164 // Dummy screen required to be the screen instance. |
| 159 std::unique_ptr<display::test::TestScreen> test_screen_; | 165 std::unique_ptr<display::test::TestScreen> test_screen_; |
| 160 | 166 |
| 161 std::unique_ptr<aura::Env> aura_env_; | 167 std::unique_ptr<aura::Env> aura_env_; |
| 162 ::wm::WMState wm_state_; | 168 ::wm::WMState wm_state_; |
| 163 aura::PropertyConverter property_converter_; | 169 aura::PropertyConverter property_converter_; |
| 164 aura::test::TestFocusClient focus_client_; | 170 aura::test::TestFocusClient focus_client_; |
| 165 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_; | 171 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_; |
| 166 aura::Window* root_ = nullptr; | 172 aura::Window* root_ = nullptr; |
| 167 aura::WindowManagerClient* window_manager_client_ = nullptr; | 173 aura::WindowManagerClient* window_manager_client_ = nullptr; |
| 168 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; | 174 std::unique_ptr<aura::WindowTreeClient> window_tree_client_; |
| 169 std::unique_ptr<ui::GpuService> gpu_service_; | 175 std::unique_ptr<ui::GpuService> gpu_service_; |
| 170 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_; | 176 std::unique_ptr<aura::MusContextFactory> compositor_context_factory_; |
| 171 | 177 |
| 172 bool started_ = false; | 178 bool started_ = false; |
| 173 | 179 |
| 174 DISALLOW_COPY_AND_ASSIGN(TestWM); | 180 DISALLOW_COPY_AND_ASSIGN(TestWM); |
| 175 }; | 181 }; |
| 176 | 182 |
| 177 } // namespace test | 183 } // namespace test |
| 178 } // namespace ui | 184 } // namespace ui |
| 179 | 185 |
| 180 MojoResult ServiceMain(MojoHandle service_request_handle) { | 186 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 181 service_manager::ServiceRunner runner(new ui::test::TestWM); | 187 service_manager::ServiceRunner runner(new ui::test::TestWM); |
| 182 return runner.Run(service_request_handle); | 188 return runner.Run(service_request_handle); |
| 183 } | 189 } |
| OLD | NEW |