Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: webrtc/modules/desktop_capture/mac/window_list_utils.cc

Issue 2479553006: Remove GetWindowList / GetScreenList and SelectWindow / SelectScreen from WebRTC (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/desktop_capture/mac/window_list_utils.h" 11 #include "webrtc/modules/desktop_capture/mac/window_list_utils.h"
12 12
13 #include <ApplicationServices/ApplicationServices.h> 13 #include <ApplicationServices/ApplicationServices.h>
14 14
15 #include "webrtc/base/macutils.h" 15 #include "webrtc/base/macutils.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 18
19 bool GetWindowList(WindowCapturer::WindowList* windows) { 19 bool GetWindowList(DesktopCapturer::SourceList* windows) {
Sergey Ulanov 2016/11/07 20:20:56 Style guide discourages overloaded. I don't think
Hzj_jie 2016/11/07 23:00:18 Done.
20 return GetWindowList(windows, false);
21 }
22
23 bool GetWindowList(DesktopCapturer::SourceList* windows,
24 bool ignore_minimized) {
20 // Only get on screen, non-desktop windows. 25 // Only get on screen, non-desktop windows.
21 CFArrayRef window_array = CGWindowListCopyWindowInfo( 26 CFArrayRef window_array = CGWindowListCopyWindowInfo(
22 kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, 27 kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements,
23 kCGNullWindowID); 28 kCGNullWindowID);
24 if (!window_array) 29 if (!window_array)
25 return false; 30 return false;
26 31
32 MacDesktopConfiguration desktop_config;
33 if (ignore_minimized) {
34 desktop_config = MacDesktopConfiguration::GetCurrent(
35 MacDesktopConfiguration::TopLeftOrigin);
36 }
37
27 // Check windows to make sure they have an id, title, and use window layer 38 // Check windows to make sure they have an id, title, and use window layer
28 // other than 0. 39 // other than 0.
29 CFIndex count = CFArrayGetCount(window_array); 40 CFIndex count = CFArrayGetCount(window_array);
30 for (CFIndex i = 0; i < count; ++i) { 41 for (CFIndex i = 0; i < count; ++i) {
31 CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>( 42 CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
32 CFArrayGetValueAtIndex(window_array, i)); 43 CFArrayGetValueAtIndex(window_array, i));
33 CFStringRef window_title = reinterpret_cast<CFStringRef>( 44 CFStringRef window_title = reinterpret_cast<CFStringRef>(
34 CFDictionaryGetValue(window, kCGWindowName)); 45 CFDictionaryGetValue(window, kCGWindowName));
35 CFNumberRef window_id = reinterpret_cast<CFNumberRef>( 46 CFNumberRef window_id = reinterpret_cast<CFNumberRef>(
36 CFDictionaryGetValue(window, kCGWindowNumber)); 47 CFDictionaryGetValue(window, kCGWindowNumber));
37 CFNumberRef window_layer = reinterpret_cast<CFNumberRef>( 48 CFNumberRef window_layer = reinterpret_cast<CFNumberRef>(
38 CFDictionaryGetValue(window, kCGWindowLayer)); 49 CFDictionaryGetValue(window, kCGWindowLayer));
39 if (window_title && window_id && window_layer) { 50 if (window_title && window_id && window_layer) {
40 // Skip windows with layer=0 (menu, dock). 51 // Skip windows with layer=0 (menu, dock).
41 int layer; 52 int layer;
42 CFNumberGetValue(window_layer, kCFNumberIntType, &layer); 53 CFNumberGetValue(window_layer, kCFNumberIntType, &layer);
43 if (layer != 0) 54 if (layer != 0)
44 continue; 55 continue;
45 56
46 int id; 57 int id;
47 CFNumberGetValue(window_id, kCFNumberIntType, &id); 58 CFNumberGetValue(window_id, kCFNumberIntType, &id);
48 WindowCapturer::Window window; 59
60 // Skip windows that are minimized and not full screen.
61 if (ignore_minimized && IsWindowMinimized(id) &&
62 !IsWindowFullScreen(desktop_config, window)) { continue; }
Sergey Ulanov 2016/11/07 20:20:56 Please move continue to a separate line.
Hzj_jie 2016/11/07 23:00:18 Done.
63
64 DesktopCapturer::Source window;
49 window.id = id; 65 window.id = id;
50 if (!rtc::ToUtf8(window_title, &(window.title)) || 66 if (!rtc::ToUtf8(window_title, &(window.title)) ||
51 window.title.empty()) { 67 window.title.empty()) {
52 continue; 68 continue;
53 } 69 }
54 windows->push_back(window); 70 windows->push_back(window);
55 } 71 }
56 } 72 }
57 73
58 CFRelease(window_array); 74 CFRelease(window_array);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 121
106 CFRelease(window_id_array); 122 CFRelease(window_id_array);
107 CFRelease(window_array); 123 CFRelease(window_array);
108 124
109 return minimized; 125 return minimized;
110 } 126 }
111 127
112 128
113 129
114 } // namespace webrtc 130 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698