| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/media/capture/cursor_renderer_aura.h" | 5 #include "content/browser/media/capture/cursor_renderer_aura.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/aura/client/screen_position_client.h" |
| 8 #include "ui/aura/env.h" | 9 #include "ui/aura/env.h" |
| 10 #include "ui/aura/window.h" |
| 9 #include "ui/aura/window_tree_host.h" | 11 #include "ui/aura/window_tree_host.h" |
| 10 #include "ui/base/cursor/cursors_aura.h" | 12 #include "ui/base/cursor/cursors_aura.h" |
| 11 #include "ui/events/event_utils.h" | 13 #include "ui/events/event_utils.h" |
| 12 #include "ui/wm/public/activation_client.h" | 14 #include "ui/wm/public/activation_client.h" |
| 13 | 15 |
| 14 namespace content { | 16 namespace content { |
| 15 | 17 |
| 16 // static | 18 // static |
| 17 std::unique_ptr<CursorRenderer> CursorRenderer::Create( | 19 std::unique_ptr<CursorRenderer> CursorRenderer::Create( |
| 18 gfx::NativeWindow window) { | 20 gfx::NativeWindow window) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 const gfx::Rect window_bounds = window_->GetBoundsInScreen(); | 77 const gfx::Rect window_bounds = window_->GetBoundsInScreen(); |
| 76 const gfx::Size view_size(window_bounds.width(), window_bounds.height()); | 78 const gfx::Size view_size(window_bounds.width(), window_bounds.height()); |
| 77 return view_size; | 79 return view_size; |
| 78 } | 80 } |
| 79 | 81 |
| 80 gfx::Point CursorRendererAura::GetCursorPositionInView() { | 82 gfx::Point CursorRendererAura::GetCursorPositionInView() { |
| 81 if (!window_) { | 83 if (!window_) { |
| 82 return gfx::Point(); | 84 return gfx::Point(); |
| 83 } | 85 } |
| 84 | 86 |
| 85 const gfx::Rect window_bounds = window_->GetBoundsInScreen(); | 87 // Convert from screen coordinates to view coordinates. |
| 88 aura::Window* const root_window = window_->GetRootWindow(); |
| 89 if (!root_window) |
| 90 return gfx::Point(); |
| 91 aura::client::ScreenPositionClient* const client = |
| 92 aura::client::GetScreenPositionClient(root_window); |
| 93 if (!client) |
| 94 return gfx::Point(); |
| 86 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); | 95 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); |
| 87 cursor_position.Offset(-window_bounds.x(), -window_bounds.y()); | 96 client->ConvertPointFromScreen(window_, &cursor_position); |
| 88 return cursor_position; | 97 return cursor_position; |
| 89 } | 98 } |
| 90 | 99 |
| 91 gfx::NativeCursor CursorRendererAura::GetLastKnownCursor() { | 100 gfx::NativeCursor CursorRendererAura::GetLastKnownCursor() { |
| 92 if (!window_) { | 101 if (!window_) { |
| 93 return gfx::NativeCursor(); | 102 return gfx::NativeCursor(); |
| 94 } | 103 } |
| 95 | 104 |
| 96 return window_->GetHost()->last_cursor(); | 105 return window_->GetHost()->last_cursor(); |
| 97 } | 106 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 124 } | 133 } |
| 125 | 134 |
| 126 void CursorRendererAura::OnWindowDestroying(aura::Window* window) { | 135 void CursorRendererAura::OnWindowDestroying(aura::Window* window) { |
| 127 DCHECK_EQ(window_, window); | 136 DCHECK_EQ(window_, window); |
| 128 window_->RemovePreTargetHandler(this); | 137 window_->RemovePreTargetHandler(this); |
| 129 window_->RemoveObserver(this); | 138 window_->RemoveObserver(this); |
| 130 window_ = nullptr; | 139 window_ = nullptr; |
| 131 } | 140 } |
| 132 | 141 |
| 133 } // namespace content | 142 } // namespace content |
| OLD | NEW |