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

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

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 #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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 ApplyDisplayLayout(GetCurrentDisplayLayout(), &active_display_list_, 261 ApplyDisplayLayout(GetCurrentDisplayLayout(), &active_display_list_,
266 &updated_ids); 262 &updated_ids);
267 for (int64_t id : updated_ids) { 263 for (int64_t id : updated_ids) {
268 NotifyMetricsChanged( 264 NotifyMetricsChanged(
269 GetDisplayForId(id), 265 GetDisplayForId(id),
270 display::DisplayObserver::DISPLAY_METRIC_BOUNDS | 266 display::DisplayObserver::DISPLAY_METRIC_BOUNDS |
271 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 267 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
272 } 268 }
273 269
274 if (delegate_) 270 if (delegate_)
275 delegate_->PostDisplayConfigurationChange(); 271 delegate_->PostDisplayConfigurationChange(false);
276 } 272 }
277 273
278 const display::Display& DisplayManager::GetDisplayForId(int64_t id) const { 274 const display::Display& DisplayManager::GetDisplayForId(int64_t id) const {
279 display::Display* display = 275 display::Display* display =
280 const_cast<DisplayManager*>(this)->FindDisplayForId(id); 276 const_cast<DisplayManager*>(this)->FindDisplayForId(id);
281 return display ? *display : GetInvalidDisplay(); 277 return display ? *display : GetInvalidDisplay();
282 } 278 }
283 279
284 const display::Display& DisplayManager::FindDisplayContainingPoint( 280 const display::Display& DisplayManager::FindDisplayContainingPoint(
285 const gfx::Point& point_in_screen) const { 281 const gfx::Point& point_in_screen) const {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 } 470 }
475 471
476 void DisplayManager::RegisterDisplayRotationProperties( 472 void DisplayManager::RegisterDisplayRotationProperties(
477 bool rotation_lock, 473 bool rotation_lock,
478 display::Display::Rotation rotation) { 474 display::Display::Rotation rotation) {
479 if (delegate_) 475 if (delegate_)
480 delegate_->PreDisplayConfigurationChange(false); 476 delegate_->PreDisplayConfigurationChange(false);
481 registered_internal_display_rotation_lock_ = rotation_lock; 477 registered_internal_display_rotation_lock_ = rotation_lock;
482 registered_internal_display_rotation_ = rotation; 478 registered_internal_display_rotation_ = rotation;
483 if (delegate_) 479 if (delegate_)
484 delegate_->PostDisplayConfigurationChange(); 480 delegate_->PostDisplayConfigurationChange(false);
485 } 481 }
486 482
487 scoped_refptr<display::ManagedDisplayMode> 483 scoped_refptr<display::ManagedDisplayMode>
488 DisplayManager::GetSelectedModeForDisplayId(int64_t id) const { 484 DisplayManager::GetSelectedModeForDisplayId(int64_t id) const {
489 std::map<int64_t, scoped_refptr<display::ManagedDisplayMode>>::const_iterator 485 std::map<int64_t, scoped_refptr<display::ManagedDisplayMode>>::const_iterator
490 iter = display_modes_.find(id); 486 iter = display_modes_.find(id);
491 if (iter == display_modes_.end()) 487 if (iter == display_modes_.end())
492 return scoped_refptr<display::ManagedDisplayMode>(); 488 return scoped_refptr<display::ManagedDisplayMode>();
493 return iter->second; 489 return iter->second;
494 } 490 }
(...skipping 20 matching lines...) Expand all
515 delegate_->PreDisplayConfigurationChange(false); 511 delegate_->PreDisplayConfigurationChange(false);
516 // Just sets color profile if it's not running on ChromeOS (like tests). 512 // Just sets color profile if it's not running on ChromeOS (like tests).
517 if (!base::SysInfo::IsRunningOnChromeOS() || 513 if (!base::SysInfo::IsRunningOnChromeOS() ||
518 delegate_->display_configurator()->SetColorCalibrationProfile(display_id, 514 delegate_->display_configurator()->SetColorCalibrationProfile(display_id,
519 profile)) { 515 profile)) {
520 display_info_[display_id].SetColorProfile(profile); 516 display_info_[display_id].SetColorProfile(profile);
521 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Display.ColorProfile", profile, 517 UMA_HISTOGRAM_ENUMERATION("ChromeOS.Display.ColorProfile", profile,
522 ui::NUM_COLOR_PROFILES); 518 ui::NUM_COLOR_PROFILES);
523 } 519 }
524 if (delegate_) 520 if (delegate_)
525 delegate_->PostDisplayConfigurationChange(); 521 delegate_->PostDisplayConfigurationChange(false);
526 #endif 522 #endif
527 } 523 }
528 524
529 void DisplayManager::OnNativeDisplaysChanged( 525 void DisplayManager::OnNativeDisplaysChanged(
530 const DisplayInfoList& updated_displays) { 526 const DisplayInfoList& updated_displays) {
531 if (updated_displays.empty()) { 527 if (updated_displays.empty()) {
532 VLOG(1) << "OnNativeDisplaysChanged(0): # of current displays=" 528 VLOG(1) << "OnNativeDisplaysChanged(0): # of current displays="
533 << active_display_list_.size(); 529 << active_display_list_.size();
534 // If the device is booted without display, or chrome is started 530 // If the device is booted without display, or chrome is started
535 // without --ash-host-window-bounds on linux desktop, use the 531 // without --ash-host-window-bounds on linux desktop, use the
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 metrics |= (display::DisplayObserver::DISPLAY_METRIC_BOUNDS | 838 metrics |= (display::DisplayObserver::DISPLAY_METRIC_BOUNDS |
843 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA); 839 display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
844 } 840 }
845 if (primary.device_scale_factor() != old_primary.device_scale_factor()) 841 if (primary.device_scale_factor() != old_primary.device_scale_factor())
846 metrics |= display::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; 842 metrics |= display::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR;
847 843
848 NotifyMetricsChanged(primary, metrics); 844 NotifyMetricsChanged(primary, metrics);
849 } 845 }
850 } 846 }
851 847
848 bool must_clear_window = false;
849 #if defined(USE_X11) && defined(OS_CHROMEOS)
850 must_clear_window =
851 !display_changes.empty() && base::SysInfo::IsRunningOnChromeOS();
852 #endif
853
852 if (delegate_) 854 if (delegate_)
853 delegate_->PostDisplayConfigurationChange(); 855 delegate_->PostDisplayConfigurationChange(must_clear_window);
854
855 #if defined(USE_X11) && defined(OS_CHROMEOS)
856 if (!display_changes.empty() && base::SysInfo::IsRunningOnChromeOS())
857 ui::ClearX11DefaultRootWindow();
858 #endif
859 856
860 // Create the mirroring window asynchronously after all displays 857 // Create the mirroring window asynchronously after all displays
861 // are added so that it can mirror the display newly added. This can 858 // are added so that it can mirror the display newly added. This can
862 // happen when switching from dock mode to software mirror mode. 859 // happen when switching from dock mode to software mirror mode.
863 CreateMirrorWindowAsyncIfAny(); 860 CreateMirrorWindowAsyncIfAny();
864 } 861 }
865 862
866 const display::Display& DisplayManager::GetDisplayAt(size_t index) const { 863 const display::Display& DisplayManager::GetDisplayAt(size_t index) const {
867 DCHECK_LT(index, active_display_list_.size()); 864 DCHECK_LT(index, active_display_list_.size());
868 return active_display_list_[index]; 865 return active_display_list_[index];
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 } 1429 }
1433 1430
1434 const display::Display& DisplayManager::GetSecondaryDisplay() const { 1431 const display::Display& DisplayManager::GetSecondaryDisplay() const {
1435 CHECK_LE(2U, GetNumDisplays()); 1432 CHECK_LE(2U, GetNumDisplays());
1436 return GetDisplayAt(0).id() == 1433 return GetDisplayAt(0).id() ==
1437 display::Screen::GetScreen()->GetPrimaryDisplay().id() 1434 display::Screen::GetScreen()->GetPrimaryDisplay().id()
1438 ? GetDisplayAt(1) 1435 ? GetDisplayAt(1)
1439 : GetDisplayAt(0); 1436 : GetDisplayAt(0);
1440 } 1437 }
1441 1438
1442 } // namespace ash 1439 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698