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

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

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/manager/display_manager.h ('k') | ui/display/test/display_manager_test_api.h » ('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 #include "ash/display/display_manager.h" 5 #include "ui/display/manager/display_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
(...skipping 13 matching lines...) Expand all
29 #include "ui/display/display_observer.h" 29 #include "ui/display/display_observer.h"
30 #include "ui/display/display_switches.h" 30 #include "ui/display/display_switches.h"
31 #include "ui/display/manager/display_layout_store.h" 31 #include "ui/display/manager/display_layout_store.h"
32 #include "ui/display/manager/display_manager_utilities.h" 32 #include "ui/display/manager/display_manager_utilities.h"
33 #include "ui/display/manager/managed_display_info.h" 33 #include "ui/display/manager/managed_display_info.h"
34 #include "ui/display/screen.h" 34 #include "ui/display/screen.h"
35 #include "ui/gfx/font_render_params.h" 35 #include "ui/gfx/font_render_params.h"
36 #include "ui/gfx/geometry/rect.h" 36 #include "ui/gfx/geometry/rect.h"
37 #include "ui/gfx/geometry/size_conversions.h" 37 #include "ui/gfx/geometry/size_conversions.h"
38 38
39 #if defined(USE_X11)
40 #include "ui/base/x/x11_util.h" // nogncheck
41 #endif
42
43 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
44 #include "base/sys_info.h" 40 #include "base/sys_info.h"
45 #endif 41 #endif
46 42
47 #if defined(OS_WIN) 43 #if defined(OS_WIN)
48 #include "base/win/windows_version.h" 44 #include "base/win/windows_version.h"
49 #endif 45 #endif
50 46
51 namespace ash { 47 namespace display {
52 48
53 namespace { 49 namespace {
54 50
55 // The number of pixels to overlap between the primary and secondary displays, 51 // The number of pixels to overlap between the primary and secondary displays,
56 // in case that the offset value is too large. 52 // in case that the offset value is too large.
57 const int kMinimumOverlapForInvalidOffset = 100; 53 const int kMinimumOverlapForInvalidOffset = 100;
58 54
59 struct DisplaySortFunctor { 55 struct DisplaySortFunctor {
60 bool operator()(const display::Display& a, const display::Display& b) { 56 bool operator()(const display::Display& a, const display::Display& b) {
61 return display::CompareDisplayIds(a.id(), b.id()); 57 return display::CompareDisplayIds(a.id(), b.id());
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 ApplyDisplayLayout(GetCurrentDisplayLayout(), &active_display_list_, 260 ApplyDisplayLayout(GetCurrentDisplayLayout(), &active_display_list_,
265 &updated_ids); 261 &updated_ids);
266 for (int64_t id : updated_ids) { 262 for (int64_t id : updated_ids) {
267 NotifyMetricsChanged( 263 NotifyMetricsChanged(
268 GetDisplayForId(id), 264 GetDisplayForId(id),
269 display::DisplayObserver::DISPLAY_METRIC_BOUNDS | 265 display::DisplayObserver::DISPLAY_METRIC_BOUNDS |
270 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 266 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
271 } 267 }
272 268
273 if (delegate_) 269 if (delegate_)
274 delegate_->PostDisplayConfigurationChange(); 270 delegate_->PostDisplayConfigurationChange(false);
275 } 271 }
276 272
277 const display::Display& DisplayManager::GetDisplayForId(int64_t id) const { 273 const display::Display& DisplayManager::GetDisplayForId(int64_t id) const {
278 display::Display* display = 274 display::Display* display =
279 const_cast<DisplayManager*>(this)->FindDisplayForId(id); 275 const_cast<DisplayManager*>(this)->FindDisplayForId(id);
280 return display ? *display : GetInvalidDisplay(); 276 return display ? *display : GetInvalidDisplay();
281 } 277 }
282 278
283 const display::Display& DisplayManager::FindDisplayContainingPoint( 279 const display::Display& DisplayManager::FindDisplayContainingPoint(
284 const gfx::Point& point_in_screen) const { 280 const gfx::Point& point_in_screen) const {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 469 }
474 470
475 void DisplayManager::RegisterDisplayRotationProperties( 471 void DisplayManager::RegisterDisplayRotationProperties(
476 bool rotation_lock, 472 bool rotation_lock,
477 display::Display::Rotation rotation) { 473 display::Display::Rotation rotation) {
478 if (delegate_) 474 if (delegate_)
479 delegate_->PreDisplayConfigurationChange(false); 475 delegate_->PreDisplayConfigurationChange(false);
480 registered_internal_display_rotation_lock_ = rotation_lock; 476 registered_internal_display_rotation_lock_ = rotation_lock;
481 registered_internal_display_rotation_ = rotation; 477 registered_internal_display_rotation_ = rotation;
482 if (delegate_) 478 if (delegate_)
483 delegate_->PostDisplayConfigurationChange(); 479 delegate_->PostDisplayConfigurationChange(false);
484 } 480 }
485 481
486 scoped_refptr<display::ManagedDisplayMode> 482 scoped_refptr<display::ManagedDisplayMode>
487 DisplayManager::GetSelectedModeForDisplayId(int64_t id) const { 483 DisplayManager::GetSelectedModeForDisplayId(int64_t id) const {
488 std::map<int64_t, scoped_refptr<display::ManagedDisplayMode>>::const_iterator 484 std::map<int64_t, scoped_refptr<display::ManagedDisplayMode>>::const_iterator
489 iter = display_modes_.find(id); 485 iter = display_modes_.find(id);
490 if (iter == display_modes_.end()) 486 if (iter == display_modes_.end())
491 return scoped_refptr<display::ManagedDisplayMode>(); 487 return scoped_refptr<display::ManagedDisplayMode>();
492 return iter->second; 488 return iter->second;
493 } 489 }
(...skipping 20 matching lines...) Expand all
514 delegate_->PreDisplayConfigurationChange(false); 510 delegate_->PreDisplayConfigurationChange(false);
515 // Just sets color profile if it's not running on ChromeOS (like tests). 511 // Just sets color profile if it's not running on ChromeOS (like tests).
516 if (!base::SysInfo::IsRunningOnChromeOS() || 512 if (!base::SysInfo::IsRunningOnChromeOS() ||
517 delegate_->display_configurator()->SetColorCalibrationProfile(display_id, 513 delegate_->display_configurator()->SetColorCalibrationProfile(display_id,
518 profile)) { 514 profile)) {
519 display_info_[display_id].SetColorProfile(profile); 515 display_info_[display_id].SetColorProfile(profile);
520 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Display.ColorProfile", profile, 516 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Display.ColorProfile", profile,
521 ui::NUM_COLOR_PROFILES); 517 ui::NUM_COLOR_PROFILES);
522 } 518 }
523 if (delegate_) 519 if (delegate_)
524 delegate_->PostDisplayConfigurationChange(); 520 delegate_->PostDisplayConfigurationChange(false);
525 #endif 521 #endif
526 } 522 }
527 523
528 void DisplayManager::OnNativeDisplaysChanged( 524 void DisplayManager::OnNativeDisplaysChanged(
529 const DisplayInfoList& updated_displays) { 525 const DisplayInfoList& updated_displays) {
530 if (updated_displays.empty()) { 526 if (updated_displays.empty()) {
531 VLOG(1) << "OnNativeDisplaysChanged(0): # of current displays=" 527 VLOG(1) << "OnNativeDisplaysChanged(0): # of current displays="
532 << active_display_list_.size(); 528 << active_display_list_.size();
533 // If the device is booted without display, or chrome is started 529 // If the device is booted without display, or chrome is started
534 // without --ash-host-window-bounds on linux desktop, use the 530 // without --ash-host-window-bounds on linux desktop, use the
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 display_changes[updated_index] = metrics; 788 display_changes[updated_index] = metrics;
793 } 789 }
794 } 790 }
795 791
796 active_display_list_ = new_displays; 792 active_display_list_ = new_displays;
797 active_only_display_list_ = active_display_list_; 793 active_only_display_list_ = active_display_list_;
798 794
799 RefreshFontParams(); 795 RefreshFontParams();
800 base::AutoReset<bool> resetter(&change_display_upon_host_resize_, false); 796 base::AutoReset<bool> resetter(&change_display_upon_host_resize_, false);
801 797
802 int active_display_list_size = active_display_list_.size(); 798 size_t active_display_list_size = active_display_list_.size();
803 is_updating_display_list_ = true; 799 is_updating_display_list_ = true;
804 // Temporarily add displays to be removed because display object 800 // Temporarily add displays to be removed because display object
805 // being removed are accessed during shutting down the root. 801 // being removed are accessed during shutting down the root.
806 active_display_list_.insert(active_display_list_.end(), 802 active_display_list_.insert(active_display_list_.end(),
807 removed_displays.begin(), removed_displays.end()); 803 removed_displays.begin(), removed_displays.end());
808 804
809 for (const auto& display : removed_displays) 805 for (const auto& display : removed_displays)
810 NotifyDisplayRemoved(display); 806 NotifyDisplayRemoved(display);
811 807
812 for (size_t index : added_display_indices) 808 for (size_t index : added_display_indices)
(...skipping 28 matching lines...) Expand all
841 metrics |= (display::DisplayObserver::DISPLAY_METRIC_BOUNDS | 837 metrics |= (display::DisplayObserver::DISPLAY_METRIC_BOUNDS |
842 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 838 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
843 } 839 }
844 if (primary.device_scale_factor() != old_primary.device_scale_factor()) 840 if (primary.device_scale_factor() != old_primary.device_scale_factor())
845 metrics |= display::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; 841 metrics |= display::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR;
846 842
847 NotifyMetricsChanged(primary, metrics); 843 NotifyMetricsChanged(primary, metrics);
848 } 844 }
849 } 845 }
850 846
847 bool must_clear_window = false;
848 #if defined(USE_X11) && defined(OS_CHROMEOS)
849 must_clear_window =
850 !display_changes.empty() && base::SysInfo::IsRunningOnChromeOS();
851 #endif
852
851 if (delegate_) 853 if (delegate_)
852 delegate_->PostDisplayConfigurationChange(); 854 delegate_->PostDisplayConfigurationChange(must_clear_window);
853
854 #if defined(USE_X11) && defined(OS_CHROMEOS)
855 if (!display_changes.empty() && base::SysInfo::IsRunningOnChromeOS())
856 ui::ClearX11DefaultRootWindow();
857 #endif
858 855
859 // Create the mirroring window asynchronously after all displays 856 // Create the mirroring window asynchronously after all displays
860 // are added so that it can mirror the display newly added. This can 857 // are added so that it can mirror the display newly added. This can
861 // happen when switching from dock mode to software mirror mode. 858 // happen when switching from dock mode to software mirror mode.
862 CreateMirrorWindowAsyncIfAny(); 859 CreateMirrorWindowAsyncIfAny();
863 } 860 }
864 861
865 const display::Display& DisplayManager::GetDisplayAt(size_t index) const { 862 const display::Display& DisplayManager::GetDisplayAt(size_t index) const {
866 DCHECK_LT(index, active_display_list_.size()); 863 DCHECK_LT(index, active_display_list_.size());
867 return active_display_list_[index]; 864 return active_display_list_[index];
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 } 1425 }
1429 1426
1430 const display::Display& DisplayManager::GetSecondaryDisplay() const { 1427 const display::Display& DisplayManager::GetSecondaryDisplay() const {
1431 CHECK_LE(2U, GetNumDisplays()); 1428 CHECK_LE(2U, GetNumDisplays());
1432 return GetDisplayAt(0).id() == 1429 return GetDisplayAt(0).id() ==
1433 display::Screen::GetScreen()->GetPrimaryDisplay().id() 1430 display::Screen::GetScreen()->GetPrimaryDisplay().id()
1434 ? GetDisplayAt(1) 1431 ? GetDisplayAt(1)
1435 : GetDisplayAt(0); 1432 : GetDisplayAt(0);
1436 } 1433 }
1437 1434
1438 } // namespace ash 1435 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/manager/display_manager.h ('k') | ui/display/test/display_manager_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698