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 auto screen = display::Screen::GetScreen(); | |
| 311 auto 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 auto display = screen->GetDisplayNearestWindow(widget_->GetNativeWindow()); |
|
reveman
2017/01/23 22:22:34
nit: Avoid "auto" here to make it clear what the t
Dominik Laskowski
2017/01/23 23:50:53
Done, and above too.
| |
| 312 display::Screen::GetScreen()->GetDisplayNearestWindow( | 315 float ui_scale = helper->GetDisplayInfo(display.id()).GetEffectiveUIScale(); |
| 313 widget_->GetNativeWindow()); | 316 |
|
reveman
2017/01/23 22:22:34
nit: is this blank line intentional? remove if not
Dominik Laskowski
2017/01/23 23:50:53
Removed in second patch.
| |
| 314 float ui_scale = WMHelper::GetInstance() | 317 float primary_dsf = screen->GetPrimaryDisplay().device_scale_factor(); |
|
reveman
2017/01/23 22:22:34
nit: remove abbreviation. s/primary_dsf/primary_de
Dominik Laskowski
2017/01/23 23:50:53
Done.
| |
| 315 ->GetDisplayInfo(display.id()) | 318 |
| 316 .GetEffectiveUIScale(); | 319 // The cursor is scaled down by the DSF of the primary display, and its |
|
reveman
2017/01/23 22:22:34
scaled up?
Dominik Laskowski
2017/01/23 23:50:53
I meant that the surface size is divided by the pr
| |
| 317 if (WMHelper::GetInstance()->GetCursorSet() == ui::CURSOR_SET_LARGE) | 320 // physical size is proportional to the DSF of the internal display. For |
| 321 // external displays (and the internal display when secondary to a display | |
| 322 // with a different DSF), scale the cursor so its physical size matches with | |
| 323 // the single display case. | |
| 324 if (!display.IsInternal() || display.device_scale_factor() != primary_dsf) { | |
| 325 auto info = helper->GetDisplayInfo(display::Display::InternalDisplayId()); | |
|
reveman
2017/01/23 22:22:34
nit: maybe internal_display_device_scale_factor in
Dominik Laskowski
2017/01/23 23:50:53
Removed variable.
| |
| 326 ui_scale *= primary_dsf / info.device_scale_factor(); | |
| 327 } | |
| 328 | |
| 329 if (helper->GetCursorSet() == ui::CURSOR_SET_LARGE) | |
| 318 ui_scale *= kLargeCursorScale; | 330 ui_scale *= kLargeCursorScale; |
| 319 | 331 |
| 320 if (ui_scale != cursor_scale_) { | 332 if (ui_scale != cursor_scale_) { |
| 321 gfx::Transform transform; | 333 gfx::Transform transform; |
| 322 transform.Scale(ui_scale, ui_scale); | 334 transform.Scale(ui_scale, ui_scale); |
| 323 widget_->GetNativeWindow()->SetTransform(transform); | 335 widget_->GetNativeWindow()->SetTransform(transform); |
| 324 cursor_scale_ = ui_scale; | 336 cursor_scale_ = ui_scale; |
| 325 } | 337 } |
| 326 } | 338 } |
| 327 | 339 |
| 328 } // namespace exo | 340 } // namespace exo |
| OLD | NEW |