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 ASH_MONITOR_MONITOR_CONTROLLER_H_ | |
6 #define ASH_MONITOR_MONITOR_CONTROLLER_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 #include <vector> | |
11 | |
12 #include "ash/ash_export.h" | |
13 #include "base/basictypes.h" | |
14 #include "base/compiler_specific.h" | |
15 #include "ui/aura/display_observer.h" | |
16 #include "ui/aura/monitor_manager.h" | |
17 | |
18 namespace aura { | |
19 class Display; | |
20 class RootWindow; | |
21 } | |
22 | |
23 namespace ash { | |
24 namespace internal { | |
25 class RootWindowController; | |
26 | |
27 // MonitorController owns and maintains RootWindows for each attached | |
28 // display, keeping them in sync with display configuration changes. | |
29 // TODO(oshima): Rename MonitorXXX to DisplayXXX. | |
30 class ASH_EXPORT MonitorController : public aura::DisplayObserver { | |
31 public: | |
32 // Layout options where the secondary monitor should be positioned. | |
33 enum SecondaryDisplayLayout { | |
34 TOP, | |
35 RIGHT, | |
36 BOTTOM, | |
37 LEFT | |
38 }; | |
39 | |
40 MonitorController(); | |
41 virtual ~MonitorController(); | |
42 | |
43 // Initializes primary display. | |
44 void InitPrimaryDisplay(); | |
45 | |
46 // Initialize secondary display. This is separated because in non | |
47 // extended desktop mode, this creates background widgets, which | |
48 // requires other controllers. | |
49 void InitSecondaryDisplays(); | |
50 | |
51 // Returns the root window for primary display. | |
52 aura::RootWindow* GetPrimaryRootWindow(); | |
53 | |
54 // Closes all child windows in the all root windows. | |
55 void CloseChildWindows(); | |
56 | |
57 // Returns all root windows. In non extended desktop mode, this | |
58 // returns the primary root window only. | |
59 std::vector<aura::RootWindow*> GetAllRootWindows(); | |
60 | |
61 // Returns all oot window controllers. In non extended desktop | |
62 // mode, this return a RootWindowController for the primary root window only. | |
63 std::vector<internal::RootWindowController*> GetAllRootWindowControllers(); | |
64 | |
65 SecondaryDisplayLayout secondary_display_layout() const { | |
66 return secondary_display_layout_; | |
67 } | |
68 void SetSecondaryDisplayLayout(SecondaryDisplayLayout layout); | |
69 | |
70 // Warps the mouse cursor to an alternate root window when the | |
71 // |location_in_root|, which is the location of the mouse cursor, | |
72 // hits or exceeds the edge of the |root_window| and the mouse cursor | |
73 // is considered to be in an alternate display. Returns true if | |
74 // the cursor was moved. | |
75 bool WarpMouseCursorIfNecessary(aura::Window* root_window, | |
76 const gfx::Point& location_in_root); | |
77 | |
78 // aura::DisplayObserver overrides: | |
79 virtual void OnDisplayBoundsChanged( | |
80 const gfx::Display& display) OVERRIDE; | |
81 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | |
82 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; | |
83 | |
84 // Is extended desktop enabled? | |
85 static bool IsExtendedDesktopEnabled(); | |
86 // Change the extended desktop mode. Used for testing. | |
87 static void SetExtendedDesktopEnabled(bool enabled); | |
88 | |
89 // Is virtual screen coordinates enabled? | |
90 static bool IsVirtualScreenCoordinatesEnabled(); | |
91 // Turns on/off the virtual screen coordinates. | |
92 static void SetVirtualScreenCoordinatesEnabled(bool enabled); | |
93 | |
94 private: | |
95 // Creates a root window for |display| and stores it in the |root_windows_| | |
96 // map. | |
97 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display); | |
98 | |
99 std::map<int, aura::RootWindow*> root_windows_; | |
100 | |
101 SecondaryDisplayLayout secondary_display_layout_; | |
102 | |
103 DISALLOW_COPY_AND_ASSIGN(MonitorController); | |
104 }; | |
105 | |
106 } // namespace internal | |
107 } // namespace ash | |
108 | |
109 #endif // ASH_MONITOR_MONITOR_CONTROLLER_H_ | |
OLD | NEW |