Chromium Code Reviews| Index: ui/aura/mus/window_tree_client.cc |
| diff --git a/ui/aura/mus/window_tree_client.cc b/ui/aura/mus/window_tree_client.cc |
| index 6f6c35090eac6685e39216ac8f3fa86a5eb27309..bcd86c362e4cceffd5a2cbabd5c8fe530b65c902 100644 |
| --- a/ui/aura/mus/window_tree_client.cc |
| +++ b/ui/aura/mus/window_tree_client.cc |
| @@ -134,10 +134,8 @@ void SetWindowTypeFromProperties( |
| } |
| // Helper function to get the device_scale_factor() of the display::Display |
| -// with |display_id|. |
| +// nearest to |window|. |
| float ScaleFactorForDisplay(Window* window) { |
| - // TODO(riajiang): Change to use display::GetDisplayWithDisplayId() after |
| - // https://codereview.chromium.org/2361283002/ is landed. |
| return display::Screen::GetScreen() |
| ->GetDisplayNearestWindow(window) |
| .device_scale_factor(); |
| @@ -645,7 +643,11 @@ void WindowTreeClient::OnWindowMusBoundsChanged(WindowMus* window, |
| if (IsRoot(window)) |
| return; |
| - ScheduleInFlightBoundsChange(window, old_bounds, new_bounds); |
| + ScheduleInFlightBoundsChange( |
| + window, gfx::ConvertRectToPixel( |
| + ScaleFactorForDisplay(window->GetWindow()), old_bounds), |
| + gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()), |
| + new_bounds)); |
| } |
| void WindowTreeClient::OnWindowMusAddChild(WindowMus* parent, |
| @@ -922,7 +924,8 @@ void WindowTreeClient::OnTopLevelCreated(uint32_t change_id, |
| GetOldestInFlightChangeMatching(bounds_change); |
| if (current_change) |
| current_change->SetRevertValueFrom(bounds_change); |
| - else if (window->GetWindow()->bounds() != bounds) |
| + else if (gfx::ConvertRectToPixel(ScaleFactorForDisplay(window->GetWindow()), |
| + window->GetWindow()->bounds()) != bounds) |
|
sadrul
2016/12/16 18:14:08
Some conversions are happening in WindowPortMus, a
riajiang
2016/12/19 23:51:55
Moved all conversions in WTC. ServerChangeData now
|
| SetWindowBoundsFromServer(window, bounds); |
| } |
| @@ -1344,24 +1347,26 @@ void WindowTreeClient::WmDisplayModified(const display::Display& display) { |
| window_manager_delegate_->OnWmDisplayModified(display); |
| } |
| -// TODO(riajiang): Convert between pixel and DIP for window bounds properly. |
| -// (http://crbug.com/646942) |
| void WindowTreeClient::WmSetBounds(uint32_t change_id, |
| Id window_id, |
| const gfx::Rect& transit_bounds) { |
|
sky
2016/12/15 22:07:32
Rename to transit_bounds_in_pixels.
riajiang
2016/12/19 23:51:55
Done.
|
| WindowMus* window = GetWindowByServerId(window_id); |
| bool result = false; |
| if (window) { |
| + float device_scale_factor = ScaleFactorForDisplay(window->GetWindow()); |
| DCHECK(window_manager_delegate_); |
| - gfx::Rect bounds = transit_bounds; |
| + gfx::Rect transit_bounds_in_dip = |
| + gfx::ConvertRectToDIP(device_scale_factor, transit_bounds); |
| + gfx::Rect bounds_in_dip = transit_bounds_in_dip; |
| // TODO: this needs to trigger scheduling a bounds change on |window|. |
| - result = |
| - window_manager_delegate_->OnWmSetBounds(window->GetWindow(), &bounds); |
| + result = window_manager_delegate_->OnWmSetBounds(window->GetWindow(), |
| + &bounds_in_dip); |
| if (result) { |
| // If the resulting bounds differ return false. Returning false ensures |
| // the client applies the bounds we set below. |
| - result = bounds == transit_bounds; |
| - window->SetBoundsFromServer(bounds); |
| + result = bounds_in_dip == transit_bounds_in_dip; |
| + window->SetBoundsFromServer( |
| + gfx::ConvertRectToPixel(device_scale_factor, bounds_in_dip)); |
|
sky
2016/12/15 22:07:32
I think you should fix 672151 before this, otherwi
riajiang
2016/12/19 23:51:55
As discussed, ignoring this comment.
|
| } |
| } |
| if (window_manager_internal_client_) |
| @@ -1525,11 +1530,11 @@ void WindowTreeClient::SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| const gfx::Vector2d& offset, |
| const gfx::Insets& hit_area) { |
| if (window_manager_internal_client_) { |
| - // TODO(riajiang): Figure out if |offset| needs to be converted. |
| - // (http://crbugs.com/646932) |
| + float device_scale_factor = ScaleFactorForDisplay(window); |
| window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| - WindowMus::Get(window)->server_id(), offset.x(), offset.y(), |
| - gfx::ConvertInsetsToDIP(ScaleFactorForDisplay(window), hit_area)); |
| + WindowMus::Get(window)->server_id(), offset.x() * device_scale_factor, |
| + offset.y() * device_scale_factor, |
| + gfx::ConvertInsetsToPixel(device_scale_factor, hit_area)); |
| } |
| } |