From 275e2683b3a1591cd5c64d29f3e2ccaf647f12e6 Mon Sep 17 00:00:00 2001 From: Nico Schlumprecht Date: Tue, 26 Jul 2022 20:00:18 -0400 Subject: [PATCH] Fix sharing full screen PowerPoint pres on macOS Before this change the full screen application handler was failing to detect PowerPoint going into presentation mode, resulting in the editor window continuing to be shared rather than the intended behavior of sharing the presentation itself. Fix this by always looking for the PowerPoint full screen presentation window, regardless of whether the editor window is still open. In the current version of PowerPoint, the editor stays open during presentation. Bug: chromium:1231437 Change-Id: I1b21e263d25320cc236d127d22d4d64bb52fcbda Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/269560 Reviewed-by: Mark Foltz Commit-Queue: Mark Foltz Cr-Commit-Position: refs/heads/main@{#37632} --- AUTHORS | 1 + .../mac/full_screen_mac_application_handler.cc | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5c88c7f203..cfc744f06c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -82,6 +82,7 @@ Miguel Paris Mike Gilbert Min Wang Mo Zanaty +Nico Schlumprecht Niek van der Maas Olivier CrĂȘte Pali Rohar diff --git a/modules/desktop_capture/mac/full_screen_mac_application_handler.cc b/modules/desktop_capture/mac/full_screen_mac_application_handler.cc index a56731a4e2..6eab0c753e 100644 --- a/modules/desktop_capture/mac/full_screen_mac_application_handler.cc +++ b/modules/desktop_capture/mac/full_screen_mac_application_handler.cc @@ -55,10 +55,12 @@ class FullScreenMacApplicationHandler : public FullScreenApplicationHandler { std::function; FullScreenMacApplicationHandler(DesktopCapturer::SourceId sourceId, - TitlePredicate title_predicate) + TitlePredicate title_predicate, + bool ignore_original_window) : FullScreenApplicationHandler(sourceId), title_predicate_(title_predicate), - owner_pid_(GetWindowOwnerPid(sourceId)) {} + owner_pid_(GetWindowOwnerPid(sourceId)), + ignore_original_window_(ignore_original_window) {} protected: using CachePredicate = @@ -119,7 +121,7 @@ class FullScreenMacApplicationHandler : public FullScreenApplicationHandler { DesktopCapturer::SourceId FindFullScreenWindow( const DesktopCapturer::SourceList& source_list, int64_t timestamp) const override { - return IsWindowOnScreen(GetSourceId()) + return !ignore_original_window_ && IsWindowOnScreen(GetSourceId()) ? 0 : FindFullScreenWindowWithSamePid(source_list, timestamp); } @@ -127,6 +129,7 @@ class FullScreenMacApplicationHandler : public FullScreenApplicationHandler { protected: const TitlePredicate title_predicate_; const int owner_pid_; + const bool ignore_original_window_; mutable int64_t cache_timestamp_ = 0; mutable DesktopCapturer::SourceList cache_sources_; }; @@ -151,7 +154,7 @@ bool slide_show_title_predicate(const std::string& original_title, class OpenOfficeApplicationHandler : public FullScreenMacApplicationHandler { public: OpenOfficeApplicationHandler(DesktopCapturer::SourceId sourceId) - : FullScreenMacApplicationHandler(sourceId, nullptr) {} + : FullScreenMacApplicationHandler(sourceId, nullptr, false) {} DesktopCapturer::SourceId FindFullScreenWindow( const DesktopCapturer::SourceList& source_list, @@ -207,10 +210,12 @@ CreateFullScreenMacApplicationHandler(DesktopCapturer::SourceId sourceId) { const std::string name{last_slash ? last_slash + 1 : buffer}; const std::string owner_name = GetWindowOwnerName(sourceId); FullScreenMacApplicationHandler::TitlePredicate predicate = nullptr; + bool ignore_original_window = false; if (name.find("Google Chrome") == 0 || name == "Chromium") { predicate = equal_title_predicate; } else if (name == "Microsoft PowerPoint") { predicate = slide_show_title_predicate; + ignore_original_window = true; } else if (name == "Keynote") { predicate = equal_title_predicate; } else if (owner_name == "OpenOffice") { @@ -218,7 +223,8 @@ CreateFullScreenMacApplicationHandler(DesktopCapturer::SourceId sourceId) { } if (predicate) { - result.reset(new FullScreenMacApplicationHandler(sourceId, predicate)); + result.reset(new FullScreenMacApplicationHandler(sourceId, predicate, + ignore_original_window)); } }