| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "ash/ash_export.h" | 14 #include "ash/ash_export.h" |
| 15 #include "ash/display/display_manager.h" | 15 #include "ash/display/display_manager.h" |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 23 #include "ui/aura/window_tree_host_observer.h" | 23 #include "ui/aura/window_tree_host_observer.h" |
| 24 #include "ui/base/ime/input_method.h" | 24 #include "ui/base/ime/input_method.h" |
| 25 #include "ui/base/ime/input_method_delegate.h" | 25 #include "ui/base/ime/input_method_delegate.h" |
| 26 #include "ui/gfx/display_observer.h" | 26 #include "ui/display/display_observer.h" |
| 27 #include "ui/gfx/geometry/point.h" | 27 #include "ui/gfx/geometry/point.h" |
| 28 | 28 |
| 29 namespace aura { | 29 namespace aura { |
| 30 class Display; | |
| 31 class WindowTreeHost; | 30 class WindowTreeHost; |
| 32 } | 31 } |
| 33 | 32 |
| 34 namespace base { | 33 namespace base { |
| 35 class Value; | 34 class Value; |
| 36 template <typename T> | 35 template <typename T> |
| 37 class JSONValueConverter; | 36 class JSONValueConverter; |
| 38 } | 37 } |
| 39 | 38 |
| 40 namespace gfx { | 39 namespace gfx { |
| 41 class Display; | |
| 42 class Insets; | 40 class Insets; |
| 43 } | 41 } |
| 44 | 42 |
| 45 namespace ash { | 43 namespace ash { |
| 46 class AshWindowTreeHost; | 44 class AshWindowTreeHost; |
| 47 struct AshWindowTreeHostInitParams; | 45 struct AshWindowTreeHostInitParams; |
| 48 class CursorWindowController; | 46 class CursorWindowController; |
| 49 class DisplayInfo; | 47 class DisplayInfo; |
| 50 class DisplayManager; | 48 class DisplayManager; |
| 51 class FocusActivationStore; | 49 class FocusActivationStore; |
| 52 class InputMethodEventHandler; | 50 class InputMethodEventHandler; |
| 53 class MirrorWindowController; | 51 class MirrorWindowController; |
| 54 class RootWindowController; | 52 class RootWindowController; |
| 55 | 53 |
| 56 // WindowTreeHostManager owns and maintains RootWindows for each attached | 54 // WindowTreeHostManager owns and maintains RootWindows for each attached |
| 57 // display, keeping them in sync with display configuration changes. | 55 // display, keeping them in sync with display configuration changes. |
| 58 class ASH_EXPORT WindowTreeHostManager | 56 class ASH_EXPORT WindowTreeHostManager |
| 59 : public gfx::DisplayObserver, | 57 : public display::DisplayObserver, |
| 60 public aura::WindowTreeHostObserver, | 58 public aura::WindowTreeHostObserver, |
| 61 public DisplayManager::Delegate, | 59 public DisplayManager::Delegate, |
| 62 public ui::internal::InputMethodDelegate { | 60 public ui::internal::InputMethodDelegate { |
| 63 public: | 61 public: |
| 64 // TODO(oshima): Consider moving this to gfx::DisplayObserver. | 62 // TODO(oshima): Consider moving this to display::DisplayObserver. |
| 65 class ASH_EXPORT Observer { | 63 class ASH_EXPORT Observer { |
| 66 public: | 64 public: |
| 67 // Invoked only once after all displays are initialized | 65 // Invoked only once after all displays are initialized |
| 68 // after startup. | 66 // after startup. |
| 69 virtual void OnDisplaysInitialized() {} | 67 virtual void OnDisplaysInitialized() {} |
| 70 | 68 |
| 71 // Invoked when the display configuration change is requested, | 69 // Invoked when the display configuration change is requested, |
| 72 // but before the change is applied to aura/ash. | 70 // but before the change is applied to aura/ash. |
| 73 virtual void OnDisplayConfigurationChanging() {} | 71 virtual void OnDisplayConfigurationChanging() {} |
| 74 | 72 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // Checks if the mouse pointer is on one of displays, and moves to | 143 // Checks if the mouse pointer is on one of displays, and moves to |
| 146 // the center of the nearest display if it's outside of all displays. | 144 // the center of the nearest display if it's outside of all displays. |
| 147 void UpdateMouseLocationAfterDisplayChange(); | 145 void UpdateMouseLocationAfterDisplayChange(); |
| 148 | 146 |
| 149 // Sets the work area's |insets| to the display assigned to |window|. | 147 // Sets the work area's |insets| to the display assigned to |window|. |
| 150 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, | 148 bool UpdateWorkAreaOfDisplayNearestWindow(const aura::Window* window, |
| 151 const gfx::Insets& insets); | 149 const gfx::Insets& insets); |
| 152 | 150 |
| 153 ui::InputMethod* input_method() { return input_method_.get(); } | 151 ui::InputMethod* input_method() { return input_method_.get(); } |
| 154 | 152 |
| 155 // gfx::DisplayObserver overrides: | 153 // display::DisplayObserver overrides: |
| 156 void OnDisplayAdded(const gfx::Display& display) override; | 154 void OnDisplayAdded(const display::Display& display) override; |
| 157 void OnDisplayRemoved(const gfx::Display& display) override; | 155 void OnDisplayRemoved(const display::Display& display) override; |
| 158 void OnDisplayMetricsChanged(const gfx::Display& display, | 156 void OnDisplayMetricsChanged(const display::Display& display, |
| 159 uint32_t metrics) override; | 157 uint32_t metrics) override; |
| 160 | 158 |
| 161 // aura::WindowTreeHostObserver overrides: | 159 // aura::WindowTreeHostObserver overrides: |
| 162 void OnHostResized(const aura::WindowTreeHost* host) override; | 160 void OnHostResized(const aura::WindowTreeHost* host) override; |
| 163 | 161 |
| 164 // aura::DisplayManager::Delegate overrides: | 162 // aura::DisplayManager::Delegate overrides: |
| 165 void CreateOrUpdateMirroringDisplay( | 163 void CreateOrUpdateMirroringDisplay( |
| 166 const DisplayInfoList& info_list) override; | 164 const DisplayInfoList& info_list) override; |
| 167 void CloseMirroringDisplayIfNotNecessary() override; | 165 void CloseMirroringDisplayIfNotNecessary() override; |
| 168 void PreDisplayConfigurationChange(bool clear_focus) override; | 166 void PreDisplayConfigurationChange(bool clear_focus) override; |
| 169 void PostDisplayConfigurationChange() override; | 167 void PostDisplayConfigurationChange() override; |
| 170 | 168 |
| 171 // ui::internal::InputMethodDelegate overrides: | 169 // ui::internal::InputMethodDelegate overrides: |
| 172 ui::EventDispatchDetails DispatchKeyEventPostIME( | 170 ui::EventDispatchDetails DispatchKeyEventPostIME( |
| 173 ui::KeyEvent* event) override; | 171 ui::KeyEvent* event) override; |
| 174 | 172 |
| 175 InputMethodEventHandler* input_method_event_handler() { | 173 InputMethodEventHandler* input_method_event_handler() { |
| 176 return input_method_event_handler_.get(); | 174 return input_method_event_handler_.get(); |
| 177 } | 175 } |
| 178 | 176 |
| 179 private: | 177 private: |
| 180 FRIEND_TEST_ALL_PREFIXES(WindowTreeHostManagerTest, BoundsUpdated); | 178 FRIEND_TEST_ALL_PREFIXES(WindowTreeHostManagerTest, BoundsUpdated); |
| 181 FRIEND_TEST_ALL_PREFIXES(WindowTreeHostManagerTest, SecondaryDisplayLayout); | 179 FRIEND_TEST_ALL_PREFIXES(WindowTreeHostManagerTest, SecondaryDisplayLayout); |
| 182 friend class DisplayManager; | 180 friend class DisplayManager; |
| 183 friend class MirrorWindowController; | 181 friend class MirrorWindowController; |
| 184 | 182 |
| 185 // Creates a WindowTreeHost for |display| and stores it in the | 183 // Creates a WindowTreeHost for |display| and stores it in the |
| 186 // |window_tree_hosts_| map. | 184 // |window_tree_hosts_| map. |
| 187 AshWindowTreeHost* AddWindowTreeHostForDisplay( | 185 AshWindowTreeHost* AddWindowTreeHostForDisplay( |
| 188 const gfx::Display& display, | 186 const display::Display& display, |
| 189 const AshWindowTreeHostInitParams& params); | 187 const AshWindowTreeHostInitParams& params); |
| 190 | 188 |
| 191 // Delete the AsWindowTreeHost. This does not remove the entry from | 189 // Delete the AsWindowTreeHost. This does not remove the entry from |
| 192 // |window_tree_hosts_|. Caller has to explicitly remove it. | 190 // |window_tree_hosts_|. Caller has to explicitly remove it. |
| 193 void DeleteHost(AshWindowTreeHost* host_to_delete); | 191 void DeleteHost(AshWindowTreeHost* host_to_delete); |
| 194 | 192 |
| 195 typedef std::map<int64_t, AshWindowTreeHost*> WindowTreeHostMap; | 193 typedef std::map<int64_t, AshWindowTreeHost*> WindowTreeHostMap; |
| 196 // The mapping from display ID to its window tree host. | 194 // The mapping from display ID to its window tree host. |
| 197 WindowTreeHostMap window_tree_hosts_; | 195 WindowTreeHostMap window_tree_hosts_; |
| 198 | 196 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 222 int64_t cursor_display_id_for_restore_; | 220 int64_t cursor_display_id_for_restore_; |
| 223 | 221 |
| 224 base::WeakPtrFactory<WindowTreeHostManager> weak_ptr_factory_; | 222 base::WeakPtrFactory<WindowTreeHostManager> weak_ptr_factory_; |
| 225 | 223 |
| 226 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManager); | 224 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostManager); |
| 227 }; | 225 }; |
| 228 | 226 |
| 229 } // namespace ash | 227 } // namespace ash |
| 230 | 228 |
| 231 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ | 229 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
| OLD | NEW |