From c2a0eb2699f7871c876a487105070f84c38a3dd0 Mon Sep 17 00:00:00 2001 From: Zijie He Date: Thu, 26 Oct 2017 13:46:17 -0700 Subject: [PATCH] [Window Capture] Mouse cursor missing during window sharing on Mac OSX CGWindowID is 32-bit, WindowId is 64-bit, using WindowId to receive int value from CFNumberGetValue() causes the top 32 bits to be random. WindowFinderMac is impacted by this issue and returns a random number. WindowCapturerMac cannot match the window_id_ with the the random number. Meanwhile MouseCursorMonitorMac uses window title to match "Dock" window. See, https://cs.chromium.org/chromium/src/third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor_mac.mm?rcl=a194e58e799ccab6c999998e5d0f75725aa3f748&l=174 This logic should not be necessary on 10.12 or upper, the name of dock window is not "Dock" anymore. But to ensure the consistency on old platforms, I have also added this logic back into GetWindowList() function. Bug: chromium:778049 Change-Id: Ie827bcd5d31f2ca69ff24c24cf640cb7cc50d419 Reviewed-on: https://webrtc-review.googlesource.com/15782 Commit-Queue: Zijie He Reviewed-by: Jamie Walch Cr-Commit-Position: refs/heads/master@{#20451} --- modules/desktop_capture/mac/window_list_utils.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/desktop_capture/mac/window_list_utils.cc b/modules/desktop_capture/mac/window_list_utils.cc index 3572d85be0..005b1c64b2 100644 --- a/modules/desktop_capture/mac/window_list_utils.cc +++ b/modules/desktop_capture/mac/window_list_utils.cc @@ -96,6 +96,12 @@ bool GetWindowList(rtc::FunctionView on_window, continue; } + // TODO(webrtc:8460): On 10.12, the name of the dock window is not "Dock" + // anymore. The following check should be removed soon or later. + if (CFStringCompare(window_title, CFSTR("Dock"), 0) == 0) { + continue; + } + CFNumberRef window_id = reinterpret_cast( CFDictionaryGetValue(window, kCGWindowNumber)); if (!window_id) { @@ -210,7 +216,10 @@ WindowId GetWindowId(CFDictionaryRef window) { return kNullWindowId; } - WindowId id; + // Note: WindowId is 64-bit on 64-bit system, but CGWindowID is always 32-bit. + // CFNumberGetValue() fills only top 32 bits, so we should use CGWindowID to + // receive the window id. + CGWindowID id; if (!CFNumberGetValue(window_id, kCFNumberIntType, &id)) { return kNullWindowId; }