| OLD | NEW |
| 1 // Copyright 2015 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 #ifndef MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 5 #ifndef ASH_MUS_WM_WINDOW_MANAGER_APPLICATION_H_ |
| 6 #define MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 6 #define ASH_MUS_WM_WINDOW_MANAGER_APPLICATION_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "components/mus/common/types.h" | 14 #include "components/mus/common/types.h" |
| 15 #include "components/mus/public/cpp/window_observer.h" | 15 #include "components/mus/public/cpp/window_observer.h" |
| 16 #include "components/mus/public/cpp/window_tree_delegate.h" | 16 #include "components/mus/public/cpp/window_tree_delegate.h" |
| 17 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" | 17 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" |
| 18 #include "components/mus/public/interfaces/window_manager.mojom.h" | 18 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 19 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 20 #include "mash/wm/public/interfaces/container.mojom.h" | |
| 21 #include "mash/wm/public/interfaces/user_window_controller.mojom.h" | |
| 22 #include "mojo/common/weak_binding_set.h" | 20 #include "mojo/common/weak_binding_set.h" |
| 23 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 21 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 24 #include "mojo/shell/public/cpp/application_delegate.h" | 22 #include "mojo/shell/public/cpp/application_delegate.h" |
| 25 #include "mojo/shell/public/cpp/interface_factory_impl.h" | 23 #include "mojo/shell/public/cpp/interface_factory_impl.h" |
| 26 | 24 |
| 27 namespace ui { | 25 namespace aura { |
| 28 namespace mojo { | 26 class Window; |
| 29 class UIInit; | |
| 30 } | |
| 31 } | 27 } |
| 32 | 28 |
| 33 namespace views { | 29 namespace ash { |
| 34 class AuraInit; | 30 namespace muswm { |
| 35 } | |
| 36 | |
| 37 namespace mash { | |
| 38 namespace wm { | |
| 39 | 31 |
| 40 class AcceleratorRegistrarImpl; | 32 class AcceleratorRegistrarImpl; |
| 41 class BackgroundLayout; | 33 class AshInit; |
| 42 class ScreenlockLayout; | |
| 43 class ShadowController; | |
| 44 class ShelfLayout; | |
| 45 class UserWindowControllerImpl; | |
| 46 class WindowLayout; | |
| 47 class WindowManagerImpl; | 34 class WindowManagerImpl; |
| 48 | 35 |
| 49 class WindowManagerApplication | 36 class WindowManagerApplication |
| 50 : public mojo::ApplicationDelegate, | 37 : public mojo::ApplicationDelegate, |
| 51 public mus::WindowObserver, | 38 public mus::WindowObserver, |
| 52 public mus::mojom::WindowTreeHostClient, | 39 public mus::mojom::WindowTreeHostClient, |
| 53 public mus::WindowTreeDelegate, | 40 public mus::WindowTreeDelegate, |
| 54 public mojo::InterfaceFactory<mash::wm::mojom::UserWindowController>, | |
| 55 public mojo::InterfaceFactory<mus::mojom::WindowManagerDeprecated>, | 41 public mojo::InterfaceFactory<mus::mojom::WindowManagerDeprecated>, |
| 56 public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { | 42 public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { |
| 57 public: | 43 public: |
| 58 WindowManagerApplication(); | 44 WindowManagerApplication(); |
| 59 ~WindowManagerApplication() override; | 45 ~WindowManagerApplication() override; |
| 60 | 46 |
| 61 mus::Window* root() { return root_; } | 47 mus::Window* root() { return root_; } |
| 48 aura::Window* aura_root(); |
| 62 | 49 |
| 63 int window_count() { return window_count_; } | 50 int window_count() { return window_count_; } |
| 64 void IncrementWindowCount() { ++window_count_; } | 51 void IncrementWindowCount() { ++window_count_; } |
| 65 | 52 |
| 66 mus::Window* GetWindowForContainer(mojom::Container container); | |
| 67 mus::Window* GetWindowById(mus::Id id); | |
| 68 bool WindowIsContainer(const mus::Window* window) const; | |
| 69 | |
| 70 mojo::ApplicationImpl* app() { return app_; } | 53 mojo::ApplicationImpl* app() { return app_; } |
| 71 | 54 |
| 72 mus::mojom::WindowTreeHost* window_tree_host() { | 55 mus::mojom::WindowTreeHost* window_tree_host() { |
| 73 return window_tree_host_.get(); | 56 return window_tree_host_.get(); |
| 74 } | 57 } |
| 75 | 58 |
| 76 private: | 59 private: |
| 77 void AddAccelerators(); | 60 void AddAccelerators(); |
| 78 void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); | 61 void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); |
| 79 | 62 |
| 80 // ApplicationDelegate: | 63 // ApplicationDelegate: |
| 81 void Initialize(mojo::ApplicationImpl* app) override; | 64 void Initialize(mojo::ApplicationImpl* app) override; |
| 82 bool ConfigureIncomingConnection( | 65 bool ConfigureIncomingConnection( |
| 83 mojo::ApplicationConnection* connection) override; | 66 mojo::ApplicationConnection* connection) override; |
| 84 | 67 |
| 85 // WindowTreeHostClient: | 68 // WindowTreeHostClient: |
| 86 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override; | 69 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override; |
| 87 | 70 |
| 88 // WindowTreeDelegate: | 71 // WindowTreeDelegate: |
| 89 void OnEmbed(mus::Window* root) override; | 72 void OnEmbed(mus::Window* root) override; |
| 90 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 73 void OnConnectionLost(mus::WindowTreeConnection* connection) override; |
| 91 | 74 |
| 92 // InterfaceFactory<mash::wm::mojom::UserWindowController>: | |
| 93 void Create(mojo::ApplicationConnection* connection, | |
| 94 mojo::InterfaceRequest<mash::wm::mojom::UserWindowController> | |
| 95 request) override; | |
| 96 | |
| 97 // InterfaceFactory<mus::mojom::AcceleratorRegistrar>: | 75 // InterfaceFactory<mus::mojom::AcceleratorRegistrar>: |
| 98 void Create(mojo::ApplicationConnection* connection, | 76 void Create(mojo::ApplicationConnection* connection, |
| 99 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) | 77 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) |
| 100 override; | 78 override; |
| 101 | 79 |
| 102 // InterfaceFactory<mus::mojom::WindowManagerDeprecated>: | 80 // InterfaceFactory<mus::mojom::WindowManagerDeprecated>: |
| 103 void Create(mojo::ApplicationConnection* connection, | 81 void Create( |
| 104 mojo::InterfaceRequest<mus::mojom::WindowManagerDeprecated> | 82 mojo::ApplicationConnection* connection, |
| 105 request) override; | 83 mojo::InterfaceRequest<mus::mojom::WindowManagerDeprecated> request) overr
ide; |
| 106 | 84 |
| 107 // mus::WindowObserver: | 85 // mus::WindowObserver: |
| 108 void OnWindowDestroyed(mus::Window* window) override; | 86 void OnWindowDestroyed(mus::Window* window) override; |
| 109 | 87 |
| 110 // Sets up the window containers used for z-space management. | 88 // Sets up the window containers used for z-space management. |
| 111 void CreateContainers(); | 89 void CreateContainers(); |
| 112 | 90 |
| 113 // nullptr until the Mus connection is established via OnEmbed(). | 91 // nullptr until the Mus connection is established via OnEmbed(). |
| 114 mus::Window* root_; | 92 mus::Window* root_; |
| 115 int window_count_; | 93 int window_count_; |
| 116 | 94 |
| 117 mojo::ApplicationImpl* app_; | 95 mojo::ApplicationImpl* app_; |
| 118 | 96 |
| 119 mojo::TracingImpl tracing_; | 97 mojo::TracingImpl tracing_; |
| 120 | 98 |
| 121 mus::mojom::WindowTreeHostPtr window_tree_host_; | 99 mus::mojom::WindowTreeHostPtr window_tree_host_; |
| 122 mojo::Binding<mus::mojom::WindowTreeHostClient> host_client_binding_; | 100 mojo::Binding<mus::mojom::WindowTreeHostClient> host_client_binding_; |
| 123 | 101 |
| 124 scoped_ptr<ui::mojo::UIInit> ui_init_; | 102 scoped_ptr<AshInit> ash_init_; |
| 125 scoped_ptr<views::AuraInit> aura_init_; | |
| 126 | 103 |
| 127 // |window_manager_| is created once OnEmbed() is called. Until that time | 104 // |window_manager_| is created once OnEmbed() is called. Until that time |
| 128 // |requests_| stores any pending WindowManager interface requests. | 105 // |requests_| stores any pending WindowManager interface requests. |
| 129 scoped_ptr<WindowManagerImpl> window_manager_; | 106 scoped_ptr<WindowManagerImpl> window_manager_; |
| 130 mojo::WeakBindingSet<mus::mojom::WindowManagerDeprecated> | 107 mojo::WeakBindingSet<mus::mojom::WindowManagerDeprecated> window_manager_bindi
ng_; |
| 131 window_manager_binding_; | 108 std::vector<scoped_ptr<mojo::InterfaceRequest<mus::mojom::WindowManagerDepreca
ted>>> |
| 132 std::vector< | |
| 133 scoped_ptr<mojo::InterfaceRequest<mus::mojom::WindowManagerDeprecated>>> | |
| 134 requests_; | 109 requests_; |
| 135 | 110 |
| 136 // |user_window_controller_| is created once OnEmbed() is called. Until that | |
| 137 // time |user_window_controller_requests_| stores pending interface requests. | |
| 138 scoped_ptr<UserWindowControllerImpl> user_window_controller_; | |
| 139 mojo::WeakBindingSet<mash::wm::mojom::UserWindowController> | |
| 140 user_window_controller_binding_; | |
| 141 std::vector< | |
| 142 scoped_ptr<mojo::InterfaceRequest<mash::wm::mojom::UserWindowController>>> | |
| 143 user_window_controller_requests_; | |
| 144 | |
| 145 scoped_ptr<BackgroundLayout> background_layout_; | |
| 146 scoped_ptr<ScreenlockLayout> screenlock_layout_; | |
| 147 scoped_ptr<ShelfLayout> shelf_layout_; | |
| 148 scoped_ptr<WindowLayout> window_layout_; | |
| 149 | |
| 150 scoped_ptr<ShadowController> shadow_controller_; | |
| 151 | |
| 152 std::set<AcceleratorRegistrarImpl*> accelerator_registrars_; | 111 std::set<AcceleratorRegistrarImpl*> accelerator_registrars_; |
| 153 | 112 |
| 154 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); | 113 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); |
| 155 }; | 114 }; |
| 156 | 115 |
| 157 } // namespace wm | 116 } // namespace muswm |
| 158 } // namespace mash | 117 } // namespace ash |
| 159 | 118 |
| 160 #endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 119 #endif // ASH_MUS_WM_WINDOW_MANAGER_APPLICATION_H_ |
| OLD | NEW |