From 3d9ec1fed4a71abfc7fe34ac87ab6d16a705381a Mon Sep 17 00:00:00 2001 From: "sergeyu@chromium.org" Date: Sat, 19 Apr 2014 00:25:35 +0000 Subject: [PATCH] Fix multi-monitor support in the screen capturer for Mac. This feature was broken in r5471. BUG=361919 R=jiayl@webrtc.org Committed: https://code.google.com/p/webrtc/source/detail?r=5937 Review URL: https://webrtc-codereview.appspot.com/12109004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5942 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../desktop_capture/mac/desktop_configuration.h | 5 +++-- .../desktop_capture/mac/desktop_configuration.mm | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/webrtc/modules/desktop_capture/mac/desktop_configuration.h b/webrtc/modules/desktop_capture/mac/desktop_configuration.h index 031d92de2..bb2339bb0 100644 --- a/webrtc/modules/desktop_capture/mac/desktop_configuration.h +++ b/webrtc/modules/desktop_capture/mac/desktop_configuration.h @@ -59,10 +59,11 @@ struct MacDesktopConfiguration { const MacDisplayConfiguration* FindDisplayConfigurationById( CGDirectDisplayID id); - // Bounds of the desktop in Density-Independent Pixels (DIPs). + // Bounds of the desktop excluding monitors with DPI settings different from + // the main monitor. In Density-Independent Pixels (DIPs). DesktopRect bounds; - // Bounds of the desktop in physical pixels. + // Same as bounds, but expressed in physical pixels. DesktopRect pixel_bounds; // Scale factor from DIPs to physical pixels. diff --git a/webrtc/modules/desktop_capture/mac/desktop_configuration.mm b/webrtc/modules/desktop_capture/mac/desktop_configuration.mm index 838973e42..35fa65be2 100644 --- a/webrtc/modules/desktop_capture/mac/desktop_configuration.mm +++ b/webrtc/modules/desktop_capture/mac/desktop_configuration.mm @@ -134,11 +134,15 @@ MacDesktopConfiguration MacDesktopConfiguration::GetCurrent(Origin origin) { // Add the display to the configuration. desktop_config.displays.push_back(display_config); - // Update the desktop bounds to account for this display. - desktop_config.bounds = - JoinRects(desktop_config.bounds, display_config.bounds); - desktop_config.pixel_bounds = - JoinRects(desktop_config.pixel_bounds, display_config.pixel_bounds); + // Update the desktop bounds to account for this display, unless the current + // display uses different DPI settings. + if (display_config.dip_to_pixel_scale == + desktop_config.dip_to_pixel_scale) { + desktop_config.bounds = + JoinRects(desktop_config.bounds, display_config.bounds); + desktop_config.pixel_bounds = + JoinRects(desktop_config.pixel_bounds, display_config.pixel_bounds); + } } return desktop_config;