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 <mfoltz@chromium.org>
Commit-Queue: Mark Foltz <mfoltz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#37632}
This commit is contained in:
Nico Schlumprecht 2022-07-26 20:00:18 -04:00 committed by WebRTC LUCI CQ
parent 1fa87c44cb
commit 275e2683b3
2 changed files with 12 additions and 5 deletions

View File

@ -82,6 +82,7 @@ Miguel Paris <mparisdiaz@gmail.com>
Mike Gilbert <floppymaster@gmail.com>
Min Wang <mingewang@gmail.com>
Mo Zanaty <mzanaty@cisco.com>
Nico Schlumprecht <me@github.nico.onl>
Niek van der Maas <mail@niekvandermaas.nl>
Olivier Crête <olivier.crete@ocrete.ca>
Pali Rohar

View File

@ -55,10 +55,12 @@ class FullScreenMacApplicationHandler : public FullScreenApplicationHandler {
std::function<bool(const std::string&, const std::string&)>;
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));
}
}