| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/window_manager_connection.h" | 5 #include "ui/views/mus/window_manager_connection.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "base/threading/thread_local.h" | 11 #include "base/threading/thread_local.h" |
| 11 #include "services/shell/public/cpp/connection.h" | 12 #include "services/shell/public/cpp/connection.h" |
| 12 #include "services/shell/public/cpp/connector.h" | 13 #include "services/shell/public/cpp/connector.h" |
| 13 #include "services/ui/common/gpu_service.h" | 14 #include "services/ui/common/gpu_service.h" |
| 14 #include "services/ui/public/cpp/property_type_converters.h" | 15 #include "services/ui/public/cpp/property_type_converters.h" |
| 15 #include "services/ui/public/cpp/window.h" | 16 #include "services/ui/public/cpp/window.h" |
| 16 #include "services/ui/public/cpp/window_property.h" | 17 #include "services/ui/public/cpp/window_property.h" |
| 17 #include "services/ui/public/cpp/window_tree_client.h" | 18 #include "services/ui/public/cpp/window_tree_client.h" |
| 18 #include "services/ui/public/interfaces/event_matcher.mojom.h" | 19 #include "services/ui/public/interfaces/event_matcher.mojom.h" |
| 19 #include "services/ui/public/interfaces/window_tree.mojom.h" | 20 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 20 #include "ui/views/mus/clipboard_mus.h" | 21 #include "ui/views/mus/clipboard_mus.h" |
| 21 #include "ui/views/mus/native_widget_mus.h" | 22 #include "ui/views/mus/native_widget_mus.h" |
| 23 #include "ui/views/mus/os_exchange_data_provider_mus.h" |
| 22 #include "ui/views/mus/screen_mus.h" | 24 #include "ui/views/mus/screen_mus.h" |
| 23 #include "ui/views/pointer_watcher.h" | 25 #include "ui/views/pointer_watcher.h" |
| 24 #include "ui/views/touch_event_watcher.h" | 26 #include "ui/views/touch_event_watcher.h" |
| 25 #include "ui/views/views_delegate.h" | 27 #include "ui/views/views_delegate.h" |
| 26 | 28 |
| 27 namespace views { | 29 namespace views { |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 using WindowManagerConnectionPtr = | 32 using WindowManagerConnectionPtr = |
| 31 base::ThreadLocalPointer<views::WindowManagerConnection>; | 33 base::ThreadLocalPointer<views::WindowManagerConnection>; |
| 32 | 34 |
| 33 // Env is thread local so that aura may be used on multiple threads. | 35 // Env is thread local so that aura may be used on multiple threads. |
| 34 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = | 36 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = |
| 35 LAZY_INSTANCE_INITIALIZER; | 37 LAZY_INSTANCE_INITIALIZER; |
| 36 | 38 |
| 37 } // namespace | 39 } // namespace |
| 38 | 40 |
| 39 WindowManagerConnection::~WindowManagerConnection() { | 41 WindowManagerConnection::~WindowManagerConnection() { |
| 40 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while | 42 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while |
| 41 // we are still valid. | 43 // we are still valid. |
| 42 client_.reset(); | 44 client_.reset(); |
| 45 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); |
| 43 ui::Clipboard::DestroyClipboardForCurrentThread(); | 46 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 44 gpu_service_.reset(); | 47 gpu_service_.reset(); |
| 45 lazy_tls_ptr.Pointer()->Set(nullptr); | 48 lazy_tls_ptr.Pointer()->Set(nullptr); |
| 46 | 49 |
| 47 if (ViewsDelegate::GetInstance()) { | 50 if (ViewsDelegate::GetInstance()) { |
| 48 ViewsDelegate::GetInstance()->set_native_widget_factory( | 51 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 49 ViewsDelegate::NativeWidgetFactory()); | 52 ViewsDelegate::NativeWidgetFactory()); |
| 50 } | 53 } |
| 51 } | 54 } |
| 52 | 55 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 client_.reset(new ui::WindowTreeClient(this, nullptr, nullptr)); | 157 client_.reset(new ui::WindowTreeClient(this, nullptr, nullptr)); |
| 155 client_->ConnectViaWindowTreeFactory(connector_); | 158 client_->ConnectViaWindowTreeFactory(connector_); |
| 156 | 159 |
| 157 screen_.reset(new ScreenMus(this)); | 160 screen_.reset(new ScreenMus(this)); |
| 158 screen_->Init(connector); | 161 screen_->Init(connector); |
| 159 | 162 |
| 160 std::unique_ptr<ClipboardMus> clipboard(new ClipboardMus); | 163 std::unique_ptr<ClipboardMus> clipboard(new ClipboardMus); |
| 161 clipboard->Init(connector); | 164 clipboard->Init(connector); |
| 162 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); | 165 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); |
| 163 | 166 |
| 167 ui::OSExchangeDataProviderFactory::SetFactory(this); |
| 168 |
| 164 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( | 169 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( |
| 165 &WindowManagerConnection::CreateNativeWidgetMus, | 170 &WindowManagerConnection::CreateNativeWidgetMus, |
| 166 base::Unretained(this), | 171 base::Unretained(this), |
| 167 std::map<std::string, std::vector<uint8_t>>())); | 172 std::map<std::string, std::vector<uint8_t>>())); |
| 168 } | 173 } |
| 169 | 174 |
| 170 bool WindowManagerConnection::HasPointerWatcher() { | 175 bool WindowManagerConnection::HasPointerWatcher() { |
| 171 // Check to see if we really have any observers left. This doesn't use | 176 // Check to see if we really have any observers left. This doesn't use |
| 172 // base::ObserverList<>::might_have_observers() because that returns true | 177 // base::ObserverList<>::might_have_observers() because that returns true |
| 173 // during iteration over the list even when the last observer is removed. | 178 // during iteration over the list even when the last observer is removed. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 234 |
| 230 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 235 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 231 if (client_) | 236 if (client_) |
| 232 NativeWidgetMus::NotifyFrameChanged(client_.get()); | 237 NativeWidgetMus::NotifyFrameChanged(client_.get()); |
| 233 } | 238 } |
| 234 | 239 |
| 235 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { | 240 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { |
| 236 return client_->GetCursorScreenPoint(); | 241 return client_->GetCursorScreenPoint(); |
| 237 } | 242 } |
| 238 | 243 |
| 244 std::unique_ptr<OSExchangeData::Provider> |
| 245 WindowManagerConnection::BuildProvider() { |
| 246 return base::MakeUnique<OSExchangeDataProviderMus>(); |
| 247 } |
| 248 |
| 239 } // namespace views | 249 } // namespace views |
| OLD | NEW |