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

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

Issue 2119963002: Move mus to //services/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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/default_access_policy.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_MUS_WS_DISPLAY_H_
6 #define COMPONENTS_MUS_WS_DISPLAY_H_
7
8 #include <stdint.h>
9
10 #include <map>
11 #include <memory>
12 #include <queue>
13 #include <set>
14
15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h"
17 #include "components/mus/common/types.h"
18 #include "components/mus/public/interfaces/window_manager_constants.mojom.h"
19 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
20 #include "components/mus/ws/focus_controller_delegate.h"
21 #include "components/mus/ws/focus_controller_observer.h"
22 #include "components/mus/ws/platform_display.h"
23 #include "components/mus/ws/server_window.h"
24 #include "components/mus/ws/server_window_observer.h"
25 #include "components/mus/ws/server_window_tracker.h"
26 #include "components/mus/ws/user_id_tracker_observer.h"
27 #include "components/mus/ws/window_manager_window_tree_factory_set_observer.h"
28
29 namespace mus {
30 namespace ws {
31
32 class DisplayBinding;
33 class DisplayManager;
34 class FocusController;
35 struct PlatformDisplayInitParams;
36 class WindowManagerDisplayRoot;
37 class WindowServer;
38 class WindowTree;
39
40 namespace test {
41 class DisplayTestApi;
42 }
43
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
46 // WindowManager. Display is configured in two distinct
47 // ways:
48 // . with a DisplayBinding. In this mode there is only ever one WindowManager
49 // for the display, which comes from the client that created the
50 // Display.
51 // . without a DisplayBinding. In this mode a WindowManager is automatically
52 // created per user.
53 class Display : public PlatformDisplayDelegate,
54 public mojom::WindowTreeHost,
55 public FocusControllerObserver,
56 public FocusControllerDelegate,
57 public ServerWindowObserver,
58 public UserIdTrackerObserver,
59 public WindowManagerWindowTreeFactorySetObserver {
60 public:
61 Display(WindowServer* window_server,
62 const PlatformDisplayInitParams& platform_display_init_params);
63 ~Display() override;
64
65 // Initializes state that depends on the existence of a Display.
66 void Init(std::unique_ptr<DisplayBinding> binding);
67
68 uint32_t id() const { return id_; }
69
70 DisplayManager* display_manager();
71 const DisplayManager* display_manager() const;
72
73 PlatformDisplay* platform_display() { return platform_display_.get(); }
74
75 // Returns a mojom::Display for the specified display. WindowManager specific
76 // values are not set.
77 mojom::DisplayPtr ToMojomDisplay() const;
78
79 // Schedules a paint for the specified region in the coordinates of |window|.
80 void SchedulePaint(const ServerWindow* window, const gfx::Rect& bounds);
81
82 // Schedules destruction of surfaces in |window|. If a frame has been
83 // scheduled but not drawn surface destruction is delayed until the frame is
84 // drawn, otherwise destruction is immediate.
85 void ScheduleSurfaceDestruction(ServerWindow* window);
86
87 mojom::Rotation GetRotation() const;
88 gfx::Size GetSize() const;
89
90 // Returns the id for the corresponding id.
91 int64_t GetPlatformDisplayId() const;
92
93 WindowServer* window_server() { return window_server_; }
94
95 // Returns the root of the Display. The root's children are the roots
96 // of the corresponding WindowManagers.
97 ServerWindow* root_window() { return root_.get(); }
98 const ServerWindow* root_window() const { return root_.get(); }
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.
105 ServerWindow* GetRootWithId(const WindowId& id);
106
107 WindowManagerDisplayRoot* GetWindowManagerDisplayRootWithRoot(
108 const ServerWindow* window);
109 WindowManagerDisplayRoot* GetWindowManagerDisplayRootForUser(
110 const UserId& user_id) {
111 return const_cast<WindowManagerDisplayRoot*>(
112 const_cast<const Display*>(this)->GetWindowManagerDisplayRootForUser(
113 user_id));
114 }
115 const WindowManagerDisplayRoot* GetWindowManagerDisplayRootForUser(
116 const UserId& user_id) const;
117 WindowManagerDisplayRoot* GetActiveWindowManagerDisplayRoot() {
118 return const_cast<WindowManagerDisplayRoot*>(
119 const_cast<const Display*>(this)->GetActiveWindowManagerDisplayRoot());
120 }
121 const WindowManagerDisplayRoot* GetActiveWindowManagerDisplayRoot() const;
122 size_t num_window_manger_states() const {
123 return window_manager_display_root_map_.size();
124 }
125
126 // TODO(sky): this should only be called by WindowServer, move to interface
127 // used by WindowServer.
128 // See description of WindowServer::SetFocusedWindow() for details on return
129 // value.
130 bool SetFocusedWindow(ServerWindow* window);
131 // NOTE: this returns the focused window only if the focused window is in this
132 // display. If this returns null focus may be in another display.
133 ServerWindow* GetFocusedWindow();
134
135 void ActivateNextWindow();
136
137 void AddActivationParent(ServerWindow* window);
138 void RemoveActivationParent(ServerWindow* window);
139
140 void UpdateTextInputState(ServerWindow* window,
141 const ui::TextInputState& state);
142 void SetImeVisibility(ServerWindow* window, bool visible);
143
144 // Called just before |tree| is destroyed.
145 void OnWillDestroyTree(WindowTree* tree);
146
147 void UpdateNativeCursor(int32_t cursor_id);
148
149 // mojom::WindowTreeHost:
150 void SetSize(const gfx::Size& size) override;
151 void SetTitle(const mojo::String& title) override;
152
153 private:
154 friend class test::DisplayTestApi;
155
156 using WindowManagerDisplayRootMap =
157 std::map<UserId, std::unique_ptr<WindowManagerDisplayRoot>>;
158
159 // Inits the necessary state once the display is ready.
160 void InitWindowManagerDisplayRootsIfNecessary();
161
162 // Creates the set of WindowManagerDisplayRoots from the
163 // WindowManagerWindowTreeFactorySet.
164 void CreateWindowManagerDisplayRootsFromFactories();
165
166 void CreateWindowManagerDisplayRootFromFactory(
167 WindowManagerWindowTreeFactory* factory);
168
169 // PlatformDisplayDelegate:
170 ServerWindow* GetRootWindow() override;
171 void OnEvent(const ui::Event& event) override;
172 void OnNativeCaptureLost() override;
173 void OnDisplayClosed() override;
174 void OnViewportMetricsChanged(const ViewportMetrics& old_metrics,
175 const ViewportMetrics& new_metrics) override;
176 void OnCompositorFrameDrawn() override;
177
178 // FocusControllerDelegate:
179 bool CanHaveActiveChildren(ServerWindow* window) const override;
180
181 // FocusControllerObserver:
182 void OnActivationChanged(ServerWindow* old_active_window,
183 ServerWindow* new_active_window) override;
184 void OnFocusChanged(FocusControllerChangeSource change_source,
185 ServerWindow* old_focused_window,
186 ServerWindow* new_focused_window) override;
187
188 // ServerWindowObserver:
189 void OnWindowDestroyed(ServerWindow* window) override;
190
191 // UserIdTrackerObserver:
192 void OnUserIdRemoved(const UserId& id) override;
193
194 // WindowManagerWindowTreeFactorySetObserver:
195 void OnWindowManagerWindowTreeFactoryReady(
196 WindowManagerWindowTreeFactory* factory) override;
197
198 const uint32_t id_;
199 std::unique_ptr<DisplayBinding> binding_;
200 // Set once Init() has been called.
201 bool init_called_ = false;
202 WindowServer* const window_server_;
203 std::unique_ptr<ServerWindow> root_;
204 std::unique_ptr<PlatformDisplay> platform_display_;
205 std::unique_ptr<FocusController> focus_controller_;
206
207 // The last cursor set. Used to track whether we need to change the cursor.
208 int32_t last_cursor_;
209
210 ServerWindowTracker activation_parents_;
211
212 // Set of windows with surfaces that need to be destroyed once the frame
213 // draws.
214 std::set<ServerWindow*> windows_needing_frame_destruction_;
215
216 WindowManagerDisplayRootMap window_manager_display_root_map_;
217
218 DISALLOW_COPY_AND_ASSIGN(Display);
219 };
220
221 } // namespace ws
222 } // namespace mus
223
224 #endif // COMPONENTS_MUS_WS_DISPLAY_H_
OLDNEW
« no previous file with comments | « components/mus/ws/default_access_policy.cc ('k') | components/mus/ws/display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698