Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / ash / display / display_manager.h
index d79654b..0dc917a 100644 (file)
 #include "ui/gfx/display.h"
 
 #if defined(OS_CHROMEOS)
-#include "chromeos/display/output_configurator.h"
+#include "ui/display/chromeos/display_configurator.h"
 #endif
 
 namespace gfx {
 class Display;
 class Insets;
 class Rect;
+class Screen;
 }
 
 namespace ash {
 class AcceleratorControllerTest;
 class DisplayController;
+class DisplayLayoutStore;
+class ScreenAsh;
 
 namespace test {
 class DisplayManagerTestApi;
 class SystemGestureEventFilterTest;
 }
-namespace internal {
-class DisplayLayoutStore;
 
 // DisplayManager maintains the current display configurations,
 // and notifies observers when configuration changes.
@@ -43,7 +44,7 @@ class DisplayLayoutStore;
 // TODO(oshima): Make this non internal.
 class ASH_EXPORT DisplayManager
 #if defined(OS_CHROMEOS)
-    : public chromeos::OutputConfigurator::SoftwareMirroringController
+    : public ui::DisplayConfigurator::SoftwareMirroringController
 #endif
       {
  public:
@@ -59,7 +60,9 @@ class ASH_EXPORT DisplayManager
     virtual void CloseNonDesktopDisplay() = 0;
 
     // Called before and after the display configuration changes.
-    virtual void PreDisplayConfigurationChange(bool display_removed) = 0;
+    // When |clear_focus| is true, the implementation should
+    // deactivate the active window and set the focus window to NULL.
+    virtual void PreDisplayConfigurationChange(bool clear_focus) = 0;
     virtual void PostDisplayConfigurationChange() = 0;
   };
 
@@ -67,13 +70,9 @@ class ASH_EXPORT DisplayManager
   // 1) EXTENDED mode extends the desktop to the second dislpay.
   // 2) MIRRORING mode copies the content of the primary display to
   //    the 2nd display. (Software Mirroring).
-  // 3) In VIRTUAL_KEYBOARD mode, the 2nd display is used as a
-  //    dedicated display for virtual keyboard, and it is not
-  //    recognized as a part of desktop.
   enum SecondDisplayMode {
     EXTENDED,
-    MIRRORING,
-    VIRTUAL_KEYBOARD
+    MIRRORING
   };
 
   // Returns the list of possible UI scales for the display.
@@ -96,9 +95,13 @@ class ASH_EXPORT DisplayManager
     return layout_store_.get();
   }
 
+  gfx::Screen* screen() {
+    return screen_;
+  }
+
   void set_delegate(Delegate* delegate) { delegate_ = delegate; }
 
-  // When set to true, the MonitorManager calls OnDisplayBoundsChanged
+  // When set to true, the MonitorManager calls OnDisplayMetricsChanged
   // even if the display's bounds didn't change. Used to swap primary
   // display.
   void set_force_bounds_changed(bool force_bounds_changed) {
@@ -115,6 +118,10 @@ class ASH_EXPORT DisplayManager
   // Initialize default display.
   void InitDefaultDisplay();
 
+  // Initializes font related params that depends on display
+  // configuration.
+  void InitFontParams();
+
   // True if the given |display| is currently connected.
   bool IsActiveDisplay(const gfx::Display& display) const;
 
@@ -155,22 +162,52 @@ class ASH_EXPORT DisplayManager
   void SetDisplayRotation(int64 display_id, gfx::Display::Rotation rotation);
 
   // Sets the display's ui scale.
+  // TODO(mukai): remove this and merge into SetDisplayMode.
   void SetDisplayUIScale(int64 display_id, float ui_scale);
 
   // Sets the display's resolution.
+  // TODO(mukai): remove this and merge into SetDisplayMode.
   void SetDisplayResolution(int64 display_id, const gfx::Size& resolution);
 
+  // Sets the external display's configuration, including resolution change,
+  // ui-scale change, and device scale factor change. Returns true if it changes
+  // the display resolution so that the caller needs to show a notification in
+  // case the new resolution actually doesn't work.
+  bool SetDisplayMode(int64 display_id, const DisplayMode& display_mode);
+
   // Register per display properties. |overscan_insets| is NULL if
   // the display has no custom overscan insets.
   void RegisterDisplayProperty(int64 display_id,
                                gfx::Display::Rotation rotation,
                                float ui_scale,
                                const gfx::Insets* overscan_insets,
-                               const gfx::Size& resolution_in_pixels);
+                               const gfx::Size& resolution_in_pixels,
+                               float device_scale_factor,
+                               ui::ColorCalibrationProfile color_profile);
+
+  // Register stored rotation properties for the internal display.
+  void RegisterDisplayRotationProperties(bool rotation_lock,
+                                         gfx::Display::Rotation rotation);
+
+  // Returns the stored rotation lock preference if it has been loaded,
+  // otherwise false.
+  bool registered_internal_display_rotation_lock() const {
+    return registered_internal_display_rotation_lock_;
+  }
+
+  // Returns the stored rotation preference for the internal display if it has
+  // been loaded, otherwise |gfx::Display::Rotate_0|.
+  gfx::Display::Rotation registered_internal_display_rotation() const {
+    return registered_internal_display_rotation_;
+  }
+
+  // Returns the display mode of |display_id| which is currently used.
+  DisplayMode GetActiveModeForDisplayId(int64 display_id) const;
 
-  // Returns the display's selected resolution.
-  bool GetSelectedResolutionForDisplayId(int64 display_id,
-                                         gfx::Size* resolution_out) const;
+  // Returns the display's selected mode. This returns false and doesn't
+  // set |mode_out| if the display mode is in default.
+  bool GetSelectedModeForDisplayId(int64 display_id,
+                                   DisplayMode* mode_out) const;
 
   // Tells if the virtual resolution feature is enabled.
   bool IsDisplayUIScalingEnabled() const;
@@ -180,6 +217,10 @@ class ASH_EXPORT DisplayManager
   // the display.
   gfx::Insets GetOverscanInsets(int64 display_id) const;
 
+  // Sets the color calibration of the display to |profile|.
+  void SetColorCalibrationProfile(int64 display_id,
+                                  ui::ColorCalibrationProfile profile);
+
   // Called when display configuration has changed. The new display
   // configurations is passed as a vector of Display object, which
   // contains each display's new infomration.
@@ -240,6 +281,7 @@ class ASH_EXPORT DisplayManager
   // SoftwareMirroringController override:
 #if defined(OS_CHROMEOS)
   virtual void SetSoftwareMirroring(bool enabled) OVERRIDE;
+  virtual bool SoftwareMirroringEnabled() const OVERRIDE;
 #endif
   bool software_mirroring_enabled() const {
     return second_display_mode_ == MIRRORING;
@@ -259,6 +301,9 @@ class ASH_EXPORT DisplayManager
   // This is used only for bootstrap.
   void CreateMirrorWindowIfAny();
 
+  // Create a screen instance to be used during shutdown.
+  void CreateScreenForShutdown() const;
+
 private:
   FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint);
   FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged);
