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

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

Issue 2445583002: Relocate display_manager from ash to ui (Closed)
Patch Set: fix windows build 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
« no previous file with comments | « ui/display/BUILD.gn ('k') | ui/display/manager/display_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class DISPLAY_EXPORT DisplayManager
52 // TODO(oshima): Make this non internal.
53 class ASH_EXPORT DisplayManager
54 #if defined(OS_CHROMEOS) 50 #if defined(OS_CHROMEOS)
55 : public ui::DisplayConfigurator::SoftwareMirroringController 51 : public ui::DisplayConfigurator::SoftwareMirroringController
56 #endif 52 #endif
57 { 53 {
58 public: 54 public:
59 class ASH_EXPORT Delegate { 55 class DISPLAY_EXPORT Delegate {
60 public: 56 public:
61 virtual ~Delegate() {} 57 virtual ~Delegate() {}
62 58
63 // Create or updates the mirroring window with |display_info_list|. 59 // Create or updates the mirroring window with |display_info_list|.
64 virtual void CreateOrUpdateMirroringDisplay( 60 virtual void CreateOrUpdateMirroringDisplay(
65 const DisplayInfoList& display_info_list) = 0; 61 const DisplayInfoList& display_info_list) = 0;
66 62
67 // Closes the mirror window if not necessary. 63 // Closes the mirror window if not necessary.
68 virtual void CloseMirroringDisplayIfNotNecessary() = 0; 64 virtual void CloseMirroringDisplayIfNotNecessary() = 0;
69 65
70 // Called before and after the display configuration changes. 66 // Called before and after the display configuration changes.
71 // When |clear_focus| is true, the implementation should 67 // When |clear_focus| is true, the implementation should
72 // deactivate the active window and set the focus window to NULL. 68 // deactivate the active window and set the focus window to NULL.
73 virtual void PreDisplayConfigurationChange(bool clear_focus) = 0; 69 virtual void PreDisplayConfigurationChange(bool clear_focus) = 0;
74 virtual void PostDisplayConfigurationChange() = 0; 70 virtual void PostDisplayConfigurationChange(bool must_clear_window) = 0;
75 71
76 #if defined(OS_CHROMEOS) 72 #if defined(OS_CHROMEOS)
77 // Get the ui::DisplayConfigurator. 73 // Get the ui::DisplayConfigurator.
78 virtual ui::DisplayConfigurator* display_configurator() = 0; 74 virtual ui::DisplayConfigurator* display_configurator() = 0;
79 #endif 75 #endif
80 76
81 virtual std::string GetInternalDisplayNameString() = 0; 77 virtual std::string GetInternalDisplayNameString() = 0;
82 virtual std::string GetUnknownDisplayNameString() = 0; 78 virtual std::string GetUnknownDisplayNameString() = 0;
83 }; 79 };
84 80
85 // How the second display will be used. 81 // How the second display will be used.
86 // 1) EXTENDED mode extends the desktop to the second dislpay. 82 // 1) EXTENDED mode extends the desktop to the second dislpay.
87 // 2) MIRRORING mode copies the content of the primary display to 83 // 2) MIRRORING mode copies the content of the primary display to
88 // the 2nd display. (Software Mirroring). 84 // the 2nd display. (Software Mirroring).
89 // 3) UNIFIED mode creates single desktop across multiple displays. 85 // 3) UNIFIED mode creates single desktop across multiple displays.
90 enum MultiDisplayMode { 86 enum MultiDisplayMode {
91 EXTENDED = 0, 87 EXTENDED = 0,
92 MIRRORING, 88 MIRRORING,
93 UNIFIED, 89 UNIFIED,
94 }; 90 };
95 91
96 // The display ID for a virtual display assigned to a unified desktop. 92 // The display ID for a virtual display assigned to a unified desktop.
97 static int64_t kUnifiedDisplayId; 93 static int64_t kUnifiedDisplayId;
98 94
99 explicit DisplayManager(std::unique_ptr<display::Screen> screen); 95 explicit DisplayManager(std::unique_ptr<Screen> screen);
100 #if defined(OS_CHROMEOS) 96 #if defined(OS_CHROMEOS)
101 ~DisplayManager() override; 97 ~DisplayManager() override;
102 #else 98 #else
103 virtual ~DisplayManager(); 99 virtual ~DisplayManager();
104 #endif 100 #endif
105 101
106 display::DisplayLayoutStore* layout_store() { return layout_store_.get(); } 102 DisplayLayoutStore* layout_store() { return layout_store_.get(); }
107 103
108 void set_delegate(Delegate* delegate) { delegate_ = delegate; } 104 void set_delegate(Delegate* delegate) { delegate_ = delegate; }
109 105
110 // When set to true, the DisplayManager calls OnDisplayMetricsChanged 106 // When set to true, the DisplayManager calls OnDisplayMetricsChanged
111 // even if the display's bounds didn't change. Used to swap primary 107 // even if the display's bounds didn't change. Used to swap primary
112 // display. 108 // display.
113 void set_force_bounds_changed(bool force_bounds_changed) { 109 void set_force_bounds_changed(bool force_bounds_changed) {
114 force_bounds_changed_ = force_bounds_changed; 110 force_bounds_changed_ = force_bounds_changed;
115 } 111 }
116 112
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 void RunPendingTasksForTest(); 414 void RunPendingTasksForTest();
419 415
420 // Applies the |layout| and updates the bounds of displays in |display_list|. 416 // Applies the |layout| and updates the bounds of displays in |display_list|.
421 // |updated_ids| contains the ids for displays whose bounds have changed. 417 // |updated_ids| contains the ids for displays whose bounds have changed.
422 void ApplyDisplayLayout(const display::DisplayLayout& layout, 418 void ApplyDisplayLayout(const display::DisplayLayout& layout,
423 display::Displays* display_list, 419 display::Displays* display_list,
424 std::vector<int64_t>* updated_ids); 420 std::vector<int64_t>* updated_ids);
425 421
426 Delegate* delegate_; // not owned. 422 Delegate* delegate_; // not owned.
427 423
428 std::unique_ptr<display::Screen> screen_; 424 std::unique_ptr<Screen> screen_;
429 425
430 std::unique_ptr<display::DisplayLayoutStore> layout_store_; 426 std::unique_ptr<DisplayLayoutStore> layout_store_;
431 427
432 int64_t first_display_id_; 428 int64_t first_display_id_;
433 429
434 // List of current active displays. 430 // List of current active displays.
435 display::Displays active_display_list_; 431 Displays active_display_list_;
436 // This list does not include the displays that will be removed if 432 // This list does not include the displays that will be removed if
437 // |UpdateDisplaysWith| is under execution. 433 // |UpdateDisplaysWith| is under execution.
438 // See https://crbug.com/632755 434 // See https://crbug.com/632755
439 display::Displays active_only_display_list_; 435 Displays active_only_display_list_;
440 436
441 // True if active_display_list is being modified and has displays that are not 437 // True if active_display_list is being modified and has displays that are not
442 // presently active. 438 // presently active.
443 // See https://crbug.com/632755 439 // See https://crbug.com/632755
444 bool is_updating_display_list_; 440 bool is_updating_display_list_;
445 441
446 int num_connected_displays_; 442 size_t num_connected_displays_;
447 443
448 bool force_bounds_changed_; 444 bool force_bounds_changed_;
449 445
450 // The mapping from the display ID to its internal data. 446 // The mapping from the display ID to its internal data.
451 std::map<int64_t, display::ManagedDisplayInfo> display_info_; 447 std::map<int64_t, ManagedDisplayInfo> display_info_;
452 448
453 // Selected display modes for displays. Key is the displays' ID. 449 // Selected display modes for displays. Key is the displays' ID.
454 std::map<int64_t, scoped_refptr<display::ManagedDisplayMode>> display_modes_; 450 std::map<int64_t, scoped_refptr<ManagedDisplayMode>> display_modes_;
455 451
456 // When set to true, the host window's resize event updates 452 // When set to true, the host window's resize event updates
457 // the display's size. This is set to true when running on 453 // the display's size. This is set to true when running on
458 // desktop environment (for debugging) so that resizing the host 454 // desktop environment (for debugging) so that resizing the host
459 // window will update the display properly. This is set to false 455 // window will update the display properly. This is set to false
460 // on device as well as during the unit tests. 456 // on device as well as during the unit tests.
461 bool change_display_upon_host_resize_; 457 bool change_display_upon_host_resize_;
462 458
463 MultiDisplayMode multi_display_mode_; 459 MultiDisplayMode multi_display_mode_;
464 MultiDisplayMode current_default_multi_display_mode_; 460 MultiDisplayMode current_default_multi_display_mode_;
465 461
466 int64_t mirroring_display_id_; 462 int64_t mirroring_display_id_;
467 display::Displays software_mirroring_display_list_; 463 Displays software_mirroring_display_list_;
468 464
469 // User preference for rotation lock of the internal display. 465 // User preference for rotation lock of the internal display.
470 bool registered_internal_display_rotation_lock_; 466 bool registered_internal_display_rotation_lock_;
471 467
472 // User preference for the rotation of the internal display. 468 // User preference for the rotation of the internal display.
473 display::Display::Rotation registered_internal_display_rotation_; 469 Display::Rotation registered_internal_display_rotation_;
474 470
475 bool unified_desktop_enabled_; 471 bool unified_desktop_enabled_;
476 472
477 base::ObserverList<display::DisplayObserver> observers_; 473 base::ObserverList<DisplayObserver> observers_;
478 474
479 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_; 475 base::WeakPtrFactory<DisplayManager> weak_ptr_factory_;
480 476
481 DISALLOW_COPY_AND_ASSIGN(DisplayManager); 477 DISALLOW_COPY_AND_ASSIGN(DisplayManager);
482 }; 478 };
483 479
484 } // namespace ash 480 } // namespace display
485 481
486 #endif // ASH_DISPLAY_DISPLAY_MANAGER_H_ 482 #endif // UI_DISPLAY_MANAGER_DISPLAY_MANAGER_H_
OLDNEW
« no previous file with comments | « ui/display/BUILD.gn ('k') | ui/display/manager/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698