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

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

Issue 2392063003: mus: Use TooltipManagerAura in NativeWidgetMus. (Closed)
Patch Set: Visibility check 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 ui::Window* GetWindowFrom(const std::map<int64_t, gfx::Point>& display_origins,
sky 2016/10/07 20:00:08 Please add a description, especially as to what di
44 const std::vector<ui::Window*>& windows,
45 const gfx::Point& screen_point) {
46 for (ui::Window* window : windows) {
47 if (!window->visible())
48 continue;
49
50 auto it = display_origins.find(window->display_id());
51 if (it == display_origins.end())
52 continue;
53
54 gfx::Rect bounds_in_screen = window->GetBoundsInRoot();
55 bounds_in_screen.Offset(it->second.x(), it->second.y());
56
57 if (bounds_in_screen.Contains(screen_point)) {
58 if (!window->children().empty()) {
59 ui::Window* child =
60 GetWindowFrom(display_origins, window->children(), screen_point);
61 if (child)
62 return child;
63 }
64
65 return window;
66 }
67 }
68 return nullptr;
69 }
70
42 } // namespace 71 } // namespace
43 72
44 WindowManagerConnection::~WindowManagerConnection() { 73 WindowManagerConnection::~WindowManagerConnection() {
45 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while 74 // ~WindowTreeClient calls back to us (we're its delegate), destroy it while
46 // we are still valid. 75 // we are still valid.
47 client_.reset(); 76 client_.reset();
48 ui::OSExchangeDataProviderFactory::SetFactory(nullptr); 77 ui::OSExchangeDataProviderFactory::SetFactory(nullptr);
49 ui::Clipboard::DestroyClipboardForCurrentThread(); 78 ui::Clipboard::DestroyClipboardForCurrentThread();
50 gpu_service_.reset(); 79 gpu_service_.reset();
51 lazy_tls_ptr.Pointer()->Set(nullptr); 80 lazy_tls_ptr.Pointer()->Set(nullptr);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 189
161 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() { 190 void WindowManagerConnection::OnWindowManagerFrameValuesChanged() {
162 if (client_) 191 if (client_)
163 NativeWidgetMus::NotifyFrameChanged(client_.get()); 192 NativeWidgetMus::NotifyFrameChanged(client_.get());
164 } 193 }
165 194
166 gfx::Point WindowManagerConnection::GetCursorScreenPoint() { 195 gfx::Point WindowManagerConnection::GetCursorScreenPoint() {
167 return client_->GetCursorScreenPoint(); 196 return client_->GetCursorScreenPoint();
168 } 197 }
169 198
199 ui::Window* WindowManagerConnection::GetWindowAtScreenPoint(
200 const gfx::Point& point) {
201 std::map<int64_t, gfx::Point> display_origins;
202 for (display::Display& d : display::Screen::GetScreen()->GetAllDisplays())
203 display_origins[d.id()] = d.bounds().origin();
204
205 const std::set<ui::Window*>& roots = GetRoots();
206 std::vector<ui::Window*> windows;
207 std::copy(roots.begin(), roots.end(), std::back_inserter(windows));
208 return GetWindowFrom(display_origins, windows, point);
209 }
210
170 std::unique_ptr<OSExchangeData::Provider> 211 std::unique_ptr<OSExchangeData::Provider>
171 WindowManagerConnection::BuildProvider() { 212 WindowManagerConnection::BuildProvider() {
172 return base::MakeUnique<OSExchangeDataProviderMus>(); 213 return base::MakeUnique<OSExchangeDataProviderMus>();
173 } 214 }
174 215
175 } // namespace views 216 } // 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