mac-capture: Avoid inadvertent capture of screen content

This commit is contained in:
jcm
2026-01-14 12:22:41 -05:00
committed by Ryan Foster
parent 65afc7ae36
commit 4021c97619
3 changed files with 14 additions and 18 deletions
+12
View File
@@ -83,6 +83,10 @@ bool build_display_list(struct screen_capture *sc, obs_properties_t *props)
obs_property_t *display_list = obs_properties_get(props, "display_uuid");
obs_property_list_clear(display_list);
// Add null entry to the top of the content list, to avoid inadvertent capture of the first enumerated display
// when opening the source's properties window
obs_property_list_add_string(display_list, " ", NULL);
for (SCDisplay *display in sc->shareable_content.displays) {
NSScreen *display_screen = nil;
for (NSScreen *screen in NSScreen.screens) {
@@ -127,6 +131,10 @@ bool build_window_list(struct screen_capture *sc, obs_properties_t *props)
obs_property_t *window_list = obs_properties_get(props, "window");
obs_property_list_clear(window_list);
// Add null entry to the top of the content list, to avoid inadvertent capture of the first enumerated window
// when opening the source's properties window
obs_property_list_add_int(window_list, " ", kCGNullWindowID);
NSPredicate *filteredWindowPredicate =
[NSPredicate predicateWithBlock:^BOOL(SCWindow *window, NSDictionary *bindings __unused) {
NSString *app_name = window.owningApplication.applicationName;
@@ -173,6 +181,10 @@ bool build_application_list(struct screen_capture *sc, obs_properties_t *props)
obs_property_t *application_list = obs_properties_get(props, "application");
obs_property_list_clear(application_list);
// Add null entry to the top of the content list, to avoid inadvertent capture of the first enumerated application
// when opening the source's properties window
obs_property_list_add_string(application_list, " ", 0);
NSArray<SCRunningApplication *> *filteredApplications;
filteredApplications = [sc->shareable_content.applications
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(SCRunningApplication *app,
+1 -17
View File
@@ -392,24 +392,8 @@ API_AVAILABLE(macos(12.5)) static uint32_t sck_video_capture_getheight(void *dat
static void sck_video_capture_defaults(obs_data_t *settings)
{
CGDirectDisplayID initial_display = 0;
{
NSScreen *mainScreen = [NSScreen mainScreen];
if (mainScreen) {
NSNumber *screen_num = mainScreen.deviceDescription[@"NSScreenNumber"];
if (screen_num) {
initial_display = (CGDirectDisplayID) (uintptr_t) screen_num.pointerValue;
}
}
}
CFUUIDRef display_uuid = CGDisplayCreateUUIDFromDisplayID(initial_display);
CFStringRef uuid_string = CFUUIDCreateString(kCFAllocatorDefault, display_uuid);
obs_data_set_default_string(settings, "display_uuid", CFStringGetCStringPtr(uuid_string, kCFStringEncodingUTF8));
CFRelease(uuid_string);
CFRelease(display_uuid);
obs_data_set_default_string(settings, "application", NULL);
obs_data_set_default_string(settings, "display_uuid", NULL);
obs_data_set_default_int(settings, "type", ScreenCaptureDisplayStream);
obs_data_set_default_int(settings, "window", kCGNullWindowID);
obs_data_set_default_bool(settings, "show_cursor", true);
+1 -1
View File
@@ -267,7 +267,7 @@ CGDirectDisplayID get_display_migrate_settings(obs_data_t *settings)
}
const char *display_uuid = obs_data_get_string(settings, "display_uuid");
if (display_uuid) {
if (display_uuid && *display_uuid) {
CFStringRef uuid_string = CFStringCreateWithCString(kCFAllocatorDefault, display_uuid, kCFStringEncodingUTF8);
CFUUIDRef uuid_ref = CFUUIDCreateFromString(kCFAllocatorDefault, uuid_string);
CGDirectDisplayID display = CGDisplayGetDisplayIDFromUUID(uuid_ref);