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

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

Issue 2392063003: mus: Use TooltipManagerAura in NativeWidgetMus. (Closed)
Patch Set: lint patch 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
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | ui/views/widget/tooltip_manager_aura.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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::vector<display::Display>& displays,
44 const std::vector<ui::Window*>& windows,
45 const gfx::Point& screen_point) {
46 for (ui::Window* window : windows) {
47 const int64_t window_display_id = window->GetRoot()->display_id();
sky 2016/10/06 21:23:42 Each window has a display id, so you should be abl
48 for (display::Display display : displays) {
sky 2016/10/06 21:23:42 As you're going to be doing this in a loop every t
49 if (display.id() != window_display_id)
50 continue;
51
52 gfx::Point display_origin = display.bounds().origin();
53 gfx::Rect bounds_in_screen = window->GetBoundsInRoot();
54 bounds_in_screen.Offset(display_origin.x(), display_origin.y());
55
56 if (bounds_in_screen.Contains(screen_point)) {
57 if (!window->children().empty()) {
58 ui::Window* child =
59 GetWindowFrom(displays, window->children(), screen_point);
60 if (child)
61 return child;
62 }
63
64 return window;
65 }
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(
sky 2016/10/06 21:23:42 Please add test coverage of this.
200 const gfx::Point& point) {
201 std::vector<display::Display> displays =
202 display::Screen::GetScreen()->GetAllDisplays();
203
204 const std::set<ui::Window*>& roots = GetRoots();
205 std::vector<ui::Window*> windows;
206 std::copy(roots.begin(), roots.end(), std::back_inserter(windows));
207 return GetWindowFrom(displays, windows, point);
208 }
209
170 std::unique_ptr<OSExchangeData::Provider> 210 std::unique_ptr<OSExchangeData::Provider>
171 WindowManagerConnection::BuildProvider() { 211 WindowManagerConnection::BuildProvider() {
172 return base::MakeUnique<OSExchangeDataProviderMus>(); 212 return base::MakeUnique<OSExchangeDataProviderMus>();
173 } 213 }
174 214
175 } // namespace views 215 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_manager_connection.h ('k') | ui/views/widget/tooltip_manager_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698