未验证 提交 890d325d 编写于 作者: J Jim 提交者: GitHub

Merge pull request #3388 from timmiehaha/issue-3146

mac-capture: show actual windows in Window Capture sources
......@@ -18,6 +18,8 @@ typedef struct cocoa_window *cocoa_window_t;
NSArray *enumerate_cocoa_windows(void);
NSArray *filter_nonzero_kcgwindowlayer_sources(NSArray *windows_arr);
bool find_window(cocoa_window_t cw, obs_data_t *settings, bool force);
void init_window(cocoa_window_t cw, obs_data_t *settings);
......
......@@ -23,14 +23,25 @@ static NSComparator win_info_cmp = ^(NSDictionary *o1, NSDictionary *o2) {
return [o1[WINDOW_NUMBER] compare:o2[WINDOW_NUMBER]];
};
NSArray *filter_nonzero_kcgwindowlayer_sources(NSArray *windows_arr)
{
NSPredicate *pred =
[NSPredicate predicateWithFormat:@"(kCGWindowLayer == 0)"];
NSArray *new_windows_arr =
[windows_arr filteredArrayUsingPredicate:pred];
return new_windows_arr;
}
NSArray *enumerate_windows(void)
{
NSArray *arr = (NSArray *)CGWindowListCopyWindowInfo(
kCGWindowListOptionOnScreenOnly, kCGNullWindowID);
NSArray *filtered_arr = filter_nonzero_kcgwindowlayer_sources(arr);
[arr autorelease];
return [arr sortedArrayUsingComparator:win_info_cmp];
return [filtered_arr sortedArrayUsingComparator:win_info_cmp];
}
#define WAIT_TIME_MS 500
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册