| OLD | NEW |
| 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_MANAGER_H_ | 5 #ifndef ASH_DISPLAY_DISPLAY_MANAGER_H_ |
| 6 #define ASH_DISPLAY_DISPLAY_MANAGER_H_ | 6 #define ASH_DISPLAY_DISPLAY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "ash/ash_export.h" | 15 #include "ash/ash_export.h" |
| 16 #include "ash/display/display_info.h" | 16 #include "ash/display/display_info.h" |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "ui/display/display.h" |
| 21 #include "ui/display/manager/display_layout.h" | 22 #include "ui/display/manager/display_layout.h" |
| 22 #include "ui/gfx/display.h" | |
| 23 | 23 |
| 24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 25 #include "ui/display/chromeos/display_configurator.h" | 25 #include "ui/display/chromeos/display_configurator.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace aura { | 28 namespace aura { |
| 29 class Window; | 29 class Window; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace chromeos { | 32 namespace chromeos { |
| 33 class DisplayNotificationsTest; | 33 class DisplayNotificationsTest; |
| 34 } | 34 } |
| 35 | 35 |
| 36 namespace gfx { | 36 namespace gfx { |
| 37 class Display; | |
| 38 class Insets; | 37 class Insets; |
| 39 class Rect; | 38 class Rect; |
| 40 class Screen; | |
| 41 } | 39 } |
| 42 | 40 |
| 43 namespace ash { | 41 namespace ash { |
| 44 class AcceleratorControllerTest; | 42 class AcceleratorControllerTest; |
| 45 class DisplayLayoutStore; | 43 class DisplayLayoutStore; |
| 46 class MouseWarpController; | 44 class MouseWarpController; |
| 47 class ScreenAsh; | 45 class ScreenAsh; |
| 48 | 46 |
| 49 typedef std::vector<DisplayInfo> DisplayInfoList; | 47 typedef std::vector<DisplayInfo> DisplayInfoList; |
| 50 | 48 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 133 |
| 136 // Returns the current display list. | 134 // Returns the current display list. |
| 137 display::DisplayIdList GetCurrentDisplayIdList() const; | 135 display::DisplayIdList GetCurrentDisplayIdList() const; |
| 138 | 136 |
| 139 // Sets the layout for the current display pair. The |layout| specifies | 137 // Sets the layout for the current display pair. The |layout| specifies |
| 140 // the locaion of the displays relative to their parents. | 138 // the locaion of the displays relative to their parents. |
| 141 void SetLayoutForCurrentDisplays( | 139 void SetLayoutForCurrentDisplays( |
| 142 std::unique_ptr<display::DisplayLayout> layout); | 140 std::unique_ptr<display::DisplayLayout> layout); |
| 143 | 141 |
| 144 // Returns display for given |id|; | 142 // Returns display for given |id|; |
| 145 const gfx::Display& GetDisplayForId(int64_t id) const; | 143 const display::Display& GetDisplayForId(int64_t id) const; |
| 146 | 144 |
| 147 // Finds the display that contains |point| in screeen coordinates. | 145 // Finds the display that contains |point| in screeen coordinates. |
| 148 // Returns invalid display if there is no display that can satisfy | 146 // Returns invalid display if there is no display that can satisfy |
| 149 // the condition. | 147 // the condition. |
| 150 const gfx::Display& FindDisplayContainingPoint( | 148 const display::Display& FindDisplayContainingPoint( |
| 151 const gfx::Point& point_in_screen) const; | 149 const gfx::Point& point_in_screen) const; |
| 152 | 150 |
| 153 // Sets the work area's |insets| to the display given by |display_id|. | 151 // Sets the work area's |insets| to the display given by |display_id|. |
| 154 bool UpdateWorkAreaOfDisplay(int64_t display_id, const gfx::Insets& insets); | 152 bool UpdateWorkAreaOfDisplay(int64_t display_id, const gfx::Insets& insets); |
| 155 | 153 |
| 156 // Registers the overscan insets for the display of the specified ID. Note | 154 // Registers the overscan insets for the display of the specified ID. Note |
| 157 // that the insets size should be specified in DIP size. It also triggers the | 155 // that the insets size should be specified in DIP size. It also triggers the |
| 158 // display's bounds change. | 156 // display's bounds change. |
| 159 void SetOverscanInsets(int64_t display_id, const gfx::Insets& insets_in_dip); | 157 void SetOverscanInsets(int64_t display_id, const gfx::Insets& insets_in_dip); |
| 160 | 158 |
| 161 // Sets the display's rotation for the given |source|. The new |rotation| will | 159 // Sets the display's rotation for the given |source|. The new |rotation| will |
| 162 // also become active. | 160 // also become active. |
| 163 void SetDisplayRotation(int64_t display_id, | 161 void SetDisplayRotation(int64_t display_id, |
| 164 gfx::Display::Rotation rotation, | 162 display::Display::Rotation rotation, |
| 165 gfx::Display::RotationSource source); | 163 display::Display::RotationSource source); |
| 166 | 164 |
| 167 // Sets the external display's configuration, including resolution change, | 165 // Sets the external display's configuration, including resolution change, |
| 168 // ui-scale change, and device scale factor change. Returns true if it changes | 166 // ui-scale change, and device scale factor change. Returns true if it changes |
| 169 // the display resolution so that the caller needs to show a notification in | 167 // the display resolution so that the caller needs to show a notification in |
| 170 // case the new resolution actually doesn't work. | 168 // case the new resolution actually doesn't work. |
| 171 bool SetDisplayMode(int64_t display_id, const DisplayMode& display_mode); | 169 bool SetDisplayMode(int64_t display_id, const DisplayMode& display_mode); |
| 172 | 170 |
| 173 // Register per display properties. |overscan_insets| is NULL if | 171 // Register per display properties. |overscan_insets| is NULL if |
| 174 // the display has no custom overscan insets. | 172 // the display has no custom overscan insets. |
| 175 void RegisterDisplayProperty(int64_t display_id, | 173 void RegisterDisplayProperty(int64_t display_id, |
| 176 gfx::Display::Rotation rotation, | 174 display::Display::Rotation rotation, |
| 177 float ui_scale, | 175 float ui_scale, |
| 178 const gfx::Insets* overscan_insets, | 176 const gfx::Insets* overscan_insets, |
| 179 const gfx::Size& resolution_in_pixels, | 177 const gfx::Size& resolution_in_pixels, |
| 180 float device_scale_factor, | 178 float device_scale_factor, |
| 181 ui::ColorCalibrationProfile color_profile); | 179 ui::ColorCalibrationProfile color_profile); |
| 182 | 180 |
| 183 // Register stored rotation properties for the internal display. | 181 // Register stored rotation properties for the internal display. |
| 184 void RegisterDisplayRotationProperties(bool rotation_lock, | 182 void RegisterDisplayRotationProperties(bool rotation_lock, |
| 185 gfx::Display::Rotation rotation); | 183 display::Display::Rotation rotation); |
| 186 | 184 |
| 187 // Returns the stored rotation lock preference if it has been loaded, | 185 // Returns the stored rotation lock preference if it has been loaded, |
| 188 // otherwise false. | 186 // otherwise false. |
| 189 bool registered_internal_display_rotation_lock() const { | 187 bool registered_internal_display_rotation_lock() const { |
| 190 return registered_internal_display_rotation_lock_; | 188 return registered_internal_display_rotation_lock_; |
| 191 } | 189 } |
| 192 | 190 |
| 193 // Returns the stored rotation preference for the internal display if it has | 191 // Returns the stored rotation preference for the internal display if it has |
| 194 // been loaded, otherwise |gfx::Display::Rotate_0|. | 192 // been loaded, otherwise |display::Display::Rotate_0|. |
| 195 gfx::Display::Rotation registered_internal_display_rotation() const { | 193 display::Display::Rotation registered_internal_display_rotation() const { |
| 196 return registered_internal_display_rotation_; | 194 return registered_internal_display_rotation_; |
| 197 } | 195 } |
| 198 | 196 |
| 199 // Returns the display mode of |display_id| which is currently used. | 197 // Returns the display mode of |display_id| which is currently used. |
| 200 DisplayMode GetActiveModeForDisplayId(int64_t display_id) const; | 198 DisplayMode GetActiveModeForDisplayId(int64_t display_id) const; |
| 201 | 199 |
| 202 // Returns the display's selected mode. This returns false and doesn't | 200 // Returns the display's selected mode. This returns false and doesn't |
| 203 // set |mode_out| if the display mode is in default. | 201 // set |mode_out| if the display mode is in default. |
| 204 bool GetSelectedModeForDisplayId(int64_t display_id, | 202 bool GetSelectedModeForDisplayId(int64_t display_id, |
| 205 DisplayMode* mode_out) const; | 203 DisplayMode* mode_out) const; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 223 const std::vector<DisplayInfo>& display_info_list); | 221 const std::vector<DisplayInfo>& display_info_list); |
| 224 | 222 |
| 225 // Updates the internal display data and notifies observers about the changes. | 223 // Updates the internal display data and notifies observers about the changes. |
| 226 void UpdateDisplaysWith(const std::vector<DisplayInfo>& display_info_list); | 224 void UpdateDisplaysWith(const std::vector<DisplayInfo>& display_info_list); |
| 227 | 225 |
| 228 // Updates current displays using current |display_info_|. | 226 // Updates current displays using current |display_info_|. |
| 229 void UpdateDisplays(); | 227 void UpdateDisplays(); |
| 230 | 228 |
| 231 // Returns the display at |index|. The display at 0 is | 229 // Returns the display at |index|. The display at 0 is |
| 232 // no longer considered "primary". | 230 // no longer considered "primary". |
| 233 const gfx::Display& GetDisplayAt(size_t index) const; | 231 const display::Display& GetDisplayAt(size_t index) const; |
| 234 | 232 |
| 235 const gfx::Display& GetPrimaryDisplayCandidate() const; | 233 const display::Display& GetPrimaryDisplayCandidate() const; |
| 236 | 234 |
| 237 // Returns the logical number of displays. This returns 1 | 235 // Returns the logical number of displays. This returns 1 |
| 238 // when displays are mirrored. | 236 // when displays are mirrored. |
| 239 size_t GetNumDisplays() const; | 237 size_t GetNumDisplays() const; |
| 240 | 238 |
| 241 const display::DisplayList& active_display_list() const { | 239 const display::DisplayList& active_display_list() const { |
| 242 return active_display_list_; | 240 return active_display_list_; |
| 243 } | 241 } |
| 244 | 242 |
| 245 // Returns true if the display specified by |display_id| is currently | 243 // Returns true if the display specified by |display_id| is currently |
| (...skipping 13 matching lines...) Expand all Loading... |
| 259 | 257 |
| 260 // Sets/gets if the unified desktop feature is enabled. | 258 // Sets/gets if the unified desktop feature is enabled. |
| 261 void SetUnifiedDesktopEnabled(bool enabled); | 259 void SetUnifiedDesktopEnabled(bool enabled); |
| 262 bool unified_desktop_enabled() const { return unified_desktop_enabled_; } | 260 bool unified_desktop_enabled() const { return unified_desktop_enabled_; } |
| 263 | 261 |
| 264 // Returns true if it's in unified desktop mode. | 262 // Returns true if it's in unified desktop mode. |
| 265 bool IsInUnifiedMode() const; | 263 bool IsInUnifiedMode() const; |
| 266 | 264 |
| 267 // Returns the display used for software mirrroring. Returns invalid | 265 // Returns the display used for software mirrroring. Returns invalid |
| 268 // display if not found. | 266 // display if not found. |
| 269 const gfx::Display GetMirroringDisplayById(int64_t id) const; | 267 const display::Display GetMirroringDisplayById(int64_t id) const; |
| 270 | 268 |
| 271 // Retuns the display info associated with |display_id|. | 269 // Retuns the display info associated with |display_id|. |
| 272 const DisplayInfo& GetDisplayInfo(int64_t display_id) const; | 270 const DisplayInfo& GetDisplayInfo(int64_t display_id) const; |
| 273 | 271 |
| 274 // Returns the human-readable name for the display |id|. | 272 // Returns the human-readable name for the display |id|. |
| 275 std::string GetDisplayNameForId(int64_t id); | 273 std::string GetDisplayNameForId(int64_t id); |
| 276 | 274 |
| 277 // Returns the display id that is capable of UI scaling. On device, | 275 // Returns the display id that is capable of UI scaling. On device, |
| 278 // this returns internal display's ID if its device scale factor is 2, | 276 // this returns internal display's ID if its device scale factor is 2, |
| 279 // or invalid ID if such internal display doesn't exist. On linux | 277 // or invalid ID if such internal display doesn't exist. On linux |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 }; | 348 }; |
| 351 | 349 |
| 352 void set_change_display_upon_host_resize(bool value) { | 350 void set_change_display_upon_host_resize(bool value) { |
| 353 change_display_upon_host_resize_ = value; | 351 change_display_upon_host_resize_ = value; |
| 354 } | 352 } |
| 355 | 353 |
| 356 // Creates software mirroring display related information. The display | 354 // Creates software mirroring display related information. The display |
| 357 // used to mirror the content is removed from the |display_info_list|. | 355 // used to mirror the content is removed from the |display_info_list|. |
| 358 void CreateSoftwareMirroringDisplayInfo(DisplayInfoList* display_info_list); | 356 void CreateSoftwareMirroringDisplayInfo(DisplayInfoList* display_info_list); |
| 359 | 357 |
| 360 gfx::Display* FindDisplayForId(int64_t id); | 358 display::Display* FindDisplayForId(int64_t id); |
| 361 | 359 |
| 362 // Add the mirror display's display info if the software based | 360 // Add the mirror display's display info if the software based |
| 363 // mirroring is in use. | 361 // mirroring is in use. |
| 364 void AddMirrorDisplayInfoIfAny(DisplayInfoList* display_info_list); | 362 void AddMirrorDisplayInfoIfAny(DisplayInfoList* display_info_list); |
| 365 | 363 |
| 366 // Inserts and update the DisplayInfo according to the overscan | 364 // Inserts and update the DisplayInfo according to the overscan |
| 367 // state. Note that The DisplayInfo stored in the |internal_display_info_| | 365 // state. Note that The DisplayInfo stored in the |internal_display_info_| |
| 368 // can be different from |new_info| (due to overscan state), so | 366 // can be different from |new_info| (due to overscan state), so |
| 369 // you must use |GetDisplayInfo| to get the correct DisplayInfo for | 367 // you must use |GetDisplayInfo| to get the correct DisplayInfo for |
| 370 // a display. | 368 // a display. |
| 371 void InsertAndUpdateDisplayInfo(const DisplayInfo& new_info); | 369 void InsertAndUpdateDisplayInfo(const DisplayInfo& new_info); |
| 372 | 370 |
| 373 // Called when the display info is updated through InsertAndUpdateDisplayInfo. | 371 // Called when the display info is updated through InsertAndUpdateDisplayInfo. |
| 374 void OnDisplayInfoUpdated(const DisplayInfo& display_info); | 372 void OnDisplayInfoUpdated(const DisplayInfo& display_info); |
| 375 | 373 |
| 376 // Creates a display object from the DisplayInfo for |display_id|. | 374 // Creates a display object from the DisplayInfo for |display_id|. |
| 377 gfx::Display CreateDisplayFromDisplayInfoById(int64_t display_id); | 375 display::Display CreateDisplayFromDisplayInfoById(int64_t display_id); |
| 378 | 376 |
| 379 // Creates a display object from the DisplayInfo for |display_id| for | 377 // Creates a display object from the DisplayInfo for |display_id| for |
| 380 // mirroring. The size of the display will be scaled using |scale| | 378 // mirroring. The size of the display will be scaled using |scale| |
| 381 // with the offset using |origin|. | 379 // with the offset using |origin|. |
| 382 gfx::Display CreateMirroringDisplayFromDisplayInfoById( | 380 display::Display CreateMirroringDisplayFromDisplayInfoById( |
| 383 int64_t display_id, | 381 int64_t display_id, |
| 384 const gfx::Point& origin, | 382 const gfx::Point& origin, |
| 385 float scale); | 383 float scale); |
| 386 | 384 |
| 387 // Updates the bounds of all non-primary displays in |display_list| and | 385 // Updates the bounds of all non-primary displays in |display_list| and |
| 388 // append the indices of displays updated to |updated_indices|. | 386 // append the indices of displays updated to |updated_indices|. |
| 389 // When the size of |display_list| equals 2, the bounds are updated using | 387 // When the size of |display_list| equals 2, the bounds are updated using |
| 390 // the layout registered for the display pair. For more than 2 displays, | 388 // the layout registered for the display pair. For more than 2 displays, |
| 391 // the bounds are updated using horizontal layout. | 389 // the bounds are updated using horizontal layout. |
| 392 void UpdateNonPrimaryDisplayBoundsForLayout( | 390 void UpdateNonPrimaryDisplayBoundsForLayout( |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 MultiDisplayMode multi_display_mode_; | 432 MultiDisplayMode multi_display_mode_; |
| 435 MultiDisplayMode current_default_multi_display_mode_; | 433 MultiDisplayMode current_default_multi_display_mode_; |
| 436 | 434 |
| 437 int64_t mirroring_display_id_; | 435 int64_t mirroring_display_id_; |
| 438 display::DisplayList software_mirroring_display_list_; | 436 display::DisplayList software_mirroring_display_list_; |
| 439 | 437 |
| 440 // User preference for rotation lock of the internal display. | 438 // User preference for rotation lock of the internal display. |
| 441 bool registered_internal_display_rotation_lock_; | 439 bool registered_internal_display_rotation_lock_; |
| 442 | 440 |
| 443 // User preference for the rotation of the internal display. | 441 // User preference for the rotation of the internal display. |
| 444 gfx::Display::Rotation registered_internal_display_rotation_; | 442 display::Display::Rotation registered_internal_display_rotation_; |
| 445 | 443 |
| 446 bool unified_desktop_enabled_; | 444 bool unified_desktop_enabled_; |
| 447 | 445 |
| 448 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; | 446 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; |
| 449 | 447 |
| 450 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 448 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
| 451 }; | 449 }; |
| 452 | 450 |
| 453 } // namespace ash | 451 } // namespace ash |
| 454 | 452 |
| 455 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ | 453 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ |
| OLD | NEW |