| 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 UI_AURA_MONITOR_MANAGER_H_ | 5 #ifndef UI_AURA_MONITOR_MANAGER_H_ |
| 6 #define UI_AURA_MONITOR_MANAGER_H_ | 6 #define UI_AURA_MONITOR_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 13 #include "ui/aura/aura_export.h" | 14 #include "ui/aura/aura_export.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 class Point; | 17 class Point; |
| 17 class Size; | 18 class Size; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace aura { | 21 namespace aura { |
| 21 class Monitor; | 22 class Monitor; |
| 22 class RootWindow; | 23 class RootWindow; |
| 23 class Window; | 24 class Window; |
| 24 | 25 |
| 25 // Observers for monitor configuration changes. | 26 // Observers for monitor configuration changes. |
| 26 // TODO(oshima): multiple monitor support. | 27 // TODO(oshima): multiple monitor support. |
| 27 class MonitorObserver { | 28 class MonitorObserver { |
| 28 public: | 29 public: |
| 29 virtual void OnMonitorBoundsChanged(const Monitor* monitor) = 0; | 30 virtual void OnMonitorBoundsChanged(const Monitor* monitor) = 0; |
| 31 virtual void OnMonitorAdded(Monitor* new_monitor) = 0; |
| 32 virtual void OnMonitorRemoved(const Monitor* old_monitor) = 0; |
| 30 }; | 33 }; |
| 31 | 34 |
| 32 // MonitorManager creates, deletes and updates Monitor objects when | 35 // MonitorManager creates, deletes and updates Monitor objects when |
| 33 // monitor configuration changes, and notifies MonitorObservers about | 36 // monitor configuration changes, and notifies MonitorObservers about |
| 34 // the change. This is owned by Env and its lifetime is longer than | 37 // the change. This is owned by Env and its lifetime is longer than |
| 35 // any windows. | 38 // any windows. |
| 36 class AURA_EXPORT MonitorManager { | 39 class AURA_EXPORT MonitorManager { |
| 37 public: | 40 public: |
| 38 static void set_use_fullscreen_host_window(bool use_fullscreen) { | 41 static void set_use_fullscreen_host_window(bool use_fullscreen) { |
| 39 use_fullscreen_host_window_ = use_fullscreen; | 42 use_fullscreen_host_window_ = use_fullscreen; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 52 // A utility function to create a root window for primary monitor. | 55 // A utility function to create a root window for primary monitor. |
| 53 static RootWindow* CreateRootWindowForPrimaryMonitor(); | 56 static RootWindow* CreateRootWindowForPrimaryMonitor(); |
| 54 | 57 |
| 55 MonitorManager(); | 58 MonitorManager(); |
| 56 virtual ~MonitorManager(); | 59 virtual ~MonitorManager(); |
| 57 | 60 |
| 58 // Adds/removes MonitorObservers. | 61 // Adds/removes MonitorObservers. |
| 59 void AddObserver(MonitorObserver* observer); | 62 void AddObserver(MonitorObserver* observer); |
| 60 void RemoveObserver(MonitorObserver* observer); | 63 void RemoveObserver(MonitorObserver* observer); |
| 61 | 64 |
| 62 // Called when native window's monitor size has changed. | 65 // Called when monitor configuration has changed. The new monitor |
| 63 // TODO(oshima): multiple monitor support. | 66 // configurations is passed as a vector of Monitor object, which |
| 64 virtual void OnNativeMonitorResized(const gfx::Size& size) = 0; | 67 // contains each monitor's new infomration. |
| 68 virtual void OnNativeMonitorsChanged( |
| 69 const std::vector<const Monitor*>& monitors) = 0; |
| 65 | 70 |
| 66 // Create a root window for given |monitor|. | 71 // Create a root window for given |monitor|. |
| 67 virtual RootWindow* CreateRootWindowForMonitor(Monitor* monitor) = 0; | 72 virtual RootWindow* CreateRootWindowForMonitor(Monitor* monitor) = 0; |
| 68 | 73 |
| 69 // Returns the monitor object nearest given |window|. | 74 // Returns the monitor object nearest given |window|. |
| 70 virtual const Monitor* GetMonitorNearestWindow( | 75 virtual const Monitor* GetMonitorNearestWindow( |
| 71 const Window* window) const = 0; | 76 const Window* window) const = 0; |
| 72 virtual Monitor* GetMonitorNearestWindow(const Window* window) = 0; | 77 virtual Monitor* GetMonitorNearestWindow(const Window* window) = 0; |
| 73 | 78 |
| 74 // Returns the monitor object nearest given |pint|. | 79 // Returns the monitor object nearest given |pint|. |
| 75 virtual const Monitor* GetMonitorNearestPoint( | 80 virtual const Monitor* GetMonitorNearestPoint( |
| 76 const gfx::Point& point) const = 0; | 81 const gfx::Point& point) const = 0; |
| 77 | 82 |
| 78 // Returns the monitor at |index|. The monitor at 0 is consiered | 83 // Returns the monitor at |index|. The monitor at 0 is considered |
| 79 // "primary". | 84 // "primary". |
| 80 virtual Monitor* GetMonitorAt(size_t index) = 0; | 85 virtual Monitor* GetMonitorAt(size_t index) = 0; |
| 81 | 86 |
| 82 virtual size_t GetNumMonitors() const = 0; | 87 virtual size_t GetNumMonitors() const = 0; |
| 83 | 88 |
| 84 protected: | 89 protected: |
| 85 // Calls observers' OnMonitorBoundsChanged methods. | 90 // Calls observers' OnMonitorBoundsChanged methods. |
| 86 void NotifyBoundsChanged(const Monitor* monitor); | 91 void NotifyBoundsChanged(const Monitor* monitor); |
| 92 void NotifyMonitorAdded(Monitor* monitor); |
| 93 void NotifyMonitorRemoved(const Monitor* monitor); |
| 87 | 94 |
| 88 private: | 95 private: |
| 89 // If set before the RootWindow is created, the host window will cover the | 96 // If set before the RootWindow is created, the host window will cover the |
| 90 // entire monitor. Note that this can still be overridden via the | 97 // entire monitor. Note that this can still be overridden via the |
| 91 // switches::kAuraHostWindowSize flag. | 98 // switches::kAuraHostWindowSize flag. |
| 92 static bool use_fullscreen_host_window_; | 99 static bool use_fullscreen_host_window_; |
| 93 | 100 |
| 94 ObserverList<MonitorObserver> observers_; | 101 ObserverList<MonitorObserver> observers_; |
| 95 DISALLOW_COPY_AND_ASSIGN(MonitorManager); | 102 DISALLOW_COPY_AND_ASSIGN(MonitorManager); |
| 96 }; | 103 }; |
| 97 | 104 |
| 98 } // namespace aura | 105 } // namespace aura |
| 99 | 106 |
| 100 #endif // UI_AURA_MONITOR_MANAGER_H_ | 107 #endif // UI_AURA_MONITOR_MANAGER_H_ |
| OLD | NEW |