| 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/input_devices/input_devices.mojom.h" |
| 16 #include "components/mus/public/interfaces/window_tree.mojom.h" | 17 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 17 #include "services/shell/public/cpp/connection.h" | 18 #include "services/shell/public/cpp/connection.h" |
| 18 #include "services/shell/public/cpp/connector.h" | 19 #include "services/shell/public/cpp/connector.h" |
| 19 #include "ui/events/devices/device_data_manager.h" | 20 #include "ui/events/devices/device_data_manager.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 { |
| (...skipping 81 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 |
| 117 if (!ui::DeviceDataManager::HasInstance()) { | 118 // Receives updates about input-devices from other another process. |
| 118 // TODO(sad): We should have a DeviceDataManager implementation that talks | 119 input_device::mojom::InputDeviceServerPtr service; |
| 119 // to a mojo service to learn about the input-devices on the system. | 120 connector->ConnectToInterface("mojo:mus", &service); |
| 120 // http://crbug.com/601981 | 121 input_device_client_.Connect(std::move(service)); |
| 121 ui::DeviceDataManager::CreateInstance(); | |
| 122 created_device_data_manager_ = true; | |
| 123 } | |
| 124 | 122 |
| 125 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( | 123 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( |
| 126 &WindowManagerConnection::CreateNativeWidgetMus, | 124 &WindowManagerConnection::CreateNativeWidgetMus, |
| 127 base::Unretained(this), | 125 base::Unretained(this), |
| 128 std::map<std::string, std::vector<uint8_t>>())); | 126 std::map<std::string, std::vector<uint8_t>>())); |
| 129 } | 127 } |
| 130 | 128 |
| 131 WindowManagerConnection::~WindowManagerConnection() { | 129 WindowManagerConnection::~WindowManagerConnection() { |
| 132 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while | 130 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while |
| 133 // we are still valid. | 131 // we are still valid. |
| 134 client_.reset(); | 132 client_.reset(); |
| 135 if (created_device_data_manager_) | |
| 136 ui::DeviceDataManager::DeleteInstance(); | |
| 137 | 133 |
| 138 if (ViewsDelegate::GetInstance()) { | 134 if (ViewsDelegate::GetInstance()) { |
| 139 ViewsDelegate::GetInstance()->set_native_widget_factory( | 135 ViewsDelegate::GetInstance()->set_native_widget_factory( |
| 140 ViewsDelegate::NativeWidgetFactory()); | 136 ViewsDelegate::NativeWidgetFactory()); |
| 141 } | 137 } |
| 142 } | 138 } |
| 143 | 139 |
| 144 bool WindowManagerConnection::HasPointerWatcher() { | 140 bool WindowManagerConnection::HasPointerWatcher() { |
| 145 // Check to see if we really have any observers left. This doesn't use | 141 // Check to see if we really have any observers left. This doesn't use |
| 146 // base::ObserverList<>::might_have_observers() because that returns true | 142 // base::ObserverList<>::might_have_observers() because that returns true |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 178 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 183 if (client_) | 179 if (client_) |
| 184 NativeWidgetMus::NotifyFrameChanged(client_.get()); | 180 NativeWidgetMus::NotifyFrameChanged(client_.get()); |
| 185 } | 181 } |
| 186 | 182 |
| 187 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { | 183 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { |
| 188 return client_->GetCursorScreenPoint(); | 184 return client_->GetCursorScreenPoint(); |
| 189 } | 185 } |
| 190 | 186 |
| 191 } // namespace views | 187 } // namespace views |
| OLD | NEW |