Commit 6e761114 authored by Cody Peterson's avatar Cody Peterson Committed by Commit Bot

Update Root Window Bounds After Rotation

Properly update the root window bounds after updating the
root transform.

Previously, the call to window()->SetTransform() would update the
transform, but it would not call UpdateRootWindowSizeInPixels(). The
call to this function is what updates the root window bounds rect with
the new transform after it is set.

Using the translation + rotation transforms, if the base
WindowTreeHost::UpdaterootWindowSizeInPixels() function is used,
you end up with bounds represented by a rect with it's own origin
not actually at (0,0). For example, with a rotation of 270 degrees
applied to a 600x1024 display, you end up with bounds represented
as a rect with its origin at (-1, 508) and its other corner at (1228, 1228)
in the device-independent coordinates.

By overriding this function in CastWindowTreeHost,
after the new transform is applied to the root window
bounds, these bounds are shifted back so that their
origin is at (0,0).

This allows located events to properly check whether or not
they are contained within the root window.

BUG=None
TEST=Check touch events on displays with rotation applied.

Change-Id: Ib5c5ec2ab9d82cd2f589bc6301e4b7b6dd712c5c
Reviewed-on: https://chromium-review.googlesource.com/941728Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Reviewed-by: default avatarAlex Sakhartchouk <alexst@chromium.org>
Reviewed-by: default avatarLuke Halliwell <halliwell@chromium.org>
Commit-Queue: Cody Peterson <crpeterson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539997}
parent 071f173d
...@@ -82,6 +82,10 @@ class CastWindowTreeHost : public aura::WindowTreeHostPlatform { ...@@ -82,6 +82,10 @@ class CastWindowTreeHost : public aura::WindowTreeHostPlatform {
// aura::WindowTreeHostPlatform implementation: // aura::WindowTreeHostPlatform implementation:
void DispatchEvent(ui::Event* event) override; void DispatchEvent(ui::Event* event) override;
// aura::WindowTreeHost implementation
void UpdateRootWindowSizeInPixels(
const gfx::Size& host_size_in_pixels) override;
private: private:
const bool enable_input_; const bool enable_input_;
...@@ -107,6 +111,15 @@ void CastWindowTreeHost::DispatchEvent(ui::Event* event) { ...@@ -107,6 +111,15 @@ void CastWindowTreeHost::DispatchEvent(ui::Event* event) {
WindowTreeHostPlatform::DispatchEvent(event); WindowTreeHostPlatform::DispatchEvent(event);
} }
void CastWindowTreeHost::UpdateRootWindowSizeInPixels(
const gfx::Size& host_size_in_pixels) {
aura::WindowTreeHost::UpdateRootWindowSizeInPixels(host_size_in_pixels);
gfx::Rect window_bounds = window()->bounds();
gfx::RectF new_bounds = gfx::RectF(window_bounds);
new_bounds.set_origin(gfx::PointF(0, 0));
window()->SetBounds(gfx::ToEnclosingRect(new_bounds));
}
// A layout manager owned by the root window. // A layout manager owned by the root window.
class CastLayoutManager : public aura::LayoutManager { class CastLayoutManager : public aura::LayoutManager {
public: public:
...@@ -227,8 +240,7 @@ void CastWindowManagerAura::Setup() { ...@@ -227,8 +240,7 @@ void CastWindowManagerAura::Setup() {
new CastWindowTreeHost(enable_input_, gfx::Rect(display_size))); new CastWindowTreeHost(enable_input_, gfx::Rect(display_size)));
window_tree_host_->InitHost(); window_tree_host_->InitHost();
window_tree_host_->window()->SetLayoutManager(new CastLayoutManager()); window_tree_host_->window()->SetLayoutManager(new CastLayoutManager());
window_tree_host_->window()->SetTransform( window_tree_host_->SetRootTransform(GetPrimaryDisplayRotationTransform());
GetPrimaryDisplayRotationTransform());
// Allow seeing through to the hardware video plane: // Allow seeing through to the hardware video plane:
window_tree_host_->compositor()->SetBackgroundColor(SK_ColorTRANSPARENT); window_tree_host_->compositor()->SetBackgroundColor(SK_ColorTRANSPARENT);
......
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