Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1548)

Side by Side Diff: ui/aura/monitor_manager.h

Issue 10540091: Rename gfx::Monitor to gfx::Display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "ui/aura/aura_export.h" 14 #include "ui/aura/aura_export.h"
15 15
16 namespace gfx { 16 namespace gfx {
17 class Monitor; 17 class Display;
18 class Point; 18 class Point;
19 class Size; 19 class Size;
20 } 20 }
21 21
22 namespace aura { 22 namespace aura {
23 class MonitorObserver; 23 class DisplayObserver;
24 class RootWindow; 24 class RootWindow;
25 class Window; 25 class Window;
26 26
27 // MonitorManager creates, deletes and updates Monitor objects when 27 // MonitorManager creates, deletes and updates Monitor objects when
28 // monitor configuration changes, and notifies MonitorObservers about 28 // monitor configuration changes, and notifies DisplayObservers about
29 // the change. This is owned by Env and its lifetime is longer than 29 // the change. This is owned by Env and its lifetime is longer than
30 // any windows. 30 // any windows.
31 class AURA_EXPORT MonitorManager { 31 class AURA_EXPORT MonitorManager {
32 public: 32 public:
33 static void set_use_fullscreen_host_window(bool use_fullscreen) { 33 static void set_use_fullscreen_host_window(bool use_fullscreen) {
34 use_fullscreen_host_window_ = use_fullscreen; 34 use_fullscreen_host_window_ = use_fullscreen;
35 } 35 }
36 static bool use_fullscreen_host_window() { 36 static bool use_fullscreen_host_window() {
37 return use_fullscreen_host_window_; 37 return use_fullscreen_host_window_;
38 } 38 }
39 39
40 // Creates a monitor from string spec. 100+200-1440x800 creates monitor 40 // Creates a monitor from string spec. 100+200-1440x800 creates monitor
41 // whose size is 1440x800 at the location (100, 200) in screen's coordinates. 41 // whose size is 1440x800 at the location (100, 200) in screen's coordinates.
42 // The location can be omitted and be just "1440x800", which creates 42 // The location can be omitted and be just "1440x800", which creates
43 // monitor at the origin of the screen. An empty string creates 43 // monitor at the origin of the screen. An empty string creates
44 // the monitor with default size. 44 // the monitor with default size.
45 // The device scale factor can be specified by "*", like "1280x780*2", 45 // The device scale factor can be specified by "*", like "1280x780*2",
46 // or |gfx::Monitor::GetDefaultDeviceScaleFactor()| will be used if omitted. 46 // or |gfx::Display::GetDefaultDeviceScaleFactor()| will be used if omitted.
47 static gfx::Monitor CreateMonitorFromSpec(const std::string& spec); 47 static gfx::Display CreateMonitorFromSpec(const std::string& spec);
48 48
49 // A utility function to create a root window for primary monitor. 49 // A utility function to create a root window for primary monitor.
50 static RootWindow* CreateRootWindowForPrimaryMonitor(); 50 static RootWindow* CreateRootWindowForPrimaryMonitor();
51 51
52 MonitorManager(); 52 MonitorManager();
53 virtual ~MonitorManager(); 53 virtual ~MonitorManager();
54 54
55 // Adds/removes MonitorObservers. 55 // Adds/removes DisplayObservers.
56 void AddObserver(MonitorObserver* observer); 56 void AddObserver(DisplayObserver* observer);
57 void RemoveObserver(MonitorObserver* observer); 57 void RemoveObserver(DisplayObserver* observer);
58 58
59 // Called when monitor configuration has changed. The new monitor 59 // Called when monitor configuration has changed. The new monitor
60 // configurations is passed as a vector of Monitor object, which 60 // configurations is passed as a vector of Monitor object, which
61 // contains each monitor's new infomration. 61 // contains each monitor's new infomration.
62 virtual void OnNativeMonitorsChanged( 62 virtual void OnNativeMonitorsChanged(
63 const std::vector<gfx::Monitor>& monitors) = 0; 63 const std::vector<gfx::Display>& display) = 0;
64 64
65 // Create a root window for given |monitor|. 65 // Create a root window for given |monitor|.
66 virtual RootWindow* CreateRootWindowForMonitor( 66 virtual RootWindow* CreateRootWindowForMonitor(
67 const gfx::Monitor& monitor) = 0; 67 const gfx::Display& display) = 0;
68 68
69 // Returns the monitor at |index|. The monitor at 0 is considered 69 // Returns the display at |index|. The display at 0 is considered "primary".
70 // "primary". 70 virtual const gfx::Display& GetMonitorAt(size_t index) = 0;
71 virtual const gfx::Monitor& GetMonitorAt(size_t index) = 0;
72 71
73 virtual size_t GetNumMonitors() const = 0; 72 virtual size_t GetNumMonitors() const = 0;
74 73
75 // Returns the monitor object nearest given |window|. 74 // Returns the display object nearest given |window|.
76 virtual const gfx::Monitor& GetMonitorNearestWindow( 75 virtual const gfx::Display& GetMonitorNearestWindow(
77 const Window* window) const = 0; 76 const Window* window) const = 0;
78 77
79 // Returns the monitor object nearest given |pint|. 78 // Returns the monitor object nearest given |pint|.
80 virtual const gfx::Monitor& GetMonitorNearestPoint( 79 virtual const gfx::Display& GetMonitorNearestPoint(
81 const gfx::Point& point) const = 0; 80 const gfx::Point& point) const = 0;
82 81
83 protected: 82 protected:
84 // Calls observers' OnMonitorBoundsChanged methods. 83 // Calls observers' OnDisplayBoundsChanged methods.
85 void NotifyBoundsChanged(const gfx::Monitor& monitor); 84 void NotifyBoundsChanged(const gfx::Display& display);
86 void NotifyMonitorAdded(const gfx::Monitor& monitor); 85 void NotifyDisplayAdded(const gfx::Display& display);
87 void NotifyMonitorRemoved(const gfx::Monitor& monitor); 86 void NotifyDisplayRemoved(const gfx::Display& display);
88 87
89 private: 88 private:
90 // If set before the RootWindow is created, the host window will cover the 89 // If set before the RootWindow is created, the host window will cover the
91 // entire monitor. Note that this can still be overridden via the 90 // entire monitor. Note that this can still be overridden via the
92 // switches::kAuraHostWindowSize flag. 91 // switches::kAuraHostWindowSize flag.
93 static bool use_fullscreen_host_window_; 92 static bool use_fullscreen_host_window_;
94 93
95 ObserverList<MonitorObserver> observers_; 94 ObserverList<DisplayObserver> observers_;
96 DISALLOW_COPY_AND_ASSIGN(MonitorManager); 95 DISALLOW_COPY_AND_ASSIGN(MonitorManager);
97 }; 96 };
98 97
99 } // namespace aura 98 } // namespace aura
100 99
101 #endif // UI_AURA_MONITOR_MANAGER_H_ 100 #endif // UI_AURA_MONITOR_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698