| 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 SERVICES_UI_WS_DISPLAY_H_ | 5 #ifndef SERVICES_UI_WS_DISPLAY_H_ |
| 6 #define SERVICES_UI_WS_DISPLAY_H_ | 6 #define SERVICES_UI_WS_DISPLAY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // Display. | 51 // Display. |
| 52 // . without a DisplayBinding. In this mode a WindowManager is automatically | 52 // . without a DisplayBinding. In this mode a WindowManager is automatically |
| 53 // created per user. | 53 // created per user. |
| 54 class Display : public PlatformDisplayDelegate, | 54 class Display : public PlatformDisplayDelegate, |
| 55 public mojom::WindowTreeHost, | 55 public mojom::WindowTreeHost, |
| 56 public FocusControllerObserver, | 56 public FocusControllerObserver, |
| 57 public FocusControllerDelegate, | 57 public FocusControllerDelegate, |
| 58 public UserIdTrackerObserver, | 58 public UserIdTrackerObserver, |
| 59 public WindowManagerWindowTreeFactorySetObserver { | 59 public WindowManagerWindowTreeFactorySetObserver { |
| 60 public: | 60 public: |
| 61 Display(WindowServer* window_server, | 61 explicit Display(WindowServer* window_server); |
| 62 const PlatformDisplayInitParams& platform_display_init_params); | |
| 63 ~Display() override; | 62 ~Display() override; |
| 64 | 63 |
| 65 // Initializes state that depends on the existence of a Display. | 64 // Initializes the display root ServerWindow and PlatformDisplay. Adds this to |
| 66 void Init(std::unique_ptr<DisplayBinding> binding); | 65 // DisplayManager as a pending display, until accelerated widget is available. |
| 66 void Init(const PlatformDisplayInitParams& init_params, |
| 67 std::unique_ptr<DisplayBinding> binding); |
| 67 | 68 |
| 68 int64_t GetId() const; | 69 int64_t GetId() const; |
| 69 | 70 |
| 70 DisplayManager* display_manager(); | 71 DisplayManager* display_manager(); |
| 71 const DisplayManager* display_manager() const; | 72 const DisplayManager* display_manager() const; |
| 72 | 73 |
| 73 PlatformDisplay* platform_display() { return platform_display_.get(); } | 74 PlatformDisplay* platform_display() { return platform_display_.get(); } |
| 74 | 75 |
| 75 // Returns a display::Display corresponding to this ws::Display. | 76 // Returns a display::Display corresponding to this ws::Display. |
| 76 display::Display ToDisplay() const; | 77 display::Display ToDisplay() const; |
| 77 | 78 |
| 79 // Returns the size of the display in physical pixels. |
| 78 gfx::Size GetSize() const; | 80 gfx::Size GetSize() const; |
| 79 | 81 |
| 80 WindowServer* window_server() { return window_server_; } | 82 WindowServer* window_server() { return window_server_; } |
| 81 | 83 |
| 82 // Returns the root of the Display. The root's children are the roots | 84 // Returns the root of the Display. The root's children are the roots |
| 83 // of the corresponding WindowManagers. | 85 // of the corresponding WindowManagers. |
| 84 ServerWindow* root_window() { return root_.get(); } | 86 ServerWindow* root_window() { return root_.get(); } |
| 85 const ServerWindow* root_window() const { return root_.get(); } | 87 const ServerWindow* root_window() const { return root_.get(); } |
| 86 | 88 |
| 87 // Returns the ServerWindow whose id is |id|. This does not do a search over | 89 // Returns the ServerWindow whose id is |id|. This does not do a search over |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Updates the size of display root ServerWindow and WM root ServerWindow(s). | 142 // Updates the size of display root ServerWindow and WM root ServerWindow(s). |
| 141 void OnViewportMetricsChanged(const display::ViewportMetrics& metrics); | 143 void OnViewportMetricsChanged(const display::ViewportMetrics& metrics); |
| 142 | 144 |
| 143 private: | 145 private: |
| 144 friend class test::DisplayTestApi; | 146 friend class test::DisplayTestApi; |
| 145 | 147 |
| 146 using WindowManagerDisplayRootMap = | 148 using WindowManagerDisplayRootMap = |
| 147 std::map<UserId, WindowManagerDisplayRoot*>; | 149 std::map<UserId, WindowManagerDisplayRoot*>; |
| 148 | 150 |
| 149 // Inits the necessary state once the display is ready. | 151 // Inits the necessary state once the display is ready. |
| 150 void InitWindowManagerDisplayRootsIfNecessary(); | 152 void InitWindowManagerDisplayRoots(); |
| 151 | 153 |
| 152 // Creates the set of WindowManagerDisplayRoots from the | 154 // Creates the set of WindowManagerDisplayRoots from the |
| 153 // WindowManagerWindowTreeFactorySet. | 155 // WindowManagerWindowTreeFactorySet. |
| 154 void CreateWindowManagerDisplayRootsFromFactories(); | 156 void CreateWindowManagerDisplayRootsFromFactories(); |
| 155 | 157 |
| 156 void CreateWindowManagerDisplayRootFromFactory( | 158 void CreateWindowManagerDisplayRootFromFactory( |
| 157 WindowManagerWindowTreeFactory* factory); | 159 WindowManagerWindowTreeFactory* factory); |
| 158 | 160 |
| 159 // Creates the root ServerWindow for this display, where |size| is in physical | 161 // Creates the root ServerWindow for this display, where |size| is in physical |
| 160 // pixels. | 162 // pixels. |
| 161 void CreateRootWindow(const gfx::Size& size); | 163 void CreateRootWindow(const gfx::Size& size); |
| 162 | 164 |
| 163 // PlatformDisplayDelegate: | 165 // PlatformDisplayDelegate: |
| 164 ServerWindow* GetRootWindow() override; | 166 ServerWindow* GetRootWindow() override; |
| 167 void OnAcceleratedWidgetAvailable() override; |
| 165 bool IsInHighContrastMode() override; | 168 bool IsInHighContrastMode() override; |
| 166 void OnEvent(const ui::Event& event) override; | 169 void OnEvent(const ui::Event& event) override; |
| 167 void OnNativeCaptureLost() override; | 170 void OnNativeCaptureLost() override; |
| 168 | 171 |
| 169 // FocusControllerDelegate: | 172 // FocusControllerDelegate: |
| 170 bool CanHaveActiveChildren(ServerWindow* window) const override; | 173 bool CanHaveActiveChildren(ServerWindow* window) const override; |
| 171 | 174 |
| 172 // FocusControllerObserver: | 175 // FocusControllerObserver: |
| 173 void OnActivationChanged(ServerWindow* old_active_window, | 176 void OnActivationChanged(ServerWindow* old_active_window, |
| 174 ServerWindow* new_active_window) override; | 177 ServerWindow* new_active_window) override; |
| 175 void OnFocusChanged(FocusControllerChangeSource change_source, | 178 void OnFocusChanged(FocusControllerChangeSource change_source, |
| 176 ServerWindow* old_focused_window, | 179 ServerWindow* old_focused_window, |
| 177 ServerWindow* new_focused_window) override; | 180 ServerWindow* new_focused_window) override; |
| 178 | 181 |
| 179 // UserIdTrackerObserver: | 182 // UserIdTrackerObserver: |
| 180 void OnUserIdRemoved(const UserId& id) override; | 183 void OnUserIdRemoved(const UserId& id) override; |
| 181 | 184 |
| 182 // WindowManagerWindowTreeFactorySetObserver: | 185 // WindowManagerWindowTreeFactorySetObserver: |
| 183 void OnWindowManagerWindowTreeFactoryReady( | 186 void OnWindowManagerWindowTreeFactoryReady( |
| 184 WindowManagerWindowTreeFactory* factory) override; | 187 WindowManagerWindowTreeFactory* factory) override; |
| 185 | 188 |
| 186 std::unique_ptr<DisplayBinding> binding_; | 189 std::unique_ptr<DisplayBinding> binding_; |
| 187 // Set once Init() has been called. | |
| 188 bool init_called_ = false; | |
| 189 WindowServer* const window_server_; | 190 WindowServer* const window_server_; |
| 190 std::unique_ptr<ServerWindow> root_; | 191 std::unique_ptr<ServerWindow> root_; |
| 191 std::unique_ptr<PlatformDisplay> platform_display_; | 192 std::unique_ptr<PlatformDisplay> platform_display_; |
| 192 std::unique_ptr<FocusController> focus_controller_; | 193 std::unique_ptr<FocusController> focus_controller_; |
| 193 | 194 |
| 194 // The last cursor set. Used to track whether we need to change the cursor. | 195 // The last cursor set. Used to track whether we need to change the cursor. |
| 195 mojom::Cursor last_cursor_; | 196 mojom::Cursor last_cursor_; |
| 196 | 197 |
| 197 ServerWindowTracker activation_parents_; | 198 ServerWindowTracker activation_parents_; |
| 198 | 199 |
| 199 WindowManagerDisplayRootMap window_manager_display_root_map_; | 200 WindowManagerDisplayRootMap window_manager_display_root_map_; |
| 200 | 201 |
| 201 DISALLOW_COPY_AND_ASSIGN(Display); | 202 DISALLOW_COPY_AND_ASSIGN(Display); |
| 202 }; | 203 }; |
| 203 | 204 |
| 204 } // namespace ws | 205 } // namespace ws |
| 205 } // namespace ui | 206 } // namespace ui |
| 206 | 207 |
| 207 #endif // SERVICES_UI_WS_DISPLAY_H_ | 208 #endif // SERVICES_UI_WS_DISPLAY_H_ |
| OLD | NEW |