Fix mouse not being shared with Handgouts on Win10
When setting display scale to 200%, the mouse was shared only
for the top left quarter.
Regressed since https://chromium-review.googlesource.com/641075.
Indeed frame->rect() takes into account scale_factor while the
frame is constructed with a size that does not take this scale
factor into account.
Also make sure to do a float disivison in DesktopFrame::scale_factor()
so that it returns 1.5 instead of 1 when dpi is 144 (i.e. 150%).
Bug: chromium:948362
Change-Id: Ic10f44946c9f1b53181244a44a5b45109c259f9f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130371
Reviewed-by: Brave Yao <braveyao@webrtc.org>
Commit-Queue: Julien Isorce <julien.isorce@chromium.org>
Cr-Commit-Position: refs/heads/master@{#27424}
diff --git a/modules/desktop_capture/desktop_frame.cc b/modules/desktop_capture/desktop_frame.cc
index 2758ffa..eaee0aa 100644
--- a/modules/desktop_capture/desktop_frame.cc
+++ b/modules/desktop_capture/desktop_frame.cc
@@ -69,8 +69,13 @@
float DesktopFrame::scale_factor() const {
float scale = 1.0f;
+
+#if defined(WEBRTC_MAC)
+ // At least on Windows the logical and physical pixel are the same
+ // See http://crbug.com/948362.
if (!dpi().is_zero() && dpi().x() == dpi().y())
scale = dpi().x() / kStandardDPI;
+#endif
return scale;
}
diff --git a/modules/desktop_capture/desktop_frame.h b/modules/desktop_capture/desktop_frame.h
index 5c595a5..ef5ed72 100644
--- a/modules/desktop_capture/desktop_frame.h
+++ b/modules/desktop_capture/desktop_frame.h
@@ -22,7 +22,7 @@
namespace webrtc {
-const int kStandardDPI = 96;
+const float kStandardDPI = 96.0f;
// DesktopFrame represents a video frame captured from the screen.
class RTC_EXPORT DesktopFrame {