Index: ash/display/display_controller.h |
diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h |
index 324214fccd4a3c73f92b884f8cfeb46485f5afcb..d6e122ec86406cbe36ecf1ba1e78f1165abc0799 100644 |
--- a/ash/display/display_controller.h |
+++ b/ash/display/display_controller.h |
@@ -19,22 +19,48 @@ class Display; |
class RootWindow; |
} |
+namespace base { |
+class Value; |
+template <typename T> class JSONValueConverter; |
+} |
+ |
namespace ash { |
namespace internal { |
class RootWindowController; |
+} |
-// DisplayController owns and maintains RootWindows for each attached |
-// display, keeping them in sync with display configuration changes. |
-class ASH_EXPORT DisplayController : public aura::DisplayObserver { |
- public: |
+struct ASH_EXPORT DisplayLayout { |
// Layout options where the secondary display should be positioned. |
- enum SecondaryDisplayLayout { |
+ enum Position { |
TOP, |
RIGHT, |
BOTTOM, |
LEFT |
}; |
+ DisplayLayout(); |
+ DisplayLayout(Position position, int offset); |
+ |
+ // Converter functions to/from base::Value. |
+ static bool ConvertFromValue(const base::Value& value, DisplayLayout* layout); |
+ static bool ConvertToValue(const DisplayLayout& layout, base::Value* value); |
+ |
+ // This method is used by base::JSONValueConverter, you don't need to call |
+ // this directly. Instead consider using converter functions above. |
+ static void RegisterJSONConverter( |
+ base::JSONValueConverter<DisplayLayout>* converter); |
+ |
+ Position position; |
+ |
+ // The offset of the position of the secondary display. The offset is |
+ // based on the top/left edge of the primary display. |
+ int offset; |
+}; |
+ |
+// DisplayController owns and maintains RootWindows for each attached |
+// display, keeping them in sync with display configuration changes. |
+class ASH_EXPORT DisplayController : public aura::DisplayObserver { |
+ public: |
DisplayController(); |
virtual ~DisplayController(); |
@@ -61,15 +87,16 @@ class ASH_EXPORT DisplayController : public aura::DisplayObserver { |
// mode, this return a RootWindowController for the primary root window only. |
std::vector<internal::RootWindowController*> GetAllRootWindowControllers(); |
- SecondaryDisplayLayout secondary_display_layout() const { |
- return secondary_display_layout_; |
+ const DisplayLayout& default_display_layout() const { |
+ return default_display_layout_; |
} |
- void SetSecondaryDisplayLayout(SecondaryDisplayLayout layout); |
+ void SetDefaultDisplayLayout(const DisplayLayout& layout); |
- int secondary_display_offset() const { |
- return secondary_display_offset_; |
- } |
- void SetSecondaryDisplayOffset(int offset); |
+ // Sets/gets the display layout for the specified display name. Getter |
+ // returns the default value in case it doesn't have its own layout yet. |
+ void SetLayoutForDisplayName(const std::string& name, |
+ const DisplayLayout& layout); |
+ const DisplayLayout& GetLayoutForDisplayName(const std::string& name); |
// aura::DisplayObserver overrides: |
virtual void OnDisplayBoundsChanged( |
@@ -87,16 +114,15 @@ class ASH_EXPORT DisplayController : public aura::DisplayObserver { |
// The mapping from display ID to its root window. |
std::map<int64, aura::RootWindow*> root_windows_; |
- SecondaryDisplayLayout secondary_display_layout_; |
+ // The default display layout. |
+ DisplayLayout default_display_layout_; |
- // The offset of the position of the secondary display. The offset is |
- // based on the top/left edge of the primary display. |
- int secondary_display_offset_; |
+ // Per-device display layout. |
+ std::map<std::string, DisplayLayout> secondary_layouts_; |
DISALLOW_COPY_AND_ASSIGN(DisplayController); |
}; |
-} // namespace internal |
} // namespace ash |
#endif // ASH_DISPLAY_DISPLAY_CONTROLLER_H_ |