Commit 43262f95 authored by Yuwei Huang's avatar Yuwei Huang Committed by Commit Bot

[Remoting Mobile] Move the minimum portrait resolution checking logic to ChromotingSession

This CL moves the logic of ignoring client resolution of a portrait mode
phone screen into ChromotingSession, so that the Android client can get
this for free.

Bug: 874626
Change-Id: I0bf946c8a2ba5ce52e70b54b06517a3334f5727e
Reviewed-on: https://chromium-review.googlesource.com/1187802
Commit-Queue: Yuwei Huang <yuweih@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586001}
parent 8a3fad51
...@@ -55,6 +55,13 @@ const int kMinDimension = 640; ...@@ -55,6 +55,13 @@ const int kMinDimension = 640;
// Interval at which to log performance statistics, if enabled. // Interval at which to log performance statistics, if enabled.
constexpr base::TimeDelta kPerfStatsInterval = base::TimeDelta::FromMinutes(1); constexpr base::TimeDelta kPerfStatsInterval = base::TimeDelta::FromMinutes(1);
bool IsClientResolutionValid(int dips_width, int dips_height) {
// This prevents sending resolution on a portrait mode small phone screen
// because resizing the remote desktop to portrait will mess with icons and
// such on the desktop and it probably isn't what the user wants.
return (dips_width >= dips_height) || (dips_width >= kMinDimension);
}
// Normalizes the resolution so that both dimensions are not smaller than // Normalizes the resolution so that both dimensions are not smaller than
// kMinDimension. // kMinDimension.
void NormalizeClientResolution(protocol::ClientResolution* resolution) { void NormalizeClientResolution(protocol::ClientResolution* resolution) {
...@@ -277,6 +284,10 @@ void ChromotingSession::Core::SendClientResolution(int dips_width, ...@@ -277,6 +284,10 @@ void ChromotingSession::Core::SendClientResolution(int dips_width,
int dips_height, int dips_height,
float scale) { float scale) {
DCHECK(network_task_runner()->BelongsToCurrentThread()); DCHECK(network_task_runner()->BelongsToCurrentThread());
if (!IsClientResolutionValid(dips_width, dips_height)) {
return;
}
protocol::ClientResolution client_resolution; protocol::ClientResolution client_resolution;
client_resolution.set_dips_width(dips_width); client_resolution.set_dips_width(dips_width);
client_resolution.set_dips_height(dips_height); client_resolution.set_dips_height(dips_height);
......
...@@ -407,14 +407,7 @@ static NSString* const kFeedbackContext = @"InSessionFeedbackContext"; ...@@ -407,14 +407,7 @@ static NSString* const kFeedbackContext = @"InSessionFeedbackContext";
} }
- (void)resizeHostToFitIfNeeded { - (void)resizeHostToFitIfNeeded {
// Don't adjust if it's the phone and in portrait orientation because UI looks if (_settings.shouldResizeHostToFit) {
// too tight.
BOOL isPhonePortrait =
self.traitCollection.horizontalSizeClass ==
UIUserInterfaceSizeClassCompact &&
self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassRegular;
if (_settings.shouldResizeHostToFit && !isPhonePortrait) {
UIEdgeInsets safeInsets = remoting::SafeAreaInsetsForView(_hostView); UIEdgeInsets safeInsets = remoting::SafeAreaInsetsForView(_hostView);
CGRect safeRect = UIEdgeInsetsInsetRect(_hostView.frame, safeInsets); CGRect safeRect = UIEdgeInsetsInsetRect(_hostView.frame, safeInsets);
[_client setHostResolution:safeRect.size [_client setHostResolution:safeRect.size
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment