| Index: services/ui/display/platform_screen_ozone.cc
|
| diff --git a/services/ui/display/platform_screen_ozone.cc b/services/ui/display/platform_screen_ozone.cc
|
| index 0660e2d7298462179ab1057296bf3a956e3f7ce8..664402847e820bc95fc30949302f3d1bd3e3c5b6 100644
|
| --- a/services/ui/display/platform_screen_ozone.cc
|
| +++ b/services/ui/display/platform_screen_ozone.cc
|
| @@ -65,6 +65,7 @@ PlatformScreenOzone::~PlatformScreenOzone() {
|
| void PlatformScreenOzone::AddInterfaces(
|
| service_manager::InterfaceRegistry* registry) {
|
| registry->AddInterface<mojom::DisplayController>(this);
|
| + registry->AddInterface<mojom::TestDisplayController>(this);
|
| }
|
|
|
| void PlatformScreenOzone::Init(PlatformScreenDelegate* delegate) {
|
| @@ -74,6 +75,8 @@ void PlatformScreenOzone::Init(PlatformScreenDelegate* delegate) {
|
| std::unique_ptr<ui::NativeDisplayDelegate> native_display_delegate =
|
| ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate();
|
|
|
| + // The FakeDisplayController gives us a way to make the NativeDisplayDelegate
|
| + // pretend something display related has happened.
|
| if (!base::SysInfo::IsRunningOnChromeOS()) {
|
| fake_display_controller_ =
|
| native_display_delegate->GetFakeDisplayController();
|
| @@ -104,7 +107,7 @@ int64_t PlatformScreenOzone::GetPrimaryDisplayId() const {
|
| return primary_display_id_;
|
| }
|
|
|
| -void PlatformScreenOzone::ToggleVirtualDisplay() {
|
| +void PlatformScreenOzone::ToggleAddRemoveDisplay() {
|
| if (!fake_display_controller_ || wait_for_display_config_update_)
|
| return;
|
|
|
| @@ -121,6 +124,45 @@ void PlatformScreenOzone::ToggleVirtualDisplay() {
|
| }
|
| }
|
|
|
| +void PlatformScreenOzone::SwapPrimaryDisplay() {
|
| + const size_t num_displays = cached_displays_.size();
|
| + if (num_displays <= 1)
|
| + return;
|
| +
|
| + // Find index of current primary display.
|
| + size_t primary_display_index = 0;
|
| + for (size_t i = 0; i < num_displays; i++) {
|
| + if (cached_displays_[i].id == primary_display_id_) {
|
| + primary_display_index = i;
|
| + break;
|
| + }
|
| + }
|
| +
|
| + // Set next display index as primary, or loop back to first display if last.
|
| + if (primary_display_index + 1 == num_displays) {
|
| + primary_display_id_ = cached_displays_[0].id;
|
| + } else {
|
| + primary_display_id_ = cached_displays_[primary_display_index + 1].id;
|
| + }
|
| +
|
| + // TODO(kylechar): Update ws::DisplayManager.
|
| +}
|
| +
|
| +void PlatformScreenOzone::SetDisplayWorkArea(int64_t display_id,
|
| + const gfx::Size& size,
|
| + const gfx::Insets& insets) {
|
| + CachedDisplayIterator iter = GetCachedDisplayIterator(display_id);
|
| + if (iter == cached_displays_.end()) {
|
| + NOTREACHED() << display_id;
|
| + return;
|
| + }
|
| +
|
| + DisplayInfo& display_info = *iter;
|
| + if (display_info.bounds.size() == size) {
|
| + // TODO(kylechar): Change workarea and update ws::DisplayManager.
|
| + }
|
| +}
|
| +
|
| void PlatformScreenOzone::ProcessRemovedDisplays(
|
| const ui::DisplayConfigurator::DisplayStateList& snapshots) {
|
| std::vector<int64_t> current_ids;
|
| @@ -266,7 +308,13 @@ void PlatformScreenOzone::OnDisplayModeChangeFailed(
|
| void PlatformScreenOzone::Create(
|
| const service_manager::Identity& remote_identity,
|
| mojom::DisplayControllerRequest request) {
|
| - bindings_.AddBinding(this, std::move(request));
|
| + controller_bindings_.AddBinding(this, std::move(request));
|
| +}
|
| +
|
| +void PlatformScreenOzone::Create(
|
| + const service_manager::Identity& remote_identity,
|
| + mojom::TestDisplayControllerRequest request) {
|
| + test_bindings_.AddBinding(this, std::move(request));
|
| }
|
|
|
| } // namespace display
|
|
|