Commit 1516b047 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Commit Bot

exo: Commit ClientControlledShellSurface scale in tablet mode

When the display's device_scale_factor changes in tablet mode, we expect
that the app does not change its position on the screen, event in
split-screen mode.

However, when this happens, the bounds of the app in DP will change,
since the display size in DP changes. We need to ensure that the scale
in ClientControlledShellSurface gets updated before the DP bounds of the
surface changes, so that when the client is notified of the bounds
change, it will be scaled with the new scale factor.

The client's bounds changes in OnDeviceScaleFactorChanged(), which gets
called before the surface's OnDisplayMetricsChanged(). To ensure the
scale is updated before the bounds change, we set the scale in both
methods.

BUG=b:163424969
TEST=Change display scale with client app open in split-screen mode;
observe that the client app remains in the expected position.

Change-Id: I09ffccc9994357fdeba794041c2abf9274ef986b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391658Reviewed-by: default avatarMitsuru Oshima (Slow: gardener) <oshima@chromium.org>
Commit-Queue: Prabir Pradhan <prabirmsp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805612}
parent 1646cd51
......@@ -843,6 +843,15 @@ gfx::Size ClientControlledShellSurface::GetMaximumSize() const {
void ClientControlledShellSurface::OnDeviceScaleFactorChanged(float old_dsf,
float new_dsf) {
if (!use_default_scale_cancellation_) {
SetScale(new_dsf);
// Commit scale changes immediately if we expect that the window will not be
// resized.
if (widget_->IsMaximized() || widget_->IsFullscreen() ||
WMHelper::GetInstance()->InTabletMode())
CommitPendingScale();
}
views::View::OnDeviceScaleFactorChanged(old_dsf, new_dsf);
UpdateWidgetBounds();
......@@ -879,18 +888,19 @@ void ClientControlledShellSurface::OnDisplayMetricsChanged(
if (current_display.id() != new_display.id())
return;
bool in_tablet_mode = WMHelper::GetInstance()->InTabletMode();
if (!use_default_scale_cancellation_ &&
changed_metrics &
display::DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR) {
SetScale(new_display.device_scale_factor());
// Commit scale changes immediately if we expect that the window will not be
// resized.
if (frame_type_ != SurfaceFrameType::NORMAL || widget_->IsMaximized() ||
widget_->IsFullscreen())
if (widget_->IsMaximized() || widget_->IsFullscreen() || in_tablet_mode)
CommitPendingScale();
}
if (!WMHelper::GetInstance()->InTabletMode() || !widget_->IsActive() ||
if (!in_tablet_mode || !widget_->IsActive() ||
!(changed_metrics & display::DisplayObserver::DISPLAY_METRIC_ROTATION)) {
return;
}
......
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