Commit 576387b5 authored by Zakhar Voit's avatar Zakhar Voit Committed by Commit Bot

[exo] Apply the correct scaling for cursor bitmap

This patch makes sure that cursor bitmap received via
wl_pointer_set_cursor is scaled correctly before creating the
corresponding PlatformCursor.

The previous approach had two issues:
1. The cursor size was incorrect for scale less than 200% since we used
default DSF (ManagedDisplayInfo::GetDensityRatio()) instead of the
effective one (Display::device_scale_factor()). This led to cursor
always being upscaled to 200%.
2. We didn't use the same logic that ash uses for scaling cursors:
ui::GetScaleForScaleFactor() + ui::GetSupportedScaleFactor(). So the
cursor size was different from ash when using fractional scale.

Bug: 1140175
Change-Id: Id034cb6d92718a01e3ac0a70047b1e4224b9cf96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485157Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Zakhar Voit <zvoit@igalia.com>
Cr-Commit-Position: refs/heads/master@{#819517}
parent e3b28bdb
......@@ -30,8 +30,9 @@
#include "ui/base/cursor/cursor_size.h"
#include "ui/base/cursor/cursor_util.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/layout.h"
#include "ui/base/resource/scale_factor.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/manager/managed_display_info.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
......@@ -750,10 +751,12 @@ void Pointer::UpdateCursor() {
// TODO(oshima|weidongg): Add cutsom cursor API to handle size/display
// change without explicit management like this. https://crbug.com/721601.
const display::Display& display = cursor_client->GetDisplay();
float scale =
helper->GetDisplayInfo(display.id()).GetDensityRatio() / capture_ratio_;
// Scaling bitmap to match the corresponding supported scale factor of ash.
const display::Display& display = cursor_client->GetDisplay();
float scale = ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(
display.device_scale_factor())) /
capture_scale_;
if (cursor_client->GetCursorSize() == ui::CursorSize::kLarge)
scale *= kLargeCursorScale;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment