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 <jamiewalch@chromium.org>
Commit-Queue: Zijie He <zijiehe@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#19617}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 3aa4afd6307b915dfba0c7be6fd3bac0864541f8
diff --git a/modules/desktop_capture/mac/window_list_utils.cc b/modules/desktop_capture/mac/window_list_utils.cc
index 8b668c9..10c12c1 100644
--- a/modules/desktop_capture/mac/window_list_utils.cc
+++ b/modules/desktop_capture/mac/window_list_utils.cc
@@ -141,7 +141,7 @@
bool IsWindowOnScreen(CFDictionaryRef window) {
CFBooleanRef on_screen = reinterpret_cast<CFBooleanRef>(
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 @@
CFArrayCreate(NULL, reinterpret_cast<const void **>(&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<CFDictionaryRef>(
diff --git a/modules/desktop_capture/mac/window_list_utils.h b/modules/desktop_capture/mac/window_list_utils.h
index b4608f6..5e204a7 100644
--- a/modules/desktop_capture/mac/window_list_utils.h
+++ b/modules/desktop_capture/mac/window_list_utils.h
@@ -36,15 +36,12 @@
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