| 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_connection.h" | 14 #include "components/mus/public/cpp/window_tree_connection.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/gfx/geometry/mojo/geometry_type_converters.h" | 20 #include "ui/gfx/geometry/mojo/geometry_type_converters.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" |
| 22 #include "ui/views/mus/screen_mus.h" | 23 #include "ui/views/mus/screen_mus.h" |
| 23 #include "ui/views/pointer_watcher.h" | 24 #include "ui/views/pointer_watcher.h" |
| 24 #include "ui/views/views_delegate.h" | 25 #include "ui/views/views_delegate.h" |
| 25 | 26 |
| 26 namespace views { | 27 namespace views { |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 using WindowManagerConnectionPtr = | 30 using WindowManagerConnectionPtr = |
| 30 base::ThreadLocalPointer<views::WindowManagerConnection>; | 31 base::ThreadLocalPointer<views::WindowManagerConnection>; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 const shell::Identity& identity) | 104 const shell::Identity& identity) |
| 104 : connector_(connector), | 105 : connector_(connector), |
| 105 identity_(identity), | 106 identity_(identity), |
| 106 window_tree_connection_(nullptr) { | 107 window_tree_connection_(nullptr) { |
| 107 window_tree_connection_.reset( | 108 window_tree_connection_.reset( |
| 108 mus::WindowTreeConnection::Create(this, connector_)); | 109 mus::WindowTreeConnection::Create(this, connector_)); |
| 109 | 110 |
| 110 screen_.reset(new ScreenMus(this)); | 111 screen_.reset(new ScreenMus(this)); |
| 111 screen_->Init(connector); | 112 screen_->Init(connector); |
| 112 | 113 |
| 114 // We keep a weak ptr to clipboard_ |
| 115 std::unique_ptr<ClipboardMus> clipboard(new ClipboardMus); |
| 116 clipboard->Init(connector); |
| 117 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); |
| 118 |
| 113 // TODO(sad): We should have a DeviceDataManager implementation that talks to | 119 // TODO(sad): We should have a DeviceDataManager implementation that talks to |
| 114 // a mojo service to learn about the input-devices on the system. | 120 // a mojo service to learn about the input-devices on the system. |
| 115 // http://crbug.com/601981 | 121 // http://crbug.com/601981 |
| 116 ui::DeviceDataManager::CreateInstance(); | 122 ui::DeviceDataManager::CreateInstance(); |
| 117 | 123 |
| 118 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( | 124 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( |
| 119 &WindowManagerConnection::CreateNativeWidgetMus, | 125 &WindowManagerConnection::CreateNativeWidgetMus, |
| 120 base::Unretained(this), | 126 base::Unretained(this), |
| 121 std::map<std::string, std::vector<uint8_t>>())); | 127 std::map<std::string, std::vector<uint8_t>>())); |
| 122 } | 128 } |
| 123 | 129 |
| 124 WindowManagerConnection::~WindowManagerConnection() { | 130 WindowManagerConnection::~WindowManagerConnection() { |
| 125 // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate), | 131 // ~WindowTreeConnection calls back to us (we're the WindowTreeDelegate), |
| 126 // destroy it while we are still valid. | 132 // destroy it while we are still valid. |
| 127 window_tree_connection_.reset(); | 133 window_tree_connection_.reset(); |
| 128 | 134 |
| 135 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 136 |
| 129 ui::DeviceDataManager::DeleteInstance(); | 137 ui::DeviceDataManager::DeleteInstance(); |
| 130 } | 138 } |
| 131 | 139 |
| 132 bool WindowManagerConnection::HasPointerWatcher() { | 140 bool WindowManagerConnection::HasPointerWatcher() { |
| 133 // 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 |
| 134 // base::ObserverList<>::might_have_observers() because that returns true | 142 // base::ObserverList<>::might_have_observers() because that returns true |
| 135 // during iteration over the list even when the last observer is removed. | 143 // during iteration over the list even when the last observer is removed. |
| 136 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); | 144 base::ObserverList<PointerWatcher>::Iterator iterator(&pointer_watchers_); |
| 137 return !!iterator.GetNext(); | 145 return !!iterator.GetNext(); |
| 138 } | 146 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 178 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 171 if (window_tree_connection_) | 179 if (window_tree_connection_) |
| 172 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); | 180 NativeWidgetMus::NotifyFrameChanged(window_tree_connection_.get()); |
| 173 } | 181 } |
| 174 | 182 |
| 175 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { | 183 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { |
| 176 return window_tree_connection_->GetCursorScreenPoint(); | 184 return window_tree_connection_->GetCursorScreenPoint(); |
| 177 } | 185 } |
| 178 | 186 |
| 179 } // namespace views | 187 } // namespace views |
| OLD | NEW |