@@ -289,6 +334,9 @@ private:
   // a display.
   void InsertAndUpdateDisplayInfo(const DisplayInfo& new_info);
 
+  // Called when the display info is updated through InsertAndUpdateDisplayInfo.
+  void OnDisplayInfoUpdated(const DisplayInfo& display_info);
+
   // Creates a display object from the DisplayInfo for |display_id|.
   gfx::Display CreateDisplayFromDisplayInfoById(int64 display_id);
 
@@ -307,11 +355,15 @@ private:
 
   Delegate* delegate_;  // not owned.
 
+  scoped_ptr<ScreenAsh> screen_ash_;
+  // This is to have an accessor without ScreenAsh definition.
+  gfx::Screen* screen_;
+
   scoped_ptr<DisplayLayoutStore> layout_store_;
 
   int64 first_display_id_;
 
-  // List of current active dispays.
+  // List of current active displays.
   DisplayList displays_;
 
   int num_connected_displays_;
@@ -321,13 +373,13 @@ private:
   // The mapping from the display ID to its internal data.
   std::map<int64, DisplayInfo> display_info_;
 
-  // Selected resolutions for displays. Key is the displays' ID.
-  std::map<int64, gfx::Size> resolutions_;
+  // Selected display modes for displays. Key is the displays' ID.
+  std::map<int64, DisplayMode> display_modes_;
 
   // When set to true, the host window's resize event updates
   // the display's size. This is set to true when running on
   // desktop environment (for debugging) so that resizing the host
-  // window wil update the display properly. This is set to false
+  // window will update the display properly. This is set to false
   // on device as well as during the unit tests.
   bool change_display_upon_host_resize_;
 
@@ -335,10 +387,15 @@ private:
   int64 mirrored_display_id_;
   gfx::Display non_desktop_display_;
 
+  // User preference for rotation lock of the internal display.
+  bool registered_internal_display_rotation_lock_;
+
+  // User preference for the rotation of the internal display.
+  gfx::Display::Rotation registered_internal_display_rotation_;
+
   DISALLOW_COPY_AND_ASSIGN(DisplayManager);
 };
 
-}  // namespace internal
 }  // namespace ash
 
 #endif  // ASH_DISPLAY_DISPLAY_MANAGER_H_