From 20a60ea39dc60530f9afdc54b032dd0516c1999f Mon Sep 17 00:00:00 2001 From: "jiayl@webrtc.org" Date: Tue, 4 Feb 2014 17:49:12 +0000 Subject: [PATCH] Fix a cursor capturing issue on Windows. The input position to WindowFromPoint should be relative to the desktop, not relative to the window; if the result from WindowFromPoint is a child window of the shared top window, it should be captured. BUG= R=sergeyu@chromium.org Review URL: https://webrtc-codereview.appspot.com/7959004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5487 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/desktop_capture/mouse_cursor_monitor_win.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webrtc/modules/desktop_capture/mouse_cursor_monitor_win.cc b/webrtc/modules/desktop_capture/mouse_cursor_monitor_win.cc index 01dace904e..fc041ef517 100644 --- a/webrtc/modules/desktop_capture/mouse_cursor_monitor_win.cc +++ b/webrtc/modules/desktop_capture/mouse_cursor_monitor_win.cc @@ -105,9 +105,12 @@ void MouseCursorMonitorWin::Capture() { position.set(0, 0); inside = false; } else { + if (inside) { + HWND windowUnderCursor = WindowFromPoint(cursor_info.ptScreenPos); + inside = windowUnderCursor ? + (window_ == GetAncestor(windowUnderCursor, GA_ROOT)) : false; + } position = position.subtract(DesktopVector(rect.left, rect.top)); - if (inside) - inside = (window_ == WindowFromPoint(cursor_info.ptScreenPos)); } } else { assert(screen_ != kInvalidScreenId);