| 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/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| 11 #include "components/mus/public/cpp/property_type_converters.h" | 11 #include "components/mus/public/cpp/property_type_converters.h" |
| 12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
| 13 #include "components/mus/public/cpp/window_property.h" | 13 #include "components/mus/public/cpp/window_property.h" |
| 14 #include "components/mus/public/cpp/window_tree_client.h" | 14 #include "components/mus/public/cpp/window_tree_client.h" |
| 15 #include "components/mus/public/interfaces/event_matcher.mojom.h" | 15 #include "components/mus/public/interfaces/event_matcher.mojom.h" |
| 16 #include "components/mus/public/interfaces/window_tree.mojom.h" | 16 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 17 #include "services/shell/public/cpp/connection.h" | 17 #include "services/shell/public/cpp/connection.h" |
| 18 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
| 19 #include "ui/events/devices/device_data_manager.h" | 19 #include "ui/events/devices/device_data_manager.h" |
| 20 #include "ui/views/mus/clipboard_mus.h" |
| 20 #include "ui/views/mus/native_widget_mus.h" | 21 #include "ui/views/mus/native_widget_mus.h" |
| 21 #include "ui/views/mus/screen_mus.h" | 22 #include "ui/views/mus/screen_mus.h" |
| 22 #include "ui/views/pointer_watcher.h" | 23 #include "ui/views/pointer_watcher.h" |
| 23 #include "ui/views/views_delegate.h" | 24 #include "ui/views/views_delegate.h" |
| 24 | 25 |
| 25 namespace views { | 26 namespace views { |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 using WindowManagerConnectionPtr = | 29 using WindowManagerConnectionPtr = |
| 29 base::ThreadLocalPointer<views::WindowManagerConnection>; | 30 base::ThreadLocalPointer<views::WindowManagerConnection>; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 const shell::Identity& identity) | 108 const shell::Identity& identity) |
| 108 : connector_(connector), | 109 : connector_(connector), |
| 109 identity_(identity), | 110 identity_(identity), |
| 110 created_device_data_manager_(false) { | 111 created_device_data_manager_(false) { |
| 111 client_.reset(new mus::WindowTreeClient(this, nullptr, nullptr)); | 112 client_.reset(new mus::WindowTreeClient(this, nullptr, nullptr)); |
| 112 client_->ConnectViaWindowTreeFactory(connector_); | 113 client_->ConnectViaWindowTreeFactory(connector_); |
| 113 | 114 |
| 114 screen_.reset(new ScreenMus(this)); | 115 screen_.reset(new ScreenMus(this)); |
| 115 screen_->Init(connector); | 116 screen_->Init(connector); |
| 116 | 117 |
| 118 std::unique_ptr<ClipboardMus> clipboard(new ClipboardMus); |
| 119 clipboard->Init(connector); |
| 120 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); |
| 121 |
| 117 if (!ui::DeviceDataManager::HasInstance()) { | 122 if (!ui::DeviceDataManager::HasInstance()) { |
| 118 // TODO(sad): We should have a DeviceDataManager implementation that talks | 123 // TODO(sad): We should have a DeviceDataManager implementation that talks |
| 119 // to a mojo service to learn about the input-devices on the system. | 124 // to a mojo service to learn about the input-devices on the system. |
| 120 // http://crbug.com/601981 | 125 // http://crbug.com/601981 |
| 121 ui::DeviceDataManager::CreateInstance(); | 126 ui::DeviceDataManager::CreateInstance(); |
| 122 created_device_data_manager_ = true; | 127 created_device_data_manager_ = true; |
| 123 } | 128 } |
| 124 | 129 |
| 125 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( | 130 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( |
| 126 &WindowManagerConnection::CreateNativeWidgetMus, | 131 &WindowManagerConnection::CreateNativeWidgetMus, |
| 127 base::Unretained(this), | 132 base::Unretained(this), |
| 128 std::map<std::string, std::vector<uint8_t>>())); | 133 std::map<std::string, std::vector<uint8_t>>())); |
| 129 } | 134 } |
| 130 | 135 |
| 131 WindowManagerConnection::~WindowManagerConnection() { | 136 WindowManagerConnection::~WindowManagerConnection() { |
| 132 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while | 137 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while |
| 133 // we are still valid. | 138 // we are still valid. |
| 134 client_.reset(); | 139 client_.reset(); |
| 140 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 135 if (created_device_data_manager_) | 141 if (created_device_data_manager_) |
| 136 ui::DeviceDataManager::DeleteInstance(); | 142 ui::DeviceDataManager::DeleteInstance(); |
| 137 | 143 |
| 138 if (ViewsDelegate::GetInstance()) { | 144 if (ViewsDelegate::GetInstance()) { |
| 139 ViewsDelegate::GetInstance()->set_native_widget_factory( | 145 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 140 ViewsDelegate::NativeWidgetFactory()); | 146 ViewsDelegate::NativeWidgetFactory()); |
| 141 } | 147 } |
| 142 } | 148 } |
| 143 | 149 |
| 144 bool WindowManagerConnection::HasPointerWatcher() { | 150 bool WindowManagerConnection::HasPointerWatcher() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 188 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 183 if (client_) | 189 if (client_) |
| 184 NativeWidgetMus::NotifyFrameChanged(client_.get()); | 190 NativeWidgetMus::NotifyFrameChanged(client_.get()); |
| 185 } | 191 } |
| 186 | 192 |
| 187 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { | 193 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { |
| 188 return client_->GetCursorScreenPoint(); | 194 return client_->GetCursorScreenPoint(); |
| 189 } | 195 } |
| 190 | 196 |
| 191 } // namespace views | 197 } // namespace views |
| OLD | NEW |