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

Side by Side Diff: ui/display/manager/display_manager.h

Issue 2445583002: Relocate display_manager from ash to ui (Closed)
Patch Set: Created 4 years, 1 month 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
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_MANAGER_H_ 5 #ifndef UI_DISPLAY_MANAGER_DISPLAY_MANAGER_H_
6 #define ASH_DISPLAY_DISPLAY_MANAGER_H_ 6 #define UI_DISPLAY_MANAGER_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"
16 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
17 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
18 #include "base/macros.h" 17 #include "base/macros.h"
19 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
20 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
21 #include "base/observer_list.h" 20 #include "base/observer_list.h"
22 #include "ui/display/display.h" 21 #include "ui/display/display.h"
22 #include "ui/display/display_export.h"
23 #include "ui/display/display_observer.h" 23 #include "ui/display/display_observer.h"
24 #include "ui/display/manager/display_layout.h" 24 #include "ui/display/manager/display_layout.h"
25 #include "ui/display/manager/managed_display_info.h" 25 #include "ui/display/manager/managed_display_info.h"
26 26
27 #if defined(OS_CHROMEOS) 27 #if defined(OS_CHROMEOS)
28 #include "ui/display/chromeos/display_configurator.h" 28 #include "ui/display/chromeos/display_configurator.h"
29 #endif 29 #endif
30 30
31 namespace display {
32 class DisplayLayoutStore;
33 class DisplayObserver;
34 class Screen;
35 }
36
37 namespace gfx { 31 namespace gfx {
38 class Insets; 32 class Insets;
39 class Rect; 33 class Rect;
40 } 34 }
41 35
42 namespace ash { 36 namespace display {
43 using DisplayInfoList = std::vector<display::ManagedDisplayInfo>; 37 using DisplayInfoList = std::vector<ManagedDisplayInfo>;
38
39 class DisplayLayoutStore;
40 class DisplayObserver;
41 class Screen;
44 42
45 namespace test { 43 namespace test {
46 class DisplayManagerTestApi; 44 class DisplayManagerTestApi;
47 } 45 }
48 46
49 // DisplayManager maintains the current display configurations, 47 // DisplayManager maintains the current display configurations,
50 // and notifies observers when configuration changes. 48 // and notifies observers when configuration changes.
51 // 49 //
52 // TODO(oshima): Make this non internal. 50 // TODO(oshima): Make this non internal.
kylechar 2016/10/24 14:55:15 TODO is fulfilled.
oshima 2016/10/24 19:29:16 yes :)
rjkroege 2016/10/25 23:30:26 Done! :-)
53 class ASH_EXPORT DisplayManager 51 class DISPLAY_EXPORT DisplayManager
54 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
55 : public ui::DisplayConfigurator::SoftwareMirroringController 53 : public ui::DisplayConfigurator::SoftwareMirroringController
56 #endif 54 #endif
57 { 55 {
58 public: 56 public:
59 class ASH_EXPORT Delegate { 57 class DISPLAY_EXPORT Delegate {
60 public: 58 public:
61 virtual ~Delegate() {} 59 virtual ~Delegate() {}
62 60
63 // Create or updates the mirroring window with |display_info_list|. 61 // Create or updates the mirroring window with |display_info_list|.
64 virtual void CreateOrUpdateMirroringDisplay( 62 virtual void CreateOrUpdateMirroringDisplay(
65 const DisplayInfoList& display_info_list) = 0; 63 const DisplayInfoList& display_info_list) = 0;
66 64
67 // Closes the mirror window if not necessary. 65 // Closes the mirror window if not necessary.
68 virtual void CloseMirroringDisplayIfNotNecessary() = 0; 66 virtual void CloseMirroringDisplayIfNotNecessary() = 0;
69 67
70 // Called before and after the display configuration changes. 68 // Called before and after the display configuration changes.
71 // When |clear_focus| is true, the implementation should 69 // When |clear_focus| is true, the implementation should
72 // deactivate the active window and set the focus window to NULL. 70 // deactivate the active window and set the focus window to NULL.
73 virtual void PreDisplayConfigurationChange(bool clear_focus) = 0; 71 virtual void PreDisplayConfigurationChange(bool clear_focus) = 0;
74 virtual void PostDisplayConfigurationChange() = 0; 72 virtual void PostDisplayConfigurationChange(bool must_clear_window) = 0;
75 73
76 #if defined(OS_CHROMEOS) 74 #if defined(OS_CHROMEOS)
77 // Get the ui::DisplayConfigurator. 75 // Get the ui::DisplayConfigurator.
78 virtual ui::DisplayConfigurator* display_configurator() = 0; 76 virtual ui::DisplayConfigurator* display_configurator() = 0;
79 #endif 77 #endif
80 78
81 virtual std::string GetInternalDisplayNameString() = 0; 79 virtual std::string GetInternalDisplayNameString() = 0;
82 virtual std::string GetUnknownDisplayNameString() = 0; 80 virtual std::string GetUnknownDisplayNameString() = 0;
83 }; 81 };
84 82
85 // How the second display will be used. 83 // How the second display will be used.
86 // 1) EXTENDED mode extends the desktop to the second dislpay. 84 // 1) EXTENDED mode extends the desktop to the second dislpay.
87 // 2) MIRRORING mode copies the content of the primary display to 85 // 2) MIRRORING mode copies the content of the primary display to
88 // the 2nd display. (Software Mirroring). 86 // the 2nd display. (Software Mirroring).
89 // 3) UNIFIED mode creates single desktop across multiple displays. 87 // 3) UNIFIED mode creates single desktop across multiple displays.
90 enum MultiDisplayMode { 88 enum MultiDisplayMode {
91 EXTENDED = 0, 89 EXTENDED = 0,
92 MIRRORING, 90 MIRRORING,
93 UNIFIED, 91 UNIFIED,
94 }; 92 };
95 93
96 // The display ID for a virtual display assigned to a unified desktop. 94 // The display ID for a virtual display assigned to a unified desktop.
97 static int64_t kUnifiedDisplayId; 95 static int64_t kUnifiedDisplayId;
98 96
99 explicit DisplayManager(std::unique_ptr<display::Screen> screen); 97 explicit DisplayManager(std::unique_ptr<Screen> screen);
100 #if defined(OS_CHROMEOS) 98 #if defined(OS_CHROMEOS)
101 ~DisplayManager() override; 99 ~DisplayManager() override;
102 #else 100 #else
103 virtual ~DisplayManager(); 101 virtual ~DisplayManager();
104 #endif 102 #endif
105 103
106 display::DisplayLayoutStore* layout_store() { return layout_store_.get(); } 104 DisplayLayoutStore* layout_store() { return layout_store_.get(); }
107 105
108 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 106 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
109 107
110 // When set to true, the DisplayManager calls OnDisplayMetricsChanged 108 // When set to true, the DisplayManager calls OnDisplayMetricsChanged
111 // even if the display's bounds didn't change. Used to swap primary 109 // even if the display's bounds didn't change. Used to swap primary
112 // display. 110 // display.
113 void set_force_bounds_changed(bool force_bounds_changed) { 111 void set_force_bounds_changed(bool force_bounds_changed) {
114 force_bounds_changed_ = force_bounds_changed; 112 force_bounds_changed_ = force_bounds_changed;
115 } 113 }
116 114
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 void RunPendingTasksForTest(); 416 void RunPendingTasksForTest();
419 417
420 // Applies the |layout| and updates the bounds of displays in |display_list|. 418 // Applies the |layout| and updates the bounds of displays in |display_list|.
421 // |updated_ids| contains the ids for displays whose bounds have changed. 419 // |updated_ids| contains the ids for displays whose bounds have changed.
422 void ApplyDisplayLayout(const display::DisplayLayout& layout, 420 void ApplyDisplayLayout(const display::DisplayLayout& layout,
423 display::Displays* display_list, 421 display::Displays* display_list,
424 std::vector<int64_t>* updated_ids); 422 std::vector<int64_t>* updated_ids);
425 423
426 Delegate* delegate_; // not owned. 424 Delegate* delegate_; // not owned.
427 425
428 std::unique_ptr<display::Screen> screen_; 426 std::unique_ptr<Screen> screen_;
429 427
430 std::unique_ptr<display::DisplayLayoutStore> layout_store_; 428 std::unique_ptr<DisplayLayoutStore> layout_store_;
431 429
432 int64_t first_display_id_; 430 int64_t first_display_id_;
433 431
434 // List of current active displays. 432 // List of current active displays.
435 display::Displays active_display_list_; 433 Displays active_display_list_;
436 // This list does not include the displays that will be removed if 434 // This list does not include the displays that will be removed if
437 // |UpdateDisplaysWith| is under execution. 435 // |UpdateDisplaysWith| is under execution.
438 // See https://crbug.com/632755 436 // See https://crbug.com/632755
439 display::Displays active_only_display_list_; 437 Displays active_only_display_list_;
440 438
441 // True if active_display_list is being modified and has displays that are not 439 // True if active_display_list is being modified and has displays that are not
442 // presently active. 440 // presently active.
443 // See https://crbug.com/632755 441 // See https://crbug.com/632755
444 bool is_updating_display_list_; 442 bool is_updating_display_list_;
445 443
446 int num_connected_displays_; 444 int num_connected_displays_;
447 445
448 bool force_bounds_changed_; 446 bool force_bounds_changed_;
449 447
450 // The mapping from the display ID to its internal data. 448 // The mapping from the display ID to its internal data.
451 std::map<int64_t, display::ManagedDisplayInfo> display_info_; 449 std::map<int64_t, ManagedDisplayInfo> display_info_;
452 450
453 // Selected display modes for displays. Key is the displays' ID. 451 // Selected display modes for displays. Key is the displays' ID.
454 std::map<int64_t, scoped_refptr<display::ManagedDisplayMode>> display_modes_; 452 std::map<int64_t, scoped_refptr<ManagedDisplayMode>> display_modes_;
455 453
456 // When set to true, the host window's resize event updates 454 // When set to true, the host window's resize event updates
457 // the display's size. This is set to true when running on 455 // the display's size. This is set to true when running on
458 // desktop environment (for debugging) so that resizing the host 456 // desktop environment (for debugging) so that resizing the host
459 // window will update the display properly. This is set to false 457 // window will update the display properly. This is set to false
460 // on device as well as during the unit tests. 458 // on device as well as during the unit tests.
461 bool change_display_upon_host_resize_; 459 bool change_display_upon_host_resize_;
462 460
463 MultiDisplayMode multi_display_mode_; 461 MultiDisplayMode multi_display_mode_;
464 MultiDisplayMode current_default_multi_display_mode_; 462 MultiDisplayMode current_default_multi_display_mode_;
465 463
466 int64_t mirroring_display_id_; 464 int64_t mirroring_display_id_;
467 display::Displays software_mirroring_display_list_; 465 Displays software_mirroring_display_list_;
468 466
469 // User preference for rotation lock of the internal display. 467 // User preference for rotation lock of the internal display.
470 bool registered_internal_display_rotation_lock_; 468 bool registered_internal_display_rotation_lock_;
471 469
472 // User preference for the rotation of the internal display. 470 // User preference for the rotation of the internal display.
473 display::Display::Rotation registered_internal_display_rotation_; 471 Display::Rotation registered_internal_display_rotation_;
474 472
475 bool unified_desktop_enabled_; 473 bool unified_desktop_enabled_;
476 474
477 base::ObserverList<display::DisplayObserver> observers_; 475 base::ObserverList<DisplayObserver> observers_;
478 476
479 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; 477 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_;
480 478
481 DISALLOW_COPY_AND_ASSIGN(DisplayManager); 479 DISALLOW_COPY_AND_ASSIGN(DisplayManager);
482 }; 480 };
483 481
484 } // namespace ash 482 } // namespace display
485 483
486 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ 484 #endif // UI_DISPLAY_MANAGER_DISPLAY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698