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 5e8b37d2d29ec593d7aa67ab8d9cea795e9fb481..37e41f4220750a6d595f2e8daa8d6b819f355123 100644 |
| --- a/ui/aura/mus/window_tree_client.cc |
| +++ b/ui/aura/mus/window_tree_client.cc |
| @@ -38,6 +38,7 @@ |
| #include "ui/display/display.h" |
| #include "ui/display/screen.h" |
| #include "ui/events/event.h" |
| +#include "ui/gfx/geometry/dip_util.h" |
| #include "ui/gfx/geometry/insets.h" |
| #include "ui/gfx/geometry/size.h" |
| @@ -117,6 +118,16 @@ bool IsInternalProperty(const void* key) { |
| return key == client::kModalKey; |
| } |
| +// Helper function to get the device_scale_factor() of the display::Display |
| +// with |display_id|. |
| +float DeviceScaleFactorForDisplay(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(); |
| +} |
| + |
| } // namespace |
| WindowTreeClient::WindowTreeClient( |
| @@ -204,13 +215,32 @@ void WindowTreeClient::SetClientArea( |
| const gfx::Insets& client_area, |
| const std::vector<gfx::Rect>& additional_client_areas) { |
| DCHECK(tree_); |
| - tree_->SetClientArea(WindowMus::Get(window)->server_id(), client_area, |
| - additional_client_areas); |
| + float device_scale_factor = DeviceScaleFactorForDisplay(window); |
| + if (device_scale_factor == 1.f) { |
| + tree_->SetClientArea(WindowMus::Get(window)->server_id(), client_area, |
| + additional_client_areas); |
| + } else { |
| + std::vector<gfx::Rect> additional_client_areas_in_pixel; |
| + for (const gfx::Rect& area : additional_client_areas) { |
| + additional_client_areas_in_pixel.push_back( |
| + gfx::ConvertRectToPixel(device_scale_factor, area)); |
| + } |
| + tree_->SetClientArea( |
| + WindowMus::Get(window)->server_id(), |
| + gfx::ConvertInsetsToPixel(device_scale_factor, client_area), |
| + additional_client_areas_in_pixel); |
| + } |
| } |
| void WindowTreeClient::SetHitTestMask(Window* window, const gfx::Rect& mask) { |
| DCHECK(tree_); |
| - tree_->SetHitTestMask(WindowMus::Get(window)->server_id(), mask); |
| + float device_scale_factor = DeviceScaleFactorForDisplay(window); |
| + if (device_scale_factor == 1.f) { |
| + tree_->SetHitTestMask(WindowMus::Get(window)->server_id(), mask); |
| + } else { |
| + tree_->SetHitTestMask(WindowMus::Get(window)->server_id(), |
| + gfx::ConvertRectToPixel(device_scale_factor, mask)); |
| + } |
| } |
| void WindowTreeClient::ClearHitTestMask(Window* window) { |
| @@ -947,6 +977,7 @@ void WindowTreeClient::OnClientAreaChanged( |
| const gfx::Insets& new_client_area, |
| mojo::Array<gfx::Rect> new_additional_client_areas) { |
| // TODO: client area. |
| + // TODO(riajiang): Convert from pixel to DIP. |
|
sky
2016/11/09 23:22:57
Reference bugs.
riajiang
2016/11/10 19:16:08
Done.
|
| /* |
| Window* window = GetWindowByServerId(window_id); |
| if (window) { |
| @@ -1305,6 +1336,7 @@ void WindowTreeClient::WmDisplayModified(const display::Display& display) { |
| window_manager_delegate_->OnWmDisplayModified(display); |
| } |
| +// TODO(riajiang): Convert between pixel and DIP for window bounds properly. |
| void WindowTreeClient::WmSetBounds(uint32_t change_id, |
| Id window_id, |
| const gfx::Rect& transit_bounds) { |
| @@ -1471,8 +1503,18 @@ void WindowTreeClient::SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| const gfx::Vector2d& offset, |
| const gfx::Insets& hit_area) { |
| if (window_manager_internal_client_) { |
| - window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| - WindowMus::Get(window)->server_id(), offset.x(), offset.y(), hit_area); |
| + float device_scale_factor = DeviceScaleFactorForDisplay(window); |
| + if (device_scale_factor == 1.f) { |
| + window_manager_internal_client_ |
| + ->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| + WindowMus::Get(window)->server_id(), offset.x(), offset.y(), |
| + hit_area); |
| + } else { |
| + window_manager_internal_client_ |
| + ->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| + WindowMus::Get(window)->server_id(), offset.x(), offset.y(), |
| + gfx::ConvertInsetsToDIP(device_scale_factor, hit_area)); |
| + } |
| } |
| } |