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

Unified Diff: components/mus/public/cpp/lib/window_tree_client_impl.cc

Issue 1568263003: Changes top level window creation to include window state in callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix gn Created 4 years, 11 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
« no previous file with comments | « components/mus/public/cpp/lib/window_tree_client_impl.h ('k') | components/mus/public/cpp/tests/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/public/cpp/lib/window_tree_client_impl.cc
diff --git a/components/mus/public/cpp/lib/window_tree_client_impl.cc b/components/mus/public/cpp/lib/window_tree_client_impl.cc
index 7d2a79537bf8fbdf4ff1069c135b2c5f5a5c4577..0e46a96ac5a30125230f3990241749ddc490db43 100644
--- a/components/mus/public/cpp/lib/window_tree_client_impl.cc
+++ b/components/mus/public/cpp/lib/window_tree_client_impl.cc
@@ -36,8 +36,8 @@ Id MakeTransportId(ConnectionSpecificId connection_id,
Window* AddWindowToConnection(WindowTreeClientImpl* client,
Window* parent,
const mojom::WindowDataPtr& window_data) {
- // We don't use the cto that takes a WindowTreeConnection here, since it will
- // call back to the service and attempt to create a new window.
+ // We don't use the ctor that takes a WindowTreeConnection here, since it
+ // will call back to the service and attempt to create a new window.
Window* window = WindowPrivate::LocalCreate();
WindowPrivate private_window(window);
private_window.set_connection(client);
@@ -523,6 +523,68 @@ void WindowTreeClientImpl::OnUnembed(Id window_id) {
WindowPrivate(window).LocalDestroy();
}
+void WindowTreeClientImpl::OnTopLevelCreated(uint32_t change_id,
+ mojom::WindowDataPtr data) {
+ // The server ack'd the top level window we created and supplied the state
+ // of the window at the time the server created it. For properties we do not
+ // have changes in flight for we can update them immediately. For properties
+ // with changes in flight we set the revert value from the server.
+
+ scoped_ptr<InFlightChange> change(std::move(in_flight_map_[change_id]));
+ in_flight_map_.erase(change_id);
+ DCHECK(change);
+
+ Window* window = change->window();
+ WindowPrivate window_private(window);
+
+ // Drawn state and ViewportMetrics always come from the server (they can't
+ // be modified locally).
+ window_private.set_drawn(data->drawn);
+ window_private.LocalSetViewportMetrics(mojom::ViewportMetrics(),
+ *data->viewport_metrics);
+
+ // The default visibilty is false, we only need update visibility if it
+ // differs from that.
+ if (data->visible) {
+ InFlightVisibleChange visible_change(window, data->visible);
+ InFlightChange* current_change =
+ GetOldestInFlightChangeMatching(visible_change);
+ if (current_change)
+ current_change->SetRevertValueFrom(visible_change);
+ else
+ window_private.LocalSetVisible(true);
+ }
+
+ const gfx::Rect bounds(data->bounds.To<gfx::Rect>());
+ {
+ InFlightBoundsChange bounds_change(window, bounds);
+ InFlightChange* current_change =
+ GetOldestInFlightChangeMatching(bounds_change);
+ if (current_change)
+ current_change->SetRevertValueFrom(bounds_change);
+ else if (window->bounds() != bounds)
+ window_private.LocalSetBounds(window->bounds(), bounds);
+ }
+
+ // There is currently no API to bulk set properties, so we iterate over each
+ // property individually.
+ Window::SharedProperties properties =
+ data->properties.To<std::map<std::string, std::vector<uint8_t>>>();
+ for (const auto& pair : properties) {
+ InFlightPropertyChange property_change(
+ window, pair.first, mojo::Array<uint8_t>::From(pair.second));
+ InFlightChange* current_change =
+ GetOldestInFlightChangeMatching(property_change);
+ if (current_change)
+ current_change->SetRevertValueFrom(property_change);
+ else
+ window_private.LocalSetSharedProperty(pair.first, &(pair.second));
+ }
+
+ // Top level windows should not have a parent.
+ DCHECK_EQ(0u, data->parent_id);
+}
+
void WindowTreeClientImpl::OnWindowBoundsChanged(Id window_id,
mojo::RectPtr old_bounds,
mojo::RectPtr new_bounds) {
« no previous file with comments | « components/mus/public/cpp/lib/window_tree_client_impl.h ('k') | components/mus/public/cpp/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698