| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/mus/mus_client.h" | 5 #include "ui/views/mus/mus_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "services/service_manager/public/cpp/connection.h" | 9 #include "services/service_manager/public/cpp/connection.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" | 10 #include "services/service_manager/public/cpp/connector.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "ui/views/mus/desktop_window_tree_host_mus.h" | 23 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
| 24 #include "ui/views/mus/screen_mus.h" | 24 #include "ui/views/mus/screen_mus.h" |
| 25 #include "ui/views/views_delegate.h" | 25 #include "ui/views/views_delegate.h" |
| 26 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 26 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 27 #include "ui/wm/core/capture_controller.h" | 27 #include "ui/wm/core/capture_controller.h" |
| 28 #include "ui/wm/core/wm_state.h" | 28 #include "ui/wm/core/wm_state.h" |
| 29 | 29 |
| 30 namespace views { | 30 namespace views { |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 // TODO: property converter should likely live in aura as it needs to be used |
| 34 // by both ash and views. http://crbug.com/663522. |
| 33 class PropertyConverterImpl : public aura::PropertyConverter { | 35 class PropertyConverterImpl : public aura::PropertyConverter { |
| 34 public: | 36 public: |
| 35 PropertyConverterImpl() {} | 37 PropertyConverterImpl() {} |
| 36 ~PropertyConverterImpl() override {} | 38 ~PropertyConverterImpl() override {} |
| 37 | 39 |
| 38 // aura::PropertyConverter: | 40 // aura::PropertyConverter: |
| 39 bool ConvertPropertyForTransport( | 41 bool ConvertPropertyForTransport( |
| 40 aura::Window* window, | 42 aura::Window* window, |
| 41 const void* key, | 43 const void* key, |
| 42 std::string* transport_name, | 44 std::string* transport_name, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 112 |
| 111 gpu_service_ = aura::GpuService::Create(connector, std::move(io_task_runner)); | 113 gpu_service_ = aura::GpuService::Create(connector, std::move(io_task_runner)); |
| 112 compositor_context_factory_ = | 114 compositor_context_factory_ = |
| 113 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get()); | 115 base::MakeUnique<aura::MusContextFactory>(gpu_service_.get()); |
| 114 aura::Env::GetInstance()->set_context_factory( | 116 aura::Env::GetInstance()->set_context_factory( |
| 115 compositor_context_factory_.get()); | 117 compositor_context_factory_.get()); |
| 116 window_tree_client_ = | 118 window_tree_client_ = |
| 117 base::MakeUnique<aura::WindowTreeClient>(this, nullptr, nullptr); | 119 base::MakeUnique<aura::WindowTreeClient>(this, nullptr, nullptr); |
| 118 window_tree_client_->ConnectViaWindowTreeFactory(connector_); | 120 window_tree_client_->ConnectViaWindowTreeFactory(connector_); |
| 119 | 121 |
| 120 // TODO(sky): wire up PointerWatcherEventRouter. | 122 // TODO: wire up PointerWatcherEventRouter. http://crbug.com/663526. |
| 121 | 123 |
| 122 screen_ = base::MakeUnique<ScreenMus>(this); | 124 screen_ = base::MakeUnique<ScreenMus>(this); |
| 123 screen_->Init(connector); | 125 screen_->Init(connector); |
| 124 | 126 |
| 125 std::unique_ptr<ClipboardMus> clipboard = base::MakeUnique<ClipboardMus>(); | 127 std::unique_ptr<ClipboardMus> clipboard = base::MakeUnique<ClipboardMus>(); |
| 126 clipboard->Init(connector); | 128 clipboard->Init(connector); |
| 127 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); | 129 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); |
| 128 | 130 |
| 129 ui::OSExchangeDataProviderFactory::SetFactory(this); | 131 ui::OSExchangeDataProviderFactory::SetFactory(this); |
| 130 | 132 |
| 131 ViewsDelegate::GetInstance()->set_native_widget_factory( | 133 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 132 base::Bind(&MusClient::CreateNativeWidget, base::Unretained(this))); | 134 base::Bind(&MusClient::CreateNativeWidget, base::Unretained(this))); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void MusClient::OnEmbed( | 137 void MusClient::OnEmbed( |
| 136 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { | 138 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
| 137 NOTREACHED(); | 139 NOTREACHED(); |
| 138 } | 140 } |
| 139 | 141 |
| 140 void MusClient::OnLostConnection(aura::WindowTreeClient* client) {} | 142 void MusClient::OnLostConnection(aura::WindowTreeClient* client) {} |
| 141 | 143 |
| 142 void MusClient::OnEmbedRootDestroyed(aura::Window* root) { | 144 void MusClient::OnEmbedRootDestroyed(aura::Window* root) { |
| 143 // Not called for MusClient as WindowTreeClient isn't created by | 145 // Not called for MusClient as WindowTreeClient isn't created by |
| 144 // way of an Embed(). | 146 // way of an Embed(). |
| 145 NOTREACHED(); | 147 NOTREACHED(); |
| 146 } | 148 } |
| 147 | 149 |
| 148 void MusClient::OnPointerEventObserved(const ui::PointerEvent& event, | 150 void MusClient::OnPointerEventObserved(const ui::PointerEvent& event, |
| 149 aura::Window* target) { | 151 aura::Window* target) { |
| 150 // TODO(sky): wire up pointer events. | 152 // TODO: wire up PointerWatcherEventRouter. http://crbug.com/663526. |
| 151 NOTIMPLEMENTED(); | 153 NOTIMPLEMENTED(); |
| 152 } | 154 } |
| 153 | 155 |
| 154 void MusClient::OnWindowManagerFrameValuesChanged() { | 156 void MusClient::OnWindowManagerFrameValuesChanged() { |
| 155 // TODO(sky): wire up to DesktopNativeWidgetAura. | 157 // TODO: wire up client area. http://crbug.com/663525. |
| 156 NOTIMPLEMENTED(); | 158 NOTIMPLEMENTED(); |
| 157 } | 159 } |
| 158 | 160 |
| 159 aura::client::CaptureClient* MusClient::GetCaptureClient() { | 161 aura::client::CaptureClient* MusClient::GetCaptureClient() { |
| 160 return wm::CaptureController::Get(); | 162 return wm::CaptureController::Get(); |
| 161 } | 163 } |
| 162 | 164 |
| 163 aura::PropertyConverter* MusClient::GetPropertyConverter() { | 165 aura::PropertyConverter* MusClient::GetPropertyConverter() { |
| 164 return property_converter_.get(); | 166 return property_converter_.get(); |
| 165 } | 167 } |
| 166 | 168 |
| 167 gfx::Point MusClient::GetCursorScreenPoint() { | 169 gfx::Point MusClient::GetCursorScreenPoint() { |
| 168 return window_tree_client_->GetCursorScreenPoint(); | 170 return window_tree_client_->GetCursorScreenPoint(); |
| 169 } | 171 } |
| 170 | 172 |
| 171 aura::Window* MusClient::GetWindowAtScreenPoint(const gfx::Point& point) { | 173 aura::Window* MusClient::GetWindowAtScreenPoint(const gfx::Point& point) { |
| 172 for (aura::Window* root : window_tree_client_->GetRoots()) { | 174 for (aura::Window* root : window_tree_client_->GetRoots()) { |
| 173 aura::WindowTreeHost* window_tree_host = root->GetHost(); | 175 aura::WindowTreeHost* window_tree_host = root->GetHost(); |
| 174 if (!window_tree_host) | 176 if (!window_tree_host) |
| 175 continue; | 177 continue; |
| 176 // TODO: this likely gets z-order wrong. | 178 // TODO: this likely gets z-order wrong. http://crbug.com/663606. |
| 177 gfx::Point relative_point(point); | 179 gfx::Point relative_point(point); |
| 178 window_tree_host->ConvertPointFromNativeScreen(&relative_point); | 180 window_tree_host->ConvertPointFromNativeScreen(&relative_point); |
| 179 if (gfx::Rect(root->bounds().size()).Contains(relative_point)) | 181 if (gfx::Rect(root->bounds().size()).Contains(relative_point)) |
| 180 return root->GetTopWindowContainingPoint(relative_point); | 182 return root->GetTopWindowContainingPoint(relative_point); |
| 181 } | 183 } |
| 182 return nullptr; | 184 return nullptr; |
| 183 } | 185 } |
| 184 | 186 |
| 185 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { | 187 std::unique_ptr<OSExchangeData::Provider> MusClient::BuildProvider() { |
| 186 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); | 188 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
| 187 } | 189 } |
| 188 | 190 |
| 189 } // namespace views | 191 } // namespace views |
| OLD | NEW |