OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h" | 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "components/mus/public/cpp/lib/window_private.h" | 8 #include "components/mus/public/cpp/lib/window_private.h" |
9 #include "components/mus/public/cpp/util.h" | 9 #include "components/mus/public/cpp/util.h" |
10 #include "components/mus/public/cpp/window_observer.h" | 10 #include "components/mus/public/cpp/window_observer.h" |
11 #include "components/mus/public/cpp/window_tree_connection.h" | 11 #include "components/mus/public/cpp/window_tree_connection.h" |
12 #include "components/mus/public/cpp/window_tree_delegate.h" | 12 #include "components/mus/public/cpp/window_tree_delegate.h" |
13 #include "mojo/application/public/cpp/application_impl.h" | 13 #include "mojo/application/public/cpp/application_impl.h" |
14 #include "mojo/application/public/cpp/connect.h" | 14 #include "mojo/application/public/cpp/connect.h" |
15 #include "mojo/application/public/cpp/service_provider_impl.h" | 15 #include "mojo/application/public/cpp/service_provider_impl.h" |
16 #include "mojo/application/public/interfaces/service_provider.mojom.h" | 16 #include "mojo/application/public/interfaces/service_provider.mojom.h" |
17 #include "mojo/converters/geometry/geometry_type_converters.h" | 17 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 18 #include "ui/gfx/geometry/insets.h" |
18 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
19 | 20 |
20 namespace mus { | 21 namespace mus { |
21 namespace { | 22 namespace { |
22 | 23 |
23 void WindowManagerCallback(mus::mojom::WindowManagerErrorCode error_code) {} | 24 void WindowManagerCallback(mus::mojom::WindowManagerErrorCode error_code) {} |
24 | 25 |
25 } // namespace | 26 } // namespace |
26 | 27 |
27 Id MakeTransportId(ConnectionSpecificId connection_id, | 28 Id MakeTransportId(ConnectionSpecificId connection_id, |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 const gfx::Rect& requested_bounds, | 176 const gfx::Rect& requested_bounds, |
176 const gfx::Rect& real_bounds, | 177 const gfx::Rect& real_bounds, |
177 bool success) { | 178 bool success) { |
178 if (success) | 179 if (success) |
179 return; | 180 return; |
180 Window* window = GetWindowById(window_id); | 181 Window* window = GetWindowById(window_id); |
181 WindowPrivate(window).LocalSetBounds(requested_bounds, real_bounds); | 182 WindowPrivate(window).LocalSetBounds(requested_bounds, real_bounds); |
182 } | 183 } |
183 | 184 |
184 void WindowTreeClientImpl::SetClientArea(Id window_id, | 185 void WindowTreeClientImpl::SetClientArea(Id window_id, |
185 const gfx::Rect& client_area) { | 186 const gfx::Insets& client_area) { |
186 DCHECK(tree_); | 187 DCHECK(tree_); |
187 tree_->SetClientArea(window_id, mojo::Rect::From(client_area)); | 188 tree_->SetClientArea(window_id, mojo::Insets::From(client_area)); |
188 } | 189 } |
189 | 190 |
190 void WindowTreeClientImpl::SetFocus(Id window_id) { | 191 void WindowTreeClientImpl::SetFocus(Id window_id) { |
191 // In order for us to get here we had to have exposed a window, which implies | 192 // In order for us to get here we had to have exposed a window, which implies |
192 // we got a connection. | 193 // we got a connection. |
193 DCHECK(tree_); | 194 DCHECK(tree_); |
194 tree_->SetFocus(window_id); | 195 tree_->SetFocus(window_id); |
195 } | 196 } |
196 | 197 |
197 void WindowTreeClientImpl::SetVisible(Id window_id, bool visible) { | 198 void WindowTreeClientImpl::SetVisible(Id window_id, bool visible) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 355 } |
355 | 356 |
356 void WindowTreeClientImpl::OnWindowBoundsChanged(Id window_id, | 357 void WindowTreeClientImpl::OnWindowBoundsChanged(Id window_id, |
357 mojo::RectPtr old_bounds, | 358 mojo::RectPtr old_bounds, |
358 mojo::RectPtr new_bounds) { | 359 mojo::RectPtr new_bounds) { |
359 Window* window = GetWindowById(window_id); | 360 Window* window = GetWindowById(window_id); |
360 WindowPrivate(window) | 361 WindowPrivate(window) |
361 .LocalSetBounds(old_bounds.To<gfx::Rect>(), new_bounds.To<gfx::Rect>()); | 362 .LocalSetBounds(old_bounds.To<gfx::Rect>(), new_bounds.To<gfx::Rect>()); |
362 } | 363 } |
363 | 364 |
364 void WindowTreeClientImpl::OnClientAreaChanged(uint32_t window_id, | 365 void WindowTreeClientImpl::OnClientAreaChanged( |
365 mojo::RectPtr old_client_area, | 366 uint32_t window_id, |
366 mojo::RectPtr new_client_area) { | 367 mojo::InsetsPtr old_client_area, |
| 368 mojo::InsetsPtr new_client_area) { |
367 Window* window = GetWindowById(window_id); | 369 Window* window = GetWindowById(window_id); |
368 if (window) | 370 if (window) |
369 WindowPrivate(window).LocalSetClientArea(new_client_area.To<gfx::Rect>()); | 371 WindowPrivate(window).LocalSetClientArea(new_client_area.To<gfx::Insets>()); |
370 } | 372 } |
371 | 373 |
372 namespace { | 374 namespace { |
373 | 375 |
374 void SetViewportMetricsOnDecendants(Window* root, | 376 void SetViewportMetricsOnDecendants(Window* root, |
375 const mojom::ViewportMetrics& old_metrics, | 377 const mojom::ViewportMetrics& old_metrics, |
376 const mojom::ViewportMetrics& new_metrics) { | 378 const mojom::ViewportMetrics& new_metrics) { |
377 WindowPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics); | 379 WindowPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics); |
378 const Window::Children& children = root->children(); | 380 const Window::Children& children = root->children(); |
379 for (size_t i = 0; i < children.size(); ++i) | 381 for (size_t i = 0; i < children.size(); ++i) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 void WindowTreeClientImpl::OnActionCompleted(bool success) { | 499 void WindowTreeClientImpl::OnActionCompleted(bool success) { |
498 if (!change_acked_callback_.is_null()) | 500 if (!change_acked_callback_.is_null()) |
499 change_acked_callback_.Run(); | 501 change_acked_callback_.Run(); |
500 } | 502 } |
501 | 503 |
502 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { | 504 mojo::Callback<void(bool)> WindowTreeClientImpl::ActionCompletedCallback() { |
503 return [this](bool success) { OnActionCompleted(success); }; | 505 return [this](bool success) { OnActionCompleted(success); }; |
504 } | 506 } |
505 | 507 |
506 } // namespace mus | 508 } // namespace mus |
OLD | NEW |