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

Unified Diff: ui/aura/mus/window_tree_client.cc

Issue 2839743002: Wires up WindowTreeClient::SetDisplayRoot() (Closed)
Patch Set: add .cc Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/mus/window_tree_client.cc
diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc
index 6f5956f9f4bae396b86542f3f28ea016abbcb7b1..6094207625bebc209dee695fea0f3f9f7c638120 100644
--- a/ui/aura/mus/window_tree_client.cc
+++ b/ui/aura/mus/window_tree_client.cc
@@ -66,6 +66,10 @@
namespace aura {
namespace {
+// This serves to document the places that rely on bounds changes to the
+// root window being ignored.
+constexpr bool kRootWindowBoundsChangesAreIgnored = true;
+
Id MakeTransportId(ClientSpecificId client_id, ClientSpecificId local_id) {
return (client_id << 16) | local_id;
}
@@ -577,6 +581,19 @@ void WindowTreeClient::OnEmbedImpl(
delegate_->OnEmbed(std::move(window_tree_host));
}
+void WindowTreeClient::OnSetDisplayRootDone(
+ Id window_id,
+ const base::Optional<cc::FrameSinkId>& frame_sink_id) {
+ // The only way SetDisplayRoot() should fail is if we've done something wrong.
+ CHECK(frame_sink_id);
+
+ WindowMus* window = GetWindowByServerId(window_id);
+ if (!window)
+ return; // Display was already deleted.
+
+ window->SetFrameSinkIdFromServer(*frame_sink_id);
+}
+
WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl(
const display::Display& display,
ui::mojom::WindowDataPtr root_data,
@@ -589,9 +606,9 @@ WindowTreeHostMus* WindowTreeClient::WmNewDisplayAddedImpl(
window_manager_delegate_->OnWmWillCreateDisplay(display);
- std::unique_ptr<WindowTreeHostMus> window_tree_host =
- CreateWindowTreeHost(WindowMusType::DISPLAY, *root_data, display.id(),
- frame_sink_id, local_surface_id);
+ std::unique_ptr<WindowTreeHostMus> window_tree_host = CreateWindowTreeHost(
+ WindowMusType::DISPLAY_AUTOMATICALLY_CREATED, *root_data, display.id(),
+ frame_sink_id, local_surface_id);
WindowTreeHostMus* window_tree_host_ptr = window_tree_host.get();
window_manager_delegate_->OnWmNewDisplay(std::move(window_tree_host),
@@ -693,6 +710,39 @@ void WindowTreeClient::OnWindowMusCreated(WindowMus* window) {
base::MakeUnique<CrashInFlightChange>(window, ChangeType::NEW_WINDOW));
tree_->NewWindow(change_id, window->server_id(),
std::move(transport_properties));
+ if (window->window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED) {
+ WindowTreeHostMus* window_tree_host = GetWindowTreeHostMus(window);
+ std::unique_ptr<DisplayInitParams> display_init_params =
+ window_tree_host->ReleaseDisplayInitParams();
+ DCHECK(display_init_params);
+ display::Display display;
+ if (display_init_params->display) {
+ display = *display_init_params->display;
+ } else {
+ const bool has_display =
+ display::Screen::GetScreen()->GetDisplayWithDisplayId(
+ window_tree_host->display_id(), &display);
+ DCHECK(has_display);
+ }
+ // As |window| is a root, changes to its bounds are ignored (it's assumed
+ // bounds changes are routed through OnWindowTreeHostBoundsWillChange()).
+ // But the display is created with an initial bounds, and we need to push
+ // that to the server.
+ DCHECK(kRootWindowBoundsChangesAreIgnored);
+ ScheduleInFlightBoundsChange(
+ window, gfx::Rect(),
+ gfx::Rect(
+ display_init_params->viewport_metrics.bounds_in_pixels.size()));
+
+ // Tests may not config |window_manager_internal_client_|.
+ if (window_manager_internal_client_) {
+ window_manager_internal_client_->SetDisplayRoot(
+ display, display_init_params->viewport_metrics.Clone(),
+ display_init_params->is_primary_display, window->server_id(),
+ base::Bind(&WindowTreeClient::OnSetDisplayRootDone,
+ base::Unretained(this), window->server_id()));
+ }
+ }
}
void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) {
@@ -736,8 +786,10 @@ void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window,
// Changes to bounds of root windows are routed through
// OnWindowTreeHostBoundsWillChange(). Any bounds that happen here are a side
// effect of those and can be ignored.
- if (IsRoot(window))
+ if (IsRoot(window)) {
+ DCHECK(kRootWindowBoundsChangesAreIgnored);
return;
+ }
float device_scale_factor = ScaleFactorForDisplay(window->GetWindow());
ScheduleInFlightBoundsChange(
@@ -1425,6 +1477,15 @@ bool WindowTreeClient::WaitForInitialDisplays() {
return valid_wait;
}
+WindowTreeHostMusInitParams WindowTreeClient::CreateInitParamsForNewDisplay() {
+ WindowTreeHostMusInitParams init_params;
+ init_params.window_port = base::MakeUnique<WindowPortMus>(
+ this, WindowMusType::DISPLAY_MANUALLY_CREATED);
+ roots_.insert(init_params.window_port.get());
+ init_params.window_tree_client = this;
+ return init_params;
+}
+
void WindowTreeClient::OnConnect(ClientSpecificId client_id) {
client_id_ = client_id;
if (window_manager_delegate_)

Powered by Google App Engine
This is Rietveld 408576698