Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/exo/pointer.h" | 5 #include "components/exo/pointer.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "components/exo/pointer_delegate.h" | 8 #include "components/exo/pointer_delegate.h" |
| 9 #include "components/exo/pointer_stylus_delegate.h" | 9 #include "components/exo/pointer_stylus_delegate.h" |
| 10 #include "components/exo/surface.h" | 10 #include "components/exo/surface.h" |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 if (!target) | 300 if (!target) |
| 301 return nullptr; | 301 return nullptr; |
| 302 | 302 |
| 303 return delegate_->CanAcceptPointerEventsForSurface(target) ? target : nullptr; | 303 return delegate_->CanAcceptPointerEventsForSurface(target) ? target : nullptr; |
| 304 } | 304 } |
| 305 | 305 |
| 306 void Pointer::UpdateCursorScale() { | 306 void Pointer::UpdateCursorScale() { |
| 307 if (!focus_) | 307 if (!focus_) |
| 308 return; | 308 return; |
| 309 | 309 |
| 310 display::Screen* screen = display::Screen::GetScreen(); | |
| 311 WMHelper* helper = WMHelper::GetInstance(); | |
| 312 | |
| 310 // Update cursor scale if the effective UI scale has changed. | 313 // Update cursor scale if the effective UI scale has changed. |
| 311 display::Display display = | 314 display::Display display = |
| 312 display::Screen::GetScreen()->GetDisplayNearestWindow( | 315 screen->GetDisplayNearestWindow(widget_->GetNativeWindow()); |
| 313 widget_->GetNativeWindow()); | 316 float ui_scale = helper->GetDisplayInfo(display.id()).GetEffectiveUIScale(); |
| 314 float ui_scale = WMHelper::GetInstance() | 317 |
| 315 ->GetDisplayInfo(display.id()) | 318 // TODO(domlaskowski): Density in ARC is currently configured at build time, |
| 316 .GetEffectiveUIScale(); | 319 // but it should be dynamic to support devices without an internal display. |
|
reveman
2017/01/24 00:16:01
nit: I don't think this TODO belongs here as the c
Dominik Laskowski
2017/01/24 00:20:36
Done.
| |
| 317 if (WMHelper::GetInstance()->GetCursorSet() == ui::CURSOR_SET_LARGE) | 320 if (display::Display::HasInternalDisplay()) { |
| 321 float primary_device_scale_factor = | |
| 322 screen->GetPrimaryDisplay().device_scale_factor(); | |
| 323 | |
| 324 // The size of the cursor surface is the quotient of its physical size and | |
| 325 // the DSF of the primary display. The physical size is proportional to the | |
| 326 // DSF of the internal display. For external displays (and the internal | |
| 327 // display when secondary to a display with a different DSF), scale the | |
| 328 // cursor so its physical size matches with the single display case. | |
| 329 if (!display.IsInternal() || | |
| 330 display.device_scale_factor() != primary_device_scale_factor) { | |
| 331 ui_scale *= primary_device_scale_factor / | |
| 332 helper->GetDisplayInfo(display::Display::InternalDisplayId()) | |
| 333 .device_scale_factor(); | |
| 334 } | |
| 335 } | |
| 336 | |
| 337 if (helper->GetCursorSet() == ui::CURSOR_SET_LARGE) | |
| 318 ui_scale *= kLargeCursorScale; | 338 ui_scale *= kLargeCursorScale; |
| 319 | 339 |
| 320 if (ui_scale != cursor_scale_) { | 340 if (ui_scale != cursor_scale_) { |
| 321 gfx::Transform transform; | 341 gfx::Transform transform; |
| 322 transform.Scale(ui_scale, ui_scale); | 342 transform.Scale(ui_scale, ui_scale); |
| 323 widget_->GetNativeWindow()->SetTransform(transform); | 343 widget_->GetNativeWindow()->SetTransform(transform); |
| 324 cursor_scale_ = ui_scale; | 344 cursor_scale_ = ui_scale; |
| 325 } | 345 } |
| 326 } | 346 } |
| 327 | 347 |
| 328 } // namespace exo | 348 } // namespace exo |
| OLD | NEW |