Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: components/mus/ws/display.h

Issue 2089023002: Promotes remaining global window manager state into WindowManagerState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: override Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/ws/cursor_unittest.cc ('k') | components/mus/ws/display.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 COMPONENTS_MUS_WS_DISPLAY_H_ 5 #ifndef COMPONENTS_MUS_WS_DISPLAY_H_
6 #define COMPONENTS_MUS_WS_DISPLAY_H_ 6 #define COMPONENTS_MUS_WS_DISPLAY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 15 matching lines...) Expand all
26 #include "components/mus/ws/user_id_tracker_observer.h" 26 #include "components/mus/ws/user_id_tracker_observer.h"
27 #include "components/mus/ws/window_manager_window_tree_factory_set_observer.h" 27 #include "components/mus/ws/window_manager_window_tree_factory_set_observer.h"
28 28
29 namespace mus { 29 namespace mus {
30 namespace ws { 30 namespace ws {
31 31
32 class DisplayBinding; 32 class DisplayBinding;
33 class DisplayManager; 33 class DisplayManager;
34 class FocusController; 34 class FocusController;
35 struct PlatformDisplayInitParams; 35 struct PlatformDisplayInitParams;
36 class WindowManagerState; 36 class WindowManagerDisplayRoot;
37 class WindowServer; 37 class WindowServer;
38 class WindowTree; 38 class WindowTree;
39 39
40 namespace test { 40 namespace test {
41 class DisplayTestApi; 41 class DisplayTestApi;
42 } 42 }
43 43
44 // Displays manages the state associated with a single display. Display has a 44 // Displays manages the state associated with a single display. Display has a
45 // single root window whose children are the roots for a per-user 45 // single root window whose children are the roots for a per-user
46 // WindowManager. Display is configured in two distinct 46 // WindowManager. Display is configured in two distinct
(...skipping 16 matching lines...) Expand all
63 ~Display() override; 63 ~Display() override;
64 64
65 // Initializes state that depends on the existence of a Display. 65 // Initializes state that depends on the existence of a Display.
66 void Init(std::unique_ptr<DisplayBinding> binding); 66 void Init(std::unique_ptr<DisplayBinding> binding);
67 67
68 uint32_t id() const { return id_; } 68 uint32_t id() const { return id_; }
69 69
70 DisplayManager* display_manager(); 70 DisplayManager* display_manager();
71 const DisplayManager* display_manager() const; 71 const DisplayManager* display_manager() const;
72 72
73 PlatformDisplay* platform_display() { return platform_display_.get(); }
74
73 // Returns a mojom::Display for the specified display. WindowManager specific 75 // Returns a mojom::Display for the specified display. WindowManager specific
74 // values are not set. In general you should use 76 // values are not set.
75 // WindowManagerState::ToMojomDisplay().
76 mojom::DisplayPtr ToMojomDisplay() const; 77 mojom::DisplayPtr ToMojomDisplay() const;
77 78
78 // Schedules a paint for the specified region in the coordinates of |window|. 79 // Schedules a paint for the specified region in the coordinates of |window|.
79 void SchedulePaint(const ServerWindow* window, const gfx::Rect& bounds); 80 void SchedulePaint(const ServerWindow* window, const gfx::Rect& bounds);
80 81
81 // Schedules destruction of surfaces in |window|. If a frame has been 82 // Schedules destruction of surfaces in |window|. If a frame has been
82 // scheduled but not drawn surface destruction is delayed until the frame is 83 // scheduled but not drawn surface destruction is delayed until the frame is
83 // drawn, otherwise destruction is immediate. 84 // drawn, otherwise destruction is immediate.
84 void ScheduleSurfaceDestruction(ServerWindow* window); 85 void ScheduleSurfaceDestruction(ServerWindow* window);
85 86
86 mojom::Rotation GetRotation() const; 87 mojom::Rotation GetRotation() const;
87 gfx::Size GetSize() const; 88 gfx::Size GetSize() const;
88 89
89 // Returns the id for the corresponding id. 90 // Returns the id for the corresponding id.
90 int64_t GetPlatformDisplayId() const; 91 int64_t GetPlatformDisplayId() const;
91 92
92 WindowServer* window_server() { return window_server_; } 93 WindowServer* window_server() { return window_server_; }
93 94
94 // Returns the root of the Display. The root's children are the roots 95 // Returns the root of the Display. The root's children are the roots
95 // of the corresponding WindowManagers. 96 // of the corresponding WindowManagers.
96 ServerWindow* root_window() { return root_.get(); } 97 ServerWindow* root_window() { return root_.get(); }
97 const ServerWindow* root_window() const { return root_.get(); } 98 const ServerWindow* root_window() const { return root_.get(); }
98 99
100 // Returns the ServerWindow whose id is |id|. This does not do a search over
101 // all windows, rather just the display and window manager root windows.
102 //
103 // In general you shouldn't use this, rather use WindowServer::GetWindow(),
104 // which calls this as necessary.
99 ServerWindow* GetRootWithId(const WindowId& id); 105 ServerWindow* GetRootWithId(const WindowId& id);
100 106
101 WindowManagerState* GetWindowManagerStateWithRoot(const ServerWindow* window); 107 WindowManagerDisplayRoot* GetWindowManagerDisplayRootWithRoot(
102 WindowManagerState* GetWindowManagerStateForUser(const UserId& user_id) { 108 const ServerWindow* window);
103 return const_cast<WindowManagerState*>( 109 WindowManagerDisplayRoot* GetWindowManagerDisplayRootForUser(
104 const_cast<const Display*>(this)->GetWindowManagerStateForUser( 110 const UserId& user_id) {
111 return const_cast<WindowManagerDisplayRoot*>(
112 const_cast<const Display*>(this)->GetWindowManagerDisplayRootForUser(
105 user_id)); 113 user_id));
106 } 114 }
107 const WindowManagerState* GetWindowManagerStateForUser( 115 const WindowManagerDisplayRoot* GetWindowManagerDisplayRootForUser(
108 const UserId& user_id) const; 116 const UserId& user_id) const;
109 WindowManagerState* GetActiveWindowManagerState() { 117 WindowManagerDisplayRoot* GetActiveWindowManagerDisplayRoot() {
110 return const_cast<WindowManagerState*>( 118 return const_cast<WindowManagerDisplayRoot*>(
111 const_cast<const Display*>(this)->GetActiveWindowManagerState()); 119 const_cast<const Display*>(this)->GetActiveWindowManagerDisplayRoot());
112 } 120 }
113 const WindowManagerState* GetActiveWindowManagerState() const; 121 const WindowManagerDisplayRoot* GetActiveWindowManagerDisplayRoot() const;
114 size_t num_window_manger_states() const { 122 size_t num_window_manger_states() const {
115 return window_manager_state_map_.size(); 123 return window_manager_display_root_map_.size();
116 } 124 }
117 125
118 // TODO(sky): this should only be called by WindowServer, move to interface 126 // TODO(sky): this should only be called by WindowServer, move to interface
119 // used by WindowServer. 127 // used by WindowServer.
120 // See description of WindowServer::SetFocusedWindow() for details on return 128 // See description of WindowServer::SetFocusedWindow() for details on return
121 // value. 129 // value.
122 bool SetFocusedWindow(ServerWindow* window); 130 bool SetFocusedWindow(ServerWindow* window);
123 // NOTE: this returns the focused window only if the focused window is in this 131 // NOTE: this returns the focused window only if the focused window is in this
124 // display. If this returns null focus may be in another display. 132 // display. If this returns null focus may be in another display.
125 ServerWindow* GetFocusedWindow(); 133 ServerWindow* GetFocusedWindow();
(...skipping 12 matching lines...) Expand all
138 146
139 void UpdateNativeCursor(int32_t cursor_id); 147 void UpdateNativeCursor(int32_t cursor_id);
140 148
141 // mojom::WindowTreeHost: 149 // mojom::WindowTreeHost:
142 void SetSize(const gfx::Size& size) override; 150 void SetSize(const gfx::Size& size) override;
143 void SetTitle(const mojo::String& title) override; 151 void SetTitle(const mojo::String& title) override;
144 152
145 private: 153 private:
146 friend class test::DisplayTestApi; 154 friend class test::DisplayTestApi;
147 155
148 using WindowManagerStateMap = 156 using WindowManagerDisplayRootMap =
149 std::map<UserId, std::unique_ptr<WindowManagerState>>; 157 std::map<UserId, std::unique_ptr<WindowManagerDisplayRoot>>;
150 158
151 // Inits the necessary state once the display is ready. 159 // Inits the necessary state once the display is ready.
152 void InitWindowManagersIfNecessary(); 160 void InitWindowManagerDisplayRootsIfNecessary();
153 161
154 // Creates the set of WindowManagerStates from the 162 // Creates the set of WindowManagerDisplayRoots from the
155 // WindowManagerWindowTreeFactorySet. 163 // WindowManagerWindowTreeFactorySet.
156 void CreateWindowManagerStatesFromFactories(); 164 void CreateWindowManagerDisplayRootsFromFactories();
157 165
158 void CreateWindowManagerStateFromFactory( 166 void CreateWindowManagerDisplayRootFromFactory(
159 WindowManagerWindowTreeFactory* factory); 167 WindowManagerWindowTreeFactory* factory);
160 168
161 // PlatformDisplayDelegate: 169 // PlatformDisplayDelegate:
162 ServerWindow* GetRootWindow() override; 170 ServerWindow* GetRootWindow() override;
163 void OnEvent(const ui::Event& event) override; 171 void OnEvent(const ui::Event& event) override;
164 void OnNativeCaptureLost() override; 172 void OnNativeCaptureLost() override;
165 void OnDisplayClosed() override; 173 void OnDisplayClosed() override;
166 void OnViewportMetricsChanged(const ViewportMetrics& old_metrics, 174 void OnViewportMetricsChanged(const ViewportMetrics& old_metrics,
167 const ViewportMetrics& new_metrics) override; 175 const ViewportMetrics& new_metrics) override;
168 void OnCompositorFrameDrawn() override; 176 void OnCompositorFrameDrawn() override;
169 177
170 // FocusControllerDelegate: 178 // FocusControllerDelegate:
171 bool CanHaveActiveChildren(ServerWindow* window) const override; 179 bool CanHaveActiveChildren(ServerWindow* window) const override;
172 180
173 // FocusControllerObserver: 181 // FocusControllerObserver:
174 void OnActivationChanged(ServerWindow* old_active_window, 182 void OnActivationChanged(ServerWindow* old_active_window,
175 ServerWindow* new_active_window) override; 183 ServerWindow* new_active_window) override;
176 void OnFocusChanged(FocusControllerChangeSource change_source, 184 void OnFocusChanged(FocusControllerChangeSource change_source,
177 ServerWindow* old_focused_window, 185 ServerWindow* old_focused_window,
178 ServerWindow* new_focused_window) override; 186 ServerWindow* new_focused_window) override;
179 187
180 // ServerWindowObserver: 188 // ServerWindowObserver:
181 void OnWindowDestroyed(ServerWindow* window) override; 189 void OnWindowDestroyed(ServerWindow* window) override;
182 190
183 // UserIdTrackerObserver: 191 // UserIdTrackerObserver:
184 void OnActiveUserIdChanged(const UserId& previously_active_id,
185 const UserId& active_id) override;
186 void OnUserIdAdded(const UserId& id) override;
187 void OnUserIdRemoved(const UserId& id) override; 192 void OnUserIdRemoved(const UserId& id) override;
188 193
189 // WindowManagerWindowTreeFactorySetObserver: 194 // WindowManagerWindowTreeFactorySetObserver:
190 void OnWindowManagerWindowTreeFactoryReady( 195 void OnWindowManagerWindowTreeFactoryReady(
191 WindowManagerWindowTreeFactory* factory) override; 196 WindowManagerWindowTreeFactory* factory) override;
192 197
193 const uint32_t id_; 198 const uint32_t id_;
194 std::unique_ptr<DisplayBinding> binding_; 199 std::unique_ptr<DisplayBinding> binding_;
195 // Set once Init() has been called. 200 // Set once Init() has been called.
196 bool init_called_ = false; 201 bool init_called_ = false;
197 WindowServer* const window_server_; 202 WindowServer* const window_server_;
198 std::unique_ptr<ServerWindow> root_; 203 std::unique_ptr<ServerWindow> root_;
199 std::unique_ptr<PlatformDisplay> platform_display_; 204 std::unique_ptr<PlatformDisplay> platform_display_;
200 std::unique_ptr<FocusController> focus_controller_; 205 std::unique_ptr<FocusController> focus_controller_;
201 206
202 // The last cursor set. Used to track whether we need to change the cursor. 207 // The last cursor set. Used to track whether we need to change the cursor.
203 int32_t last_cursor_; 208 int32_t last_cursor_;
204 209
205 ServerWindowTracker activation_parents_; 210 ServerWindowTracker activation_parents_;
206 211
207 // Set of windows with surfaces that need to be destroyed once the frame 212 // Set of windows with surfaces that need to be destroyed once the frame
208 // draws. 213 // draws.
209 std::set<ServerWindow*> windows_needing_frame_destruction_; 214 std::set<ServerWindow*> windows_needing_frame_destruction_;
210 215
211 WindowManagerStateMap window_manager_state_map_; 216 WindowManagerDisplayRootMap window_manager_display_root_map_;
212 217
213 DISALLOW_COPY_AND_ASSIGN(Display); 218 DISALLOW_COPY_AND_ASSIGN(Display);
214 }; 219 };
215 220
216 } // namespace ws 221 } // namespace ws
217 } // namespace mus 222 } // namespace mus
218 223
219 #endif // COMPONENTS_MUS_WS_DISPLAY_H_ 224 #endif // COMPONENTS_MUS_WS_DISPLAY_H_
OLDNEW
« no previous file with comments | « components/mus/ws/cursor_unittest.cc ('k') | components/mus/ws/display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698