Commit 280f616d authored by Henrique Ferreiro's avatar Henrique Ferreiro Committed by Commit Bot

Make Lacros cursor scale factor match the one in Ash

Ash limits the cursor scale factor to the available resource scale
factors, currently 100P and 200P. Lacros should follow this behavior;
otherwise, the cursor may change sizes when hovering a Lacros window.

Bug: 1127962
Change-Id: I17c0ded04153dd10efb7b90665e1426634c9a7af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2461227
Commit-Queue: Henrique Ferreiro <hferreiro@igalia.com>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816502}
parent 29138de1
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//build/buildflag_header.gni") import("//build/buildflag_header.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni") import("//build/config/features.gni")
import("//build/config/ozone.gni") import("//build/config/ozone.gni")
import("//build/config/ui.gni") import("//build/config/ui.gni")
...@@ -761,6 +762,8 @@ component("views") { ...@@ -761,6 +762,8 @@ component("views") {
"//ui/base/cursor", "//ui/base/cursor",
"//ui/base/cursor/mojom:cursor_type", "//ui/base/cursor/mojom:cursor_type",
] ]
deps += [ "//build:chromeos_buildflags" ]
if (use_x11) { if (use_x11) {
public_deps += [ public_deps += [
"//ui/base/x", "//ui/base/x",
...@@ -784,6 +787,9 @@ component("views") { ...@@ -784,6 +787,9 @@ component("views") {
public += [ "widget/desktop_aura/desktop_screen_ozone.h" ] public += [ "widget/desktop_aura/desktop_screen_ozone.h" ]
sources += [ "widget/desktop_aura/desktop_screen_ozone.cc" ] sources += [ "widget/desktop_aura/desktop_screen_ozone.cc" ]
} }
if (is_lacros) {
deps += [ "//ui/base:ui_data_pack" ]
}
if (is_linux || is_chromeos) { if (is_linux || is_chromeos) {
public += [ "widget/desktop_aura/desktop_window_tree_host_linux.h" ] public += [ "widget/desktop_aura/desktop_window_tree_host_linux.h" ]
sources += [ sources += [
......
...@@ -7,11 +7,17 @@ ...@@ -7,11 +7,17 @@
#include <utility> #include <utility>
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "build/chromeos_buildflags.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor_loader.h" #include "ui/base/cursor/cursor_loader.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h" #include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#if BUILDFLAG(IS_LACROS)
#include "ui/base/layout.h"
#include "ui/base/resource/scale_factor.h"
#endif
namespace views { namespace views {
DesktopNativeCursorManager::DesktopNativeCursorManager() { DesktopNativeCursorManager::DesktopNativeCursorManager() {
...@@ -43,8 +49,14 @@ void DesktopNativeCursorManager::RemoveHost(aura::WindowTreeHost* host) { ...@@ -43,8 +49,14 @@ void DesktopNativeCursorManager::RemoveHost(aura::WindowTreeHost* host) {
void DesktopNativeCursorManager::SetDisplay( void DesktopNativeCursorManager::SetDisplay(
const display::Display& display, const display::Display& display,
wm::NativeCursorManagerDelegate* delegate) { wm::NativeCursorManagerDelegate* delegate) {
cursor_loader_->SetDisplayData(display.rotation(), float cursor_scale = display.device_scale_factor();
display.device_scale_factor()); #if BUILDFLAG(IS_LACROS)
// Use the nearest resource scale factor, as Ash does, so that the cursor
// doesn't change its size when hovering a Lacros window.
cursor_scale =
ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(cursor_scale));
#endif
cursor_loader_->SetDisplayData(display.rotation(), cursor_scale);
SetCursor(delegate->GetCursor(), delegate); SetCursor(delegate->GetCursor(), delegate);
} }
......
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