Commit e0e48885 authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

ws: Fix scaling in DesktopWindowTreeHostMus during Init

Initialize the cached display device scale factor before usage.
Otherwise, the scale factor is 1 and the window is misplaced/sized.

I'll land a unit test separately, to make merging easier.

Bug: 899084, 665965
Test: KSV (Ctrl-Alt-/) search context menu supports display & UI scales.
Change-Id: Ie74cb70af33110aa09022d4dbb5c6d0069b6cc7c
Reviewed-on: https://chromium-review.googlesource.com/c/1311080
Commit-Queue: Michael Wasserman <msw@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605543}
parent f4f9b683
...@@ -348,6 +348,11 @@ WindowTreeHost::WindowTreeHost(std::unique_ptr<Window> window) ...@@ -348,6 +348,11 @@ WindowTreeHost::WindowTreeHost(std::unique_ptr<Window> window)
display::Screen::GetScreen()->AddObserver(this); display::Screen::GetScreen()->AddObserver(this);
} }
void WindowTreeHost::IntializeDeviceScaleFactor(float device_scale_factor) {
DCHECK(!compositor_->root_layer()) << "Only call this before InitHost()";
device_scale_factor_ = device_scale_factor;
}
void WindowTreeHost::DestroyCompositor() { void WindowTreeHost::DestroyCompositor() {
if (compositor_) { if (compositor_) {
compositor_->RemoveObserver(this); compositor_->RemoveObserver(this);
......
...@@ -248,6 +248,10 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate, ...@@ -248,6 +248,10 @@ class AURA_EXPORT WindowTreeHost : public ui::internal::InputMethodDelegate,
explicit WindowTreeHost(std::unique_ptr<Window> window = nullptr); explicit WindowTreeHost(std::unique_ptr<Window> window = nullptr);
// Set the cached display device scale factor. This should only be called
// during subclass initialization, when the value is needed before InitHost().
void IntializeDeviceScaleFactor(float device_scale_factor);
void DestroyCompositor(); void DestroyCompositor();
void DestroyDispatcher(); void DestroyDispatcher();
......
...@@ -421,8 +421,11 @@ void DesktopWindowTreeHostMus::Init(const Widget::InitParams& params) { ...@@ -421,8 +421,11 @@ void DesktopWindowTreeHostMus::Init(const Widget::InitParams& params) {
if (params.show_state != ui::SHOW_STATE_DEFAULT) if (params.show_state != ui::SHOW_STATE_DEFAULT)
window()->SetProperty(aura::client::kShowStateKey, params.show_state); window()->SetProperty(aura::client::kShowStateKey, params.show_state);
if (!params.bounds.IsEmpty()) if (!params.bounds.IsEmpty()) {
// Init the scale now (before InitHost below), it is used by SetBoundsInDIP.
IntializeDeviceScaleFactor(GetDisplay().device_scale_factor());
SetBoundsInDIP(params.bounds); SetBoundsInDIP(params.bounds);
}
cursor_manager_ = std::make_unique<wm::CursorManager>( cursor_manager_ = std::make_unique<wm::CursorManager>(
std::make_unique<NativeCursorManagerMus>(window())); std::make_unique<NativeCursorManagerMus>(window()));
......
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