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 "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/observer_list.h" |
21 #include "ui/display/display.h" | 22 #include "ui/display/display.h" |
| 23 #include "ui/display/display_observer.h" |
22 #include "ui/display/manager/display_layout.h" | 24 #include "ui/display/manager/display_layout.h" |
23 #include "ui/display/manager/managed_display_info.h" | 25 #include "ui/display/manager/managed_display_info.h" |
24 | 26 |
25 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
26 #include "ui/display/chromeos/display_configurator.h" | 28 #include "ui/display/chromeos/display_configurator.h" |
27 #endif | 29 #endif |
28 | 30 |
29 namespace aura { | 31 namespace aura { |
30 class Window; | 32 class Window; |
31 } | 33 } |
32 | 34 |
33 namespace chromeos { | 35 namespace chromeos { |
34 class DisplayNotificationsTest; | 36 class DisplayNotificationsTest; |
35 } | 37 } |
36 | 38 |
37 namespace display { | 39 namespace display { |
38 class DisplayLayoutStore; | 40 class DisplayLayoutStore; |
| 41 class DisplayObserver; |
| 42 class Screen; |
39 } | 43 } |
40 | 44 |
41 namespace gfx { | 45 namespace gfx { |
42 class Insets; | 46 class Insets; |
43 class Rect; | 47 class Rect; |
44 } | 48 } |
45 | 49 |
46 namespace ash { | 50 namespace ash { |
47 class AcceleratorControllerTest; | 51 class AcceleratorControllerTest; |
48 class ScreenAsh; | |
49 | 52 |
50 using DisplayInfoList = std::vector<display::ManagedDisplayInfo>; | 53 using DisplayInfoList = std::vector<display::ManagedDisplayInfo>; |
51 | 54 |
52 namespace test { | 55 namespace test { |
53 class AshTestBase; | 56 class AshTestBase; |
54 class DisplayManagerTestApi; | 57 class DisplayManagerTestApi; |
55 class SystemGestureEventFilterTest; | 58 class SystemGestureEventFilterTest; |
56 } | 59 } |
57 | 60 |
58 // DisplayManager maintains the current display configurations, | 61 // DisplayManager maintains the current display configurations, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // 3) UNIFIED mode creates single desktop across multiple displays. | 93 // 3) UNIFIED mode creates single desktop across multiple displays. |
91 enum MultiDisplayMode { | 94 enum MultiDisplayMode { |
92 EXTENDED = 0, | 95 EXTENDED = 0, |
93 MIRRORING, | 96 MIRRORING, |
94 UNIFIED, | 97 UNIFIED, |
95 }; | 98 }; |
96 | 99 |
97 // The display ID for a virtual display assigned to a unified desktop. | 100 // The display ID for a virtual display assigned to a unified desktop. |
98 static int64_t kUnifiedDisplayId; | 101 static int64_t kUnifiedDisplayId; |
99 | 102 |
100 DisplayManager(); | 103 explicit DisplayManager(std::unique_ptr<display::Screen> screen); |
101 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
102 ~DisplayManager() override; | 105 ~DisplayManager() override; |
103 #else | 106 #else |
104 virtual ~DisplayManager(); | 107 virtual ~DisplayManager(); |
105 #endif | 108 #endif |
106 | 109 |
107 display::DisplayLayoutStore* layout_store() { return layout_store_.get(); } | 110 display::DisplayLayoutStore* layout_store() { return layout_store_.get(); } |
108 | 111 |
109 void set_delegate(Delegate* delegate) { delegate_ = delegate; } | 112 void set_delegate(Delegate* delegate) { delegate_ = delegate; } |
110 | 113 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // impl to |SetDefaultMultiDisplayMode|. | 323 // impl to |SetDefaultMultiDisplayMode|. |
321 void ReconfigureDisplays(); | 324 void ReconfigureDisplays(); |
322 | 325 |
323 // Update the bounds of the display given by |display_id|. | 326 // Update the bounds of the display given by |display_id|. |
324 bool UpdateDisplayBounds(int64_t display_id, const gfx::Rect& new_bounds); | 327 bool UpdateDisplayBounds(int64_t display_id, const gfx::Rect& new_bounds); |
325 | 328 |
326 // Creates mirror window asynchronously if the software mirror mode | 329 // Creates mirror window asynchronously if the software mirror mode |
327 // is enabled. | 330 // is enabled. |
328 void CreateMirrorWindowAsyncIfAny(); | 331 void CreateMirrorWindowAsyncIfAny(); |
329 | 332 |
330 // Create a screen instance to be used during shutdown. | |
331 void CreateScreenForShutdown() const; | |
332 | |
333 // A unit test may change the internal display id (which never happens on | 333 // A unit test may change the internal display id (which never happens on |
334 // a real device). This will update the mode list for internal display | 334 // a real device). This will update the mode list for internal display |
335 // for this test scenario. | 335 // for this test scenario. |
336 void UpdateInternalManagedDisplayModeListForTest(); | 336 void UpdateInternalManagedDisplayModeListForTest(); |
337 | 337 |
338 // Zoom the internal display. | 338 // Zoom the internal display. |
339 bool ZoomInternalDisplay(bool up); | 339 bool ZoomInternalDisplay(bool up); |
340 | 340 |
341 // Reset the internal display zoom. | 341 // Reset the internal display zoom. |
342 void ResetInternalDisplayZoom(); | 342 void ResetInternalDisplayZoom(); |
343 | 343 |
| 344 // Notifies observers of display configuration changes. |
| 345 void NotifyMetricsChanged(const display::Display& display, uint32_t metrics); |
| 346 void NotifyDisplayAdded(const display::Display& display); |
| 347 void NotifyDisplayRemoved(const display::Display& display); |
| 348 |
| 349 // Delegated from the Screen implementation. |
| 350 void AddObserver(display::DisplayObserver* observer); |
| 351 void RemoveObserver(display::DisplayObserver* observer); |
| 352 |
344 private: | 353 private: |
345 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); | 354 FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint); |
346 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged); | 355 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged); |
347 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, | 356 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, |
348 NativeDisplaysChangedAfterPrimaryChange); | 357 NativeDisplaysChangedAfterPrimaryChange); |
349 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets); | 358 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, AutomaticOverscanInsets); |
350 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, Rotate); | 359 FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, Rotate); |
351 friend class AcceleratorControllerTest; | 360 friend class AcceleratorControllerTest; |
352 friend class DisplayManagerTest; | 361 friend class DisplayManagerTest; |
353 friend class chromeos::DisplayNotificationsTest; | 362 friend class chromeos::DisplayNotificationsTest; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 void RunPendingTasksForTest(); | 423 void RunPendingTasksForTest(); |
415 | 424 |
416 // Applies the |layout| and updates the bounds of displays in |display_list|. | 425 // Applies the |layout| and updates the bounds of displays in |display_list|. |
417 // |updated_ids| contains the ids for displays whose bounds have changed. | 426 // |updated_ids| contains the ids for displays whose bounds have changed. |
418 void ApplyDisplayLayout(const display::DisplayLayout& layout, | 427 void ApplyDisplayLayout(const display::DisplayLayout& layout, |
419 display::DisplayList* display_list, | 428 display::DisplayList* display_list, |
420 std::vector<int64_t>* updated_ids); | 429 std::vector<int64_t>* updated_ids); |
421 | 430 |
422 Delegate* delegate_; // not owned. | 431 Delegate* delegate_; // not owned. |
423 | 432 |
424 std::unique_ptr<ScreenAsh> screen_; | 433 std::unique_ptr<display::Screen> screen_; |
425 | 434 |
426 std::unique_ptr<display::DisplayLayoutStore> layout_store_; | 435 std::unique_ptr<display::DisplayLayoutStore> layout_store_; |
427 | 436 |
428 int64_t first_display_id_; | 437 int64_t first_display_id_; |
429 | 438 |
430 // List of current active displays. | 439 // List of current active displays. |
431 display::DisplayList active_display_list_; | 440 display::DisplayList active_display_list_; |
432 // This list does not include the displays that will be removed if | 441 // This list does not include the displays that will be removed if |
433 // |UpdateDisplaysWith| is under execution. | 442 // |UpdateDisplaysWith| is under execution. |
434 // See https://crbug.com/632755 | 443 // See https://crbug.com/632755 |
(...skipping 28 matching lines...) Expand all Loading... |
463 display::DisplayList software_mirroring_display_list_; | 472 display::DisplayList software_mirroring_display_list_; |
464 | 473 |
465 // User preference for rotation lock of the internal display. | 474 // User preference for rotation lock of the internal display. |
466 bool registered_internal_display_rotation_lock_; | 475 bool registered_internal_display_rotation_lock_; |
467 | 476 |
468 // User preference for the rotation of the internal display. | 477 // User preference for the rotation of the internal display. |
469 display::Display::Rotation registered_internal_display_rotation_; | 478 display::Display::Rotation registered_internal_display_rotation_; |
470 | 479 |
471 bool unified_desktop_enabled_; | 480 bool unified_desktop_enabled_; |
472 | 481 |
| 482 base::ObserverList<display::DisplayObserver> observers_; |
| 483 |
473 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; | 484 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; |
474 | 485 |
475 DISALLOW_COPY_AND_ASSIGN(DisplayManager); | 486 DISALLOW_COPY_AND_ASSIGN(DisplayManager); |
476 }; | 487 }; |
477 | 488 |
478 } // namespace ash | 489 } // namespace ash |
479 | 490 |
480 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ | 491 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ |
OLD | NEW |