Commit 17c449d1 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

specify the initial bounds for exo::ShellSurface

Bug: b/77472684
Change-Id: I23a9d55eb778cc9e3e38babcf77efdbd5fcfb699
Reviewed-on: https://chromium-review.googlesource.com/1008402
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550696}
parent 07bb6c7f
......@@ -206,6 +206,7 @@ test("exo_unittests") {
"//ui/aura:test_support",
"//ui/base",
"//ui/compositor:test_support",
"//ui/display:display_manager_test_api",
"//ui/gl:test_support",
]
......
......@@ -504,8 +504,13 @@ void ClientControlledShellSurface::OnDragFinished(bool canceled,
// SurfaceDelegate overrides:
void ClientControlledShellSurface::OnSurfaceCommit() {
if (!widget_)
if (!widget_) {
// Modify the |origin_| to the |pending_geometry_| to place the window
// on the intended display. See b/77472684 for the details.
if (!pending_geometry_.IsEmpty())
origin_ = pending_geometry_.origin();
CreateShellSurfaceWidget(ash::ToWindowShowState(pending_window_state_));
}
ash::wm::WindowState* window_state = GetWindowState();
if (window_state->GetStateType() != pending_window_state_) {
......
......@@ -35,6 +35,8 @@
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
#include "ui/compositor_extra/shadow.h"
#include "ui/display/display.h"
#include "ui/display/test/display_manager_test_api.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event_targeter.h"
#include "ui/events/test/event_generator.h"
......@@ -1098,4 +1100,56 @@ TEST_F(ClientControlledShellSurfaceTest, WideFrame) {
EXPECT_FALSE(shell_surface->wide_frame_for_test());
}
TEST_F(ClientControlledShellSurfaceTest, MultiDisplay) {
display::test::DisplayManagerTestApi test_api(
ash::Shell::Get()->display_manager());
test_api.UpdateDisplay("100x100,100+0-100x100");
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
{
std::unique_ptr<Surface> surface(new Surface);
auto shell_surface =
exo_test_helper()->CreateClientControlledShellSurface(surface.get());
gfx::Rect geometry(16, 16, 32, 32);
shell_surface->SetGeometry(geometry);
surface->Attach(buffer.get());
surface->Commit();
EXPECT_EQ(geometry.size().ToString(), shell_surface->GetWidget()
->GetWindowBoundsInScreen()
.size()
.ToString());
display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(
shell_surface->host_window());
EXPECT_EQ(gfx::Point(0, 0).ToString(),
display.bounds().origin().ToString());
}
{
std::unique_ptr<Surface> surface(new Surface);
auto shell_surface =
exo_test_helper()->CreateClientControlledShellSurface(surface.get());
gfx::Rect geometry(116, 16, 32, 32);
shell_surface->SetGeometry(geometry);
surface->Attach(buffer.get());
surface->Commit();
EXPECT_EQ(geometry.size().ToString(), shell_surface->GetWidget()
->GetWindowBoundsInScreen()
.size()
.ToString());
display::Display display =
display::Screen::GetScreen()->GetDisplayNearestWindow(
shell_surface->host_window());
EXPECT_EQ(gfx::Point(100, 0).ToString(),
display.bounds().origin().ToString());
}
}
} // namespace exo
......@@ -301,6 +301,8 @@ class ShellSurfaceBase : public SurfaceTreeHost,
gfx::Vector2d pending_origin_offset_accumulator_;
int resize_component_ = HTCAPTION; // HT constant (see ui/base/hit_test.h)
int pending_resize_component_ = HTCAPTION;
gfx::Rect geometry_;
gfx::Rect pending_geometry_;
base::Optional<gfx::Rect> shadow_bounds_;
bool shadow_bounds_changed_ = false;
std::unique_ptr<ash::WindowResizer> resizer_;
......@@ -354,8 +356,6 @@ class ShellSurfaceBase : public SurfaceTreeHost,
bool pending_show_widget_ = false;
std::string application_id_;
std::string startup_id_;
gfx::Rect geometry_;
gfx::Rect pending_geometry_;
base::RepeatingClosure close_callback_;
base::OnceClosure surface_destroyed_callback_;
ScopedConfigure* scoped_configure_ = nullptr;
......
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