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 #include "ash/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
13 #include "ash/display/display_layout_store.h" | 13 #include "ash/display/display_layout_store.h" |
14 #include "ash/display/screen_ash.h" | 14 #include "ash/display/screen_ash.h" |
15 #include "ash/screen_util.h" | 15 #include "ash/screen_util.h" |
16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
17 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "grit/ash_strings.h" | 25 #include "grit/ash_strings.h" |
26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/layout.h" | 27 #include "ui/base/layout.h" |
28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
29 #include "ui/gfx/display.h" | 29 #include "ui/gfx/display.h" |
30 #include "ui/gfx/display_observer.h" | |
30 #include "ui/gfx/rect.h" | 31 #include "ui/gfx/rect.h" |
31 #include "ui/gfx/screen.h" | 32 #include "ui/gfx/screen.h" |
32 #include "ui/gfx/size_conversions.h" | 33 #include "ui/gfx/size_conversions.h" |
33 | 34 |
34 #if defined(USE_X11) | 35 #if defined(USE_X11) |
35 #include "ui/base/x/x11_util.h" | 36 #include "ui/base/x/x11_util.h" |
36 #endif | 37 #endif |
37 | 38 |
38 #if defined(OS_CHROMEOS) | 39 #if defined(OS_CHROMEOS) |
39 #include "ash/display/display_configurator_animation.h" | 40 #include "ash/display/display_configurator_animation.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 delegate_->PreDisplayConfigurationChange(false); | 341 delegate_->PreDisplayConfigurationChange(false); |
341 // PreDisplayConfigurationChange(false); | 342 // PreDisplayConfigurationChange(false); |
342 // TODO(oshima): Call UpdateDisplays instead. | 343 // TODO(oshima): Call UpdateDisplays instead. |
343 const DisplayLayout layout = GetCurrentDisplayLayout(); | 344 const DisplayLayout layout = GetCurrentDisplayLayout(); |
344 UpdateDisplayBoundsForLayoutById( | 345 UpdateDisplayBoundsForLayoutById( |
345 layout, primary, | 346 layout, primary, |
346 ScreenUtil::GetSecondaryDisplay().id()); | 347 ScreenUtil::GetSecondaryDisplay().id()); |
347 | 348 |
348 // Primary's bounds stay the same. Just notify bounds change | 349 // Primary's bounds stay the same. Just notify bounds change |
349 // on the secondary. | 350 // on the secondary. |
350 screen_ash_->NotifyBoundsChanged( | 351 int metrics = gfx::DisplayObserver::DISPLAY_METRICS_BOUNDS | |
351 ScreenUtil::GetSecondaryDisplay()); | 352 gfx::DisplayObserver::DISPLAY_METRICS_WORKAREA; |
353 screen_ash_->NotifyMetricsChanged(ScreenUtil::GetSecondaryDisplay(), | |
354 static_cast<gfx::DisplayObserver::MetricsType>(metrics)); | |
352 if (delegate_) | 355 if (delegate_) |
353 delegate_->PostDisplayConfigurationChange(); | 356 delegate_->PostDisplayConfigurationChange(); |
354 } | 357 } |
355 } | 358 } |
356 | 359 |
357 const gfx::Display& DisplayManager::GetDisplayForId(int64 id) const { | 360 const gfx::Display& DisplayManager::GetDisplayForId(int64 id) const { |
358 gfx::Display* display = | 361 gfx::Display* display = |
359 const_cast<DisplayManager*>(this)->FindDisplayForId(id); | 362 const_cast<DisplayManager*>(this)->FindDisplayForId(id); |
360 return display ? *display : GetInvalidDisplay(); | 363 return display ? *display : GetInvalidDisplay(); |
361 } | 364 } |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
798 for (std::vector<size_t>::iterator iter = added_display_indices.begin(); | 801 for (std::vector<size_t>::iterator iter = added_display_indices.begin(); |
799 iter != added_display_indices.end(); ++iter) { | 802 iter != added_display_indices.end(); ++iter) { |
800 screen_ash_->NotifyDisplayAdded(displays_[*iter]); | 803 screen_ash_->NotifyDisplayAdded(displays_[*iter]); |
801 } | 804 } |
802 // Create the non destkop window after all displays are added so that | 805 // Create the non destkop window after all displays are added so that |
803 // it can mirror the display newly added. This can happen when switching | 806 // it can mirror the display newly added. This can happen when switching |
804 // from dock mode to software mirror mode. | 807 // from dock mode to software mirror mode. |
805 non_desktop_display_updater.reset(); | 808 non_desktop_display_updater.reset(); |
806 for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); | 809 for (std::vector<size_t>::iterator iter = changed_display_indices.begin(); |
807 iter != changed_display_indices.end(); ++iter) { | 810 iter != changed_display_indices.end(); ++iter) { |
808 screen_ash_->NotifyBoundsChanged(displays_[*iter]); | 811 int metrics = gfx::DisplayObserver::DISPLAY_METRICS_BOUNDS | |
812 gfx::DisplayObserver::DISPLAY_METRICS_WORKAREA | | |
813 gfx::DisplayObserver::DISPLAY_METRICS_ROTATION; | |
oshima
2014/05/08 18:06:50
are you going to change this to notify the correct
mlamouri (slow - plz ping)
2014/05/09 16:11:39
Done. Understanding how the Display objects are ha
| |
814 screen_ash_->NotifyMetricsChanged(displays_[*iter], | |
815 static_cast<gfx::DisplayObserver::MetricsType>(metrics)); | |
809 } | 816 } |
810 if (delegate_) | 817 if (delegate_) |
811 delegate_->PostDisplayConfigurationChange(); | 818 delegate_->PostDisplayConfigurationChange(); |
812 | 819 |
813 #if defined(USE_X11) && defined(OS_CHROMEOS) | 820 #if defined(USE_X11) && defined(OS_CHROMEOS) |
814 if (!changed_display_indices.empty() && base::SysInfo::IsRunningOnChromeOS()) | 821 if (!changed_display_indices.empty() && base::SysInfo::IsRunningOnChromeOS()) |
815 ui::ClearX11DefaultRootWindow(); | 822 ui::ClearX11DefaultRootWindow(); |
816 #endif | 823 #endif |
817 } | 824 } |
818 | 825 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
948 | 955 |
949 bool DisplayManager::UpdateDisplayBounds(int64 display_id, | 956 bool DisplayManager::UpdateDisplayBounds(int64 display_id, |
950 const gfx::Rect& new_bounds) { | 957 const gfx::Rect& new_bounds) { |
951 if (change_display_upon_host_resize_) { | 958 if (change_display_upon_host_resize_) { |
952 display_info_[display_id].SetBounds(new_bounds); | 959 display_info_[display_id].SetBounds(new_bounds); |
953 // Don't notify observers if the mirrored window has changed. | 960 // Don't notify observers if the mirrored window has changed. |
954 if (software_mirroring_enabled() && mirrored_display_id_ == display_id) | 961 if (software_mirroring_enabled() && mirrored_display_id_ == display_id) |
955 return false; | 962 return false; |
956 gfx::Display* display = FindDisplayForId(display_id); | 963 gfx::Display* display = FindDisplayForId(display_id); |
957 display->SetSize(display_info_[display_id].size_in_pixel()); | 964 display->SetSize(display_info_[display_id].size_in_pixel()); |
958 screen_ash_->NotifyBoundsChanged(*display); | 965 screen_ash_->NotifyMetricsChanged(*display, |
966 gfx::DisplayObserver::DISPLAY_METRICS_BOUNDS); | |
959 return true; | 967 return true; |
960 } | 968 } |
961 return false; | 969 return false; |
962 } | 970 } |
963 | 971 |
964 void DisplayManager::CreateMirrorWindowIfAny() { | 972 void DisplayManager::CreateMirrorWindowIfAny() { |
965 NonDesktopDisplayUpdater updater(this, delegate_); | 973 NonDesktopDisplayUpdater updater(this, delegate_); |
966 } | 974 } |
967 | 975 |
968 void DisplayManager::CreateScreenForShutdown() const { | 976 void DisplayManager::CreateScreenForShutdown() const { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1117 new_secondary_origin.Offset(-secondary_bounds.width(), offset); | 1125 new_secondary_origin.Offset(-secondary_bounds.width(), offset); |
1118 break; | 1126 break; |
1119 } | 1127 } |
1120 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 1128 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
1121 secondary_display->set_bounds( | 1129 secondary_display->set_bounds( |
1122 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 1130 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
1123 secondary_display->UpdateWorkAreaFromInsets(insets); | 1131 secondary_display->UpdateWorkAreaFromInsets(insets); |
1124 } | 1132 } |
1125 | 1133 |
1126 } // namespace ash | 1134 } // namespace ash |
OLD | NEW |