| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "components/mus/common/util.h" | 11 #include "components/mus/common/util.h" |
| 12 #include "components/mus/public/cpp/input_event_handler.h" | 12 #include "components/mus/public/cpp/input_event_handler.h" |
| 13 #include "components/mus/public/cpp/lib/in_flight_change.h" | 13 #include "components/mus/public/cpp/lib/in_flight_change.h" |
| 14 #include "components/mus/public/cpp/lib/window_private.h" | 14 #include "components/mus/public/cpp/lib/window_private.h" |
| 15 #include "components/mus/public/cpp/window_manager_delegate.h" | 15 #include "components/mus/public/cpp/window_manager_delegate.h" |
| 16 #include "components/mus/public/cpp/window_observer.h" | 16 #include "components/mus/public/cpp/window_observer.h" |
| 17 #include "components/mus/public/cpp/window_tracker.h" | 17 #include "components/mus/public/cpp/window_tracker.h" |
| 18 #include "components/mus/public/cpp/window_tree_connection.h" | 18 #include "components/mus/public/cpp/window_tree_connection.h" |
| 19 #include "components/mus/public/cpp/window_tree_connection_observer.h" | 19 #include "components/mus/public/cpp/window_tree_connection_observer.h" |
| 20 #include "components/mus/public/cpp/window_tree_delegate.h" | 20 #include "components/mus/public/cpp/window_tree_delegate.h" |
| 21 #include "mojo/converters/geometry/geometry_type_converters.h" | 21 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 22 #include "mojo/shell/public/cpp/application_impl.h" | 22 #include "mojo/shell/public/cpp/shell.h" |
| 23 #include "mojo/shell/public/cpp/connect.h" | |
| 24 #include "mojo/shell/public/cpp/service_provider_impl.h" | |
| 25 #include "mojo/shell/public/interfaces/service_provider.mojom.h" | |
| 26 #include "ui/gfx/geometry/insets.h" | 23 #include "ui/gfx/geometry/insets.h" |
| 27 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
| 28 | 25 |
| 29 namespace mus { | 26 namespace mus { |
| 30 | 27 |
| 31 Id MakeTransportId(ConnectionSpecificId connection_id, | 28 Id MakeTransportId(ConnectionSpecificId connection_id, |
| 32 ConnectionSpecificId local_id) { | 29 ConnectionSpecificId local_id) { |
| 33 return (connection_id << 16) | local_id; | 30 return (connection_id << 16) | local_id; |
| 34 } | 31 } |
| 35 | 32 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 Window* window = AddWindowToConnection( | 73 Window* window = AddWindowToConnection( |
| 77 client, !parents.empty() ? parents.back() : NULL, windows[i]); | 74 client, !parents.empty() ? parents.back() : NULL, windows[i]); |
| 78 if (!last_window) | 75 if (!last_window) |
| 79 root = window; | 76 root = window; |
| 80 last_window = window; | 77 last_window = window; |
| 81 } | 78 } |
| 82 return root; | 79 return root; |
| 83 } | 80 } |
| 84 | 81 |
| 85 WindowTreeConnection* WindowTreeConnection::Create(WindowTreeDelegate* delegate, | 82 WindowTreeConnection* WindowTreeConnection::Create(WindowTreeDelegate* delegate, |
| 86 mojo::ApplicationImpl* app) { | 83 mojo::Shell* shell) { |
| 87 WindowTreeClientImpl* client = | 84 WindowTreeClientImpl* client = |
| 88 new WindowTreeClientImpl(delegate, nullptr, nullptr); | 85 new WindowTreeClientImpl(delegate, nullptr, nullptr); |
| 89 client->ConnectViaWindowTreeFactory(app); | 86 client->ConnectViaWindowTreeFactory(shell); |
| 90 return client; | 87 return client; |
| 91 } | 88 } |
| 92 | 89 |
| 93 WindowTreeConnection* WindowTreeConnection::Create( | 90 WindowTreeConnection* WindowTreeConnection::Create( |
| 94 WindowTreeDelegate* delegate, | 91 WindowTreeDelegate* delegate, |
| 95 mojo::InterfaceRequest<mojom::WindowTreeClient> request, | 92 mojo::InterfaceRequest<mojom::WindowTreeClient> request, |
| 96 CreateType create_type) { | 93 CreateType create_type) { |
| 97 WindowTreeClientImpl* client = | 94 WindowTreeClientImpl* client = |
| 98 new WindowTreeClientImpl(delegate, nullptr, std::move(request)); | 95 new WindowTreeClientImpl(delegate, nullptr, std::move(request)); |
| 99 if (create_type == CreateType::WAIT_FOR_EMBED) | 96 if (create_type == CreateType::WAIT_FOR_EMBED) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // exception is the window manager and embed roots, which may know about | 151 // exception is the window manager and embed roots, which may know about |
| 155 // other random windows that it doesn't own. | 152 // other random windows that it doesn't own. |
| 156 // NOTE: we manually delete as we're a friend. | 153 // NOTE: we manually delete as we're a friend. |
| 157 while (!tracker.windows().empty()) | 154 while (!tracker.windows().empty()) |
| 158 delete tracker.windows().front(); | 155 delete tracker.windows().front(); |
| 159 | 156 |
| 160 delegate_->OnConnectionLost(this); | 157 delegate_->OnConnectionLost(this); |
| 161 } | 158 } |
| 162 | 159 |
| 163 void WindowTreeClientImpl::ConnectViaWindowTreeFactory( | 160 void WindowTreeClientImpl::ConnectViaWindowTreeFactory( |
| 164 mojo::ApplicationImpl* app) { | 161 mojo::Shell* shell) { |
| 165 // Clients created with no root shouldn't delete automatically. | 162 // Clients created with no root shouldn't delete automatically. |
| 166 delete_on_no_roots_ = false; | 163 delete_on_no_roots_ = false; |
| 167 | 164 |
| 168 // The connection id doesn't really matter, we use 101 purely for debugging. | 165 // The connection id doesn't really matter, we use 101 purely for debugging. |
| 169 connection_id_ = 101; | 166 connection_id_ = 101; |
| 170 | 167 |
| 171 mojom::WindowTreeFactoryPtr factory; | 168 mojom::WindowTreeFactoryPtr factory; |
| 172 app->ConnectToService("mojo:mus", &factory); | 169 shell->ConnectToService("mojo:mus", &factory); |
| 173 factory->CreateWindowTree(GetProxy(&tree_ptr_), | 170 factory->CreateWindowTree(GetProxy(&tree_ptr_), |
| 174 binding_.CreateInterfacePtrAndBind()); | 171 binding_.CreateInterfacePtrAndBind()); |
| 175 tree_ = tree_ptr_.get(); | 172 tree_ = tree_ptr_.get(); |
| 176 } | 173 } |
| 177 | 174 |
| 178 void WindowTreeClientImpl::WaitForEmbed() { | 175 void WindowTreeClientImpl::WaitForEmbed() { |
| 179 DCHECK(roots_.empty()); | 176 DCHECK(roots_.empty()); |
| 180 // OnEmbed() is the first function called. | 177 // OnEmbed() is the first function called. |
| 181 binding_.WaitForIncomingMethodCall(); | 178 binding_.WaitForIncomingMethodCall(); |
| 182 // TODO(sky): deal with pipe being closed before we get OnEmbed(). | 179 // TODO(sky): deal with pipe being closed before we get OnEmbed(). |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 | 929 |
| 933 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( | 930 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 934 Window* window, | 931 Window* window, |
| 935 const gfx::Vector2d& offset, | 932 const gfx::Vector2d& offset, |
| 936 const gfx::Insets& hit_area) { | 933 const gfx::Insets& hit_area) { |
| 937 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 934 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 938 window->id(), offset.x(), offset.y(), mojo::Insets::From(hit_area)); | 935 window->id(), offset.x(), offset.y(), mojo::Insets::From(hit_area)); |
| 939 } | 936 } |
| 940 | 937 |
| 941 } // namespace mus | 938 } // namespace mus |
| OLD | NEW |