Enable full screen windows to be shown in window picker for mac. Before this patch a full screen window can be shared if sharing is started before the window is entered into full screen mode, but not if it's already in full screen.
BUG=chromium:575990 TEST: Manual test using TextEdit full screen mode. Review URL: https://codereview.webrtc.org/1579213007 Cr-Commit-Position: refs/heads/master@{#11311}
This commit is contained in:
parent
95c8b401fd
commit
3a6bf2d68b
@ -15,7 +15,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/macutils.h"
|
||||
#include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
|
||||
#include "webrtc/modules/desktop_capture/mac/window_list_utils.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
|
||||
@ -26,56 +25,6 @@ namespace {
|
||||
|
||||
const int64_t kUpdateIntervalMs = 500;
|
||||
|
||||
// Returns true if the window is minimized.
|
||||
bool IsWindowMinimized(CGWindowID id) {
|
||||
CFArrayRef window_id_array =
|
||||
CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL);
|
||||
CFArrayRef window_array =
|
||||
CGWindowListCreateDescriptionFromArray(window_id_array);
|
||||
bool minimized = false;
|
||||
|
||||
if (window_array && CFArrayGetCount(window_array)) {
|
||||
CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
|
||||
CFArrayGetValueAtIndex(window_array, 0));
|
||||
CFBooleanRef on_screen = reinterpret_cast<CFBooleanRef>(
|
||||
CFDictionaryGetValue(window, kCGWindowIsOnscreen));
|
||||
|
||||
minimized = !on_screen;
|
||||
}
|
||||
|
||||
CFRelease(window_id_array);
|
||||
CFRelease(window_array);
|
||||
|
||||
return minimized;
|
||||
}
|
||||
|
||||
// Returns true if the window is occupying a full screen.
|
||||
bool IsWindowFullScreen(const MacDesktopConfiguration& desktop_config,
|
||||
CFDictionaryRef window) {
|
||||
bool fullscreen = false;
|
||||
|
||||
CFDictionaryRef bounds_ref = reinterpret_cast<CFDictionaryRef>(
|
||||
CFDictionaryGetValue(window, kCGWindowBounds));
|
||||
|
||||
CGRect bounds;
|
||||
if (bounds_ref &&
|
||||
CGRectMakeWithDictionaryRepresentation(bounds_ref, &bounds)) {
|
||||
for (MacDisplayConfigurations::const_iterator it =
|
||||
desktop_config.displays.begin();
|
||||
it != desktop_config.displays.end(); ++it) {
|
||||
if (it->bounds.equals(DesktopRect::MakeXYWH(bounds.origin.x,
|
||||
bounds.origin.y,
|
||||
bounds.size.width,
|
||||
bounds.size.height))) {
|
||||
fullscreen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fullscreen;
|
||||
}
|
||||
|
||||
std::string GetWindowTitle(CGWindowID id) {
|
||||
CFArrayRef window_id_array =
|
||||
CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL);
|
||||
|
||||
@ -59,4 +59,56 @@ bool GetWindowList(WindowCapturer::WindowList* windows) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns true if the window is occupying a full screen.
|
||||
bool IsWindowFullScreen(
|
||||
const MacDesktopConfiguration& desktop_config,
|
||||
CFDictionaryRef window) {
|
||||
bool fullscreen = false;
|
||||
CFDictionaryRef bounds_ref = reinterpret_cast<CFDictionaryRef>(
|
||||
CFDictionaryGetValue(window, kCGWindowBounds));
|
||||
|
||||
CGRect bounds;
|
||||
if (bounds_ref &&
|
||||
CGRectMakeWithDictionaryRepresentation(bounds_ref, &bounds)) {
|
||||
for (MacDisplayConfigurations::const_iterator it =
|
||||
desktop_config.displays.begin();
|
||||
it != desktop_config.displays.end(); ++it) {
|
||||
if (it->bounds.equals(DesktopRect::MakeXYWH(bounds.origin.x,
|
||||
bounds.origin.y,
|
||||
bounds.size.width,
|
||||
bounds.size.height))) {
|
||||
fullscreen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fullscreen;
|
||||
}
|
||||
|
||||
// Returns true if the window is minimized.
|
||||
bool IsWindowMinimized(CGWindowID id) {
|
||||
CFArrayRef window_id_array =
|
||||
CFArrayCreate(NULL, reinterpret_cast<const void **>(&id), 1, NULL);
|
||||
CFArrayRef window_array =
|
||||
CGWindowListCreateDescriptionFromArray(window_id_array);
|
||||
bool minimized = false;
|
||||
|
||||
if (window_array && CFArrayGetCount(window_array)) {
|
||||
CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
|
||||
CFArrayGetValueAtIndex(window_array, 0));
|
||||
CFBooleanRef on_screen = reinterpret_cast<CFBooleanRef>(
|
||||
CFDictionaryGetValue(window, kCGWindowIsOnscreen));
|
||||
|
||||
minimized = !on_screen;
|
||||
}
|
||||
|
||||
CFRelease(window_id_array);
|
||||
CFRelease(window_array);
|
||||
|
||||
return minimized;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -11,6 +11,9 @@
|
||||
#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_WINDOW_LIST_UTILS_H_
|
||||
#define WEBRTC_MODULES_DESKTOP_CAPTURE_WINDOW_LIST_UTILS_H_
|
||||
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
|
||||
#include "webrtc/modules/desktop_capture/mac/desktop_configuration.h"
|
||||
#include "webrtc/modules/desktop_capture/window_capturer.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -18,6 +21,14 @@ namespace webrtc {
|
||||
// A helper function to get the on-screen windows.
|
||||
bool GetWindowList(WindowCapturer::WindowList* windows);
|
||||
|
||||
// Returns true if the window is occupying a full screen.
|
||||
bool IsWindowFullScreen(const MacDesktopConfiguration& desktop_config,
|
||||
CFDictionaryRef window);
|
||||
|
||||
// Returns true if the window is minimized.
|
||||
bool IsWindowMinimized(CGWindowID id);
|
||||
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_WINDOW_LIST_UTILS_H_
|
||||
|
||||
@ -82,11 +82,12 @@ WindowCapturerMac::~WindowCapturerMac() {
|
||||
bool WindowCapturerMac::GetWindowList(WindowList* windows) {
|
||||
// Only get on screen, non-desktop windows.
|
||||
CFArrayRef window_array = CGWindowListCopyWindowInfo(
|
||||
kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements,
|
||||
kCGWindowListExcludeDesktopElements,
|
||||
kCGNullWindowID);
|
||||
if (!window_array)
|
||||
return false;
|
||||
|
||||
MacDesktopConfiguration desktop_config = MacDesktopConfiguration::GetCurrent(
|
||||
MacDesktopConfiguration::TopLeftOrigin);
|
||||
// Check windows to make sure they have an id, title, and use window layer
|
||||
// other than 0.
|
||||
CFIndex count = CFArrayGetCount(window_array);
|
||||
@ -108,6 +109,11 @@ bool WindowCapturerMac::GetWindowList(WindowList* windows) {
|
||||
|
||||
int id;
|
||||
CFNumberGetValue(window_id, kCFNumberIntType, &id);
|
||||
|
||||
// Skip windows that are minimized and not full screen.
|
||||
if (IsWindowMinimized(id) &&
|
||||
!IsWindowFullScreen(desktop_config, window)) { continue;}
|
||||
|
||||
WindowCapturer::Window window;
|
||||
window.id = id;
|
||||
if (!rtc::ToUtf8(window_title, &(window.title)) ||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user