| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ASH_DISPLAY_DISPLAY_CONTROLLER_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
| 6 #define ASH_DISPLAY_DISPLAY_CONTROLLER_H_ | 6 #define ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class Value; | 30 class Value; |
| 31 template <typename T> class JSONValueConverter; | 31 template <typename T> class JSONValueConverter; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace gfx { | 34 namespace gfx { |
| 35 class Display; | 35 class Display; |
| 36 class Insets; | 36 class Insets; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace ash { | 39 namespace ash { |
| 40 namespace internal { | |
| 41 class CursorWindowController; | 40 class CursorWindowController; |
| 42 class DisplayInfo; | 41 class DisplayInfo; |
| 43 class DisplayManager; | 42 class DisplayManager; |
| 44 class FocusActivationStore; | 43 class FocusActivationStore; |
| 45 class MirrorWindowController; | 44 class MirrorWindowController; |
| 46 class RootWindowController; | 45 class RootWindowController; |
| 47 class VirtualKeyboardWindowController; | 46 class VirtualKeyboardWindowController; |
| 48 } | |
| 49 | 47 |
| 50 // DisplayController owns and maintains RootWindows for each attached | 48 // DisplayController owns and maintains RootWindows for each attached |
| 51 // display, keeping them in sync with display configuration changes. | 49 // display, keeping them in sync with display configuration changes. |
| 52 class ASH_EXPORT DisplayController : public gfx::DisplayObserver, | 50 class ASH_EXPORT DisplayController : public gfx::DisplayObserver, |
| 53 public aura::WindowTreeHostObserver, | 51 public aura::WindowTreeHostObserver, |
| 54 public internal::DisplayManager::Delegate { | 52 public DisplayManager::Delegate { |
| 55 public: | 53 public: |
| 56 class ASH_EXPORT Observer { | 54 class ASH_EXPORT Observer { |
| 57 public: | 55 public: |
| 58 // Invoked only once after all displays are initialized | 56 // Invoked only once after all displays are initialized |
| 59 // after startup. | 57 // after startup. |
| 60 virtual void OnDisplaysInitialized() {} | 58 virtual void OnDisplaysInitialized() {} |
| 61 | 59 |
| 62 // Invoked when the display configuration change is requested, | 60 // Invoked when the display configuration change is requested, |
| 63 // but before the change is applied to aura/ash. | 61 // but before the change is applied to aura/ash. |
| 64 virtual void OnDisplayConfigurationChanging() {} | 62 virtual void OnDisplayConfigurationChanging() {} |
| 65 | 63 |
| 66 // Invoked when the all display configuration changes | 64 // Invoked when the all display configuration changes |
| 67 // have been applied. | 65 // have been applied. |
| 68 virtual void OnDisplayConfigurationChanged() {}; | 66 virtual void OnDisplayConfigurationChanged() {}; |
| 69 | 67 |
| 70 protected: | 68 protected: |
| 71 virtual ~Observer() {} | 69 virtual ~Observer() {} |
| 72 }; | 70 }; |
| 73 | 71 |
| 74 DisplayController(); | 72 DisplayController(); |
| 75 virtual ~DisplayController(); | 73 virtual ~DisplayController(); |
| 76 | 74 |
| 77 void Start(); | 75 void Start(); |
| 78 void Shutdown(); | 76 void Shutdown(); |
| 79 | 77 |
| 80 // Returns primary display's ID. | 78 // Returns primary display's ID. |
| 81 // TODO(oshima): Move this out from DisplayController; | 79 // TODO(oshima): Move this out from DisplayController; |
| 82 static int64 GetPrimaryDisplayId(); | 80 static int64 GetPrimaryDisplayId(); |
| 83 | 81 |
| 84 internal::CursorWindowController* cursor_window_controller() { | 82 CursorWindowController* cursor_window_controller() { |
| 85 return cursor_window_controller_.get(); | 83 return cursor_window_controller_.get(); |
| 86 } | 84 } |
| 87 | 85 |
| 88 internal::MirrorWindowController* mirror_window_controller() { | 86 MirrorWindowController* mirror_window_controller() { |
| 89 return mirror_window_controller_.get(); | 87 return mirror_window_controller_.get(); |
| 90 } | 88 } |
| 91 | 89 |
| 92 internal::VirtualKeyboardWindowController* | 90 VirtualKeyboardWindowController* virtual_keyboard_window_controller() { |
| 93 virtual_keyboard_window_controller() { | |
| 94 return virtual_keyboard_window_controller_.get(); | 91 return virtual_keyboard_window_controller_.get(); |
| 95 } | 92 } |
| 96 | 93 |
| 97 // Initializes primary display. | 94 // Initializes primary display. |
| 98 void InitPrimaryDisplay(); | 95 void InitPrimaryDisplay(); |
| 99 | 96 |
| 100 // Initialize secondary displays. | 97 // Initialize secondary displays. |
| 101 void InitSecondaryDisplays(); | 98 void InitSecondaryDisplays(); |
| 102 | 99 |
| 103 // Add/Remove observers. | 100 // Add/Remove observers. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 126 | 123 |
| 127 // Closes all child windows in the all root windows. | 124 // Closes all child windows in the all root windows. |
| 128 void CloseChildWindows(); | 125 void CloseChildWindows(); |
| 129 | 126 |
| 130 // Returns all root windows. In non extended desktop mode, this | 127 // Returns all root windows. In non extended desktop mode, this |
| 131 // returns the primary root window only. | 128 // returns the primary root window only. |
| 132 aura::Window::Windows GetAllRootWindows(); | 129 aura::Window::Windows GetAllRootWindows(); |
| 133 | 130 |
| 134 // Returns all oot window controllers. In non extended desktop | 131 // Returns all oot window controllers. In non extended desktop |
| 135 // mode, this return a RootWindowController for the primary root window only. | 132 // mode, this return a RootWindowController for the primary root window only. |
| 136 std::vector<internal::RootWindowController*> GetAllRootWindowControllers(); | 133 std::vector<RootWindowController*> GetAllRootWindowControllers(); |
| 137 | 134 |
| 138 // Gets/Sets/Clears the overscan insets for the specified |display_id|. See | 135 // Gets/Sets/Clears the overscan insets for the specified |display_id|. See |
| 139 // display_manager.h for the details. | 136 // display_manager.h for the details. |
| 140 gfx::Insets GetOverscanInsets(int64 display_id) const; | 137 gfx::Insets GetOverscanInsets(int64 display_id) const; |
| 141 void SetOverscanInsets(int64 display_id, const gfx::Insets& insets_in_dip); | 138 void SetOverscanInsets(int64 display_id, const gfx::Insets& insets_in_dip); |
| 142 | 139 |
| 143 // Checks if the mouse pointer is on one of displays, and moves to | 140 // Checks if the mouse pointer is on one of displays, and moves to |
| 144 // the center of the nearest display if it's outside of all displays. | 141 // the center of the nearest display if it's outside of all displays. |
| 145 void EnsurePointerInDisplays(); | 142 void EnsurePointerInDisplays(); |
| 146 | 143 |
| 147 // Sets the work area's |insets| to the display assigned to |window|. | 144 // Sets the work area's |insets| to the display assigned to |window|. |
| 148 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, | 145 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, |
| 149 const gfx::Insets& insets); | 146 const gfx::Insets& insets); |
| 150 // aura::DisplayObserver overrides: | 147 // aura::DisplayObserver overrides: |
| 151 virtual void OnDisplayBoundsChanged( | 148 virtual void OnDisplayBoundsChanged( |
| 152 const gfx::Display& display) OVERRIDE; | 149 const gfx::Display& display) OVERRIDE; |
| 153 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | 150 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; |
| 154 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; | 151 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; |
| 155 | 152 |
| 156 // aura::WindowTreeHostObserver overrides: | 153 // aura::WindowTreeHostObserver overrides: |
| 157 virtual void OnHostResized(const aura::WindowTreeHost* host) OVERRIDE; | 154 virtual void OnHostResized(const aura::WindowTreeHost* host) OVERRIDE; |
| 158 | 155 |
| 159 // aura::DisplayManager::Delegate overrides: | 156 // aura::DisplayManager::Delegate overrides: |
| 160 virtual void CreateOrUpdateNonDesktopDisplay( | 157 virtual void CreateOrUpdateNonDesktopDisplay(const DisplayInfo& info) |
| 161 const internal::DisplayInfo& info) OVERRIDE; | 158 OVERRIDE; |
| 162 virtual void CloseNonDesktopDisplay() OVERRIDE; | 159 virtual void CloseNonDesktopDisplay() OVERRIDE; |
| 163 virtual void PreDisplayConfigurationChange(bool clear_focus) OVERRIDE; | 160 virtual void PreDisplayConfigurationChange(bool clear_focus) OVERRIDE; |
| 164 virtual void PostDisplayConfigurationChange() OVERRIDE; | 161 virtual void PostDisplayConfigurationChange() OVERRIDE; |
| 165 | 162 |
| 166 private: | 163 private: |
| 167 FRIEND_TEST_ALL_PREFIXES(DisplayControllerTest, BoundsUpdated); | 164 FRIEND_TEST_ALL_PREFIXES(DisplayControllerTest, BoundsUpdated); |
| 168 FRIEND_TEST_ALL_PREFIXES(DisplayControllerTest, SecondaryDisplayLayout); | 165 FRIEND_TEST_ALL_PREFIXES(DisplayControllerTest, SecondaryDisplayLayout); |
| 169 friend class internal::DisplayManager; | 166 friend class DisplayManager; |
| 170 friend class internal::MirrorWindowController; | 167 friend class MirrorWindowController; |
| 171 | 168 |
| 172 // Creates a WindowTreeHost for |display| and stores it in the |root_windows_| | 169 // Creates a WindowTreeHost for |display| and stores it in the |root_windows_| |
| 173 // map. | 170 // map. |
| 174 aura::WindowTreeHost* AddWindowTreeHostForDisplay( | 171 aura::WindowTreeHost* AddWindowTreeHostForDisplay( |
| 175 const gfx::Display& display); | 172 const gfx::Display& display); |
| 176 | 173 |
| 177 void OnFadeOutForSwapDisplayFinished(); | 174 void OnFadeOutForSwapDisplayFinished(); |
| 178 | 175 |
| 179 void UpdateHostWindowNames(); | 176 void UpdateHostWindowNames(); |
| 180 | 177 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 200 | 197 |
| 201 // The mapping from display ID to its root window. | 198 // The mapping from display ID to its root window. |
| 202 std::map<int64, aura::Window*> root_windows_; | 199 std::map<int64, aura::Window*> root_windows_; |
| 203 | 200 |
| 204 ObserverList<Observer> observers_; | 201 ObserverList<Observer> observers_; |
| 205 | 202 |
| 206 // Store the primary root window temporarily while replacing | 203 // Store the primary root window temporarily while replacing |
| 207 // display. | 204 // display. |
| 208 aura::Window* primary_root_window_for_replace_; | 205 aura::Window* primary_root_window_for_replace_; |
| 209 | 206 |
| 210 scoped_ptr<internal::FocusActivationStore> focus_activation_store_; | 207 scoped_ptr<FocusActivationStore> focus_activation_store_; |
| 211 | 208 |
| 212 scoped_ptr<internal::CursorWindowController> cursor_window_controller_; | 209 scoped_ptr<CursorWindowController> cursor_window_controller_; |
| 213 scoped_ptr<internal::MirrorWindowController> mirror_window_controller_; | 210 scoped_ptr<MirrorWindowController> mirror_window_controller_; |
| 214 scoped_ptr<internal::VirtualKeyboardWindowController> | 211 scoped_ptr<VirtualKeyboardWindowController> |
| 215 virtual_keyboard_window_controller_; | 212 virtual_keyboard_window_controller_; |
| 216 | 213 |
| 217 // Stores the curent cursor location (in native coordinates) used to | 214 // Stores the curent cursor location (in native coordinates) used to |
| 218 // restore the cursor location when display configuration | 215 // restore the cursor location when display configuration |
| 219 // changed. | 216 // changed. |
| 220 gfx::Point cursor_location_in_native_coords_for_restore_; | 217 gfx::Point cursor_location_in_native_coords_for_restore_; |
| 221 | 218 |
| 222 DISALLOW_COPY_AND_ASSIGN(DisplayController); | 219 DISALLOW_COPY_AND_ASSIGN(DisplayController); |
| 223 }; | 220 }; |
| 224 | 221 |
| 225 } // namespace ash | 222 } // namespace ash |
| 226 | 223 |
| 227 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ | 224 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
| OLD | NEW |