OLD | NEW |
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, |
| 20 bool ignore_minimized) { |
20 // Only get on screen, non-desktop windows. | 21 // Only get on screen, non-desktop windows. |
21 CFArrayRef window_array = CGWindowListCopyWindowInfo( | 22 CFArrayRef window_array = CGWindowListCopyWindowInfo( |
22 kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, | 23 kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, |
23 kCGNullWindowID); | 24 kCGNullWindowID); |
24 if (!window_array) | 25 if (!window_array) |
25 return false; | 26 return false; |
26 | 27 |
| 28 MacDesktopConfiguration desktop_config; |
| 29 if (ignore_minimized) { |
| 30 desktop_config = MacDesktopConfiguration::GetCurrent( |
| 31 MacDesktopConfiguration::TopLeftOrigin); |
| 32 } |
| 33 |
27 // Check windows to make sure they have an id, title, and use window layer | 34 // Check windows to make sure they have an id, title, and use window layer |
28 // other than 0. | 35 // other than 0. |
29 CFIndex count = CFArrayGetCount(window_array); | 36 CFIndex count = CFArrayGetCount(window_array); |
30 for (CFIndex i = 0; i < count; ++i) { | 37 for (CFIndex i = 0; i < count; ++i) { |
31 CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>( | 38 CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>( |
32 CFArrayGetValueAtIndex(window_array, i)); | 39 CFArrayGetValueAtIndex(window_array, i)); |
33 CFStringRef window_title = reinterpret_cast<CFStringRef>( | 40 CFStringRef window_title = reinterpret_cast<CFStringRef>( |
34 CFDictionaryGetValue(window, kCGWindowName)); | 41 CFDictionaryGetValue(window, kCGWindowName)); |
35 CFNumberRef window_id = reinterpret_cast<CFNumberRef>( | 42 CFNumberRef window_id = reinterpret_cast<CFNumberRef>( |
36 CFDictionaryGetValue(window, kCGWindowNumber)); | 43 CFDictionaryGetValue(window, kCGWindowNumber)); |
37 CFNumberRef window_layer = reinterpret_cast<CFNumberRef>( | 44 CFNumberRef window_layer = reinterpret_cast<CFNumberRef>( |
38 CFDictionaryGetValue(window, kCGWindowLayer)); | 45 CFDictionaryGetValue(window, kCGWindowLayer)); |
39 if (window_title && window_id && window_layer) { | 46 if (window_title && window_id && window_layer) { |
40 // Skip windows with layer=0 (menu, dock). | 47 // Skip windows with layer=0 (menu, dock). |
41 int layer; | 48 int layer; |
42 CFNumberGetValue(window_layer, kCFNumberIntType, &layer); | 49 CFNumberGetValue(window_layer, kCFNumberIntType, &layer); |
43 if (layer != 0) | 50 if (layer != 0) |
44 continue; | 51 continue; |
45 | 52 |
46 int id; | 53 int id; |
47 CFNumberGetValue(window_id, kCFNumberIntType, &id); | 54 CFNumberGetValue(window_id, kCFNumberIntType, &id); |
48 WindowCapturer::Window window; | 55 |
| 56 // Skip windows that are minimized and not full screen. |
| 57 if (ignore_minimized && IsWindowMinimized(id) && |
| 58 !IsWindowFullScreen(desktop_config, window)) { |
| 59 continue; |
| 60 } |
| 61 |
| 62 DesktopCapturer::Source window; |
49 window.id = id; | 63 window.id = id; |
50 if (!rtc::ToUtf8(window_title, &(window.title)) || | 64 if (!rtc::ToUtf8(window_title, &(window.title)) || |
51 window.title.empty()) { | 65 window.title.empty()) { |
52 continue; | 66 continue; |
53 } | 67 } |
54 windows->push_back(window); | 68 windows->push_back(window); |
55 } | 69 } |
56 } | 70 } |
57 | 71 |
58 CFRelease(window_array); | 72 CFRelease(window_array); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 119 |
106 CFRelease(window_id_array); | 120 CFRelease(window_id_array); |
107 CFRelease(window_array); | 121 CFRelease(window_array); |
108 | 122 |
109 return minimized; | 123 return minimized; |
110 } | 124 } |
111 | 125 |
112 | 126 |
113 | 127 |
114 } // namespace webrtc | 128 } // namespace webrtc |
OLD | NEW |