| 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/ws/window_tree_impl.h" | 5 #include "components/mus/ws/window_tree_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "components/mus/ws/connection_manager.h" | 9 #include "components/mus/ws/connection_manager.h" |
| 10 #include "components/mus/ws/default_access_policy.h" | 10 #include "components/mus/ws/default_access_policy.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 const gfx::Rect& old_bounds, | 180 const gfx::Rect& old_bounds, |
| 181 const gfx::Rect& new_bounds, | 181 const gfx::Rect& new_bounds, |
| 182 bool originated_change) { | 182 bool originated_change) { |
| 183 if (originated_change || !IsWindowKnown(window)) | 183 if (originated_change || !IsWindowKnown(window)) |
| 184 return; | 184 return; |
| 185 client()->OnWindowBoundsChanged(WindowIdToTransportId(window->id()), | 185 client()->OnWindowBoundsChanged(WindowIdToTransportId(window->id()), |
| 186 Rect::From(old_bounds), | 186 Rect::From(old_bounds), |
| 187 Rect::From(new_bounds)); | 187 Rect::From(new_bounds)); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void WindowTreeImpl::ProcessClientAreaChanged(const ServerWindow* window, | 190 void WindowTreeImpl::ProcessClientAreaChanged( |
| 191 const gfx::Rect& old_client_area, | 191 const ServerWindow* window, |
| 192 const gfx::Rect& new_client_area, | 192 const gfx::Insets& old_client_area, |
| 193 bool originated_change) { | 193 const gfx::Insets& new_client_area, |
| 194 bool originated_change) { |
| 194 if (originated_change || !IsWindowKnown(window)) | 195 if (originated_change || !IsWindowKnown(window)) |
| 195 return; | 196 return; |
| 196 client()->OnClientAreaChanged(WindowIdToTransportId(window->id()), | 197 client()->OnClientAreaChanged(WindowIdToTransportId(window->id()), |
| 197 Rect::From(old_client_area), | 198 mojo::Insets::From(old_client_area), |
| 198 Rect::From(new_client_area)); | 199 mojo::Insets::From(new_client_area)); |
| 199 } | 200 } |
| 200 | 201 |
| 201 void WindowTreeImpl::ProcessViewportMetricsChanged( | 202 void WindowTreeImpl::ProcessViewportMetricsChanged( |
| 202 const mojom::ViewportMetrics& old_metrics, | 203 const mojom::ViewportMetrics& old_metrics, |
| 203 const mojom::ViewportMetrics& new_metrics, | 204 const mojom::ViewportMetrics& new_metrics, |
| 204 bool originated_change) { | 205 bool originated_change) { |
| 205 client()->OnWindowViewportMetricsChanged(old_metrics.Clone(), | 206 client()->OnWindowViewportMetricsChanged(old_metrics.Clone(), |
| 206 new_metrics.Clone()); | 207 new_metrics.Clone()); |
| 207 } | 208 } |
| 208 | 209 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 if (success) { | 696 if (success) { |
| 696 if (!state.is_null()) | 697 if (!state.is_null()) |
| 697 window->SetTextInputState(state.To<ui::TextInputState>()); | 698 window->SetTextInputState(state.To<ui::TextInputState>()); |
| 698 | 699 |
| 699 WindowTreeHostImpl* host = GetHost(); | 700 WindowTreeHostImpl* host = GetHost(); |
| 700 if (host) | 701 if (host) |
| 701 host->SetImeVisibility(window, visible); | 702 host->SetImeVisibility(window, visible); |
| 702 } | 703 } |
| 703 } | 704 } |
| 704 | 705 |
| 705 void WindowTreeImpl::SetClientArea(Id transport_window_id, mojo::RectPtr rect) { | 706 void WindowTreeImpl::SetClientArea(Id transport_window_id, |
| 707 mojo::InsetsPtr insets) { |
| 706 ServerWindow* window = | 708 ServerWindow* window = |
| 707 GetWindow(WindowIdFromTransportId(transport_window_id)); | 709 GetWindow(WindowIdFromTransportId(transport_window_id)); |
| 708 if (!window || !access_policy_->CanSetClientArea(window)) | 710 if (!window || !access_policy_->CanSetClientArea(window)) |
| 709 return; | 711 return; |
| 710 | 712 |
| 711 if (rect.is_null()) | 713 window->SetClientArea(insets.To<gfx::Insets>()); |
| 712 window->SetClientArea(gfx::Rect(window->bounds().size())); | |
| 713 else | |
| 714 window->SetClientArea(rect.To<gfx::Rect>()); | |
| 715 } | 714 } |
| 716 | 715 |
| 717 void WindowTreeImpl::Embed(Id transport_window_id, | 716 void WindowTreeImpl::Embed(Id transport_window_id, |
| 718 mojom::WindowTreeClientPtr client, | 717 mojom::WindowTreeClientPtr client, |
| 719 uint32_t policy_bitmask, | 718 uint32_t policy_bitmask, |
| 720 const EmbedCallback& callback) { | 719 const EmbedCallback& callback) { |
| 721 ConnectionSpecificId connection_id = kInvalidConnectionId; | 720 ConnectionSpecificId connection_id = kInvalidConnectionId; |
| 722 const bool result = Embed(WindowIdFromTransportId(transport_window_id), | 721 const bool result = Embed(WindowIdFromTransportId(transport_window_id), |
| 723 client.Pass(), policy_bitmask, &connection_id); | 722 client.Pass(), policy_bitmask, &connection_id); |
| 724 callback.Run(result, connection_id); | 723 callback.Run(result, connection_id); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 751 void WindowTreeImpl::SetShowState(uint32_t window_id, | 750 void WindowTreeImpl::SetShowState(uint32_t window_id, |
| 752 mojom::ShowState show_state, | 751 mojom::ShowState show_state, |
| 753 const SetShowStateCallback& callback) { | 752 const SetShowStateCallback& callback) { |
| 754 if (!GetHost() || !GetHost()->window_manager()) | 753 if (!GetHost() || !GetHost()->window_manager()) |
| 755 return; | 754 return; |
| 756 | 755 |
| 757 // TODO(sky): verify window_id is valid for the client. | 756 // TODO(sky): verify window_id is valid for the client. |
| 758 GetHost()->window_manager()->SetShowState(window_id, show_state, callback); | 757 GetHost()->window_manager()->SetShowState(window_id, show_state, callback); |
| 759 } | 758 } |
| 760 | 759 |
| 761 void WindowTreeImpl::GetDisplays(const GetDisplaysCallback& callback) { | |
| 762 if (!GetHost() || !GetHost()->window_manager()) | |
| 763 return; | |
| 764 | |
| 765 GetHost()->window_manager()->GetDisplays(callback); | |
| 766 } | |
| 767 | |
| 768 bool WindowTreeImpl::IsRootForAccessPolicy(const WindowId& id) const { | 760 bool WindowTreeImpl::IsRootForAccessPolicy(const WindowId& id) const { |
| 769 return IsRoot(id); | 761 return IsRoot(id); |
| 770 } | 762 } |
| 771 | 763 |
| 772 bool WindowTreeImpl::IsWindowKnownForAccessPolicy( | 764 bool WindowTreeImpl::IsWindowKnownForAccessPolicy( |
| 773 const ServerWindow* window) const { | 765 const ServerWindow* window) const { |
| 774 return IsWindowKnown(window); | 766 return IsWindowKnown(window); |
| 775 } | 767 } |
| 776 | 768 |
| 777 bool WindowTreeImpl::IsWindowRootOfAnotherConnectionForAccessPolicy( | 769 bool WindowTreeImpl::IsWindowRootOfAnotherConnectionForAccessPolicy( |
| 778 const ServerWindow* window) const { | 770 const ServerWindow* window) const { |
| 779 WindowTreeImpl* connection = | 771 WindowTreeImpl* connection = |
| 780 connection_manager_->GetConnectionWithRoot(window->id()); | 772 connection_manager_->GetConnectionWithRoot(window->id()); |
| 781 return connection && connection != this; | 773 return connection && connection != this; |
| 782 } | 774 } |
| 783 | 775 |
| 784 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { | 776 bool WindowTreeImpl::IsDescendantOfEmbedRoot(const ServerWindow* window) { |
| 785 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); | 777 return is_embed_root_ && root_ && GetWindow(*root_)->Contains(window); |
| 786 } | 778 } |
| 787 | 779 |
| 788 } // namespace ws | 780 } // namespace ws |
| 789 | 781 |
| 790 } // namespace mus | 782 } // namespace mus |
| OLD | NEW |