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

Side by Side Diff: ash/display/display_controller.h

Issue 10905288: Switch primary display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 3 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
« no previous file with comments | « ash/accelerators/accelerator_table.cc ('k') | ash/display/display_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "ui/aura/display_observer.h" 16 #include "ui/aura/display_observer.h"
17 #include "ui/aura/display_manager.h" 17 #include "ui/aura/display_manager.h"
18 #include "ui/gfx/display.h"
18 19
19 namespace aura { 20 namespace aura {
20 class Display; 21 class Display;
21 class RootWindow; 22 class RootWindow;
22 } 23 }
23 24
24 namespace base { 25 namespace base {
25 class Value; 26 class Value;
26 template <typename T> class JSONValueConverter; 27 template <typename T> class JSONValueConverter;
27 } 28 }
28 29
29 namespace ash { 30 namespace ash {
30 namespace internal { 31 namespace internal {
31 class RootWindowController; 32 class RootWindowController;
32 } 33 }
33 34
34 struct ASH_EXPORT DisplayLayout { 35 struct ASH_EXPORT DisplayLayout {
35 // Layout options where the secondary display should be positioned. 36 // Layout options where the secondary display should be positioned.
36 enum Position { 37 enum Position {
37 TOP, 38 TOP,
38 RIGHT, 39 RIGHT,
39 BOTTOM, 40 BOTTOM,
40 LEFT 41 LEFT
41 }; 42 };
42 43
43 DisplayLayout(); 44 DisplayLayout();
44 DisplayLayout(Position position, int offset); 45 DisplayLayout(Position position, int offset);
45 46
47 // Returns an inverted display layout.
48 DisplayLayout Invert() const WARN_UNUSED_RESULT;
49
46 // Converter functions to/from base::Value. 50 // Converter functions to/from base::Value.
47 static bool ConvertFromValue(const base::Value& value, DisplayLayout* layout); 51 static bool ConvertFromValue(const base::Value& value, DisplayLayout* layout);
48 static bool ConvertToValue(const DisplayLayout& layout, base::Value* value); 52 static bool ConvertToValue(const DisplayLayout& layout, base::Value* value);
49 53
50 // This method is used by base::JSONValueConverter, you don't need to call 54 // This method is used by base::JSONValueConverter, you don't need to call
51 // this directly. Instead consider using converter functions above. 55 // this directly. Instead consider using converter functions above.
52 static void RegisterJSONConverter( 56 static void RegisterJSONConverter(
53 base::JSONValueConverter<DisplayLayout>* converter); 57 base::JSONValueConverter<DisplayLayout>* converter);
54 58
55 Position position; 59 Position position;
56 60
57 // The offset of the position of the secondary display. The offset is 61 // The offset of the position of the secondary display. The offset is
58 // based on the top/left edge of the primary display. 62 // based on the top/left edge of the primary display.
59 int offset; 63 int offset;
64
65 // Returns string representation of the layout for debugging/testing.
66 std::string ToString() const;
60 }; 67 };
61 68
62 // DisplayController owns and maintains RootWindows for each attached 69 // DisplayController owns and maintains RootWindows for each attached
63 // display, keeping them in sync with display configuration changes. 70 // display, keeping them in sync with display configuration changes.
64 class ASH_EXPORT DisplayController : public aura::DisplayObserver { 71 class ASH_EXPORT DisplayController : public aura::DisplayObserver {
65 public: 72 public:
66 class ASH_EXPORT Observer { 73 class ASH_EXPORT Observer {
67 public: 74 public:
68 // Invoked when the display configuration change is requested, 75 // Invoked when the display configuration change is requested,
69 // but before the change is applied to aura/ash. 76 // but before the change is applied to aura/ash.
(...skipping 15 matching lines...) Expand all
85 // Add/Remove observers. 92 // Add/Remove observers.
86 void AddObserver(Observer* observer); 93 void AddObserver(Observer* observer);
87 void RemoveObserver(Observer* observer); 94 void RemoveObserver(Observer* observer);
88 95
89 // Returns the root window for primary display. 96 // Returns the root window for primary display.
90 aura::RootWindow* GetPrimaryRootWindow(); 97 aura::RootWindow* GetPrimaryRootWindow();
91 98
92 // Returns the root window for |display_id|. 99 // Returns the root window for |display_id|.
93 aura::RootWindow* GetRootWindowForDisplayId(int64 id); 100 aura::RootWindow* GetRootWindowForDisplayId(int64 id);
94 101
102 // Sets/Gets primary display.
103 const gfx::Display& primary_display() const {
104 return primary_display_;
105 }
106 void SetPrimaryDisplay(const gfx::Display& display);
107
108 // Returns the secondary display.
109 gfx::Display* GetSecondaryDisplay();
110
95 // Closes all child windows in the all root windows. 111 // Closes all child windows in the all root windows.
96 void CloseChildWindows(); 112 void CloseChildWindows();
97 113
98 // Returns all root windows. In non extended desktop mode, this 114 // Returns all root windows. In non extended desktop mode, this
99 // returns the primary root window only. 115 // returns the primary root window only.
100 std::vector<aura::RootWindow*> GetAllRootWindows(); 116 std::vector<aura::RootWindow*> GetAllRootWindows();
101 117
102 // Returns all oot window controllers. In non extended desktop 118 // Returns all oot window controllers. In non extended desktop
103 // mode, this return a RootWindowController for the primary root window only. 119 // mode, this return a RootWindowController for the primary root window only.
104 std::vector<internal::RootWindowController*> GetAllRootWindowControllers(); 120 std::vector<internal::RootWindowController*> GetAllRootWindowControllers();
105 121
106 const DisplayLayout& default_display_layout() const { 122 const DisplayLayout& default_display_layout() const {
107 return default_display_layout_; 123 return default_display_layout_;
108 } 124 }
109 void SetDefaultDisplayLayout(const DisplayLayout& layout); 125 void SetDefaultDisplayLayout(const DisplayLayout& layout);
110 126
111 // Sets/gets the display layout for the specified display name. Getter 127 // Sets/gets the display layout for the specified display or display
112 // returns the default value in case it doesn't have its own layout yet. 128 // name. Getter returns the default value in case it doesn't have
129 // its own layout yet.
113 void SetLayoutForDisplayName(const std::string& name, 130 void SetLayoutForDisplayName(const std::string& name,
114 const DisplayLayout& layout); 131 const DisplayLayout& layout);
115 const DisplayLayout& GetLayoutForDisplayName(const std::string& name); 132 const DisplayLayout& GetLayoutForDisplay(const gfx::Display& display) const;
133
134 // Returns the display layout used for current secondary display.
135 const DisplayLayout& GetCurrentDisplayLayout() const;
116 136
117 // aura::DisplayObserver overrides: 137 // aura::DisplayObserver overrides:
118 virtual void OnDisplayBoundsChanged( 138 virtual void OnDisplayBoundsChanged(
119 const gfx::Display& display) OVERRIDE; 139 const gfx::Display& display) OVERRIDE;
120 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; 140 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
121 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; 141 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
122 142
123 private: 143 private:
124 // Creates a root window for |display| and stores it in the |root_windows_| 144 // Creates a root window for |display| and stores it in the |root_windows_|
125 // map. 145 // map.
126 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display); 146 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display);
127 147
128 void UpdateDisplayBoundsForLayout(); 148 void UpdateDisplayBoundsForLayout();
129 149
130 void NotifyDisplayConfigurationChanging(); 150 void NotifyDisplayConfigurationChanging();
131 151
132 // The mapping from display ID to its root window. 152 // The mapping from display ID to its root window.
133 std::map<int64, aura::RootWindow*> root_windows_; 153 std::map<int64, aura::RootWindow*> root_windows_;
134 154
135 // The default display layout. 155 // The default display layout.
136 DisplayLayout default_display_layout_; 156 DisplayLayout default_display_layout_;
137 157
138 // Per-device display layout. 158 // Per-device display layout.
139 std::map<std::string, DisplayLayout> secondary_layouts_; 159 std::map<std::string, DisplayLayout> secondary_layouts_;
140 160
141 ObserverList<Observer> observers_; 161 ObserverList<Observer> observers_;
142 162
163 gfx::Display primary_display_;
164
143 DISALLOW_COPY_AND_ASSIGN(DisplayController); 165 DISALLOW_COPY_AND_ASSIGN(DisplayController);
144 }; 166 };
145 167
146 } // namespace ash 168 } // namespace ash
147 169
148 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ 170 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/accelerators/accelerator_table.cc ('k') | ash/display/display_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698