| 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 "components/mus/public/cpp/window.h" | 5 #include "components/mus/public/cpp/window.h" |
| 6 #include "components/mus/public/cpp/window_manager_delegate.h" | 6 #include "components/mus/public/cpp/window_manager_delegate.h" |
| 7 #include "components/mus/public/cpp/window_tree_connection.h" | 7 #include "components/mus/public/cpp/window_tree_client.h" |
| 8 #include "components/mus/public/cpp/window_tree_delegate.h" | 8 #include "components/mus/public/cpp/window_tree_client_delegate.h" |
| 9 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" | 9 #include "components/mus/public/interfaces/window_manager_factory.mojom.h" |
| 10 #include "mojo/public/c/system/main.h" | 10 #include "mojo/public/c/system/main.h" |
| 11 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
| 12 #include "services/shell/public/cpp/application_runner.h" | 12 #include "services/shell/public/cpp/application_runner.h" |
| 13 #include "services/shell/public/cpp/connector.h" | 13 #include "services/shell/public/cpp/connector.h" |
| 14 #include "services/shell/public/cpp/shell_client.h" | 14 #include "services/shell/public/cpp/shell_client.h" |
| 15 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
| 16 #include "ui/gfx/geometry/mojo/geometry_type_converters.h" | 16 #include "ui/gfx/geometry/mojo/geometry_type_converters.h" |
| 17 #include "ui/mojo/display/display_type_converters.h" | 17 #include "ui/mojo/display/display_type_converters.h" |
| 18 | 18 |
| 19 namespace mus { | 19 namespace mus { |
| 20 namespace test { | 20 namespace test { |
| 21 | 21 |
| 22 class TestWM : public shell::ShellClient, | 22 class TestWM : public shell::ShellClient, |
| 23 public mus::mojom::WindowManagerFactory, | 23 public mus::mojom::WindowManagerFactory, |
| 24 public mus::WindowTreeDelegate, | 24 public mus::WindowTreeClientDelegate, |
| 25 public mus::WindowManagerDelegate { | 25 public mus::WindowManagerDelegate { |
| 26 public: | 26 public: |
| 27 TestWM() : window_manager_factory_binding_(this) {} | 27 TestWM() : window_manager_factory_binding_(this) {} |
| 28 ~TestWM() override {} | 28 ~TestWM() override {} |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 // shell::ShellClient: | 31 // shell::ShellClient: |
| 32 void Initialize(shell::Connector* connector, | 32 void Initialize(shell::Connector* connector, |
| 33 const shell::Identity& identity, | 33 const shell::Identity& identity, |
| 34 uint32_t id) override { | 34 uint32_t id) override { |
| 35 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; | 35 mus::mojom::WindowManagerFactoryServicePtr wm_factory_service; |
| 36 connector->ConnectToInterface("mojo:mus", &wm_factory_service); | 36 connector->ConnectToInterface("mojo:mus", &wm_factory_service); |
| 37 wm_factory_service->SetWindowManagerFactory( | 37 wm_factory_service->SetWindowManagerFactory( |
| 38 window_manager_factory_binding_.CreateInterfacePtrAndBind()); | 38 window_manager_factory_binding_.CreateInterfacePtrAndBind()); |
| 39 } | 39 } |
| 40 bool AcceptConnection(shell::Connection* connection) override { | 40 bool AcceptConnection(shell::Connection* connection) override { |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // mus::mojom::WindowManagerFactory: | 44 // mus::mojom::WindowManagerFactory: |
| 45 void CreateWindowManager( | 45 void CreateWindowManager( |
| 46 mus::mojom::DisplayPtr display, | 46 mus::mojom::DisplayPtr display, |
| 47 mus::mojom::WindowTreeClientRequest request) override { | 47 mus::mojom::WindowTreeClientRequest request) override { |
| 48 mus::WindowTreeConnection::CreateForWindowManager( | 48 new mus::WindowTreeClient(this, this, std::move(request)); |
| 49 this, std::move(request), | |
| 50 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED, this); | |
| 51 } | 49 } |
| 52 | 50 |
| 53 // mus::WindowTreeDelegate: | 51 // mus::WindowTreeClientDelegate: |
| 54 void OnEmbed(mus::Window* root) override { | 52 void OnEmbed(mus::Window* root) override { |
| 55 root_ = root; | 53 root_ = root; |
| 56 window_manager_client_->AddActivationParent(root_); | 54 window_manager_client_->AddActivationParent(root_); |
| 57 mus::mojom::FrameDecorationValuesPtr frame_decoration_values = | 55 mus::mojom::FrameDecorationValuesPtr frame_decoration_values = |
| 58 mus::mojom::FrameDecorationValues::New(); | 56 mus::mojom::FrameDecorationValues::New(); |
| 59 frame_decoration_values->normal_client_area_insets = | 57 frame_decoration_values->normal_client_area_insets = |
| 60 mojo::Insets::From(gfx::Insets()); | 58 mojo::Insets::From(gfx::Insets()); |
| 61 frame_decoration_values->maximized_client_area_insets = | 59 frame_decoration_values->maximized_client_area_insets = |
| 62 mojo::Insets::From(gfx::Insets()); | 60 mojo::Insets::From(gfx::Insets()); |
| 63 frame_decoration_values->max_title_bar_button_width = 0; | 61 frame_decoration_values->max_title_bar_button_width = 0; |
| 64 window_manager_client_->SetFrameDecorationValues( | 62 window_manager_client_->SetFrameDecorationValues( |
| 65 std::move(frame_decoration_values)); | 63 std::move(frame_decoration_values)); |
| 66 } | 64 } |
| 67 void OnConnectionLost(mus::WindowTreeConnection* connection) override { | 65 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override {} |
| 68 } | |
| 69 void OnEventObserved(const ui::Event& event, mus::Window* target) override { | 66 void OnEventObserved(const ui::Event& event, mus::Window* target) override { |
| 70 // Don't care. | 67 // Don't care. |
| 71 } | 68 } |
| 72 | 69 |
| 73 // mus::WindowManagerDelegate: | 70 // mus::WindowManagerDelegate: |
| 74 void SetWindowManagerClient(mus::WindowManagerClient* client) override { | 71 void SetWindowManagerClient(mus::WindowManagerClient* client) override { |
| 75 window_manager_client_ = client; | 72 window_manager_client_ = client; |
| 76 } | 73 } |
| 77 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override { | 74 bool OnWmSetBounds(mus::Window* window, gfx::Rect* bounds) override { |
| 78 return true; | 75 return true; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 106 DISALLOW_COPY_AND_ASSIGN(TestWM); | 103 DISALLOW_COPY_AND_ASSIGN(TestWM); |
| 107 }; | 104 }; |
| 108 | 105 |
| 109 } // namespace test | 106 } // namespace test |
| 110 } // namespace mus | 107 } // namespace mus |
| 111 | 108 |
| 112 MojoResult MojoMain(MojoHandle shell_handle) { | 109 MojoResult MojoMain(MojoHandle shell_handle) { |
| 113 shell::ApplicationRunner runner(new mus::test::TestWM); | 110 shell::ApplicationRunner runner(new mus::test::TestWM); |
| 114 return runner.Run(shell_handle); | 111 return runner.Run(shell_handle); |
| 115 } | 112 } |
| OLD | NEW |