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

Side by Side Diff: webrtc/modules/desktop_capture/window_capturer_mac.mm

Issue 2202883003: Icon Capture For Window Capturer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix windows crash Created 4 years, 4 months 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 }; 70 };
71 71
72 WindowCapturerMac::WindowCapturerMac( 72 WindowCapturerMac::WindowCapturerMac(
73 rtc::scoped_refptr<FullScreenChromeWindowDetector> 73 rtc::scoped_refptr<FullScreenChromeWindowDetector>
74 full_screen_chrome_window_detector) 74 full_screen_chrome_window_detector)
75 : full_screen_chrome_window_detector_(full_screen_chrome_window_detector) {} 75 : full_screen_chrome_window_detector_(full_screen_chrome_window_detector) {}
76 76
77 WindowCapturerMac::~WindowCapturerMac() {} 77 WindowCapturerMac::~WindowCapturerMac() {}
78 78
79 bool WindowCapturerMac::GetWindowList(WindowList* windows) { 79 bool WindowCapturerMac::GetWindowList(WindowList* windows) {
80 // Only get on screen, non-desktop windows. 80 return webrtc::GetWindowList(windows);
81 CFArrayRef window_array = CGWindowListCopyWindowInfo(
82 kCGWindowListExcludeDesktopElements,
83 kCGNullWindowID);
84 if (!window_array)
85 return false;
86 MacDesktopConfiguration desktop_config = MacDesktopConfiguration::GetCurrent(
87 MacDesktopConfiguration::TopLeftOrigin);
88 // Check windows to make sure they have an id, title, and use window layer
89 // other than 0.
90 CFIndex count = CFArrayGetCount(window_array);
91 for (CFIndex i = 0; i < count; ++i) {
92 CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
93 CFArrayGetValueAtIndex(window_array, i));
94 CFStringRef window_title = reinterpret_cast<CFStringRef>(
95 CFDictionaryGetValue(window, kCGWindowName));
96 CFNumberRef window_id = reinterpret_cast<CFNumberRef>(
97 CFDictionaryGetValue(window, kCGWindowNumber));
98 CFNumberRef window_layer = reinterpret_cast<CFNumberRef>(
99 CFDictionaryGetValue(window, kCGWindowLayer));
100 if (window_title && window_id && window_layer) {
101 // Skip windows with layer=0 (menu, dock).
102 int layer;
103 CFNumberGetValue(window_layer, kCFNumberIntType, &layer);
104 if (layer != 0)
105 continue;
106
107 int id;
108 CFNumberGetValue(window_id, kCFNumberIntType, &id);
109
110 // Skip windows that are minimized and not full screen.
111 if (IsWindowMinimized(id) &&
112 !IsWindowFullScreen(desktop_config, window)) { continue;}
113
114 WindowCapturer::Window window;
115 window.id = id;
116 if (!rtc::ToUtf8(window_title, &(window.title)) ||
117 window.title.empty()) {
118 continue;
119 }
120 windows->push_back(window);
121 }
122 }
123
124 CFRelease(window_array);
125 return true;
126 } 81 }
127 82
128 bool WindowCapturerMac::SelectWindow(WindowId id) { 83 bool WindowCapturerMac::SelectWindow(WindowId id) {
129 if (!IsWindowValid(id)) 84 if (!IsWindowValid(id))
130 return false; 85 return false;
131 window_id_ = id; 86 window_id_ = id;
132 return true; 87 return true;
133 } 88 }
134 89
135 bool WindowCapturerMac::BringSelectedWindowToFront() { 90 bool WindowCapturerMac::BringSelectedWindowToFront() {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 190 }
236 191
237 } // namespace 192 } // namespace
238 193
239 // static 194 // static
240 WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) { 195 WindowCapturer* WindowCapturer::Create(const DesktopCaptureOptions& options) {
241 return new WindowCapturerMac(options.full_screen_chrome_window_detector()); 196 return new WindowCapturerMac(options.full_screen_chrome_window_detector());
242 } 197 }
243 198
244 } // namespace webrtc 199 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698