From 3aa4afd6307b915dfba0c7be6fd3bac0864541f8 Mon Sep 17 00:00:00 2001 From: Zijie He Date: Wed, 30 Aug 2017 17:29:29 -0700 Subject: [PATCH] Flip IsWindowOnScreen behavior when native APIs fail Per discussion in https://chromium-review.googlesource.com/c/external/webrtc/+/641814, the behavior of IsWindowOnScreen() functions when native APIs fail should be flipped. I.e. window is *not* on screen if OS cannot find it. Bug: chromium:758554 Change-Id: Ife449a5261fcd89c37595e29a0b1802fcf3c42a5 Reviewed-on: https://chromium-review.googlesource.com/644290 Reviewed-by: Jamie Walch Commit-Queue: Zijie He Cr-Commit-Position: refs/heads/master@{#19617} --- webrtc/modules/desktop_capture/mac/window_list_utils.cc | 4 ++-- webrtc/modules/desktop_capture/mac/window_list_utils.h | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/webrtc/modules/desktop_capture/mac/window_list_utils.cc b/webrtc/modules/desktop_capture/mac/window_list_utils.cc index 8b668c9703..10c12c1ce2 100644 --- a/webrtc/modules/desktop_capture/mac/window_list_utils.cc +++ b/webrtc/modules/desktop_capture/mac/window_list_utils.cc @@ -141,7 +141,7 @@ bool IsWindowFullScreen( bool IsWindowOnScreen(CFDictionaryRef window) { CFBooleanRef on_screen = reinterpret_cast( CFDictionaryGetValue(window, kCGWindowIsOnscreen)); - return on_screen == NULL || CFBooleanGetValue(on_screen); + return on_screen != NULL && CFBooleanGetValue(on_screen); } bool IsWindowOnScreen(CGWindowID id) { @@ -149,7 +149,7 @@ bool IsWindowOnScreen(CGWindowID id) { CFArrayCreate(NULL, reinterpret_cast(&id), 1, NULL); CFArrayRef window_array = CGWindowListCreateDescriptionFromArray(window_id_array); - bool on_screen = true; + bool on_screen = false; if (window_array && CFArrayGetCount(window_array)) { on_screen = IsWindowOnScreen(reinterpret_cast( diff --git a/webrtc/modules/desktop_capture/mac/window_list_utils.h b/webrtc/modules/desktop_capture/mac/window_list_utils.h index b4608f6641..5e204a7d20 100644 --- a/webrtc/modules/desktop_capture/mac/window_list_utils.h +++ b/webrtc/modules/desktop_capture/mac/window_list_utils.h @@ -36,15 +36,12 @@ bool GetWindowList(DesktopCapturer::SourceList* windows, bool ignore_minimized); bool IsWindowFullScreen(const MacDesktopConfiguration& desktop_config, CFDictionaryRef window); -// TODO(zijiehe): Flip the behaviors of the following two functions when native -// APIs fail. If |window| does not represent a window, or |id| cannot be found, -// returning false is more reasonable. -// Returns true if the |window| is on screen. This function returns true if +// Returns true if the |window| is on screen. This function returns false if // native APIs fail. bool IsWindowOnScreen(CFDictionaryRef window); -// Returns true if the window is on screen. This function returns true if native -// APIs fail or |id| cannot be found. +// Returns true if the window is on screen. This function returns false if +// native APIs fail or |id| cannot be found. bool IsWindowOnScreen(CGWindowID id); // Returns utf-8 encoded title of |window|. If |window| is not a window or no