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_DISPLAY_DISPLAY_CONTROLLER_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
6 #define ASH_DISPLAY_DISPLAY_CONTROLLER_H_ | 6 #define ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "ui/aura/display_observer.h" | 15 #include "ui/aura/display_observer.h" |
16 #include "ui/aura/display_manager.h" | 16 #include "ui/aura/display_manager.h" |
17 | 17 |
18 namespace aura { | 18 namespace aura { |
19 class Display; | 19 class Display; |
20 class RootWindow; | 20 class RootWindow; |
21 } | 21 } |
22 | 22 |
23 namespace base { | |
24 class DictionaryValue; | |
25 class Value; | |
26 template <typename T> class JSONValueConverter; | |
27 } | |
28 | |
23 namespace ash { | 29 namespace ash { |
24 namespace internal { | 30 namespace internal { |
25 class RootWindowController; | 31 class RootWindowController; |
26 | 32 |
27 // DisplayController owns and maintains RootWindows for each attached | 33 struct ASH_EXPORT DisplayLayout { |
28 // display, keeping them in sync with display configuration changes. | |
29 class ASH_EXPORT DisplayController : public aura::DisplayObserver { | |
30 public: | |
31 // Layout options where the secondary display should be positioned. | 34 // Layout options where the secondary display should be positioned. |
32 enum SecondaryDisplayLayout { | 35 enum Position { |
33 TOP, | 36 TOP, |
34 RIGHT, | 37 RIGHT, |
35 BOTTOM, | 38 BOTTOM, |
36 LEFT | 39 LEFT |
37 }; | 40 }; |
41 Position position; | |
38 | 42 |
43 // The offset of the position of the secondary display. The offset is | |
44 // based on the top/left edge of the primary display. | |
45 int offset; | |
46 | |
47 DisplayLayout(); | |
sky
2012/08/29 15:05:57
structs follow the same layout as classes, so meth
Jun Mukai
2012/08/30 02:08:04
Done.
| |
48 DisplayLayout(Position position, int offset); | |
49 static void RegisterJSONConverter( | |
sky
2012/08/29 15:05:57
Move this to a standalone function, and ConvertToV
Jun Mukai
2012/08/30 02:08:04
Sorry, this is needed to be a static method since
| |
50 base::JSONValueConverter<DisplayLayout>* converter); | |
51 bool ConvertToValue(base::DictionaryValue* value); | |
52 }; | |
53 | |
54 // DisplayController owns and maintains RootWindows for each attached | |
55 // display, keeping them in sync with display configuration changes. | |
56 class ASH_EXPORT DisplayController : public aura::DisplayObserver { | |
57 public: | |
39 DisplayController(); | 58 DisplayController(); |
40 virtual ~DisplayController(); | 59 virtual ~DisplayController(); |
41 | 60 |
42 // Initializes primary display. | 61 // Initializes primary display. |
43 void InitPrimaryDisplay(); | 62 void InitPrimaryDisplay(); |
44 | 63 |
45 // Initialize secondary display. This is separated because in non | 64 // Initialize secondary display. This is separated because in non |
46 // extended desktop mode, this creates background widgets, which | 65 // extended desktop mode, this creates background widgets, which |
47 // requires other controllers. | 66 // requires other controllers. |
48 void InitSecondaryDisplays(); | 67 void InitSecondaryDisplays(); |
49 | 68 |
50 // Returns the root window for primary display. | 69 // Returns the root window for primary display. |
51 aura::RootWindow* GetPrimaryRootWindow(); | 70 aura::RootWindow* GetPrimaryRootWindow(); |
52 | 71 |
53 // Returns the root window for |display_id|. | 72 // Returns the root window for |display_id|. |
54 aura::RootWindow* GetRootWindowForDisplayId(int64 id); | 73 aura::RootWindow* GetRootWindowForDisplayId(int64 id); |
55 | 74 |
56 // Closes all child windows in the all root windows. | 75 // Closes all child windows in the all root windows. |
57 void CloseChildWindows(); | 76 void CloseChildWindows(); |
58 | 77 |
59 // Returns all root windows. In non extended desktop mode, this | 78 // Returns all root windows. In non extended desktop mode, this |
60 // returns the primary root window only. | 79 // returns the primary root window only. |
61 std::vector<aura::RootWindow*> GetAllRootWindows(); | 80 std::vector<aura::RootWindow*> GetAllRootWindows(); |
62 | 81 |
63 // Returns all oot window controllers. In non extended desktop | 82 // Returns all oot window controllers. In non extended desktop |
64 // mode, this return a RootWindowController for the primary root window only. | 83 // mode, this return a RootWindowController for the primary root window only. |
65 std::vector<internal::RootWindowController*> GetAllRootWindowControllers(); | 84 std::vector<internal::RootWindowController*> GetAllRootWindowControllers(); |
66 | 85 |
67 SecondaryDisplayLayout secondary_display_layout() const { | 86 const DisplayLayout& default_display_layout() const { |
68 return secondary_display_layout_; | 87 return default_display_layout_; |
69 } | 88 } |
70 void SetSecondaryDisplayLayout(SecondaryDisplayLayout layout); | 89 void SetDefaultDisplayLayout(const DisplayLayout& layout); |
71 | 90 |
72 int secondary_display_offset() const { | 91 // Sets/gets the display layout for the specified display name. Getter |
73 return secondary_display_offset_; | 92 // returns the default value in case it doesn't have its own layout yet. |
74 } | 93 void SetLayoutForDisplayName(const std::string& name, |
75 void SetSecondaryDisplayOffset(int offset); | 94 const DisplayLayout& layout); |
95 const DisplayLayout& GetLayoutForDisplayName(const std::string& name); | |
76 | 96 |
77 void set_dont_warp_mouse(bool dont_warp_mouse) { | 97 void set_dont_warp_mouse(bool dont_warp_mouse) { |
78 dont_warp_mouse_ = dont_warp_mouse; | 98 dont_warp_mouse_ = dont_warp_mouse; |
79 } | 99 } |
80 | 100 |
81 // Warps the mouse cursor to an alternate root window when the | 101 // Warps the mouse cursor to an alternate root window when the |
82 // |point_in_root|, which is the location of the mouse cursor, | 102 // |point_in_root|, which is the location of the mouse cursor, |
83 // hits or exceeds the edge of the |root_window| and the mouse cursor | 103 // hits or exceeds the edge of the |root_window| and the mouse cursor |
84 // is considered to be in an alternate display. Returns true if | 104 // is considered to be in an alternate display. Returns true if |
85 // the cursor was moved. | 105 // the cursor was moved. |
(...skipping 17 matching lines...) Expand all Loading... | |
103 // TODO(oshima): remove |is_primary| when non extended desktop mode is | 123 // TODO(oshima): remove |is_primary| when non extended desktop mode is |
104 // removed. | 124 // removed. |
105 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display, | 125 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display, |
106 bool is_primary); | 126 bool is_primary); |
107 | 127 |
108 void UpdateDisplayBoundsForLayout(); | 128 void UpdateDisplayBoundsForLayout(); |
109 | 129 |
110 // The mapping from display ID to its root window. | 130 // The mapping from display ID to its root window. |
111 std::map<int64, aura::RootWindow*> root_windows_; | 131 std::map<int64, aura::RootWindow*> root_windows_; |
112 | 132 |
113 SecondaryDisplayLayout secondary_display_layout_; | 133 // The default display layout. |
134 DisplayLayout default_display_layout_; | |
114 | 135 |
115 // The offset of the position of the secondary display. The offset is | 136 // Per-device display layout. |
116 // based on the top/left edge of the primary display. | 137 std::map<std::string, DisplayLayout> secondary_layouts_; |
117 int secondary_display_offset_; | |
118 | 138 |
119 // If true, the mouse pointer can't move from one display to another. | 139 // If true, the mouse pointer can't move from one display to another. |
120 bool dont_warp_mouse_; | 140 bool dont_warp_mouse_; |
121 | 141 |
122 DISALLOW_COPY_AND_ASSIGN(DisplayController); | 142 DISALLOW_COPY_AND_ASSIGN(DisplayController); |
123 }; | 143 }; |
124 | 144 |
125 } // namespace internal | 145 } // namespace internal |
126 } // namespace ash | 146 } // namespace ash |
127 | 147 |
128 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ | 148 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |
OLD | NEW |