Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: ui/views/mus/window_manager_connection.cc

Issue 2392063003: mus: Use TooltipManagerAura in NativeWidgetMus. (Closed)
Patch Set: Add comment Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <set> 8 #include <set>
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
12 #include "base/threading/thread_local.h" 13 #include "base/threading/thread_local.h"
13 #include "services/shell/public/cpp/connection.h" 14 #include "services/shell/public/cpp/connection.h"
14 #include "services/shell/public/cpp/connector.h" 15 #include "services/shell/public/cpp/connector.h"
15 #include "services/ui/public/cpp/gpu_service.h" 16 #include "services/ui/public/cpp/gpu_service.h"
16 #include "services/ui/public/cpp/property_type_converters.h" 17 #include "services/ui/public/cpp/property_type_converters.h"
(...skipping 15 matching lines...) Expand all
32 namespace views { 33 namespace views {
33 namespace { 34 namespace {
34 35
35 using WindowManagerConnectionPtr = 36 using WindowManagerConnectionPtr =
36 base::ThreadLocalPointer<views::WindowManagerConnection>; 37 base::ThreadLocalPointer<views::WindowManagerConnection>;
37 38
38 // Env is thread local so that aura may be used on multiple threads. 39 // Env is thread local so that aura may be used on multiple threads.
39 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr = 40 base::LazyInstance<WindowManagerConnectionPtr>::Leaky lazy_tls_ptr =
40 LAZY_INSTANCE_INITIALIZER; 41 LAZY_INSTANCE_INITIALIZER;
41 42
43 // Recursively finds the deepest visible window from |windows| that contains
44 // |screen_point|, when offsetting by the display origins from
45 // |display_origins|.
46 ui::Window* GetWindowFrom(const std::map<int64_t, gfx::Point>& display_origins,
47 const std::vector<ui::Window*>& windows,
48 const gfx::Point& screen_point) {
49 for (ui::Window* window : windows) {
50 if (!window->visible())
51 continue;
52
53 auto it = display_origins.find(window->display_id());
54 if (it == display_origins.end())
55 continue;
56
57 gfx::Rect bounds_in_screen = window->GetBoundsInRoot();
58 bounds_in_screen.Offset(it->second.x(), it->second.y());
59
60 if (bounds_in_screen.Contains(screen_point)) {
61 if (!window->children().empty()) {
62 ui::Window* child =
63 GetWindowFrom(display_origins, window->children(), screen_point);
64 if (child)
65 return child;
66 }
67
68 return window;
69 }
70 }
71 return nullptr;
72 }
73
42 } // namespace 74 } // namespace
43 75
44 WindowManagerConnection::~WindowManagerConnection() { 76 WindowManagerConnection::~WindowManagerConnection() {
45 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while 77 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while
46 // we are still valid. 78 // we are still valid.
47 client_.reset(); 79 client_.reset();
48 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); 80 ui::OSExchangeDataProviderFactory::SetFactory(nullptr);
49 ui::Clipboard::DestroyClipboardForCurrentThread(); 81 ui::Clipboard::DestroyClipboardForCurrentThread();
50 gpu_service_.reset(); 82 gpu_service_.reset();
51 lazy_tls_ptr.Pointer()->Set(nullptr); 83 lazy_tls_ptr.Pointer()->Set(nullptr);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 192
161 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { 193 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() {
162 if (client_) 194 if (client_)
163 NativeWidgetMus::NotifyFrameChanged(client_.get()); 195 NativeWidgetMus::NotifyFrameChanged(client_.get());
164 } 196 }
165 197
166 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { 198 gfx::Point WindowManagerConnection::GetCursorScreenPoint() {
167 return client_->GetCursorScreenPoint(); 199 return client_->GetCursorScreenPoint();
168 } 200 }
169 201
202 ui::Window* WindowManagerConnection::GetWindowAtScreenPoint(
203 const gfx::Point& point) {
204 std::map<int64_t, gfx::Point> display_origins;
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 }
213
170 std::unique_ptr<OSExchangeData::Provider> 214 std::unique_ptr<OSExchangeData::Provider>
171 WindowManagerConnection::BuildProvider() { 215 WindowManagerConnection::BuildProvider() {
172 return base::MakeUnique<OSExchangeDataProviderMus>(); 216 return base::MakeUnique<OSExchangeDataProviderMus>();
173 } 217 }
174 218
175 } // namespace views 219 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | ui/views/mus/window_manager_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698