Commit 9059ff37 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: wires up WindowTree::SetTransform()

We use SetTransform() for scrolling sliding browser controls in tablet mode.

BUG=930021
TEST=covered by test

Change-Id: I8357b66e3feaebc6c61be00fe206cb3811a9b477
Reviewed-on: https://chromium-review.googlesource.com/c/1460113
Commit-Queue: Scott Violet <sky@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Auto-Submit: Scott Violet <sky@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630570}
parent 6755e4de
......@@ -1253,6 +1253,21 @@ bool WindowTree::SetWindowBoundsImpl(
return false;
}
bool WindowTree::SetWindowTransformImpl(const ClientWindowId& window_id,
const gfx::Transform& transform) {
DVLOG(3) << "SetWindowTransform window_id=" << window_id;
aura::Window* window = GetWindowByClientId(window_id);
// This doesn't allow setting the transform on top-levels as that may conflict
// with top-level animations done by the window-manager. Additionally the
// window-manager is really the one that should be animating top-levels.
if (!window || !IsClientCreatedWindow(window) || IsTopLevel(window)) {
DVLOG(1) << "SetWindowTransform failed (invalid window)";
return false;
}
window->SetTransform(transform);
return true;
}
bool WindowTree::ReorderWindowImpl(const ClientWindowId& window_id,
const ClientWindowId& relative_window_id,
mojom::OrderDirection direction) {
......@@ -1600,12 +1615,11 @@ void WindowTree::AllocateLocalSurfaceId(Id transport_window_id) {
}
void WindowTree::SetWindowTransform(uint32_t change_id,
Id window_id,
Id transport_window_id,
const gfx::Transform& transform) {
// NOTE: Tests may time out if they trigger this NOTIMPLEMENTED because
// the change is not ack'd. The code under test may need to change to
// avoid triggering window transforms outside the window manager.
NOTIMPLEMENTED_LOG_ONCE();
window_tree_client_->OnChangeCompleted(
change_id, SetWindowTransformImpl(MakeClientWindowId(transport_window_id),
transform));
}
void WindowTree::SetClientArea(
......
......@@ -344,6 +344,8 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowTree
const gfx::Rect& bounds,
const base::Optional<viz::LocalSurfaceIdAllocation>&
local_surface_id_allocation);
bool SetWindowTransformImpl(const ClientWindowId& window_id,
const gfx::Transform& transform);
bool ReorderWindowImpl(const ClientWindowId& window_id,
const ClientWindowId& relative_window_id,
mojom::OrderDirection direction);
......@@ -396,7 +398,7 @@ class COMPONENT_EXPORT(WINDOW_SERVICE) WindowTree
local_surface_id_allocation) override;
void AllocateLocalSurfaceId(Id transport_window_id) override;
void SetWindowTransform(uint32_t change_id,
Id window_id,
Id transport_window_id,
const gfx::Transform& transform) override;
void SetClientArea(Id transport_window_id,
const gfx::Insets& insets,
......
......@@ -71,6 +71,12 @@ bool WindowTreeTestHelper::ReorderWindow(aura::Window* window,
direction);
}
bool WindowTreeTestHelper::SetTransform(aura::Window* window,
const gfx::Transform& transform) {
return window_tree_->SetWindowTransformImpl(ClientWindowIdForWindow(window),
transform);
}
bool WindowTreeTestHelper::SetWindowBounds(
aura::Window* window,
const gfx::Rect& bounds,
......
......@@ -23,6 +23,7 @@ class Window;
namespace gfx {
class Insets;
class Transform;
}
namespace ui {
......@@ -65,6 +66,7 @@ class WindowTreeTestHelper {
bool ReorderWindow(aura::Window* window,
aura::Window* relative_window,
mojom::OrderDirection direction);
bool SetTransform(aura::Window* window, const gfx::Transform& transform);
bool SetWindowBounds(aura::Window* window,
const gfx::Rect& bounds,
const base::Optional<viz::LocalSurfaceIdAllocation>&
......
......@@ -40,6 +40,7 @@
#include "ui/base/hit_test.h"
#include "ui/events/mojo/event_constants.mojom.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/transform.h"
#include "ui/wm/core/capture_controller.h"
#include "ui/wm/core/default_screen_position_client.h"
#include "ui/wm/core/focus_controller.h"
......@@ -2535,5 +2536,22 @@ TEST(WindowTreeTest, ForcedWindowVisibility) {
EXPECT_TRUE(setup.changes()->empty());
}
TEST(WindowTreeTest, SetWindowTransform) {
WindowServiceTestSetup setup;
aura::Window* top_level =
setup.window_tree_test_helper()->NewTopLevelWindow();
setup.changes()->clear();
gfx::Transform scaled;
scaled.Scale(2, 2);
EXPECT_FALSE(
setup.window_tree_test_helper()->SetTransform(top_level, scaled));
EXPECT_EQ(gfx::Transform(), top_level->transform());
aura::Window* child_window = setup.window_tree_test_helper()->NewWindow();
EXPECT_TRUE(
setup.window_tree_test_helper()->SetTransform(child_window, scaled));
EXPECT_EQ(scaled, child_window->transform());
}
} // namespace
} // namespace ws
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