| 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" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Last PointerWatcher removed, stop the event observer. | 95 // Last PointerWatcher removed, stop the event observer. |
| 96 client_->SetEventObserver(nullptr); | 96 client_->SetEventObserver(nullptr); |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 WindowManagerConnection::WindowManagerConnection( | 100 WindowManagerConnection::WindowManagerConnection( |
| 101 shell::Connector* connector, | 101 shell::Connector* connector, |
| 102 const shell::Identity& identity) | 102 const shell::Identity& identity) |
| 103 : connector_(connector), | 103 : connector_(connector), |
| 104 identity_(identity), | 104 identity_(identity), |
| 105 client_(nullptr) { | 105 created_device_data_manager_(false) { |
| 106 client_.reset(new mus::WindowTreeClient(this, nullptr, nullptr)); | 106 client_.reset(new mus::WindowTreeClient(this, nullptr, nullptr)); |
| 107 client_->ConnectViaWindowTreeFactory(connector_); | 107 client_->ConnectViaWindowTreeFactory(connector_); |
| 108 | 108 |
| 109 screen_.reset(new ScreenMus(this)); | 109 screen_.reset(new ScreenMus(this)); |
| 110 screen_->Init(connector); | 110 screen_->Init(connector); |
| 111 | 111 |
| 112 // TODO(sad): We should have a DeviceDataManager implementation that talks to | 112 if (!ui::DeviceDataManager::HasInstance()) { |
| 113 // a mojo service to learn about the input-devices on the system. | 113 // TODO(sad): We should have a DeviceDataManager implementation that talks |
| 114 // http://crbug.com/601981 | 114 // to a mojo service to learn about the input-devices on the system. |
| 115 ui::DeviceDataManager::CreateInstance(); | 115 // http://crbug.com/601981 |
| 116 ui::DeviceDataManager::CreateInstance(); |
| 117 created_device_data_manager_ = true; |
| 118 } |
| 116 | 119 |
| 117 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( | 120 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( |
| 118 &WindowManagerConnection::CreateNativeWidgetMus, | 121 &WindowManagerConnection::CreateNativeWidgetMus, |
| 119 base::Unretained(this), | 122 base::Unretained(this), |
| 120 std::map<std::string, std::vector<uint8_t>>())); | 123 std::map<std::string, std::vector<uint8_t>>())); |
| 121 } | 124 } |
| 122 | 125 |
| 123 WindowManagerConnection::~WindowManagerConnection() { | 126 WindowManagerConnection::~WindowManagerConnection() { |
| 124 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while | 127 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while |
| 125 // we are still valid. | 128 // we are still valid. |
| 126 client_.reset(); | 129 client_.reset(); |
| 127 | 130 if (created_device_data_manager_) |
| 128 ui::DeviceDataManager::DeleteInstance(); | 131 ui::DeviceDataManager::DeleteInstance(); |
| 129 } | 132 } |
| 130 | 133 |
| 131 bool WindowManagerConnection::HasPointerWatcher() { | 134 bool WindowManagerConnection::HasPointerWatcher() { |
| 132 // Check to see if we really have any observers left. This doesn't use | 135 // Check to see if we really have any observers left. This doesn't use |
| 133 // base::ObserverList<>::might_have_observers() because that returns true | 136 // base::ObserverList<>::might_have_observers() because that returns true |
| 134 // during iteration over the list even when the last observer is removed. | 137 // during iteration over the list even when the last observer is removed. |
| 135 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); | 138 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); |
| 136 return !!iterator.GetNext(); | 139 return !!iterator.GetNext(); |
| 137 } | 140 } |
| 138 | 141 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 169 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 172 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 170 if (client_) | 173 if (client_) |
| 171 NativeWidgetMus::NotifyFrameChanged(client_.get()); | 174 NativeWidgetMus::NotifyFrameChanged(client_.get()); |
| 172 } | 175 } |
| 173 | 176 |
| 174 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { | 177 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { |
| 175 return client_->GetCursorScreenPoint(); | 178 return client_->GetCursorScreenPoint(); |
| 176 } | 179 } |
| 177 | 180 |
| 178 } // namespace views | 181 } // namespace views |
| OLD | NEW |