OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MASH_WM_ROOT_WINDOW_CONTROLLER_H_ | |
6 #define MASH_WM_ROOT_WINDOW_CONTROLLER_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "ash/public/interfaces/container.mojom.h" | |
11 #include "components/mus/public/cpp/window_observer.h" | |
12 #include "components/mus/public/cpp/window_tree_client.h" | |
13 #include "components/mus/public/cpp/window_tree_client_delegate.h" | |
14 #include "components/mus/public/interfaces/window_manager_constants.mojom.h" | |
15 #include "components/mus/public/interfaces/window_tree_host.mojom.h" | |
16 #include "mash/wm/shelf_layout_manager_delegate.h" | |
17 #include "mojo/public/cpp/bindings/binding.h" | |
18 #include "ui/display/display.h" | |
19 | |
20 namespace ash { | |
21 class AlwaysOnTopController; | |
22 } | |
23 | |
24 namespace mus { | |
25 class WindowManagerClient; | |
26 } | |
27 | |
28 namespace shell { | |
29 class Connector; | |
30 } | |
31 | |
32 namespace ui { | |
33 class Event; | |
34 } | |
35 | |
36 namespace mash { | |
37 namespace wm { | |
38 | |
39 class LayoutManager; | |
40 class ShadowController; | |
41 class ShelfLayoutManager; | |
42 class StatusLayoutManager; | |
43 class WindowManager; | |
44 class WindowManagerApplication; | |
45 class WmRootWindowControllerMus; | |
46 class WmShelfMus; | |
47 class WmTestBase; | |
48 class WmTestHelper; | |
49 | |
50 // RootWindowController manages the windows and state for a single display. | |
51 // | |
52 // RootWindowController deletes itself when the root mus::Window is destroyed. | |
53 // You can trigger deletion explicitly by way of Destroy(). | |
54 class RootWindowController : public mus::WindowObserver, | |
55 public mus::WindowTreeClientDelegate, | |
56 public ShelfLayoutManagerDelegate { | |
57 public: | |
58 static RootWindowController* CreateFromDisplay( | |
59 WindowManagerApplication* app, | |
60 mus::mojom::DisplayPtr display, | |
61 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> client_request); | |
62 | |
63 // Deletes this. | |
64 void Destroy(); | |
65 | |
66 shell::Connector* GetConnector(); | |
67 | |
68 mus::Window* root() { return root_; } | |
69 | |
70 int window_count() { return window_count_; } | |
71 void IncrementWindowCount() { ++window_count_; } | |
72 | |
73 mus::Window* GetWindowForContainer(ash::mojom::Container container); | |
74 bool WindowIsContainer(const mus::Window* window) const; | |
75 | |
76 WindowManager* window_manager() { return window_manager_.get(); } | |
77 | |
78 mus::WindowManagerClient* window_manager_client(); | |
79 | |
80 void OnAccelerator(uint32_t id, const ui::Event& event); | |
81 | |
82 const display::Display& display() const { return display_; } | |
83 | |
84 ShelfLayoutManager* GetShelfLayoutManager(); | |
85 StatusLayoutManager* GetStatusLayoutManager(); | |
86 | |
87 ash::AlwaysOnTopController* always_on_top_controller() { | |
88 return always_on_top_controller_.get(); | |
89 } | |
90 | |
91 WmShelfMus* wm_shelf() { return wm_shelf_.get(); } | |
92 | |
93 private: | |
94 friend class WmTestBase; | |
95 friend class WmTestHelper; | |
96 | |
97 explicit RootWindowController(WindowManagerApplication* app); | |
98 ~RootWindowController() override; | |
99 | |
100 void AddAccelerators(); | |
101 | |
102 // WindowTreeClientDelegate: | |
103 void OnEmbed(mus::Window* root) override; | |
104 void OnWindowTreeClientDestroyed(mus::WindowTreeClient* client) override; | |
105 void OnEventObserved(const ui::Event& event, mus::Window* target) override; | |
106 | |
107 // mus::WindowObserver: | |
108 void OnWindowDestroyed(mus::Window* window) override; | |
109 | |
110 // ShelfLayoutManagerDelegate: | |
111 void OnShelfWindowAvailable() override; | |
112 | |
113 // Sets up the window containers used for z-space management. | |
114 void CreateContainer(ash::mojom::Container container, | |
115 ash::mojom::Container parent_container); | |
116 void CreateContainers(); | |
117 | |
118 WindowManagerApplication* app_; | |
119 mus::Window* root_; | |
120 int window_count_; | |
121 | |
122 std::unique_ptr<WmRootWindowControllerMus> wm_root_window_controller_; | |
123 std::unique_ptr<WmShelfMus> wm_shelf_; | |
124 | |
125 std::unique_ptr<WindowManager> window_manager_; | |
126 | |
127 std::map<mus::Window*, std::unique_ptr<LayoutManager>> layout_managers_; | |
128 | |
129 std::unique_ptr<ShadowController> shadow_controller_; | |
130 | |
131 display::Display display_; | |
132 | |
133 std::unique_ptr<ash::AlwaysOnTopController> always_on_top_controller_; | |
134 | |
135 DISALLOW_COPY_AND_ASSIGN(RootWindowController); | |
136 }; | |
137 | |
138 } // namespace wm | |
139 } // namespace mash | |
140 | |
141 #endif // MASH_WM_ROOT_WINDOW_CONTROLLER_H_ | |
OLD | NEW |