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_MONITOR_MULTI_MONITOR_MANAGER_H_ | 5 #ifndef ASH_MONITOR_MULTI_MONITOR_MANAGER_H_ |
6 #define ASH_MONITOR_MULTI_MONITOR_MANAGER_H_ | 6 #define ASH_MONITOR_MULTI_MONITOR_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "ui/aura/monitor_manager.h" | 13 #include "ui/aura/monitor_manager.h" |
14 #include "ui/aura/root_window_observer.h" | 14 #include "ui/aura/root_window_observer.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 class Insets; | 18 class Insets; |
19 class Monitor; | 19 class Display; |
20 } | 20 } |
21 | 21 |
22 namespace ash { | 22 namespace ash { |
23 namespace internal { | 23 namespace internal { |
24 | 24 |
25 // MultiMonitorManager maintains the current monitor configurations, | 25 // MultiMonitorManager maintains the current monitor configurations, |
26 // and notifies observers when configuration changes. | 26 // and notifies observers when configuration changes. |
27 // This is exported for unittest. | 27 // This is exported for unittest. |
28 // | 28 // |
29 // TODO(oshima): gfx::Screen needs to return translated coordinates | 29 // TODO(oshima): gfx::Screen needs to return translated coordinates |
30 // if the root window is translated. crbug.com/119268. | 30 // if the root window is translated. crbug.com/119268. |
31 class ASH_EXPORT MultiMonitorManager : public aura::MonitorManager, | 31 class ASH_EXPORT MultiMonitorManager : public aura::MonitorManager, |
32 public aura::RootWindowObserver { | 32 public aura::RootWindowObserver { |
33 public: | 33 public: |
34 MultiMonitorManager(); | 34 MultiMonitorManager(); |
35 virtual ~MultiMonitorManager(); | 35 virtual ~MultiMonitorManager(); |
36 | 36 |
37 // Used to emulate monitor change when run in a desktop environment instead | 37 // Used to emulate monitor change when run in a desktop environment instead |
38 // of on a device. | 38 // of on a device. |
39 static void AddRemoveMonitor(); | 39 static void AddRemoveMonitor(); |
40 static void CycleMonitor(); | 40 static void CycleMonitor(); |
41 static void ToggleMonitorScale(); | 41 static void ToggleMonitorScale(); |
42 | 42 |
43 bool UpdateWorkAreaOfMonitorNearestWindow(const aura::Window* window, | 43 bool UpdateWorkAreaOfMonitorNearestWindow(const aura::Window* window, |
44 const gfx::Insets& insets); | 44 const gfx::Insets& insets); |
45 | 45 |
46 // MonitorManager overrides: | 46 // MonitorManager overrides: |
47 virtual void OnNativeMonitorsChanged( | 47 virtual void OnNativeMonitorsChanged( |
48 const std::vector<gfx::Monitor>& monitors) OVERRIDE; | 48 const std::vector<gfx::Display>& displays) OVERRIDE; |
49 virtual aura::RootWindow* CreateRootWindowForMonitor( | 49 virtual aura::RootWindow* CreateRootWindowForMonitor( |
50 const gfx::Monitor& monitor) OVERRIDE; | 50 const gfx::Display& display) OVERRIDE; |
51 virtual const gfx::Monitor& GetMonitorAt(size_t index) OVERRIDE; | 51 virtual const gfx::Display& GetMonitorAt(size_t index) OVERRIDE; |
52 | 52 |
53 virtual size_t GetNumMonitors() const OVERRIDE; | 53 virtual size_t GetNumMonitors() const OVERRIDE; |
54 virtual const gfx::Monitor& GetMonitorNearestPoint( | 54 virtual const gfx::Display& GetMonitorNearestPoint( |
55 const gfx::Point& point) const OVERRIDE; | 55 const gfx::Point& point) const OVERRIDE; |
56 virtual const gfx::Monitor& GetMonitorNearestWindow( | 56 virtual const gfx::Display& GetMonitorNearestWindow( |
57 const aura::Window* window) const OVERRIDE; | 57 const aura::Window* window) const OVERRIDE; |
58 | 58 |
59 // RootWindowObserver overrides: | 59 // RootWindowObserver overrides: |
60 virtual void OnRootWindowResized(const aura::RootWindow* root, | 60 virtual void OnRootWindowResized(const aura::RootWindow* root, |
61 const gfx::Size& new_size) OVERRIDE; | 61 const gfx::Size& new_size) OVERRIDE; |
62 | 62 |
63 private: | 63 private: |
64 typedef std::vector<gfx::Monitor> Monitors; | 64 typedef std::vector<gfx::Display> Displays; |
65 | 65 |
66 void Init(); | 66 void Init(); |
67 void AddRemoveMonitorImpl(); | 67 void AddRemoveMonitorImpl(); |
68 void CycleMonitorImpl(); | 68 void CycleMonitorImpl(); |
69 void ScaleMonitorImpl(); | 69 void ScaleMonitorImpl(); |
70 gfx::Monitor& FindMonitorById(int id); | 70 gfx::Display& FindDisplayById(int id); |
71 | 71 |
72 Monitors monitors_; | 72 Displays displays_; |
73 | 73 |
74 DISALLOW_COPY_AND_ASSIGN(MultiMonitorManager); | 74 DISALLOW_COPY_AND_ASSIGN(MultiMonitorManager); |
75 }; | 75 }; |
76 | 76 |
77 extern const aura::WindowProperty<int>* const kMonitorIdKey; | 77 extern const aura::WindowProperty<int>* const kMonitorIdKey; |
78 | 78 |
79 } // namespace internal | 79 } // namespace internal |
80 } // namespace ash | 80 } // namespace ash |
81 | 81 |
82 #endif // ASH_MONITOR_MULTI_MONITOR_MANAGER_H_ | 82 #endif // ASH_MONITOR_MULTI_MONITOR_MANAGER_H_ |
OLD | NEW |