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 if (display::Display::HasInternalDisplay()) { |
| 316 .GetEffectiveUIScale(); | 319 float primary_device_scale_factor = |
| 317 if (WMHelper::GetInstance()->GetCursorSet() == ui::CURSOR_SET_LARGE) | 320 screen->GetPrimaryDisplay().device_scale_factor(); |
| 321 | |
| 322 // The size of the cursor surface is the quotient of its physical size and | |
| 323 // the DSF of the primary display. The physical size is proportional to the | |
| 324 // DSF of the internal display. For external displays (and the internal | |
| 325 // display when secondary to a display with a different DSF), scale the | |
| 326 // cursor so its physical size matches with the single display case. | |
| 327 if (!display.IsInternal() || | |
|
oshima
2017/01/24 20:48:19
Isn't this && ?
Dominik Laskowski
2017/01/24 22:14:34
No, we want to avoid scaling if:
1) The window is
oshima
2017/01/25 21:16:01
The size of the cursor should be same (50x50 pixel
| |
| 328 display.device_scale_factor() != primary_device_scale_factor) { | |
|
oshima
2017/01/24 20:48:19
My understanding was that if the android scale fac
Dominik Laskowski
2017/01/24 22:14:34
It's a bit more complicated because:
1) HWC divid
| |
| 329 ui_scale *= primary_device_scale_factor / | |
| 330 helper->GetDisplayInfo(display::Display::InternalDisplayId()) | |
| 331 .device_scale_factor(); | |
| 332 } | |
| 333 } | |
| 334 | |
| 335 if (helper->GetCursorSet() == ui::CURSOR_SET_LARGE) | |
| 318 ui_scale *= kLargeCursorScale; | 336 ui_scale *= kLargeCursorScale; |
| 319 | 337 |
| 320 if (ui_scale != cursor_scale_) { | 338 if (ui_scale != cursor_scale_) { |
| 321 gfx::Transform transform; | 339 gfx::Transform transform; |
| 322 transform.Scale(ui_scale, ui_scale); | 340 transform.Scale(ui_scale, ui_scale); |
| 323 widget_->GetNativeWindow()->SetTransform(transform); | 341 widget_->GetNativeWindow()->SetTransform(transform); |
| 324 cursor_scale_ = ui_scale; | 342 cursor_scale_ = ui_scale; |
| 325 } | 343 } |
| 326 } | 344 } |
| 327 | 345 |
| 328 } // namespace exo | 346 } // namespace exo |
| OLD | NEW |