| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MASH_WM_WINDOW_MANAGER_APPLICATION_H_ |
| 6 #define MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 6 #define MASH_WM_WINDOW_MANAGER_APPLICATION_H_ |
| 7 | 7 |
| 8 #include <set> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 11 #include "components/mus/common/types.h" | 13 #include "components/mus/common/types.h" |
| 12 #include "components/mus/public/cpp/window_observer.h" | 14 #include "components/mus/public/cpp/window_observer.h" |
| 13 #include "components/mus/public/cpp/window_tree_delegate.h" | 15 #include "components/mus/public/cpp/window_tree_delegate.h" |
| 16 #include "components/mus/public/interfaces/accelerator_registrar.mojom.h" |
| 14 #include "components/mus/public/interfaces/window_manager.mojom.h" | 17 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | 18 #include "components/mus/public/interfaces/window_tree_host.mojom.h" |
| 16 #include "mash/wm/public/interfaces/container.mojom.h" | 19 #include "mash/wm/public/interfaces/container.mojom.h" |
| 17 #include "mojo/application/public/cpp/application_delegate.h" | 20 #include "mojo/application/public/cpp/application_delegate.h" |
| 18 #include "mojo/application/public/cpp/interface_factory_impl.h" | 21 #include "mojo/application/public/cpp/interface_factory_impl.h" |
| 19 #include "mojo/common/weak_binding_set.h" | 22 #include "mojo/common/weak_binding_set.h" |
| 20 #include "mojo/services/tracing/public/cpp/tracing_impl.h" | 23 #include "mojo/services/tracing/public/cpp/tracing_impl.h" |
| 21 | 24 |
| 22 namespace ui { | 25 namespace ui { |
| 23 namespace mojo { | 26 namespace mojo { |
| 24 class UIInit; | 27 class UIInit; |
| 25 } | 28 } |
| 26 } | 29 } |
| 27 | 30 |
| 28 namespace views { | 31 namespace views { |
| 29 class AuraInit; | 32 class AuraInit; |
| 30 } | 33 } |
| 31 | 34 |
| 32 namespace mash { | 35 namespace mash { |
| 33 namespace wm { | 36 namespace wm { |
| 34 | 37 |
| 38 class AcceleratorRegistrarImpl; |
| 35 class BackgroundLayout; | 39 class BackgroundLayout; |
| 36 class ShelfLayout; | 40 class ShelfLayout; |
| 37 class WindowLayout; | 41 class WindowLayout; |
| 38 class WindowManagerImpl; | 42 class WindowManagerImpl; |
| 39 | 43 |
| 40 class WindowManagerApplication | 44 class WindowManagerApplication |
| 41 : public mojo::ApplicationDelegate, | 45 : public mojo::ApplicationDelegate, |
| 42 public mus::WindowObserver, | 46 public mus::WindowObserver, |
| 43 public mus::mojom::WindowTreeHostClient, | 47 public mus::mojom::WindowTreeHostClient, |
| 44 public mus::WindowTreeDelegate, | 48 public mus::WindowTreeDelegate, |
| 45 public mojo::InterfaceFactory<mus::mojom::WindowManager> { | 49 public mojo::InterfaceFactory<mus::mojom::WindowManager>, |
| 50 public mojo::InterfaceFactory<mus::mojom::AcceleratorRegistrar> { |
| 46 public: | 51 public: |
| 47 WindowManagerApplication(); | 52 WindowManagerApplication(); |
| 48 ~WindowManagerApplication() override; | 53 ~WindowManagerApplication() override; |
| 49 | 54 |
| 50 mus::Window* root() { return root_; } | 55 mus::Window* root() { return root_; } |
| 51 | 56 |
| 52 int window_count() { return window_count_; } | 57 int window_count() { return window_count_; } |
| 53 void IncrementWindowCount() { ++window_count_; } | 58 void IncrementWindowCount() { ++window_count_; } |
| 54 | 59 |
| 55 mus::Window* GetWindowForContainer(mojom::Container container); | 60 mus::Window* GetWindowForContainer(mojom::Container container); |
| 56 mus::Window* GetWindowById(mus::Id id); | 61 mus::Window* GetWindowById(mus::Id id); |
| 57 | 62 |
| 58 mojo::ApplicationImpl* app() { return app_; } | 63 mojo::ApplicationImpl* app() { return app_; } |
| 59 | 64 |
| 60 mus::mojom::WindowTreeHost* window_tree_host() { | 65 mus::mojom::WindowTreeHost* window_tree_host() { |
| 61 return window_tree_host_.get(); | 66 return window_tree_host_.get(); |
| 62 } | 67 } |
| 63 | 68 |
| 64 private: | 69 private: |
| 65 void AddAccelerators(); | 70 void AddAccelerators(); |
| 71 void OnAcceleratorRegistrarDestroyed(AcceleratorRegistrarImpl* registrar); |
| 66 | 72 |
| 67 // ApplicationDelegate: | 73 // ApplicationDelegate: |
| 68 void Initialize(mojo::ApplicationImpl* app) override; | 74 void Initialize(mojo::ApplicationImpl* app) override; |
| 69 bool ConfigureIncomingConnection( | 75 bool ConfigureIncomingConnection( |
| 70 mojo::ApplicationConnection* connection) override; | 76 mojo::ApplicationConnection* connection) override; |
| 71 | 77 |
| 72 // WindowTreeHostClient: | 78 // WindowTreeHostClient: |
| 73 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override; | 79 void OnAccelerator(uint32_t id, mus::mojom::EventPtr event) override; |
| 74 | 80 |
| 75 // WindowTreeDelegate: | 81 // WindowTreeDelegate: |
| 76 void OnEmbed(mus::Window* root) override; | 82 void OnEmbed(mus::Window* root) override; |
| 77 void OnConnectionLost(mus::WindowTreeConnection* connection) override; | 83 void OnConnectionLost(mus::WindowTreeConnection* connection) override; |
| 78 | 84 |
| 85 // InterfaceFactory<mus::mojom::AcceleratorRegistrar>: |
| 86 void Create(mojo::ApplicationConnection* connection, |
| 87 mojo::InterfaceRequest<mus::mojom::AcceleratorRegistrar> request) |
| 88 override; |
| 89 |
| 79 // InterfaceFactory<mus::mojom::WindowManager>: | 90 // InterfaceFactory<mus::mojom::WindowManager>: |
| 80 void Create( | 91 void Create( |
| 81 mojo::ApplicationConnection* connection, | 92 mojo::ApplicationConnection* connection, |
| 82 mojo::InterfaceRequest<mus::mojom::WindowManager> request) override; | 93 mojo::InterfaceRequest<mus::mojom::WindowManager> request) override; |
| 83 | 94 |
| 84 // mus::WindowObserver: | 95 // mus::WindowObserver: |
| 85 void OnWindowDestroyed(mus::Window* window) override; | 96 void OnWindowDestroyed(mus::Window* window) override; |
| 86 | 97 |
| 87 // Sets up the window containers used for z-space management. | 98 // Sets up the window containers used for z-space management. |
| 88 void CreateContainers(); | 99 void CreateContainers(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 104 // |window_manager_| is created once OnEmbed() is called. Until that time | 115 // |window_manager_| is created once OnEmbed() is called. Until that time |
| 105 // |requests_| stores any pending WindowManager interface requests. | 116 // |requests_| stores any pending WindowManager interface requests. |
| 106 scoped_ptr<WindowManagerImpl> window_manager_; | 117 scoped_ptr<WindowManagerImpl> window_manager_; |
| 107 mojo::WeakBindingSet<mus::mojom::WindowManager> window_manager_binding_; | 118 mojo::WeakBindingSet<mus::mojom::WindowManager> window_manager_binding_; |
| 108 ScopedVector<mojo::InterfaceRequest<mus::mojom::WindowManager>> requests_; | 119 ScopedVector<mojo::InterfaceRequest<mus::mojom::WindowManager>> requests_; |
| 109 | 120 |
| 110 scoped_ptr<BackgroundLayout> background_layout_; | 121 scoped_ptr<BackgroundLayout> background_layout_; |
| 111 scoped_ptr<ShelfLayout> shelf_layout_; | 122 scoped_ptr<ShelfLayout> shelf_layout_; |
| 112 scoped_ptr<WindowLayout> window_layout_; | 123 scoped_ptr<WindowLayout> window_layout_; |
| 113 | 124 |
| 125 std::set<AcceleratorRegistrarImpl*> accelerator_registrars_; |
| 126 |
| 114 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); | 127 DISALLOW_COPY_AND_ASSIGN(WindowManagerApplication); |
| 115 }; | 128 }; |
| 116 | 129 |
| 117 } // namespace wm | 130 } // namespace wm |
| 118 } // namespace mash | 131 } // namespace mash |
| 119 | 132 |
| 120 #endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_ | 133 #endif // MASH_WM_WINDOW_MANAGER_APPLICATION_H_ |
| OLD | NEW |