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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 1433153002: Ignore update cursor messages from blink when the cursor position lies outside our root window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make the fix work for other platforms Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/screen_win.h » ('j') | ui/gfx/screen_win.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 77ea38814b5068f6f561e17d9c9e858b5cc6243a..a22d8974620ca216e95132fcbf099e7899d524bb 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -98,6 +98,7 @@
#include "content/common/plugin_constants_win.h"
#include "ui/base/win/hidden_window.h"
#include "ui/gfx/gdi_util.h"
+#include "ui/gfx/screen_win.h"
#include "ui/gfx/win/dpi.h"
#endif
@@ -2471,8 +2472,37 @@ void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
if (!root_window)
return;
- gfx::Point root_window_point =
- gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint();
+ gfx::Screen* screen = gfx::Screen::GetScreenFor(GetNativeView());
+ DCHECK(screen);
+
+ gfx::Point cursor_screen_point = screen->GetCursorScreenPoint();
+
+ // Ignore cursor update messages if the window under the cursor is not us.
+ aura::Window* window_at_screen_point = screen->GetWindowAtScreenPoint(
+ cursor_screen_point);;
sky 2015/11/13 16:12:18 nit: only one ';'.
ananta 2015/11/13 20:09:41 Done.
+#if defined(OS_WIN)
+ // On Windows we may fail to retrieve the aura Window at the current cursor
+ // position. This is because the WindowFromPoint API may return the legacy
+ // window which is not associated with an aura Window. In this case we need
+ // to get the aura window for the parent of the legacy window.
+ if (!window_at_screen_point) {
+ HWND hwnd_at_point = ::WindowFromPoint(cursor_screen_point.ToPOINT());
+ if (legacy_render_widget_host_HWND_ &&
+ (hwnd_at_point == legacy_render_widget_host_HWND_->hwnd())) {
+ hwnd_at_point = legacy_render_widget_host_HWND_->GetParent();
+ }
+ gfx::ScreenWin* screen_win = static_cast<gfx::ScreenWin*>(screen);
sky 2015/11/13 16:12:18 What happens if running in metro mode?
ananta 2015/11/13 20:09:41 In metro mode we should not be hitting the if (!wi
+ DCHECK(screen_win);
+ window_at_screen_point = screen_win->GetNativeWindowFromHWND(
+ hwnd_at_point);
+ }
+#endif
+ if (!window_at_screen_point ||
+ (window_at_screen_point->GetRootWindow() != root_window)) {
+ return;
+ }
+
+ gfx::Point root_window_point = cursor_screen_point;
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(root_window);
if (screen_position_client) {
« no previous file with comments | « no previous file | ui/gfx/screen_win.h » ('j') | ui/gfx/screen_win.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698