Skip to content

Commit

Permalink
Cherry-pick 2818419. rdar://problem/113608282
Browse files Browse the repository at this point in the history
    Cherry-pick 3eac88b. rdar://problem/113424298

        [macOS] Present SCKit picker with `-[SCContentSharingPicker presentPickerUsingContentStyle:]`
        https://bugs.webkit.org/show_bug.cgi?id=259851
        rdar://113424298

        Reviewed by Andy Estes.

        * Source/WebCore/platform/mediastream/mac/ScreenCaptureKitSharingSessionManager.mm:
        (WebCore::ScreenCaptureKitSharingSessionManager::promptWithSCContentSharingPicker): Call
        `-[SCContentSharingPicker presentPickerUsingContentStyle:]` when it is available and we
        are supposed to limit picking to either window or screen.

        Canonical link: https://commits.webkit.org/266640@main

    Identifier: 265870.311@safari-7616.1.27.11-branch

Canonical link: https://commits.webkit.org/265870.340@safari-7616-branch
  • Loading branch information
eric-carlson authored and Dan Robson committed Aug 11, 2023
1 parent 0ff248d commit 4d3b19c
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@

#import <pal/mac/ScreenCaptureKitSoftLink.h>

// FIXME: Remove this once it is in a public header.

#if HAVE(SC_CONTENT_SHARING_PICKER)
@interface SCContentSharingPicker (SCContentSharingPicker_Pending_Public_API)
- (void)presentPickerUsingContentStyle:(SCShareableContentStyle)contentStyle;
@end
#endif

using namespace WebCore;

@interface WebDisplayMediaPromptHelper : NSObject <SCContentSharingSessionProtocol
Expand Down Expand Up @@ -432,15 +440,19 @@ - (void)stopObservingPicker:(SCContentSharingPicker *)picker
ASSERT(useSCContentSharingPicker());

auto configuration = adoptNS([PAL::allocSCContentSharingPickerConfigurationInstance() init]);
SCShareableContentStyle shareableContentStyle = SCShareableContentStyleWindow;
switch (promptType) {
case DisplayCapturePromptType::Window:
[configuration setAllowedPickerModes:SCContentSharingPickerModeSingleWindow];
shareableContentStyle = SCShareableContentStyleWindow;
break;
case DisplayCapturePromptType::Screen:
[configuration setAllowedPickerModes:SCContentSharingPickerModeSingleDisplay];
shareableContentStyle = SCShareableContentStyleDisplay;
break;
case DisplayCapturePromptType::UserChoose:
[configuration setAllowedPickerModes:SCContentSharingPickerModeSingleWindow | SCContentSharingPickerModeSingleDisplay];
shareableContentStyle = SCShareableContentStyleNone;
break;
}

Expand All @@ -449,7 +461,11 @@ - (void)stopObservingPicker:(SCContentSharingPicker *)picker
picker.maximumStreamCount = @(1);
picker.defaultConfiguration = configuration.get();
[m_promptHelper startObservingPicker:picker];
[picker present];

if (shareableContentStyle != SCShareableContentStyleNone && [picker respondsToSelector:@selector(presentPickerUsingContentStyle:)])
[picker presentPickerUsingContentStyle:shareableContentStyle];
else
[picker present];

return true;
#else
Expand Down

0 comments on commit 4d3b19c

Please sign in to comment.