OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_AURA_DISPLAY_MANAGER_H_ | |
6 #define UI_AURA_DISPLAY_MANAGER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/observer_list.h" | |
13 #include "ui/aura/aura_export.h" | |
14 | |
15 namespace gfx { | |
16 class Display; | |
17 class Point; | |
18 class Rect; | |
19 class Size; | |
20 } | |
21 | |
22 namespace aura { | |
23 class DisplayObserver; | |
24 class RootWindow; | |
25 class Window; | |
26 | |
27 // DisplayManager creates, deletes and updates Display objects when | |
28 // display configuration changes, and notifies DisplayObservers about | |
29 // the change. This is owned by Env and its lifetime is longer than | |
30 // any windows. | |
31 class AURA_EXPORT DisplayManager { | |
32 public: | |
33 static void set_use_fullscreen_host_window(bool use_fullscreen) { | |
34 use_fullscreen_host_window_ = use_fullscreen; | |
35 } | |
36 static bool use_fullscreen_host_window() { | |
37 return use_fullscreen_host_window_; | |
38 } | |
39 | |
40 // Creates a display from string spec. 100+200-1440x800 creates display | |
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 | |
43 // display at the origin of the screen. An empty string creates | |
44 // the display with default size. | |
45 // The device scale factor can be specified by "*", like "1280x780*2", | |
46 // or will use the value of |gfx::Display::GetForcedDeviceScaleFactor()| if | |
47 // --force-device-scale-factor is specified. | |
48 static gfx::Display CreateDisplayFromSpec(const std::string& spec); | |
49 | |
50 // A utility function to create a root window for primary display. | |
51 static RootWindow* CreateRootWindowForPrimaryDisplay(); | |
52 | |
53 DisplayManager(); | |
54 virtual ~DisplayManager(); | |
55 | |
56 // Adds/removes DisplayObservers. | |
57 void AddObserver(DisplayObserver* observer); | |
58 void RemoveObserver(DisplayObserver* observer); | |
59 | |
60 // Called when display configuration has changed. The new display | |
61 // configurations is passed as a vector of Display object, which | |
62 // contains each display's new infomration. | |
63 virtual void OnNativeDisplaysChanged( | |
64 const std::vector<gfx::Display>& display) = 0; | |
65 | |
66 // Create a root window for given |display|. | |
67 virtual RootWindow* CreateRootWindowForDisplay( | |
68 const gfx::Display& display) = 0; | |
69 | |
70 // Obsoleted: Do not use in new code. | |
71 // Returns the display at |index|. The display at 0 is | |
72 // no longer considered "primary". | |
73 virtual gfx::Display* GetDisplayAt(size_t index) = 0; | |
74 | |
75 virtual size_t GetNumDisplays() const = 0; | |
76 | |
77 // Returns the display object nearest given |window|. | |
78 virtual const gfx::Display& GetDisplayNearestWindow( | |
79 const Window* window) const = 0; | |
80 | |
81 // Returns the display object nearest given |point|. | |
82 virtual const gfx::Display& GetDisplayNearestPoint( | |
83 const gfx::Point& point) const = 0; | |
84 | |
85 // Returns the display that most closely intersects |match_rect|. | |
86 virtual const gfx::Display& GetDisplayMatching( | |
87 const gfx::Rect& match_rect) const = 0; | |
88 | |
89 // Returns the human-readable name for the display specified by |display|. | |
90 virtual std::string GetDisplayNameFor(const gfx::Display& display) = 0; | |
91 | |
92 protected: | |
93 // Calls observers' OnDisplayBoundsChanged methods. | |
94 void NotifyBoundsChanged(const gfx::Display& display); | |
95 void NotifyDisplayAdded(const gfx::Display& display); | |
96 void NotifyDisplayRemoved(const gfx::Display& display); | |
97 | |
98 private: | |
99 // If set before the RootWindow is created, the host window will cover the | |
100 // entire display. Note that this can still be overridden via the | |
101 // switches::kAuraHostWindowSize flag. | |
102 static bool use_fullscreen_host_window_; | |
103 | |
104 ObserverList<DisplayObserver> observers_; | |
105 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | |
106 }; | |
107 | |
108 } // namespace aura | |
109 | |
110 #endif // UI_AURA_DISPLAY_MANAGER_H_ | |
OLD | NEW |