| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if (child) | 64 if (child) |
| 65 return child; | 65 return child; |
| 66 } | 66 } |
| 67 | 67 |
| 68 return window; | 68 return window; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 return nullptr; | 71 return nullptr; |
| 72 } | 72 } |
| 73 | 73 |
| 74 aura::Window* GetAuraWindowFromUiWindow(ui::Window* window) { |
| 75 if (!window) |
| 76 return nullptr; |
| 77 NativeWidgetMus* nw_mus = NativeWidgetMus::GetForWindow(window); |
| 78 return nw_mus |
| 79 ? static_cast<internal::NativeWidgetPrivate*>(nw_mus) |
| 80 ->GetNativeView() |
| 81 : nullptr; |
| 82 } |
| 83 |
| 74 } // namespace | 84 } // namespace |
| 75 | 85 |
| 76 WindowManagerConnection::~WindowManagerConnection() { | 86 WindowManagerConnection::~WindowManagerConnection() { |
| 77 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while | 87 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while |
| 78 // we are still valid. | 88 // we are still valid. |
| 79 client_.reset(); | 89 client_.reset(); |
| 80 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); | 90 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); |
| 81 ui::Clipboard::DestroyClipboardForCurrentThread(); | 91 ui::Clipboard::DestroyClipboardForCurrentThread(); |
| 82 gpu_service_.reset(); | 92 gpu_service_.reset(); |
| 83 lazy_tls_ptr.Pointer()->Set(nullptr); | 93 lazy_tls_ptr.Pointer()->Set(nullptr); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); | 174 ui::Clipboard::SetClipboardForCurrentThread(std::move(clipboard)); |
| 165 | 175 |
| 166 ui::OSExchangeDataProviderFactory::SetFactory(this); | 176 ui::OSExchangeDataProviderFactory::SetFactory(this); |
| 167 | 177 |
| 168 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( | 178 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( |
| 169 &WindowManagerConnection::CreateNativeWidgetMus, | 179 &WindowManagerConnection::CreateNativeWidgetMus, |
| 170 base::Unretained(this), | 180 base::Unretained(this), |
| 171 std::map<std::string, std::vector<uint8_t>>())); | 181 std::map<std::string, std::vector<uint8_t>>())); |
| 172 } | 182 } |
| 173 | 183 |
| 184 ui::Window* WindowManagerConnection::GetUiWindowAtScreenPoint( |
| 185 const gfx::Point& point) { |
| 186 std::map<int64_t, gfx::Point> display_origins; |
| 187 for (display::Display& d : display::Screen::GetScreen()->GetAllDisplays()) |
| 188 display_origins[d.id()] = d.bounds().origin(); |
| 189 |
| 190 const std::set<ui::Window*>& roots = GetRoots(); |
| 191 std::vector<ui::Window*> windows; |
| 192 std::copy(roots.begin(), roots.end(), std::back_inserter(windows)); |
| 193 return GetWindowFrom(display_origins, windows, point); |
| 194 } |
| 195 |
| 174 void WindowManagerConnection::OnEmbed(ui::Window* root) {} | 196 void WindowManagerConnection::OnEmbed(ui::Window* root) {} |
| 175 | 197 |
| 176 void WindowManagerConnection::OnLostConnection(ui::WindowTreeClient* client) { | 198 void WindowManagerConnection::OnLostConnection(ui::WindowTreeClient* client) { |
| 177 DCHECK_EQ(client, client_.get()); | 199 DCHECK_EQ(client, client_.get()); |
| 178 client_.reset(); | 200 client_.reset(); |
| 179 } | 201 } |
| 180 | 202 |
| 181 void WindowManagerConnection::OnEmbedRootDestroyed(ui::Window* root) { | 203 void WindowManagerConnection::OnEmbedRootDestroyed(ui::Window* root) { |
| 182 // Not called for WindowManagerConnection as WindowTreeClient isn't created by | 204 // Not called for WindowManagerConnection as WindowTreeClient isn't created by |
| 183 // way of an Embed(). | 205 // way of an Embed(). |
| 184 NOTREACHED(); | 206 NOTREACHED(); |
| 185 } | 207 } |
| 186 | 208 |
| 187 void WindowManagerConnection::OnPointerEventObserved( | 209 void WindowManagerConnection::OnPointerEventObserved( |
| 188 const ui::PointerEvent& event, | 210 const ui::PointerEvent& event, |
| 189 ui::Window* target) { | 211 ui::Window* target) { |
| 190 pointer_watcher_event_router_->OnPointerEventObserved(event, target); | 212 pointer_watcher_event_router_->OnPointerEventObserved(event, target); |
| 191 } | 213 } |
| 192 | 214 |
| 193 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { | 215 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { |
| 194 if (client_) | 216 if (client_) |
| 195 NativeWidgetMus::NotifyFrameChanged(client_.get()); | 217 NativeWidgetMus::NotifyFrameChanged(client_.get()); |
| 196 } | 218 } |
| 197 | 219 |
| 198 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { | 220 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { |
| 199 return client_->GetCursorScreenPoint(); | 221 return client_->GetCursorScreenPoint(); |
| 200 } | 222 } |
| 201 | 223 |
| 202 ui::Window* WindowManagerConnection::GetWindowAtScreenPoint( | 224 aura::Window* WindowManagerConnection::GetWindowAtScreenPoint( |
| 203 const gfx::Point& point) { | 225 const gfx::Point& point) { |
| 204 std::map<int64_t, gfx::Point> display_origins; | 226 return GetAuraWindowFromUiWindow(GetUiWindowAtScreenPoint(point)); |
| 205 for (display::Display& d : display::Screen::GetScreen()->GetAllDisplays()) | |
| 206 display_origins[d.id()] = d.bounds().origin(); | |
| 207 | |
| 208 const std::set<ui::Window*>& roots = GetRoots(); | |
| 209 std::vector<ui::Window*> windows; | |
| 210 std::copy(roots.begin(), roots.end(), std::back_inserter(windows)); | |
| 211 return GetWindowFrom(display_origins, windows, point); | |
| 212 } | 227 } |
| 213 | 228 |
| 214 std::unique_ptr<OSExchangeData::Provider> | 229 std::unique_ptr<OSExchangeData::Provider> |
| 215 WindowManagerConnection::BuildProvider() { | 230 WindowManagerConnection::BuildProvider() { |
| 216 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); | 231 return base::MakeUnique<aura::OSExchangeDataProviderMus>(); |
| 217 } | 232 } |
| 218 | 233 |
| 219 } // namespace views | 234 } // namespace views |
| OLD | NEW |