Commit 8f47b453 authored by Emircan Uysaler's avatar Emircan Uysaler Committed by Commit Bot

[Fuchsia] Process ViewAttached events on Scenic Window

This CL adds a new state to ScenicWindow that checks if the view
is attached to a rendered scene graph.

Bug: 1044802
Change-Id: Ieeb98a2bbe4d214fed302d60360dd77f0b702838
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2015675
Commit-Queue: Emircan Uysaler <emircan@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741155}
parent 08896cbe
...@@ -134,9 +134,11 @@ class WindowParentingClientImpl : public aura::client::WindowParentingClient { ...@@ -134,9 +134,11 @@ class WindowParentingClientImpl : public aura::client::WindowParentingClient {
// WindowTreeHost that hosts web frames. // WindowTreeHost that hosts web frames.
class FrameWindowTreeHost : public aura::WindowTreeHostPlatform { class FrameWindowTreeHost : public aura::WindowTreeHostPlatform {
public: public:
explicit FrameWindowTreeHost(ui::PlatformWindowInitProperties properties) explicit FrameWindowTreeHost(ui::PlatformWindowInitProperties properties,
content::WebContents* web_contents)
: aura::WindowTreeHostPlatform(std::move(properties)), : aura::WindowTreeHostPlatform(std::move(properties)),
window_parenting_client_(window()) {} window_parenting_client_(window()),
web_contents_(web_contents) {}
~FrameWindowTreeHost() override = default; ~FrameWindowTreeHost() override = default;
...@@ -152,8 +154,17 @@ class FrameWindowTreeHost : public aura::WindowTreeHostPlatform { ...@@ -152,8 +154,17 @@ class FrameWindowTreeHost : public aura::WindowTreeHostPlatform {
} }
} }
void OnWindowStateChanged(ui::PlatformWindowState new_state) override {
if (new_state == ui::PlatformWindowState::kMinimized) {
web_contents_->WasOccluded();
} else {
web_contents_->WasShown();
}
}
private: private:
WindowParentingClientImpl window_parenting_client_; WindowParentingClientImpl window_parenting_client_;
content::WebContents* web_contents_;
DISALLOW_COPY_AND_ASSIGN(FrameWindowTreeHost); DISALLOW_COPY_AND_ASSIGN(FrameWindowTreeHost);
}; };
...@@ -495,8 +506,8 @@ void FrameImpl::CreateView(fuchsia::ui::views::ViewToken view_token) { ...@@ -495,8 +506,8 @@ void FrameImpl::CreateView(fuchsia::ui::views::ViewToken view_token) {
std::move(semantics_manager), std::move(accessibility_view_ref), std::move(semantics_manager), std::move(accessibility_view_ref),
web_contents_.get()); web_contents_.get());
SetWindowTreeHost( SetWindowTreeHost(std::make_unique<FrameWindowTreeHost>(std::move(properties),
std::make_unique<FrameWindowTreeHost>(std::move(properties))); web_contents_.get()));
} }
void FrameImpl::GetNavigationController( void FrameImpl::GetNavigationController(
...@@ -693,7 +704,7 @@ void FrameImpl::EnableHeadlessRendering() { ...@@ -693,7 +704,7 @@ void FrameImpl::EnableHeadlessRendering() {
} }
SetWindowTreeHost(std::make_unique<FrameWindowTreeHost>( SetWindowTreeHost(std::make_unique<FrameWindowTreeHost>(
ui::PlatformWindowInitProperties())); ui::PlatformWindowInitProperties(), web_contents_.get()));
gfx::Rect bounds(kHeadlessWindowSize); gfx::Rect bounds(kHeadlessWindowSize);
if (semantics_manager_for_test_) { if (semantics_manager_for_test_) {
......
...@@ -245,14 +245,30 @@ void ScenicWindow::OnScenicEvents( ...@@ -245,14 +245,30 @@ void ScenicWindow::OnScenicEvents(
std::vector<fuchsia::ui::scenic::Event> events) { std::vector<fuchsia::ui::scenic::Event> events) {
for (const auto& event : events) { for (const auto& event : events) {
if (event.is_gfx()) { if (event.is_gfx()) {
if (event.gfx().is_metrics()) { switch (event.gfx().Which()) {
if (event.gfx().metrics().node_id != node_.id()) case fuchsia::ui::gfx::Event::kMetrics: {
continue; if (event.gfx().metrics().node_id != node_.id())
OnViewMetrics(event.gfx().metrics().metrics); continue;
} else if (event.gfx().is_view_properties_changed()) { OnViewMetrics(event.gfx().metrics().metrics);
if (event.gfx().view_properties_changed().view_id != view_.id()) break;
continue; }
OnViewProperties(event.gfx().view_properties_changed().properties); case fuchsia::ui::gfx::Event::kViewPropertiesChanged: {
DCHECK(event.gfx().view_properties_changed().view_id == view_.id());
OnViewProperties(event.gfx().view_properties_changed().properties);
break;
}
case fuchsia::ui::gfx::Event::kViewAttachedToScene: {
DCHECK(event.gfx().view_attached_to_scene().view_id == view_.id());
OnViewAttachedChanged(true);
break;
}
case fuchsia::ui::gfx::Event::kViewDetachedFromScene: {
DCHECK(event.gfx().view_detached_from_scene().view_id == view_.id());
OnViewAttachedChanged(false);
break;
}
default:
break;
} }
} else if (event.is_input()) { } else if (event.is_input()) {
OnInputEvent(event.input()); OnInputEvent(event.input());
...@@ -283,6 +299,12 @@ void ScenicWindow::OnViewProperties( ...@@ -283,6 +299,12 @@ void ScenicWindow::OnViewProperties(
UpdateSize(); UpdateSize();
} }
void ScenicWindow::OnViewAttachedChanged(bool is_view_attached) {
delegate_->OnWindowStateChanged(is_view_attached
? PlatformWindowState::kNormal
: PlatformWindowState::kMinimized);
}
void ScenicWindow::OnInputEvent(const fuchsia::ui::input::InputEvent& event) { void ScenicWindow::OnInputEvent(const fuchsia::ui::input::InputEvent& event) {
if (event.is_focus()) { if (event.is_focus()) {
delegate_->OnActivationChanged(event.focus().focused); delegate_->OnActivationChanged(event.focus().focused);
......
...@@ -86,6 +86,7 @@ class COMPONENT_EXPORT(OZONE) ScenicWindow ...@@ -86,6 +86,7 @@ class COMPONENT_EXPORT(OZONE) ScenicWindow
// Called from OnScenicEvents() to handle view properties and metrics changes. // Called from OnScenicEvents() to handle view properties and metrics changes.
void OnViewProperties(const fuchsia::ui::gfx::ViewProperties& properties); void OnViewProperties(const fuchsia::ui::gfx::ViewProperties& properties);
void OnViewMetrics(const fuchsia::ui::gfx::Metrics& metrics); void OnViewMetrics(const fuchsia::ui::gfx::Metrics& metrics);
void OnViewAttachedChanged(bool is_view_attached);
// Called from OnScenicEvents() to handle input events. // Called from OnScenicEvents() to handle input events.
void OnInputEvent(const fuchsia::ui::input::InputEvent& event); void OnInputEvent(const fuchsia::ui::input::InputEvent& event);
......
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