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

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: rebase 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 | « no previous file | ash/display/display_controller.cc » ('j') | ash/display/display_controller.cc » ('J')
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 "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();
48 DisplayLayout(Position p, int o);
oshima 2012/08/27 23:00:46 p -> position, o ->offset
Jun Mukai 2012/08/28 08:12:42 Done.
49 static void RegisterJSONConverter(
50 base::JSONValueConverter<DisplayLayout>* converter);
51 bool GetValue(base::DictionaryValue* value);
oshima 2012/08/27 23:00:46 GetValue is a bit confusing. How about SetValueTo
Jun Mukai 2012/08/28 08:12:42 Changed to ConvertToValue(). What do you think?
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 DisplayLayout::Position secondary_display_layout() const {
68 return secondary_display_layout_; 87 return default_display_layout_.position;
69 } 88 }
oshima 2012/08/27 23:00:46 since DisplayLayout is POD, it'd be better to simp
Jun Mukai 2012/08/28 08:12:42 Done.
70 void SetSecondaryDisplayLayout(SecondaryDisplayLayout layout); 89 void SetSecondaryDisplayLayout(DisplayLayout::Position layout);
71 90
72 int secondary_display_offset() const { 91 int secondary_display_offset() const {
73 return secondary_display_offset_; 92 return default_display_layout_.offset;
74 } 93 }
75 void SetSecondaryDisplayOffset(int offset); 94 void SetSecondaryDisplayOffset(int offset);
76 95
96 void SetDisplayLayoutForName(const std::string& name,
97 const base::Value& value);
98 void GetLayoutForDisplay(const gfx::Display& display,
99 int* layout, int* offset);
oshima 2012/08/27 23:00:46 document these methods
Jun Mukai 2012/08/28 08:12:42 Done.
100
77 void set_dont_warp_mouse(bool dont_warp_mouse) { 101 void set_dont_warp_mouse(bool dont_warp_mouse) {
78 dont_warp_mouse_ = dont_warp_mouse; 102 dont_warp_mouse_ = dont_warp_mouse;
79 } 103 }
80 104
81 // Warps the mouse cursor to an alternate root window when the 105 // Warps the mouse cursor to an alternate root window when the
82 // |point_in_root|, which is the location of the mouse cursor, 106 // |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 107 // 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 108 // is considered to be in an alternate display. Returns true if
85 // the cursor was moved. 109 // the cursor was moved.
86 bool WarpMouseCursorIfNecessary(aura::RootWindow* root_window, 110 bool WarpMouseCursorIfNecessary(aura::RootWindow* root_window,
(...skipping 16 matching lines...) Expand all
103 // TODO(oshima): remove |is_primary| when non extended desktop mode is 127 // TODO(oshima): remove |is_primary| when non extended desktop mode is
104 // removed. 128 // removed.
105 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display, 129 aura::RootWindow* AddRootWindowForDisplay(const gfx::Display& display,
106 bool is_primary); 130 bool is_primary);
107 131
108 void UpdateDisplayBoundsForLayout(); 132 void UpdateDisplayBoundsForLayout();
109 133
110 // The mapping from display ID to its root window. 134 // The mapping from display ID to its root window.
111 std::map<int64, aura::RootWindow*> root_windows_; 135 std::map<int64, aura::RootWindow*> root_windows_;
112 136
113 SecondaryDisplayLayout secondary_display_layout_; 137 // The default display layout.
138 DisplayLayout default_display_layout_;
114 139
115 // The offset of the position of the secondary display. The offset is 140 // Per-device display layout.
116 // based on the top/left edge of the primary display. 141 std::map<std::string, DisplayLayout> secondary_layouts_;
117 int secondary_display_offset_;
118 142
119 // If true, the mouse pointer can't move from one display to another. 143 // If true, the mouse pointer can't move from one display to another.
120 bool dont_warp_mouse_; 144 bool dont_warp_mouse_;
121 145
122 DISALLOW_COPY_AND_ASSIGN(DisplayController); 146 DISALLOW_COPY_AND_ASSIGN(DisplayController);
123 }; 147 };
124 148
125 } // namespace internal 149 } // namespace internal
126 } // namespace ash 150 } // namespace ash
127 151
128 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ 152 #endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/display/display_controller.cc » ('j') | ash/display/display_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698