Skip to content

Commit

Permalink
Rollback GetRootTransform change and dependent changes
Browse files Browse the repository at this point in the history
Changes to GetRootTransform and OnHostResizedInPixels
caused regression in linux-wayland and windows and this, so
I'm reverting these changes for now.

I will come up with a different approach.

Bug: 1333437, 1329481
Change-Id: Ia98870a342bad3dad41905a99eb533955b1fb552
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3710772
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1016240}
  • Loading branch information
mitoshima authored and Chromium LUCI CQ committed Jun 21, 2022
1 parent 9b35f59 commit 808f40a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
6 changes: 0 additions & 6 deletions ui/ozone/platform/wayland/host/wayland_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -659,12 +659,6 @@ void WaylandWindow::OnEnteredOutput() {
if (AsWaylandPopup())
return;

// Notify normal window's delegate only as updating the pixel bounds
// may close the popup, and popup will not usually enter new display.
// TODO(crbug.com/1306688): Revisit this when wayland implementation
// is switced to dip based.
delegate()->OnMovedToAnotherDisplay();

UpdateWindowScale(true);
}

Expand Down
8 changes: 6 additions & 2 deletions ui/ozone/platform/x11/x11_screen_ozone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ display::Display X11ScreenOzone::GetDisplayForAcceleratedWidget(
return GetPrimaryDisplay();

X11Window* window = window_manager_->GetWindow(widget);
if (window)
return GetDisplayMatching(window->GetBoundsInDIP());
if (window) {
// TODO(crbug.com/1306688): Change to use GetBoundsInDIP();
gfx::Rect bounds_dip = gfx::ToEnclosingRect(gfx::ConvertRectToDips(
window->GetBoundsInPixels(), GetXDisplayScaleFactor()));
return GetDisplayMatching(bounds_dip);
}
return GetPrimaryDisplay();
}

Expand Down
2 changes: 0 additions & 2 deletions ui/platform_window/platform_window_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ gfx::Rect PlatformWindowDelegate::ConvertRectToPixels(
return rect_in_dip;
}

void PlatformWindowDelegate::OnMovedToAnotherDisplay() {}

gfx::Rect PlatformWindowDelegate::ConvertRectToDIP(
const gfx::Rect& rect_in_pixels) const {
return rect_in_pixels;
Expand Down
3 changes: 0 additions & 3 deletions ui/platform_window/platform_window_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ class COMPONENT_EXPORT(PLATFORM_WINDOW) PlatformWindowDelegate {
// Enables or disables frame rate throttling.
virtual void SetFrameRateThrottleEnabled(bool enabled);

// Called when the platform window is moved to another display.
virtual void OnMovedToAnotherDisplay();

// Convert gfx::Rect in pixels to DIP in screen, and vice versa.
virtual gfx::Rect ConvertRectToPixels(const gfx::Rect& rect_in_dp) const;
virtual gfx::Rect ConvertRectToDIP(const gfx::Rect& rect_in_pixells) const;
Expand Down
18 changes: 13 additions & 5 deletions ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,20 @@ void DesktopWindowTreeHostPlatform::SetBoundsInDIP(const gfx::Rect& bounds) {
}

gfx::Transform DesktopWindowTreeHostPlatform::GetRootTransform() const {
// TODO(crbug.com/1306688): This can use wrong scale during initialization.
// Revisit this as a part of 'use dip' work.

display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
// This might be called before the |platform_window| is created. Thus,
// explicitly check if that exists before trying to access its visibility and
// the display where it is shown.
if (platform_window())
display = GetDisplayNearestRootWindow();
else if (window_parent_)
display = window_parent_->GetDisplayNearestRootWindow();
gfx::Transform transform;
transform.Scale(device_scale_factor(), device_scale_factor());
float scale = display.device_scale_factor();
transform.Scale(scale, scale);
return transform;
}

Expand Down Expand Up @@ -895,10 +907,6 @@ DesktopWindowTreeHostPlatform::GetOwnedWindowAnchorAndRectInPx() {
return window_anchor;
}

void DesktopWindowTreeHostPlatform::OnMovedToAnotherDisplay() {
WindowTreeHost::OnHostResizedInPixels(GetBoundsInPixels().size());
}

gfx::Rect DesktopWindowTreeHostPlatform::ConvertRectToPixels(
const gfx::Rect& rect_in_dip) const {
return ToPixelRect(rect_in_dip);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
absl::optional<ui::MenuType> GetMenuType() override;
absl::optional<ui::OwnedWindowAnchor> GetOwnedWindowAnchorAndRectInPx()
override;
void OnMovedToAnotherDisplay() override;
gfx::Rect ConvertRectToPixels(const gfx::Rect& rect_in_dip) const override;
gfx::Rect ConvertRectToDIP(const gfx::Rect& rect_in_pixels) const override;
gfx::PointF ConvertScreenPointToLocalDIP(
Expand Down

0 comments on commit 808f40a

Please sign in to comment.