| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 const gfx::Rect window_bounds = window_->GetBoundsInScreen(); | 70 const gfx::Rect window_bounds = window_->GetBoundsInScreen(); |
| 71 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); | 71 gfx::Point cursor_position = aura::Env::GetInstance()->last_mouse_location(); |
| 72 if (!window_bounds.Contains(cursor_position)) { | 72 if (!window_bounds.Contains(cursor_position)) { |
| 73 // Return early if there is no need to draw the cursor. | 73 // Return early if there is no need to draw the cursor. |
| 74 DVLOG(2) << "Skipping update with cursor outside the window"; | 74 DVLOG(2) << "Skipping update with cursor outside the window"; |
| 75 Clear(); | 75 Clear(); |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 | 78 |
| 79 aura::client::ActivationClient* activation_client = | 79 // If we are sharing the root window, or namely the whole screen, we will |
| 80 aura::client::GetActivationClient(window_->GetRootWindow()); | 80 // render the mouse cursor. For ordinary window, we only render the mouse |
| 81 DCHECK(activation_client); | 81 // cursor when the window is active. |
| 82 aura::Window* active_window = activation_client->GetActiveWindow(); | 82 if (!window_->IsRootWindow()) { |
| 83 if (!active_window->Contains(window_)) { | 83 aura::client::ActivationClient* activation_client = |
| 84 // Return early if the target window is not active. | 84 aura::client::GetActivationClient(window_->GetRootWindow()); |
| 85 DVLOG(2) << "Skipping update on an inactive window"; | 85 DCHECK(activation_client); |
| 86 Clear(); | 86 aura::Window* active_window = activation_client->GetActiveWindow(); |
| 87 return false; | 87 if (!active_window->Contains(window_)) { |
| 88 // Return early if the target window is not active. |
| 89 DVLOG(2) << "Skipping update on an inactive window"; |
| 90 Clear(); |
| 91 return false; |
| 92 } |
| 88 } | 93 } |
| 89 | 94 |
| 90 gfx::NativeCursor cursor = window_->GetHost()->last_cursor(); | 95 gfx::NativeCursor cursor = window_->GetHost()->last_cursor(); |
| 91 gfx::Point cursor_hot_point; | 96 gfx::Point cursor_hot_point; |
| 92 if (last_cursor_ != cursor || | 97 if (last_cursor_ != cursor || |
| 93 window_size_when_cursor_last_updated_ != window_bounds.size()) { | 98 window_size_when_cursor_last_updated_ != window_bounds.size()) { |
| 94 SkBitmap cursor_bitmap; | 99 SkBitmap cursor_bitmap; |
| 95 if (ui::GetCursorBitmap(cursor, &cursor_bitmap, &cursor_hot_point)) { | 100 if (ui::GetCursorBitmap(cursor, &cursor_bitmap, &cursor_hot_point)) { |
| 96 const int scaled_width = cursor_bitmap.width() * region_in_frame.width() / | 101 const int scaled_width = cursor_bitmap.width() * region_in_frame.width() / |
| 97 window_bounds.width(); | 102 window_bounds.width(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 210 } |
| 206 | 211 |
| 207 void CursorRendererAura::OnWindowDestroying(aura::Window* window) { | 212 void CursorRendererAura::OnWindowDestroying(aura::Window* window) { |
| 208 DCHECK_EQ(window_, window); | 213 DCHECK_EQ(window_, window); |
| 209 window_->RemovePreTargetHandler(this); | 214 window_->RemovePreTargetHandler(this); |
| 210 window_->RemoveObserver(this); | 215 window_->RemoveObserver(this); |
| 211 window_ = nullptr; | 216 window_ = nullptr; |
| 212 } | 217 } |
| 213 | 218 |
| 214 } // namespace content | 219 } // namespace content |
| OLD | NEW |