Commit 5cf0fa8b authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

mus: Support the unified display config for mus without viz

Add AshWindowTreeHostMusUnified and AshWindowTreeHostMusMirroringUnified.
(near copies of AshWindowTreeHostUnified and AshWindowTreeHostMirroringUnified)
Make ShellPortMus::CreateAshWindowTreeHost construct these like AshWindowTreeHost::Create.

Loosen DisplayManager::SetDisplayConfiguration restrictions for unified (w/o viz).
Do not show the PlatformDisplay's window for the virtual/offscreen unified display.

TODO: Fix targeting of events on the second display during capture.
TODO: Fix a crash on shutdown when unified mode is still active.

Bug: 764472,770243
TBR: dpranke@chromium.org
Test: Unified mode works reasonably in Mus (needs event handling work)
Change-Id: I25a4f2f917275b4fd9f73cb62a5f22aaf01806ca
Reviewed-on: https://chromium-review.googlesource.com/817761
Commit-Queue: Michael Wasserman <msw@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524186}
parent b992fb57
......@@ -212,6 +212,10 @@ component("ash") {
"host/ash_window_tree_host_mirroring_unified.h",
"host/ash_window_tree_host_mus.cc",
"host/ash_window_tree_host_mus.h",
"host/ash_window_tree_host_mus_mirroring_unified.cc",
"host/ash_window_tree_host_mus_mirroring_unified.h",
"host/ash_window_tree_host_mus_unified.cc",
"host/ash_window_tree_host_mus_unified.h",
"host/ash_window_tree_host_platform.cc",
"host/ash_window_tree_host_platform.h",
"host/ash_window_tree_host_unified.cc",
......
......@@ -102,6 +102,8 @@ specific_include_rules = {
"shell_port_mus\.cc": [
"+ash/host/ash_window_tree_host_init_params.h",
"+ash/host/ash_window_tree_host_mus.h",
"+ash/host/ash_window_tree_host_mus_mirroring_unified.h",
"+ash/host/ash_window_tree_host_mus_unified.h",
],
"touch_transformer_controller\.*": [
"+ash/host"
......
......@@ -197,8 +197,7 @@ void MirrorWindowController::UpdateWindow(
AshWindowTreeHost* unified_ash_host =
Shell::Get()
->window_tree_host_manager()
->GetAshWindowTreeHostForDisplayId(
display::Screen::GetScreen()->GetPrimaryDisplay().id());
->GetAshWindowTreeHostForDisplayId(primary.id());
unified_ash_host->RegisterMirroringHost(host_info->ash_host.get());
aura::client::SetScreenPositionClient(host->window(),
screen_position_client_.get());
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/host/ash_window_tree_host_mus_mirroring_unified.h"
#include "ash/host/ash_window_tree_host_mirroring_delegate.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/transform.h"
namespace ash {
AshWindowTreeHostMusMirroringUnified::AshWindowTreeHostMusMirroringUnified(
aura::WindowTreeHostMusInitParams init_params,
int64_t mirroring_display_id,
AshWindowTreeHostMirroringDelegate* delegate)
: AshWindowTreeHostMus(std::move(init_params)),
mirroring_display_id_(mirroring_display_id),
delegate_(delegate) {
DCHECK(delegate_);
}
AshWindowTreeHostMusMirroringUnified::~AshWindowTreeHostMusMirroringUnified() =
default;
gfx::Transform
AshWindowTreeHostMusMirroringUnified::GetRootTransformForLocalEventCoordinates()
const {
gfx::Transform trans = GetRootTransform();
if (!is_shutting_down_) {
const auto* display =
delegate_->GetMirroringDisplayById(mirroring_display_id_);
DCHECK(display);
// Undo the translation in the root window transform, since this transform
// should be applied on local points to this host.
trans.Translate(SkIntToMScalar(display->bounds().x()),
SkIntToMScalar(display->bounds().y()));
}
return trans;
}
void AshWindowTreeHostMusMirroringUnified::ConvertDIPToPixels(
gfx::Point* point) const {
auto point_3f = gfx::Point3F(gfx::PointF(*point));
// GetRootTransform() returns a transform that takes a point from the
// *unified* host coordinates to the *mirroring* host's pixel coordinates.
// ConvertDIPToPixels() and ConvertDIPToScreenInPixels() are called on local
// points in the *mirroring* host's root window, not on points in the unified
// host's. That's why we use the GetRootTransformForLocalEventCoordinates()
// defined above, which only scales those local points to the right size, and
// leaves the translation to be done by the MirroringScreenPositionClient
// functions.
GetRootTransformForLocalEventCoordinates().TransformPoint(&point_3f);
*point = gfx::ToFlooredPoint(point_3f.AsPointF());
}
void AshWindowTreeHostMusMirroringUnified::ConvertPixelsToDIP(
gfx::Point* point) const {
auto point_3f = gfx::Point3F(gfx::PointF(*point));
GetInverseRootTransformForLocalEventCoordinates().TransformPoint(&point_3f);
*point = gfx::ToFlooredPoint(point_3f.AsPointF());
}
void AshWindowTreeHostMusMirroringUnified::PrepareForShutdown() {
is_shutting_down_ = true;
AshWindowTreeHostMus::PrepareForShutdown();
}
} // namespace ash
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_HOST_ASH_WINDOW_TREE_HOST_MUS_MIRRORING_UNIFIED_H_
#define ASH_HOST_ASH_WINDOW_TREE_HOST_MUS_MIRRORING_UNIFIED_H_
#include "ash/host/ash_window_tree_host_mus.h"
#include "base/macros.h"
#include "ui/aura/mus/window_tree_host_mus_init_params.h"
namespace ash {
class AshWindowTreeHostMirroringDelegate;
// A WTH for the displays mirroring the unified desktop in mus without viz.
// This is a near copy of AshWindowTreeHostMirroringUnified.
class AshWindowTreeHostMusMirroringUnified : public AshWindowTreeHostMus {
public:
AshWindowTreeHostMusMirroringUnified(
aura::WindowTreeHostMusInitParams init_params,
int64_t mirroring_display_id,
AshWindowTreeHostMirroringDelegate* delegate);
~AshWindowTreeHostMusMirroringUnified() override;
// aura::WindowTreeHost:
gfx::Transform GetRootTransformForLocalEventCoordinates() const override;
void ConvertDIPToPixels(gfx::Point* point) const override;
void ConvertPixelsToDIP(gfx::Point* point) const override;
// ash::AshWindowTreeHostMus:
void PrepareForShutdown() override;
private:
int64_t mirroring_display_id_;
AshWindowTreeHostMirroringDelegate* delegate_; // Not owned.
bool is_shutting_down_ = false;
DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostMusMirroringUnified);
};
} // namespace ash
#endif // ASH_HOST_ASH_WINDOW_TREE_HOST_MUS_MIRRORING_UNIFIED_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/host/ash_window_tree_host_mus_unified.h"
#include <memory>
#include <utility>
#include "ash/host/ash_window_tree_host_mirroring_delegate.h"
#include "ash/host/root_window_transformer.h"
#include "base/logging.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_targeter.h"
#include "ui/compositor/compositor.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/platform_window/stub/stub_window.h"
namespace ash {
// TODO(msw): Fix targeting of events on the second display during capture.
class UnifiedEventTargeter : public aura::WindowTargeter {
public:
UnifiedEventTargeter(aura::Window* src_root,
aura::Window* dst_root,
AshWindowTreeHostMirroringDelegate* delegate)
: src_root_(src_root), dst_root_(dst_root), delegate_(delegate) {
DCHECK(delegate);
}
ui::EventTarget* FindTargetForEvent(ui::EventTarget* root,
ui::Event* event) override {
// Unlike the classic config, mus may provide a target for the event.
if (root == src_root_) {
delegate_->SetCurrentEventTargeterSourceHost(src_root_->GetHost());
if (event->IsLocatedEvent()) {
ui::LocatedEvent* located_event = static_cast<ui::LocatedEvent*>(event);
located_event->ConvertLocationToTarget(
static_cast<aura::Window*>(event->target()), dst_root_);
located_event->set_root_location_f(located_event->location_f());
}
if (event->target())
ui::Event::DispatcherApi(event).set_target(nullptr);
ignore_result(
dst_root_->GetHost()->event_sink()->OnEventFromSource(event));
// Reset the source host.
delegate_->SetCurrentEventTargeterSourceHost(nullptr);
return nullptr;
}
NOTREACHED();
return aura::WindowTargeter::FindTargetForEvent(root, event);
}
private:
aura::Window* src_root_;
aura::Window* dst_root_;
AshWindowTreeHostMirroringDelegate* delegate_; // Not owned.
DISALLOW_COPY_AND_ASSIGN(UnifiedEventTargeter);
};
AshWindowTreeHostMusUnified::AshWindowTreeHostMusUnified(
aura::WindowTreeHostMusInitParams init_params,
AshWindowTreeHostMirroringDelegate* delegate)
: AshWindowTreeHostMus(std::move(init_params)), delegate_(delegate) {
DCHECK(delegate);
}
AshWindowTreeHostMusUnified::~AshWindowTreeHostMusUnified() {
for (auto* ash_host : mirroring_hosts_)
ash_host->AsWindowTreeHost()->window()->RemoveObserver(this);
}
void AshWindowTreeHostMusUnified::PrepareForShutdown() {
AshWindowTreeHostMus::PrepareForShutdown();
for (auto* host : mirroring_hosts_)
host->PrepareForShutdown();
}
void AshWindowTreeHostMusUnified::RegisterMirroringHost(
AshWindowTreeHost* mirroring_ash_host) {
aura::Window* src_root = mirroring_ash_host->AsWindowTreeHost()->window();
src_root->SetEventTargeter(
std::make_unique<UnifiedEventTargeter>(src_root, window(), delegate_));
DCHECK(std::find(mirroring_hosts_.begin(), mirroring_hosts_.end(),
mirroring_ash_host) == mirroring_hosts_.end());
mirroring_hosts_.push_back(mirroring_ash_host);
mirroring_ash_host->AsWindowTreeHost()->window()->AddObserver(this);
}
void AshWindowTreeHostMusUnified::SetBoundsInPixels(const gfx::Rect& bounds) {
AshWindowTreeHostMus::SetBoundsInPixels(bounds);
OnHostResizedInPixels(bounds.size());
}
void AshWindowTreeHostMusUnified::SetCursorNative(gfx::NativeCursor cursor) {
for (auto* host : mirroring_hosts_)
host->AsWindowTreeHost()->SetCursor(cursor);
}
void AshWindowTreeHostMusUnified::OnCursorVisibilityChangedNative(bool show) {
for (auto* host : mirroring_hosts_)
host->AsWindowTreeHost()->OnCursorVisibilityChanged(show);
}
void AshWindowTreeHostMusUnified::OnBoundsChanged(const gfx::Rect& bounds) {
if (platform_window())
OnHostResizedInPixels(bounds.size());
}
void AshWindowTreeHostMusUnified::OnWindowDestroying(aura::Window* window) {
auto iter =
std::find_if(mirroring_hosts_.begin(), mirroring_hosts_.end(),
[window](AshWindowTreeHost* ash_host) {
return ash_host->AsWindowTreeHost()->window() == window;
});
DCHECK(iter != mirroring_hosts_.end());
window->RemoveObserver(this);
mirroring_hosts_.erase(iter);
}
} // namespace ash
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_HOST_ASH_WINDOW_TREE_HOST_MUS_UNIFIED_H_
#define ASH_HOST_ASH_WINDOW_TREE_HOST_MUS_UNIFIED_H_
#include <vector>
#include "ash/host/ash_window_tree_host_mus.h"
#include "base/macros.h"
#include "ui/aura/mus/window_tree_host_mus_init_params.h"
#include "ui/aura/window_observer.h"
namespace ash {
class AshWindowTreeHostMirroringDelegate;
// A WTH for the unified desktop display in mus without viz.
// This is a near copy of AshWindowTreeHostUnified.
class AshWindowTreeHostMusUnified : public AshWindowTreeHostMus,
public aura::WindowObserver {
public:
AshWindowTreeHostMusUnified(aura::WindowTreeHostMusInitParams init_params,
AshWindowTreeHostMirroringDelegate* delegate);
~AshWindowTreeHostMusUnified() override;
private:
// AshWindowTreeHost:
void PrepareForShutdown() override;
void RegisterMirroringHost(AshWindowTreeHost* mirroring_ash_host) override;
// aura::WindowTreeHost:
void SetBoundsInPixels(const gfx::Rect& bounds) override;
void SetCursorNative(gfx::NativeCursor cursor) override;
void OnCursorVisibilityChangedNative(bool show) override;
// ui::PlatformWindowDelegate:
void OnBoundsChanged(const gfx::Rect& bounds) override;
// aura::WindowObserver:
void OnWindowDestroying(aura::Window* window) override;
AshWindowTreeHostMirroringDelegate* delegate_; // Not owned.
std::vector<AshWindowTreeHost*> mirroring_hosts_;
DISALLOW_COPY_AND_ASSIGN(AshWindowTreeHostMusUnified);
};
} // namespace ash
#endif // ASH_HOST_ASH_WINDOW_TREE_HOST_MUS_UNIFIED_H_
......@@ -11,6 +11,8 @@
#include "ash/display/display_synchronizer.h"
#include "ash/host/ash_window_tree_host_init_params.h"
#include "ash/host/ash_window_tree_host_mus.h"
#include "ash/host/ash_window_tree_host_mus_mirroring_unified.h"
#include "ash/host/ash_window_tree_host_mus_unified.h"
#include "ash/keyboard/keyboard_ui_mash.h"
#include "ash/pointer_watcher_adapter_classic.h"
#include "ash/public/cpp/config.h"
......@@ -209,6 +211,19 @@ std::unique_ptr<AshWindowTreeHost> ShellPortMus::CreateAshWindowTreeHost(
aura_init_params.use_classic_ime = !Shell::ShouldUseIMEService();
aura_init_params.uses_real_accelerated_widget =
!::switches::IsMusHostingViz();
if (!::switches::IsMusHostingViz()) {
if (init_params.mirroring_unified) {
return std::make_unique<AshWindowTreeHostMusMirroringUnified>(
std::move(aura_init_params), init_params.display_id,
init_params.mirroring_delegate);
}
if (init_params.offscreen) {
return std::make_unique<AshWindowTreeHostMusUnified>(
std::move(aura_init_params), init_params.mirroring_delegate);
}
}
return std::make_unique<AshWindowTreeHostMus>(std::move(aura_init_params));
}
......
......@@ -131,23 +131,10 @@ bool DisplayManager::SetDisplayConfiguration(
primary_display_index = i;
found_internal_display |= display.id() == internal_display_id;
Display* ws_display = GetDisplayById(display.id());
if (!ws_display) {
if (display.id() == display::kUnifiedDisplayId) {
if (displays.size() != 1u) {
LOG(ERROR) << "SetDisplayConfiguration passed 2+ displays in unified";
return false;
}
if (mirrors.size() <= 1u) {
LOG(ERROR) << "SetDisplayConfiguration passed <2 mirrors in unified";
return false;
}
NOTIMPLEMENTED() << "TODO(crbug.com/764472): Mus unified mode.";
return false;
} else {
LOG(ERROR) << "SetDisplayConfiguration passed unknown display id "
<< display.id();
return false;
}
if (!ws_display && display.id() != display::kUnifiedDisplayId) {
LOG(ERROR) << "SetDisplayConfiguration passed unknown display id "
<< display.id();
return false;
}
}
if (primary_display_index == std::numeric_limits<size_t>::max()) {
......
......@@ -85,7 +85,9 @@ void PlatformDisplayDefault::Init(PlatformDisplayDelegate* delegate) {
NOTREACHED() << "Unsupported platform";
#endif
platform_window_->Show();
// Show the platform window, unless it's the virtual unified display window.
if (delegate_->GetDisplay().id() != display::kUnifiedDisplayId)
platform_window_->Show();
if (image_cursors_) {
image_cursors_->SetDisplay(delegate_->GetDisplay(),
metrics_.device_scale_factor);
......
......@@ -817,8 +817,7 @@
},
{
"args": [
"--mus",
"--test-launcher-filter-file=../../testing/buildbot/filters/ash_unittests_mus.filter"
"--mus"
],
"name": "ash_unittests-mus",
"override_isolate_target": "ash_unittests",
......
......@@ -4273,8 +4273,7 @@
},
{
"args": [
"--mus",
"--test-launcher-filter-file=../../testing/buildbot/filters/ash_unittests_mus.filter"
"--mus"
],
"name": "ash_unittests-mus",
"override_isolate_target": "ash_unittests",
......
......@@ -736,8 +736,7 @@
},
{
"args": [
"--mus",
"--test-launcher-filter-file=../../testing/buildbot/filters/ash_unittests_mus.filter"
"--mus"
],
"name": "ash_unittests-mus",
"override_isolate_target": "ash_unittests",
......
......@@ -21,7 +21,6 @@ source_set("ash_unittests_filters") {
data = [
"//testing/buildbot/filters/ash_unittests_mash.filter",
"//testing/buildbot/filters/ash_unittests_mus.filter",
]
}
......
-UnifiedMouseWarpControllerTest.BoundaryTestGrid
-UnifiedMouseWarpControllerTest.WarpMouse
-UnifiedMouseWarpControllerTest.BoundaryAndWarpSimpleTest
# When adding new exclusions be sure to file bug with reason. Group with the
# above if applicable.
......@@ -1127,7 +1127,6 @@
'override_isolate_target': 'ash_unittests',
'args': [
'--mus',
'--test-launcher-filter-file=../../testing/buildbot/filters/ash_unittests_mus.filter',
],
},
'mus_browser_tests': {
......@@ -1167,7 +1166,6 @@
'ash_unittests-mus': {
'args': [
'--mus',
'--test-launcher-filter-file=../../testing/buildbot/filters/ash_unittests_mus.filter',
],
'override_isolate_target': 'ash_unittests',
'test': 'ash_unittests',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment