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

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

Issue 10870036: Allow storing display preferences per device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix 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
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 "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 Value;
25 template <typename T> class JSONValueConverter;
26 }
27
23 namespace ash { 28 namespace ash {
24 namespace internal { 29 namespace internal {
25 class RootWindowController; 30 class RootWindowController;
31 }
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 };
38 41
42 DisplayLayout();
43 DisplayLayout(Position position, int offset);
44
45 // Converter functions to/from base::Value.
46 static bool ConvertFromValue(const base::Value& value, DisplayLayout* layout);
47 static bool ConvertToValue(const DisplayLayout& layout, base::Value* value);
48
49 // This method is used by base::JSONValueConverter, you don't need to call
50 // this directly. Instead consider using converter functions above.
51 static void RegisterJSONConverter(
52 base::JSONValueConverter<DisplayLayout>* converter);
53
54 Position position;
55
56 // The offset of the position of the secondary display. The offset is
57 // based on the top/left edge of the primary display.
58 int offset;
59 };
60
61 // DisplayController owns and maintains RootWindows for each attached
62 // display, keeping them in sync with display configuration changes.
63 class ASH_EXPORT DisplayController : public aura::DisplayObserver {
64 public:
39 DisplayController(); 65 DisplayController();
40 virtual ~DisplayController(); 66 virtual ~DisplayController();
41 67
42 // Initializes primary display. 68 // Initializes primary display.
43 void InitPrimaryDisplay(); 69 void InitPrimaryDisplay();
44 70
45 // Initialize secondary display. This is separated because in non 71 // Initialize secondary display. This is separated because in non
46 // extended desktop mode, this creates background widgets, which 72 // extended desktop mode, this creates background widgets, which
47 // requires other controllers. 73 // requires other controllers.
48 void InitSecondaryDisplays(); 74 void InitSecondaryDisplays();
49 75
50 // Returns the root window for primary display. 76 // Returns the root window for primary display.
51 aura::RootWindow* GetPrimaryRootWindow(); 77 aura::RootWindow* GetPrimaryRootWindow();
52 78
53 // Returns the root window for |display_id|. 79 // Returns the root window for |display_id|.
54 aura::RootWindow* GetRootWindowForDisplayId(int64 id); 80 aura::RootWindow* GetRootWindowForDisplayId(int64 id);
55 81
56 // Closes all child windows in the all root windows. 82 // Closes all child windows in the all root windows.
57 void CloseChildWindows(); 83 void CloseChildWindows();
58 84
59 // Returns all root windows. In non extended desktop mode, this 85 // Returns all root windows. In non extended desktop mode, this
60 // returns the primary root window only. 86 // returns the primary root window only.
61 std::vector<aura::RootWindow*> GetAllRootWindows(); 87 std::vector<aura::RootWindow*> GetAllRootWindows();
62 88
63 // Returns all oot window controllers. In non extended desktop 89 // Returns all oot window controllers. In non extended desktop
64 // mode, this return a RootWindowController for the primary root window only. 90 // mode, this return a RootWindowController for the primary root window only.
65 std::vector<internal::RootWindowController*> GetAllRootWindowControllers(); 91 std::vector<internal::RootWindowController*> GetAllRootWindowControllers();
66 92
67 SecondaryDisplayLayout secondary_display_layout() const { 93 const DisplayLayout& default_display_layout() const {
68 return secondary_display_layout_; 94 return default_display_layout_;
69 } 95 }
70 void SetSecondaryDisplayLayout(SecondaryDisplayLayout layout); 96 void SetDefaultDisplayLayout(const DisplayLayout& layout);
71 97
72 int secondary_display_offset() const { 98 // Sets/gets the display layout for the specified display name. Getter
73 return secondary_display_offset_; 99 // returns the default value in case it doesn't have its own layout yet.
74 } 100 void SetLayoutForDisplayName(const std::string& name,
75 void SetSecondaryDisplayOffset(int offset); 101 const DisplayLayout& layout);
102 const DisplayLayout& GetLayoutForDisplayName(const std::string& name);
76 103
77 void set_dont_warp_mouse(bool dont_warp_mouse) { 104 void set_dont_warp_mouse(bool dont_warp_mouse) {
78 dont_warp_mouse_ = dont_warp_mouse; 105 dont_warp_mouse_ = dont_warp_mouse;
79 } 106 }
107 bool dont_warp_mouse_for_testing() const {
108 return dont_warp_mouse_;
109 }
80 110
81 // Warps the mouse cursor to an alternate root window when the 111 // Warps the mouse cursor to an alternate root window when the
82 // |point_in_root|, which is the location of the mouse cursor, 112 // |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 113 // 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 114 // is considered to be in an alternate display. Returns true if
85 // the cursor was moved. 115 // the cursor was moved.
86 bool WarpMouseCursorIfNecessary(aura::RootWindow* root_window, 116 bool WarpMouseCursorIfNecessary(aura::RootWindow* root_window,
87 const gfx::Point& point_in_root); 117 const gfx::Point& point_in_root);
88 118
89 // aura::DisplayObserver overrides: 119 // aura::DisplayObserver overrides:
90 virtual void OnDisplayBoundsChanged( 120 virtual void OnDisplayBoundsChanged(
91 const gfx::Display& display) OVERRIDE; 121 const gfx::Display& display) OVERRIDE;
92 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; 122 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE;
93 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; 123 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE;
94 124
95 // Is extended desktop enabled? 125 // Is extended desktop enabled?
96 static bool IsExtendedDesktopEnabled(); 126 static bool IsExtendedDesktopEnabled();
97 127
98 private: 128 private:
99 FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, WarpMousePointer);
100
101 // Creates a root window for |display| and stores it in the |root_windows_| 129 // Creates a root window for |display| and stores it in the |root_windows_|
102 // map. 130 // map.
103 // TODO(oshima): remove |is_primary| when non extended desktop mode is 131 // TODO(oshima): remove |is_primary| when non extended desktop mode is
104 // removed. 132 // removed.
105 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display, 133 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display,
106 bool is_primary); 134 bool is_primary);
107 135
108 void UpdateDisplayBoundsForLayout(); 136 void UpdateDisplayBoundsForLayout();
109 137
110 // The mapping from display ID to its root window. 138 // The mapping from display ID to its root window.
111 std::map<int64, aura::RootWindow*> root_windows_; 139 std::map<int64, aura::RootWindow*> root_windows_;
112 140
113 SecondaryDisplayLayout secondary_display_layout_; 141 // The default display layout.
142 DisplayLayout default_display_layout_;
114 143
115 // The offset of the position of the secondary display. The offset is 144 // Per-device display layout.
116 // based on the top/left edge of the primary display. 145 std::map<std::string, DisplayLayout> secondary_layouts_;
117 int secondary_display_offset_;
118 146
119 // If true, the mouse pointer can't move from one display to another. 147 // If true, the mouse pointer can't move from one display to another.
120 bool dont_warp_mouse_; 148 bool dont_warp_mouse_;
121 149
122 DISALLOW_COPY_AND_ASSIGN(DisplayController); 150 DISALLOW_COPY_AND_ASSIGN(DisplayController);
123 }; 151 };
124 152
125 } // namespace internal
126 } // namespace ash 153 } // namespace ash
127 154
128 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ 155 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/display/display_controller.cc » ('j') | chrome/browser/ui/webui/options/chromeos/display_options_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698